@splinetool/viewer 1.10.54 → 1.10.56

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.
@@ -3172,7 +3172,7 @@ void main() {
3172
3172
  squared_mean = squared_mean / samples;
3173
3173
  float std_dev = sqrt( squared_mean - mean * mean );
3174
3174
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3175
- }`;function E6(e,t,i){let r=new _b,s=new re,a=new re,n=new zt,o=new iT({depthPacking:V3}),l=new S6,h={},c=i.maxTextureSize,u={[en]:$r,[$r]:en,[_s]:_s},d=new ci({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new re},radius:{value:4}},vertexShader:A6,fragmentShader:M6}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new gt;f.setAttribute("position",new Tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new zi(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gb,this.render=function(_,M,S){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||_.length===0)return;let E=e.getRenderTarget(),A=e.getActiveCubeFace(),T=e.getActiveMipmapLevel(),P=e.state;P.setBlending(Mr),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);for(let R=0,z=_.length;R<z;R++){let U=_[R],L=U.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",U,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;s.copy(L.mapSize);let H=L.getFrameExtents();if(s.multiply(H),a.copy(L.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(a.x=Math.floor(c/H.x),s.x=a.x*H.x,L.mapSize.x=a.x),s.y>c&&(a.y=Math.floor(c/H.y),s.y=a.y*H.y,L.mapSize.y=a.y)),L.map===null){let Z=this.type!==Dd?{minFilter:$t,magFilter:$t}:{};L.map=new hi(s.x,s.y,Z),L.map.texture.name=U.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let q=L.getViewportCount();for(let Z=0;Z<q;Z++){let X=L.getViewport(Z);n.set(a.x*X.x,a.y*X.y,a.x*X.z,a.y*X.w),P.viewport(n),L.updateMatrices(U,Z),r=L.getFrustum(),b(M,S,L.camera,U,this.type)}L.isPointLightShadow!==!0&&this.type===Dd&&y(L,S),L.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(E,A,T)};function y(_,M){let S=t.update(g);d.defines.VSM_SAMPLES!==_.blurSamples&&(d.defines.VSM_SAMPLES=_.blurSamples,p.defines.VSM_SAMPLES=_.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new hi(s.x,s.y)),d.uniforms.shadow_pass.value=_.map.texture,d.uniforms.resolution.value=_.mapSize,d.uniforms.radius.value=_.radius,e.setRenderTarget(_.mapPass),e.clear(),e.renderBufferDirect(M,null,S,d,g,null),p.uniforms.shadow_pass.value=_.mapPass.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,e.setRenderTarget(_.map),e.clear(),e.renderBufferDirect(M,null,S,p,g,null)}function x(_,M,S,E,A,T){let P=null,R=S.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)P=R;else if(P=S.isPointLight===!0?l:o,e.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0){let z=P.uuid,U=M.uuid,L=h[z];L===void 0&&(L={},h[z]=L);let H=L[U];H===void 0&&(H=P.clone(),L[U]=H),P=H}return P.visible=M.visible,P.wireframe=M.wireframe,T===Dd?P.side=M.shadowSide!==null?M.shadowSide:M.side:P.side=M.shadowSide!==null?M.shadowSide:u[M.side],P.alphaMap=M.alphaMap,P.alphaTest=M.alphaTest,P.map=M.map,P.clipShadows=M.clipShadows,P.clippingPlanes=M.clippingPlanes,P.clipIntersection=M.clipIntersection,P.displacementMap=M.displacementMap,P.displacementScale=M.displacementScale,P.displacementBias=M.displacementBias,P.wireframeLinewidth=M.wireframeLinewidth,P.linewidth=M.linewidth,S.isPointLight===!0&&P.isMeshDistanceMaterial===!0&&(P.referencePosition.setFromMatrixPosition(S.matrixWorld),P.nearDistance=E,P.farDistance=A),P}function b(_,M,S,E,A){if(_.visible===!1)return;if(_.layers.test(M.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&A===Dd)&&(!_.frustumCulled||r.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,_.matrixWorld);let P=t.update(_),R=_.material;if(Array.isArray(R)){let z=P.groups;for(let U=0,L=z.length;U<L;U++){let H=z[U],q=R[H.materialIndex];if(q&&q.visible){let Z=x(_,q,E,S.near,S.far,A);e.renderBufferDirect(S,null,P,Z,_,H)}}}else if(R.visible){let z=x(_,R,E,S.near,S.far,A);e.renderBufferDirect(S,null,P,z,_,null)}}let T=_.children;for(let P=0,R=T.length;P<R;P++)b(T[P],M,S,E,A)}}function C6(e,t,i){let r=i.isWebGL2;function s(){let me=!1,Ee=new zt,Xe=null,Ke=new zt(0,0,0,0);return{setMask:function(vt){Xe!==vt&&!me&&(e.colorMask(vt,vt,vt,vt),Xe=vt)},setLocked:function(vt){me=vt},setClear:function(vt,Mt,wi,ji,Tr){Tr===!0&&(vt*=ji,Mt*=ji,wi*=ji),Ee.set(vt,Mt,wi,ji),Ke.equals(Ee)===!1&&(e.clearColor(vt,Mt,wi,ji),Ke.copy(Ee))},reset:function(){me=!1,Xe=null,Ke.set(-1,0,0,0)}}}function a(){let me=!1,Ee=null,Xe=null,Ke=null;return{setTest:function(vt){vt?Pe(2929):ve(2929)},setMask:function(vt){Ee!==vt&&!me&&(e.depthMask(vt),Ee=vt)},setFunc:function(vt){if(Xe!==vt){switch(vt){case YB:e.depthFunc(512);break;case QB:e.depthFunc(519);break;case ZB:e.depthFunc(513);break;case ly:e.depthFunc(515);break;case KB:e.depthFunc(514);break;case JB:e.depthFunc(518);break;case $B:e.depthFunc(516);break;case ez:e.depthFunc(517);break;default:e.depthFunc(515)}Xe=vt}},setLocked:function(vt){me=vt},setClear:function(vt){Ke!==vt&&(e.clearDepth(vt),Ke=vt)},reset:function(){me=!1,Ee=null,Xe=null,Ke=null}}}function n(){let me=!1,Ee=null,Xe=null,Ke=null,vt=null,Mt=null,wi=null,ji=null,Tr=null;return{setTest:function(Ei){me||(Ei?Pe(2960):ve(2960))},setMask:function(Ei){Ee!==Ei&&!me&&(e.stencilMask(Ei),Ee=Ei)},setFunc:function(Ei,ss,Pr){(Xe!==Ei||Ke!==ss||vt!==Pr)&&(e.stencilFunc(Ei,ss,Pr),Xe=Ei,Ke=ss,vt=Pr)},setOp:function(Ei,ss,Pr){(Mt!==Ei||wi!==ss||ji!==Pr)&&(e.stencilOp(Ei,ss,Pr),Mt=Ei,wi=ss,ji=Pr)},setLocked:function(Ei){me=Ei},setClear:function(Ei){Tr!==Ei&&(e.clearStencil(Ei),Tr=Ei)},reset:function(){me=!1,Ee=null,Xe=null,Ke=null,vt=null,Mt=null,wi=null,ji=null,Tr=null}}}let o=new s,l=new a,h=new n,c=new WeakMap,u=new WeakMap,d={},p={},f=new WeakMap,g=[],m=null,y=!1,x=null,b=null,_=null,M=null,S=null,E=null,A=null,T=!1,P=null,R=null,z=null,U=null,L=null,H=e.getParameter(35661),q=!1,Z=0,X=e.getParameter(7938);X.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(X)[1]),q=Z>=1):X.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),q=Z>=2);let se=null,le={},te=e.getParameter(3088),ie=e.getParameter(2978),fe=new zt().fromArray(te),ce=new zt().fromArray(ie);function ue(me,Ee,Xe){let Ke=new Uint8Array(4),vt=e.createTexture();e.bindTexture(me,vt),e.texParameteri(me,10241,9728),e.texParameteri(me,10240,9728);for(let Mt=0;Mt<Xe;Mt++)e.texImage2D(Ee+Mt,0,6408,1,1,0,6408,5121,Ke);return vt}let ae={};ae[3553]=ue(3553,3553,1),ae[34067]=ue(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),Pe(2929),l.setFunc(ly),st(!1),nt(x2),Pe(2884),it(Mr);function Pe(me){d[me]!==!0&&(e.enable(me),d[me]=!0)}function ve(me){d[me]!==!1&&(e.disable(me),d[me]=!1)}function Ae(me,Ee){return p[me]!==Ee?(e.bindFramebuffer(me,Ee),p[me]=Ee,r&&(me===36009&&(p[36160]=Ee),me===36160&&(p[36009]=Ee)),!0):!1}function ye(me,Ee){let Xe=g,Ke=!1;if(me)if(Xe=f.get(Ee),Xe===void 0&&(Xe=[],f.set(Ee,Xe)),me.isWebGLMultipleRenderTargets){let vt=me.texture;if(Xe.length!==vt.length||Xe[0]!==36064){for(let Mt=0,wi=vt.length;Mt<wi;Mt++)Xe[Mt]=36064+Mt;Xe.length=vt.length,Ke=!0}}else Xe[0]!==36064&&(Xe[0]=36064,Ke=!0);else Xe[0]!==1029&&(Xe[0]=1029,Ke=!0);Ke&&(i.isWebGL2?e.drawBuffers(Xe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Xe))}function Ve(me){return m!==me?(e.useProgram(me),m=me,!0):!1}let Ie={[Oc]:32774,[FB]:32778,[kB]:32779};if(r)Ie[S2]=32775,Ie[A2]=32776;else{let me=t.get("EXT_blend_minmax");me!==null&&(Ie[S2]=me.MIN_EXT,Ie[A2]=me.MAX_EXT)}let Ce={[UB]:0,[NB]:1,[VB]:768,[R3]:770,[XB]:776,[WB]:774,[HB]:772,[jB]:769,[L3]:771,[qB]:775,[GB]:773};function it(me,Ee,Xe,Ke,vt,Mt,wi,ji){if(me===Mr){y===!0&&(ve(3042),y=!1);return}if(y===!1&&(Pe(3042),y=!0),me!==zB){if(me!==x||ji!==T){if((b!==Oc||S!==Oc)&&(e.blendEquation(32774),b=Oc,S=Oc),ji)switch(me){case yh:e.blendFuncSeparate(1,771,1,771);break;case b2:e.blendFunc(1,1);break;case w2:e.blendFuncSeparate(0,769,0,1);break;case _2:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}else switch(me){case yh:e.blendFuncSeparate(770,771,1,771);break;case b2:e.blendFunc(770,1);break;case w2:e.blendFuncSeparate(0,769,0,1);break;case _2:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}_=null,M=null,E=null,A=null,x=me,T=ji}return}vt=vt||Ee,Mt=Mt||Xe,wi=wi||Ke,(Ee!==b||vt!==S)&&(e.blendEquationSeparate(Ie[Ee],Ie[vt]),b=Ee,S=vt),(Xe!==_||Ke!==M||Mt!==E||wi!==A)&&(e.blendFuncSeparate(Ce[Xe],Ce[Ke],Ce[Mt],Ce[wi]),_=Xe,M=Ke,E=Mt,A=wi),x=me,T=!1}function Je(me,Ee){me.side===_s?ve(2884):Pe(2884);let Xe=me.side===$r;Ee&&(Xe=!Xe),st(Xe),me.blending===yh&&me.transparent===!1?it(Mr):it(me.blending,me.blendEquation,me.blendSrc,me.blendDst,me.blendEquationAlpha,me.blendSrcAlpha,me.blendDstAlpha,me.premultipliedAlpha),l.setFunc(me.depthFunc),l.setTest(me.depthTest),l.setMask(me.depthWrite),o.setMask(me.colorWrite);let Ke=me.stencilWrite;h.setTest(Ke),Ke&&(h.setMask(me.stencilWriteMask),h.setFunc(me.stencilFunc,me.stencilRef,me.stencilFuncMask),h.setOp(me.stencilFail,me.stencilZFail,me.stencilZPass)),Qe(me.polygonOffset,me.polygonOffsetFactor,me.polygonOffsetUnits),me.alphaToCoverage===!0?Pe(32926):ve(32926)}function st(me){P!==me&&(me?e.frontFace(2304):e.frontFace(2305),P=me)}function nt(me){me!==RB?(Pe(2884),me!==R&&(me===x2?e.cullFace(1029):me===LB?e.cullFace(1028):e.cullFace(1032))):ve(2884),R=me}function Ze(me){me!==z&&(q&&e.lineWidth(me),z=me)}function Qe(me,Ee,Xe){me?(Pe(32823),(U!==Ee||L!==Xe)&&(e.polygonOffset(Ee,Xe),U=Ee,L=Xe)):ve(32823)}function pt(me){me?Pe(3089):ve(3089)}function wt(me){me===void 0&&(me=33984+H-1),se!==me&&(e.activeTexture(me),se=me)}function ee(me,Ee,Xe){Xe===void 0&&(se===null?Xe=33984+H-1:Xe=se);let Ke=le[Xe];Ke===void 0&&(Ke={type:void 0,texture:void 0},le[Xe]=Ke),(Ke.type!==me||Ke.texture!==Ee)&&(se!==Xe&&(e.activeTexture(Xe),se=Xe),e.bindTexture(me,Ee||ae[me]),Ke.type=me,Ke.texture=Ee)}function W(){let me=le[se];me!==void 0&&me.type!==void 0&&(e.bindTexture(me.type,null),me.type=void 0,me.texture=void 0)}function _e(){try{e.compressedTexImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function We(){try{e.compressedTexImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function V(){try{e.texSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function Oe(){try{e.texSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ut(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function He(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ze(){try{e.texStorage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ke(){try{e.texStorage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function dt(){try{e.texImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ot(){try{e.texImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function _t(me){fe.equals(me)===!1&&(e.scissor(me.x,me.y,me.z,me.w),fe.copy(me))}function bt(me){ce.equals(me)===!1&&(e.viewport(me.x,me.y,me.z,me.w),ce.copy(me))}function ri(me,Ee){let Xe=u.get(Ee);Xe===void 0&&(Xe=new WeakMap,u.set(Ee,Xe));let Ke=Xe.get(me);Ke===void 0&&(Ke=e.getUniformBlockIndex(Ee,me.name),Xe.set(me,Ke))}function vi(me,Ee){let Xe=u.get(Ee).get(me);c.get(Ee)!==Xe&&(e.uniformBlockBinding(Ee,Xe,me.__bindingPointIndex),c.set(Ee,Xe))}function ii(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},se=null,le={},p={},f=new WeakMap,g=[],m=null,y=!1,x=null,b=null,_=null,M=null,S=null,E=null,A=null,T=!1,P=null,R=null,z=null,U=null,L=null,fe.set(0,0,e.canvas.width,e.canvas.height),ce.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:Pe,disable:ve,bindFramebuffer:Ae,drawBuffers:ye,useProgram:Ve,setBlending:it,setMaterial:Je,setFlipSided:st,setCullFace:nt,setLineWidth:Ze,setPolygonOffset:Qe,setScissorTest:pt,activeTexture:wt,bindTexture:ee,unbindTexture:W,compressedTexImage2D:_e,compressedTexImage3D:We,texImage2D:dt,texImage3D:ot,updateUBOMapping:ri,uniformBlockBinding:vi,texStorage2D:ze,texStorage3D:ke,texSubImage2D:V,texSubImage3D:Oe,compressedTexSubImage2D:ut,compressedTexSubImage3D:He,scissor:_t,viewport:bt,reset:ii}}function T6(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,c=s.maxTextureSize,u=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(ee,W){return y?new OffscreenCanvas(ee,W):sp("canvas")}function b(ee,W,_e,We){let V=1;if((ee.width>We||ee.height>We)&&(V=We/Math.max(ee.width,ee.height)),V<1||W===!0)if(typeof HTMLImageElement<"u"&&ee instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ee instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ee instanceof ImageBitmap){let Oe=W?tg:Math.floor,ut=Oe(V*ee.width),He=Oe(V*ee.height);g===void 0&&(g=x(ut,He));let ze=_e?x(ut,He):g;return ze.width=ut,ze.height=He,ze.getContext("2d").drawImage(ee,0,0,ut,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ee.width+"x"+ee.height+") to ("+ut+"x"+He+")."),ze}else return"data"in ee&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ee.width+"x"+ee.height+")."),ee;return ee}function _(ee){return my(ee.width)&&my(ee.height)}function M(ee){return o?!1:ee.wrapS!==Gi||ee.wrapT!==Gi||ee.minFilter!==$t&&ee.minFilter!==Xt}function S(ee,W){return ee.generateMipmaps&&W&&ee.minFilter!==$t&&ee.minFilter!==Xt}function E(ee){e.generateMipmap(ee)}function A(ee,W,_e,We,V=!1){if(o===!1)return W;if(ee!==null){if(e[ee]!==void 0)return e[ee];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ee+"'")}let Oe=W;return W===6403&&(_e===5126&&(Oe=33326),_e===5131&&(Oe=33325),_e===5121&&(Oe=33321)),W===33319&&(_e===5126&&(Oe=33328),_e===5131&&(Oe=33327),_e===5121&&(Oe=33323)),W===6408&&(_e===5126&&(Oe=34836),_e===5131&&(Oe=34842),_e===5121&&(Oe=We===Gt&&V===!1?35907:32856),_e===32819&&(Oe=32854),_e===32820&&(Oe=32855)),(Oe===33325||Oe===33326||Oe===33327||Oe===33328||Oe===34842||Oe===34836)&&t.get("EXT_color_buffer_float"),Oe}function T(ee,W,_e){return S(ee,_e)===!0||ee.isFramebufferTexture&&ee.minFilter!==$t&&ee.minFilter!==Xt?Math.log2(Math.max(W.width,W.height))+1:ee.mipmaps!==void 0&&ee.mipmaps.length>0?ee.mipmaps.length:ee.isCompressedTexture&&Array.isArray(ee.image)?W.mipmaps.length:1}function P(ee){return ee===$t||ee===M2||ee===i0?9728:9729}function R(ee){let W=ee.target;W.removeEventListener("dispose",R),U(W),W.isVideoTexture&&f.delete(W)}function z(ee){let W=ee.target;W.removeEventListener("dispose",z),H(W)}function U(ee){let W=r.get(ee);if(W.__webglInit===void 0)return;let _e=ee.source,We=m.get(_e);if(We){let V=We[W.__cacheKey];V.usedTimes--,V.usedTimes===0&&L(ee),Object.keys(We).length===0&&m.delete(_e)}r.remove(ee)}function L(ee){let W=r.get(ee);e.deleteTexture(W.__webglTexture);let _e=ee.source,We=m.get(_e);delete We[W.__cacheKey],n.memory.textures--}function H(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);if(We.__webglTexture!==void 0&&(e.deleteTexture(We.__webglTexture),n.memory.textures--),ee.depthTexture&&ee.depthTexture.dispose(),ee.isWebGLCubeRenderTarget)for(let V=0;V<6;V++)e.deleteFramebuffer(_e.__webglFramebuffer[V]),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer[V]);else{if(e.deleteFramebuffer(_e.__webglFramebuffer),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer),_e.__webglMultisampledFramebuffer&&e.deleteFramebuffer(_e.__webglMultisampledFramebuffer),_e.__webglColorRenderbuffer)for(let V=0;V<_e.__webglColorRenderbuffer.length;V++)_e.__webglColorRenderbuffer[V]&&e.deleteRenderbuffer(_e.__webglColorRenderbuffer[V]);_e.__webglDepthRenderbuffer&&e.deleteRenderbuffer(_e.__webglDepthRenderbuffer)}if(ee.isWebGLMultipleRenderTargets)for(let V=0,Oe=W.length;V<Oe;V++){let ut=r.get(W[V]);ut.__webglTexture&&(e.deleteTexture(ut.__webglTexture),n.memory.textures--),r.remove(W[V])}r.remove(W),r.remove(ee)}let q=0;function Z(){q=0}function X(){let ee=q;return ee>=l&&console.warn("THREE.WebGLTextures: Trying to use "+ee+" texture units while this GPU supports only "+l),q+=1,ee}function se(ee){let W=[];return W.push(ee.wrapS),W.push(ee.wrapT),W.push(ee.wrapR||0),W.push(ee.magFilter),W.push(ee.minFilter),W.push(ee.anisotropy),W.push(ee.internalFormat),W.push(ee.format),W.push(ee.type),W.push(ee.generateMipmaps),W.push(ee.premultiplyAlpha),W.push(ee.flipY),W.push(ee.unpackAlignment),W.push(ee.encoding),W.join()}function le(ee,W){let _e=r.get(ee);if(ee.isVideoTexture&&pt(ee),ee.isRenderTargetTexture===!1&&ee.version>0&&_e.__version!==ee.version){let We=ee.image;if(We===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(We.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ve(_e,ee,W);return}}i.bindTexture(3553,_e.__webglTexture,33984+W)}function te(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(35866,_e.__webglTexture,33984+W)}function ie(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(32879,_e.__webglTexture,33984+W)}function fe(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){Ae(_e,ee,W);return}i.bindTexture(34067,_e.__webglTexture,33984+W)}let ce={[So]:10497,[Gi]:33071,[uy]:33648},ue={[$t]:9728,[M2]:9984,[i0]:9986,[Xt]:9729,[lz]:9985,[au]:9987};function ae(ee,W,_e){if(_e?(e.texParameteri(ee,10242,ce[W.wrapS]),e.texParameteri(ee,10243,ce[W.wrapT]),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,ce[W.wrapR]),e.texParameteri(ee,10240,ue[W.magFilter]),e.texParameteri(ee,10241,ue[W.minFilter])):(e.texParameteri(ee,10242,33071),e.texParameteri(ee,10243,33071),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,33071),(W.wrapS!==Gi||W.wrapT!==Gi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(ee,10240,P(W.magFilter)),e.texParameteri(ee,10241,P(W.minFilter)),W.minFilter!==$t&&W.minFilter!==Xt&&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 We=t.get("EXT_texture_filter_anisotropic");if(W.magFilter===$t||W.minFilter!==i0&&W.minFilter!==au||W.type===Ti&&t.has("OES_texture_float_linear")===!1||o===!1&&W.type===Oo&&t.has("OES_texture_half_float_linear")===!1)return;(W.anisotropy>1||r.get(W).__currentAnisotropy)&&(e.texParameterf(ee,We.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(W.anisotropy,s.getMaxAnisotropy())),r.get(W).__currentAnisotropy=W.anisotropy)}}function Pe(ee,W){let _e=!1;ee.__webglInit===void 0&&(ee.__webglInit=!0,W.addEventListener("dispose",R));let We=W.source,V=m.get(We);V===void 0&&(V={},m.set(We,V));let Oe=se(W);if(Oe!==ee.__cacheKey){V[Oe]===void 0&&(V[Oe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,_e=!0),V[Oe].usedTimes++;let ut=V[ee.__cacheKey];ut!==void 0&&(V[ee.__cacheKey].usedTimes--,ut.usedTimes===0&&L(W)),ee.__cacheKey=Oe,ee.__webglTexture=V[Oe].texture}return _e}function ve(ee,W,_e){let We=3553;(W.isDataArrayTexture||W.isCompressedArrayTexture)&&(We=35866),W.isData3DTexture&&(We=32879);let V=Pe(ee,W),Oe=W.source;i.bindTexture(We,ee.__webglTexture,33984+_e);let ut=r.get(Oe);if(Oe.version!==ut.__version||V===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let He=M(W)&&_(W.image)===!1,ze=b(W.image,He,!1,c);ze=wt(W,ze);let ke=_(ze)||o,dt=a.convert(W.format,W.encoding),ot=a.convert(W.type),_t=A(W.internalFormat,dt,ot,W.encoding,W.isVideoTexture);ae(We,W,ke);let bt,ri=W.mipmaps,vi=o&&W.isVideoTexture!==!0,ii=ut.__version===void 0||V===!0,me=T(W,ze,ke);if(W.isDepthTexture)_t=6402,o?W.type===Ti?_t=36012:W.type===Ao?_t=33190:W.type===xh?_t=35056:_t=33189:W.type===Ti&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),W.format===bh&&_t===6402&&W.type!==F3&&W.type!==Ao&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),W.type=Ao,ot=a.convert(W.type)),W.format===Ch&&_t===6402&&(_t=34041,W.type!==xh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),W.type=xh,ot=a.convert(W.type))),ii&&(vi?i.texStorage2D(3553,1,_t,ze.width,ze.height):i.texImage2D(3553,0,_t,ze.width,ze.height,0,dt,ot,null));else if(W.isDataTexture)if(ri.length>0&&ke){vi&&ii&&i.texStorage2D(3553,me,_t,ri[0].width,ri[0].height);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],vi?i.texSubImage2D(3553,Ee,0,0,bt.width,bt.height,dt,ot,bt.data):i.texImage2D(3553,Ee,_t,bt.width,bt.height,0,dt,ot,bt.data);W.generateMipmaps=!1}else vi?(ii&&i.texStorage2D(3553,me,_t,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,ze.width,ze.height,dt,ot,ze.data)):i.texImage2D(3553,0,_t,ze.width,ze.height,0,dt,ot,ze.data);else if(W.isCompressedTexture)if(W.isCompressedArrayTexture){vi&&ii&&i.texStorage3D(35866,me,_t,ri[0].width,ri[0].height,ze.depth);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],W.format!==qi?dt!==null?vi?i.compressedTexSubImage3D(35866,Ee,0,0,0,bt.width,bt.height,ze.depth,dt,bt.data,0,0):i.compressedTexImage3D(35866,Ee,_t,bt.width,bt.height,ze.depth,0,bt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):vi?i.texSubImage3D(35866,Ee,0,0,0,bt.width,bt.height,ze.depth,dt,ot,bt.data):i.texImage3D(35866,Ee,_t,bt.width,bt.height,ze.depth,0,dt,ot,bt.data)}else{vi&&ii&&i.texStorage2D(3553,me,_t,ri[0].width,ri[0].height);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],W.format!==qi?dt!==null?vi?i.compressedTexSubImage2D(3553,Ee,0,0,bt.width,bt.height,dt,bt.data):i.compressedTexImage2D(3553,Ee,_t,bt.width,bt.height,0,bt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):vi?i.texSubImage2D(3553,Ee,0,0,bt.width,bt.height,dt,ot,bt.data):i.texImage2D(3553,Ee,_t,bt.width,bt.height,0,dt,ot,bt.data)}else if(W.isDataArrayTexture)vi?(ii&&i.texStorage3D(35866,me,_t,ze.width,ze.height,ze.depth),i.texSubImage3D(35866,0,0,0,0,ze.width,ze.height,ze.depth,dt,ot,ze.data)):i.texImage3D(35866,0,_t,ze.width,ze.height,ze.depth,0,dt,ot,ze.data);else if(W.isData3DTexture)vi?(ii&&i.texStorage3D(32879,me,_t,ze.width,ze.height,ze.depth),i.texSubImage3D(32879,0,0,0,0,ze.width,ze.height,ze.depth,dt,ot,ze.data)):i.texImage3D(32879,0,_t,ze.width,ze.height,ze.depth,0,dt,ot,ze.data);else if(W.isFramebufferTexture){if(ii)if(vi)i.texStorage2D(3553,me,_t,ze.width,ze.height);else{let Ee=ze.width,Xe=ze.height;for(let Ke=0;Ke<me;Ke++)i.texImage2D(3553,Ke,_t,Ee,Xe,0,dt,ot,null),Ee>>=1,Xe>>=1}}else if(ri.length>0&&ke){vi&&ii&&i.texStorage2D(3553,me,_t,ri[0].width,ri[0].height);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],vi?i.texSubImage2D(3553,Ee,0,0,dt,ot,bt):i.texImage2D(3553,Ee,_t,dt,ot,bt);W.generateMipmaps=!1}else vi?(ii&&i.texStorage2D(3553,me,_t,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,dt,ot,ze)):i.texImage2D(3553,0,_t,dt,ot,ze);S(W,ke)&&E(We),ut.__version=Oe.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function Ae(ee,W,_e){if(W.image.length!==6)return;let We=Pe(ee,W),V=W.source;i.bindTexture(34067,ee.__webglTexture,33984+_e);let Oe=r.get(V);if(V.version!==Oe.__version||We===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let ut=W.isCompressedTexture||W.image[0].isCompressedTexture,He=W.image[0]&&W.image[0].isDataTexture,ze=[];for(let Ee=0;Ee<6;Ee++)!ut&&!He?ze[Ee]=b(W.image[Ee],!1,!0,h):ze[Ee]=He?W.image[Ee].image:W.image[Ee],ze[Ee]=wt(W,ze[Ee]);let ke=ze[0],dt=_(ke)||o,ot=a.convert(W.format,W.encoding),_t=a.convert(W.type),bt=A(W.internalFormat,ot,_t,W.encoding),ri=o&&W.isVideoTexture!==!0,vi=Oe.__version===void 0||We===!0,ii=T(W,ke,dt);ae(34067,W,dt);let me;if(ut){ri&&vi&&i.texStorage2D(34067,ii,bt,ke.width,ke.height);for(let Ee=0;Ee<6;Ee++){me=ze[Ee].mipmaps;for(let Xe=0;Xe<me.length;Xe++){let Ke=me[Xe];W.format!==qi?ot!==null?ri?i.compressedTexSubImage2D(34069+Ee,Xe,0,0,Ke.width,Ke.height,ot,Ke.data):i.compressedTexImage2D(34069+Ee,Xe,bt,Ke.width,Ke.height,0,Ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ri?i.texSubImage2D(34069+Ee,Xe,0,0,Ke.width,Ke.height,ot,_t,Ke.data):i.texImage2D(34069+Ee,Xe,bt,Ke.width,Ke.height,0,ot,_t,Ke.data)}}}else{me=W.mipmaps,ri&&vi&&(me.length>0&&ii++,i.texStorage2D(34067,ii,bt,ze[0].width,ze[0].height));for(let Ee=0;Ee<6;Ee++)if(He){ri?i.texSubImage2D(34069+Ee,0,0,0,ze[Ee].width,ze[Ee].height,ot,_t,ze[Ee].data):i.texImage2D(34069+Ee,0,bt,ze[Ee].width,ze[Ee].height,0,ot,_t,ze[Ee].data);for(let Xe=0;Xe<me.length;Xe++){let Ke=me[Xe].image[Ee].image;ri?i.texSubImage2D(34069+Ee,Xe+1,0,0,Ke.width,Ke.height,ot,_t,Ke.data):i.texImage2D(34069+Ee,Xe+1,bt,Ke.width,Ke.height,0,ot,_t,Ke.data)}}else{ri?i.texSubImage2D(34069+Ee,0,0,0,ot,_t,ze[Ee]):i.texImage2D(34069+Ee,0,bt,ot,_t,ze[Ee]);for(let Xe=0;Xe<me.length;Xe++){let Ke=me[Xe];ri?i.texSubImage2D(34069+Ee,Xe+1,0,0,ot,_t,Ke.image[Ee]):i.texImage2D(34069+Ee,Xe+1,bt,ot,_t,Ke.image[Ee])}}}S(W,dt)&&E(34067),Oe.__version=V.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function ye(ee,W,_e,We,V){let Oe=a.convert(_e.format,_e.encoding),ut=a.convert(_e.type),He=A(_e.internalFormat,Oe,ut,_e.encoding);r.get(W).__hasExternalTextures||(V===32879||V===35866?i.texImage3D(V,0,He,W.width,W.height,W.depth,0,Oe,ut,null):i.texImage2D(V,0,He,W.width,W.height,0,Oe,ut,null)),i.bindFramebuffer(36160,ee),Qe(W)?d.framebufferTexture2DMultisampleEXT(36160,We,V,r.get(_e).__webglTexture,0,Ze(W)):(V===3553||V>=34069&&V<=34074)&&e.framebufferTexture2D(36160,We,V,r.get(_e).__webglTexture,0),i.bindFramebuffer(36160,null)}function Ve(ee,W,_e){if(e.bindRenderbuffer(36161,ee),W.depthBuffer&&!W.stencilBuffer){let We=33189;if(_e||Qe(W)){let V=W.depthTexture;V&&V.isDepthTexture&&(V.type===Ti?We=36012:V.type===Ao&&(We=33190));let Oe=Ze(W);Qe(W)?d.renderbufferStorageMultisampleEXT(36161,Oe,We,W.width,W.height):e.renderbufferStorageMultisample(36161,Oe,We,W.width,W.height)}else e.renderbufferStorage(36161,We,W.width,W.height);e.framebufferRenderbuffer(36160,36096,36161,ee)}else if(W.depthBuffer&&W.stencilBuffer){let We=Ze(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,We,35056,W.width,W.height):Qe(W)?d.renderbufferStorageMultisampleEXT(36161,We,35056,W.width,W.height):e.renderbufferStorage(36161,34041,W.width,W.height),e.framebufferRenderbuffer(36160,33306,36161,ee)}else{let We=W.isWebGLMultipleRenderTargets===!0?W.texture:[W.texture];for(let V=0;V<We.length;V++){let Oe=We[V],ut=a.convert(Oe.format,Oe.encoding),He=a.convert(Oe.type),ze=A(Oe.internalFormat,ut,He,Oe.encoding),ke=Ze(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,ke,ze,W.width,W.height):Qe(W)?d.renderbufferStorageMultisampleEXT(36161,ke,ze,W.width,W.height):e.renderbufferStorage(36161,ze,W.width,W.height)}}e.bindRenderbuffer(36161,null)}function Ie(ee,W){if(W&&W.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,ee),!(W.depthTexture&&W.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(W.depthTexture).__webglTexture||W.depthTexture.image.width!==W.width||W.depthTexture.image.height!==W.height)&&(W.depthTexture.image.width=W.width,W.depthTexture.image.height=W.height,W.depthTexture.needsUpdate=!0),le(W.depthTexture,0);let _e=r.get(W.depthTexture).__webglTexture,We=Ze(W);if(W.depthTexture.format===bh)Qe(W)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,_e,0,We):e.framebufferTexture2D(36160,36096,3553,_e,0);else if(W.depthTexture.format===Ch)Qe(W)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,_e,0,We):e.framebufferTexture2D(36160,33306,3553,_e,0);else throw new Error("Unknown depthTexture format")}function Ce(ee){let W=r.get(ee),_e=ee.isWebGLCubeRenderTarget===!0;if(ee.depthTexture&&!W.__autoAllocateDepthBuffer){if(_e)throw new Error("target.depthTexture not supported in Cube render targets");Ie(W.__webglFramebuffer,ee)}else if(_e){W.__webglDepthbuffer=[];for(let We=0;We<6;We++)i.bindFramebuffer(36160,W.__webglFramebuffer[We]),W.__webglDepthbuffer[We]=e.createRenderbuffer(),Ve(W.__webglDepthbuffer[We],ee,!1)}else i.bindFramebuffer(36160,W.__webglFramebuffer),W.__webglDepthbuffer=e.createRenderbuffer(),Ve(W.__webglDepthbuffer,ee,!1);i.bindFramebuffer(36160,null)}function it(ee,W,_e){let We=r.get(ee);W!==void 0&&ye(We.__webglFramebuffer,ee,ee.texture,36064,3553),_e!==void 0&&Ce(ee)}function Je(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);ee.addEventListener("dispose",z),ee.isWebGLMultipleRenderTargets!==!0&&(We.__webglTexture===void 0&&(We.__webglTexture=e.createTexture()),We.__version=W.version,n.memory.textures++);let V=ee.isWebGLCubeRenderTarget===!0,Oe=ee.isWebGLMultipleRenderTargets===!0,ut=_(ee)||o;if(V){_e.__webglFramebuffer=[];for(let He=0;He<6;He++)_e.__webglFramebuffer[He]=e.createFramebuffer()}else{if(_e.__webglFramebuffer=e.createFramebuffer(),Oe)if(s.drawBuffers){let He=ee.texture;for(let ze=0,ke=He.length;ze<ke;ze++){let dt=r.get(He[ze]);dt.__webglTexture===void 0&&(dt.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&ee.samples>0&&Qe(ee)===!1){let He=Oe?W:[W];_e.__webglMultisampledFramebuffer=e.createFramebuffer(),_e.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,_e.__webglMultisampledFramebuffer);for(let ze=0;ze<He.length;ze++){let ke=He[ze];_e.__webglColorRenderbuffer[ze]=e.createRenderbuffer(),e.bindRenderbuffer(36161,_e.__webglColorRenderbuffer[ze]);let dt=a.convert(ke.format,ke.encoding),ot=a.convert(ke.type),_t=A(ke.internalFormat,dt,ot,ke.encoding,ee.isXRRenderTarget===!0),bt=Ze(ee);e.renderbufferStorageMultisample(36161,bt,_t,ee.width,ee.height),e.framebufferRenderbuffer(36160,36064+ze,36161,_e.__webglColorRenderbuffer[ze])}e.bindRenderbuffer(36161,null),ee.depthBuffer&&(_e.__webglDepthRenderbuffer=e.createRenderbuffer(),Ve(_e.__webglDepthRenderbuffer,ee,!0)),i.bindFramebuffer(36160,null)}}if(V){i.bindTexture(34067,We.__webglTexture),ae(34067,W,ut);for(let He=0;He<6;He++)ye(_e.__webglFramebuffer[He],ee,W,36064,34069+He);S(W,ut)&&E(34067),i.unbindTexture()}else if(Oe){let He=ee.texture;for(let ze=0,ke=He.length;ze<ke;ze++){let dt=He[ze],ot=r.get(dt);i.bindTexture(3553,ot.__webglTexture),ae(3553,dt,ut),ye(_e.__webglFramebuffer,ee,dt,36064+ze,3553),S(dt,ut)&&E(3553)}i.unbindTexture()}else{let He=3553;(ee.isWebGL3DRenderTarget||ee.isWebGLArrayRenderTarget)&&(o?He=ee.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(He,We.__webglTexture),ae(He,W,ut),ye(_e.__webglFramebuffer,ee,W,36064,He),S(W,ut)&&E(He),i.unbindTexture()}ee.depthBuffer&&Ce(ee)}function st(ee){let W=_(ee)||o,_e=ee.isWebGLMultipleRenderTargets===!0?ee.texture:[ee.texture];for(let We=0,V=_e.length;We<V;We++){let Oe=_e[We];if(S(Oe,W)){let ut=ee.isWebGLCubeRenderTarget?34067:3553,He=r.get(Oe).__webglTexture;i.bindTexture(ut,He),E(ut),i.unbindTexture()}}}function nt(ee){if(o&&ee.samples>0&&Qe(ee)===!1){let W=ee.isWebGLMultipleRenderTargets?ee.texture:[ee.texture],_e=ee.width,We=ee.height,V=16384,Oe=[],ut=ee.stencilBuffer?33306:36096,He=r.get(ee),ze=ee.isWebGLMultipleRenderTargets===!0;if(ze)for(let ke=0;ke<W.length;ke++)i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+ke,36161,null),i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+ke,3553,null,0);i.bindFramebuffer(36008,He.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,He.__webglFramebuffer);for(let ke=0;ke<W.length;ke++){Oe.push(36064+ke),ee.depthBuffer&&Oe.push(ut);let dt=He.__ignoreDepthValues!==void 0?He.__ignoreDepthValues:!1;if(dt===!1&&(ee.depthBuffer&&(V|=256),ee.stencilBuffer&&(V|=1024)),ze&&e.framebufferRenderbuffer(36008,36064,36161,He.__webglColorRenderbuffer[ke]),dt===!0&&(e.invalidateFramebuffer(36008,[ut]),e.invalidateFramebuffer(36009,[ut])),ze){let ot=r.get(W[ke]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,ot,0)}e.blitFramebuffer(0,0,_e,We,0,0,_e,We,V,9728),p&&e.invalidateFramebuffer(36008,Oe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ze)for(let ke=0;ke<W.length;ke++){i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+ke,36161,He.__webglColorRenderbuffer[ke]);let dt=r.get(W[ke]).__webglTexture;i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+ke,3553,dt,0)}i.bindFramebuffer(36009,He.__webglMultisampledFramebuffer)}}function Ze(ee){return Math.min(u,ee.samples)}function Qe(ee){let W=r.get(ee);return o&&ee.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&W.__useRenderToTexture!==!1}function pt(ee){let W=n.render.frame;f.get(ee)!==W&&(f.set(ee,W),ee.update())}function wt(ee,W){let _e=ee.encoding,We=ee.format,V=ee.type;return ee.isCompressedTexture===!0||ee.isVideoTexture===!0||ee.format===fy||_e!==tn&&(_e===Gt?o===!1?t.has("EXT_sRGB")===!0&&We===qi?(ee.format=fy,ee.minFilter=Xt,ee.generateMipmaps=!1):W=W3.sRGBToLinear(W):(We!==qi||V!==As)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",_e)),W}this.allocateTextureUnit=X,this.resetTextureUnits=Z,this.setTexture2D=le,this.setTexture2DArray=te,this.setTexture3D=ie,this.setTextureCube=fe,this.rebindTextures=it,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=nt,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=Qe}function P6(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===As)return 5121;if(a===dz)return 32819;if(a===pz)return 32820;if(a===hz)return 5120;if(a===cz)return 5122;if(a===F3)return 5123;if(a===uz)return 5124;if(a===Ao)return 5125;if(a===Ti)return 5126;if(a===Oo)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===fz)return 6406;if(a===qi)return 6408;if(a===mz)return 6409;if(a===gz)return 6410;if(a===bh)return 6402;if(a===Ch)return 34041;if(a===fy)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===Rm)return 6403;if(a===vz)return 36244;if(a===Zm)return 33319;if(a===yz)return 33320;if(a===k3)return 36249;if(a===r0||a===s0||a===a0||a===n0)if(n===Gt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===r0)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===s0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===a0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===n0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===r0)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===s0)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===a0)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===n0)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===E2||a===C2||a===T2||a===P2)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===E2)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===C2)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===T2)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===P2)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===xz)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===D2||a===I2)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===D2)return n===Gt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===I2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===O2||a===R2||a===L2||a===B2||a===z2||a===F2||a===k2||a===U2||a===N2||a===V2||a===j2||a===H2||a===G2||a===W2)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===O2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===R2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===L2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===B2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===z2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===F2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===k2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===U2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===N2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===V2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===j2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===H2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===G2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===W2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===o0)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===o0)return n===Gt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===bz||a===q2||a===X2||a===Y2)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===o0)return o.COMPRESSED_RED_RGTC1_EXT;if(a===q2)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===X2)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===Y2)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===xh?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var D6=class extends bs{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Eo=class extends Mi{constructor(){super(),this.isGroup=!0,this.type="Group"}},I6={type:"move"},R0=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Eo,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 Eo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new I,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new I),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Eo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new I,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new I),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],c=l.joints["thumb-tip"],u=h.position.distanceTo(c.position),d=.02,p=.005;l.inputState.pinching&&u>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(I6)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Eo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},ou=class extends Ji{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:bh,h!==bh&&h!==Ch)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===bh&&(i=Ao),i===void 0&&h===Ch&&(i=xh),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:$t,this.minFilter=o!==void 0?o:$t,this.flipY=!1,this.generateMipmaps=!1}},O6=class extends gs{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=t.getContextAttributes(),g=null,m=null,y=[],x=[],b=new Set,_=new Map,M=new bs;M.layers.enable(1),M.viewport=new zt;let S=new bs;S.layers.enable(2),S.viewport=new zt;let E=[M,S],A=new D6;A.layers.enable(1),A.layers.enable(2);let T=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let ie=y[te];return ie===void 0&&(ie=new R0,y[te]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(te){let ie=y[te];return ie===void 0&&(ie=new R0,y[te]=ie),ie.getGripSpace()},this.getHand=function(te){let ie=y[te];return ie===void 0&&(ie=new R0,y[te]=ie),ie.getHandSpace()};function R(te){let ie=x.indexOf(te.inputSource);if(ie===-1)return;let fe=y[ie];fe!==void 0&&fe.dispatchEvent({type:te.type,data:te.inputSource})}function z(){r.removeEventListener("select",R),r.removeEventListener("selectstart",R),r.removeEventListener("selectend",R),r.removeEventListener("squeeze",R),r.removeEventListener("squeezestart",R),r.removeEventListener("squeezeend",R),r.removeEventListener("end",z),r.removeEventListener("inputsourceschange",U);for(let te=0;te<y.length;te++){let ie=x[te];ie!==null&&(x[te]=null,y[te].disconnect(ie))}T=null,P=null,e.setRenderTarget(g),d=null,u=null,c=null,r=null,m=null,le.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){s=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){n=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(te){l=te},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(te){if(r=te,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",R),r.addEventListener("selectstart",R),r.addEventListener("selectend",R),r.addEventListener("squeeze",R),r.addEventListener("squeezestart",R),r.addEventListener("squeezeend",R),r.addEventListener("end",z),r.addEventListener("inputsourceschange",U),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let ie={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,ie),r.updateRenderState({baseLayer:d}),m=new hi(d.framebufferWidth,d.framebufferHeight,{format:qi,type:As,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let ie=null,fe=null,ce=null;f.depth&&(ce=f.stencil?35056:33190,ie=f.stencil?Ch:bh,fe=f.stencil?xh:Ao);let ue={colorFormat:32856,depthFormat:ce,scaleFactor:s};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(ue),r.updateRenderState({layers:[u]}),m=new hi(u.textureWidth,u.textureHeight,{format:qi,type:As,depthTexture:new ou(u.textureWidth,u.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let ae=e.properties.get(m);ae.__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),le.setContext(r),le.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function U(te){for(let ie=0;ie<te.removed.length;ie++){let fe=te.removed[ie],ce=x.indexOf(fe);ce>=0&&(x[ce]=null,y[ce].disconnect(fe))}for(let ie=0;ie<te.added.length;ie++){let fe=te.added[ie],ce=x.indexOf(fe);if(ce===-1){for(let ae=0;ae<y.length;ae++)if(ae>=x.length){x.push(fe),ce=ae;break}else if(x[ae]===null){x[ae]=fe,ce=ae;break}if(ce===-1)break}let ue=y[ce];ue&&ue.connect(fe)}}let L=new I,H=new I;function q(te,ie,fe){L.setFromMatrixPosition(ie.matrixWorld),H.setFromMatrixPosition(fe.matrixWorld);let ce=L.distanceTo(H),ue=ie.projectionMatrix.elements,ae=fe.projectionMatrix.elements,Pe=ue[14]/(ue[10]-1),ve=ue[14]/(ue[10]+1),Ae=(ue[9]+1)/ue[5],ye=(ue[9]-1)/ue[5],Ve=(ue[8]-1)/ue[0],Ie=(ae[8]+1)/ae[0],Ce=Pe*Ve,it=Pe*Ie,Je=ce/(-Ve+Ie),st=Je*-Ve;ie.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(st),te.translateZ(Je),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();let nt=Pe+Je,Ze=ve+Je,Qe=Ce-st,pt=it+(ce-st),wt=Ae*ve/Ze*nt,ee=ye*ve/Ze*nt;te.projectionMatrix.makePerspective(Qe,pt,wt,ee,nt,Ze)}function Z(te,ie){ie===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(ie.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(r===null)return;A.near=S.near=M.near=te.near,A.far=S.far=M.far=te.far,(T!==A.near||P!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),T=A.near,P=A.far);let ie=te.parent,fe=A.cameras;Z(A,ie);for(let ue=0;ue<fe.length;ue++)Z(fe[ue],ie);A.matrixWorld.decompose(A.position,A.quaternion,A.scale),te.matrix.copy(A.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale);let ce=te.children;for(let ue=0,ae=ce.length;ue<ae;ue++)ce[ue].updateMatrixWorld(!0);fe.length===2?q(A,M,S):A.projectionMatrix.copy(M.projectionMatrix)},this.getCamera=function(){return A},this.getFoveation=function(){if(!(u===null&&d===null))return o},this.setFoveation=function(te){o=te,u!==null&&(u.fixedFoveation=te),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=te)},this.getPlanes=function(){return b};let X=null;function se(te,ie){if(h=ie.getViewerPose(l||a),p=ie,h!==null){let fe=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let ce=!1;fe.length!==A.cameras.length&&(A.cameras.length=0,ce=!0);for(let ue=0;ue<fe.length;ue++){let ae=fe[ue],Pe=null;if(d!==null)Pe=d.getViewport(ae);else{let Ae=c.getViewSubImage(u,ae);Pe=Ae.viewport,ue===0&&(e.setRenderTargetTextures(m,Ae.colorTexture,u.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(m))}let ve=E[ue];ve===void 0&&(ve=new bs,ve.layers.enable(ue),ve.viewport=new zt,E[ue]=ve),ve.matrix.fromArray(ae.transform.matrix),ve.projectionMatrix.fromArray(ae.projectionMatrix),ve.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),ue===0&&A.matrix.copy(ve.matrix),ce===!0&&A.cameras.push(ve)}}for(let fe=0;fe<y.length;fe++){let ce=x[fe],ue=y[fe];ce!==null&&ue!==void 0&&ue.update(ce,ie,l||a)}if(X&&X(te,ie),ie.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:ie.detectedPlanes});let fe=null;for(let ce of b)ie.detectedPlanes.has(ce)||(fe===null&&(fe=[]),fe.push(ce));if(fe!==null)for(let ce of fe)b.delete(ce),_.delete(ce),i.dispatchEvent({type:"planeremoved",data:ce});for(let ce of ie.detectedPlanes)if(!b.has(ce))b.add(ce),_.set(ce,ie.lastChangedTime),i.dispatchEvent({type:"planeadded",data:ce});else{let ue=_.get(ce);ce.lastChangedTime>ue&&(_.set(ce,ce.lastChangedTime),i.dispatchEvent({type:"planechanged",data:ce}))}}p=null}let le=new K3;le.setAnimationLoop(se),this.setAnimationLoop=function(te){X=te},this.dispose=function(){}}};function R6(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,Z3(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,y,x,b){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),c(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),u(g,m),m.isMeshPhysicalMaterial&&d(g,m,b)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&n(g,m)):m.isPointsMaterial?o(g,m,y,x):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===$r&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===$r&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let y=t.get(m).envMap;if(y&&(g.envMap.value=y,g.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let _=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*_}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let x;m.map?x=m.map:m.specularMap?x=m.specularMap:m.displacementMap?x=m.displacementMap:m.normalMap?x=m.normalMap:m.bumpMap?x=m.bumpMap:m.roughnessMap?x=m.roughnessMap:m.metalnessMap?x=m.metalnessMap:m.alphaMap?x=m.alphaMap:m.emissiveMap?x=m.emissiveMap:m.clearcoatMap?x=m.clearcoatMap:m.clearcoatNormalMap?x=m.clearcoatNormalMap:m.clearcoatRoughnessMap?x=m.clearcoatRoughnessMap:m.iridescenceMap?x=m.iridescenceMap:m.iridescenceThicknessMap?x=m.iridescenceThicknessMap:m.specularIntensityMap?x=m.specularIntensityMap:m.specularColorMap?x=m.specularColorMap:m.transmissionMap?x=m.transmissionMap:m.thicknessMap?x=m.thicknessMap:m.sheenColorMap?x=m.sheenColorMap:m.sheenRoughnessMap&&(x=m.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix));let b;m.aoMap?b=m.aoMap:m.lightMap&&(b=m.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uv2Transform.value.copy(b.matrix))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function n(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,y,x){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=x*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let b;m.map?b=m.map:m.alphaMap&&(b=m.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uvTransform.value.copy(b.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function c(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function u(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===$r&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function L6(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(x,b){let _=b.program;r.uniformBlockBinding(x,_)}function h(x,b){let _=s[x.id];_===void 0&&(f(x),_=c(x),s[x.id]=_,x.addEventListener("dispose",m));let M=b.program;r.updateUBOMapping(x,M);let S=t.render.frame;a[x.id]!==S&&(d(x),a[x.id]=S)}function c(x){let b=u();x.__bindingPointIndex=b;let _=e.createBuffer(),M=x.__size,S=x.usage;return e.bindBuffer(35345,_),e.bufferData(35345,M,S),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,_),_}function u(){for(let x=0;x<o;x++)if(n.indexOf(x)===-1)return n.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let b=s[x.id],_=x.uniforms,M=x.__cache;e.bindBuffer(35345,b);for(let S=0,E=_.length;S<E;S++){let A=_[S];if(p(A,S,M)===!0){let T=A.__offset,P=Array.isArray(A.value)?A.value:[A.value],R=0;for(let z=0;z<P.length;z++){let U=P[z],L=g(U);typeof U=="number"?(A.__data[0]=U,e.bufferSubData(35345,T+R,A.__data)):U.isMatrix3?(A.__data[0]=U.elements[0],A.__data[1]=U.elements[1],A.__data[2]=U.elements[2],A.__data[3]=U.elements[0],A.__data[4]=U.elements[3],A.__data[5]=U.elements[4],A.__data[6]=U.elements[5],A.__data[7]=U.elements[0],A.__data[8]=U.elements[6],A.__data[9]=U.elements[7],A.__data[10]=U.elements[8],A.__data[11]=U.elements[0]):(U.toArray(A.__data,R),R+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,T,A.__data)}}e.bindBuffer(35345,null)}function p(x,b,_){let M=x.value;if(_[b]===void 0){if(typeof M=="number")_[b]=M;else{let S=Array.isArray(M)?M:[M],E=[];for(let A=0;A<S.length;A++)E.push(S[A].clone());_[b]=E}return!0}else if(typeof M=="number"){if(_[b]!==M)return _[b]=M,!0}else{let S=Array.isArray(_[b])?_[b]:[_[b]],E=Array.isArray(M)?M:[M];for(let A=0;A<S.length;A++){let T=S[A];if(T.equals(E[A])===!1)return T.copy(E[A]),!0}}return!1}function f(x){let b=x.uniforms,_=0,M=16,S=0;for(let E=0,A=b.length;E<A;E++){let T=b[E],P={boundary:0,storage:0},R=Array.isArray(T.value)?T.value:[T.value];for(let z=0,U=R.length;z<U;z++){let L=R[z],H=g(L);P.boundary+=H.boundary,P.storage+=H.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=_,E>0){S=_%M;let z=M-S;S!==0&&z-P.boundary<0&&(_+=M-S,T.__offset=_)}_+=P.storage}return S=_%M,S>0&&(_+=M-S),x.__size=_,x.__cache={},this}function g(x){let b={boundary:0,storage:0};return typeof x=="number"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),b}function m(x){let b=x.target;b.removeEventListener("dispose",m);let _=n.indexOf(b.__bindingPointIndex);n.splice(_,1),e.deleteBuffer(s[b.id]),delete s[b.id],delete a[b.id]}function y(){for(let x in s)e.deleteBuffer(s[x]);n=[],s={},a={}}return{bind:l,update:h,dispose:y}}function B6(){let e=sp("canvas");return e.style.display="block",e}function rT(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:B6(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,c;i!==null?c=i.getContextAttributes().alpha:c=e.alpha!==void 0?e.alpha:!1;let u=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=tn,this.physicallyCorrectLights=!1,this.toneMapping=Ln,this.toneMappingExposure=1;let g=this,m=!1,y=0,x=0,b=null,_=-1,M=null,S=new zt,E=new zt,A=null,T=t.width,P=t.height,R=1,z=null,U=null,L=new zt(0,0,T,P),H=new zt(0,0,T,P),q=!1,Z=new _b,X=!1,se=!1,le=null,te=new je,ie=new re,fe=new I,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ue(){return b===null?R:1}let ae=i;function Pe(J,Se){for(let Te=0;Te<J.length;Te++){let be=J[Te],Be=t.getContext(be,Se);if(Be!==null)return Be}return null}try{let J={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${bu}`),t.addEventListener("webglcontextlost",_t,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",ri,!1),ae===null){let Se=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&Se.shift(),ae=Pe(Se,J),ae===null)throw Pe(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ae.getShaderPrecisionFormat===void 0&&(ae.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let ve,Ae,ye,Ve,Ie,Ce,it,Je,st,nt,Ze,Qe,pt,wt,ee,W,_e,We,V,Oe,ut,He,ze,ke;function dt(){ve=new Yk(ae),Ae=new jk(ae,ve,e),ve.init(Ae),He=new P6(ae,ve,Ae),ye=new C6(ae,ve,Ae),Ve=new Kk,Ie=new f6,Ce=new T6(ae,ve,ye,Ie,Ae,He,Ve),it=new Gk(g),Je=new Xk(g),st=new n5(ae,Ae),ze=new Nk(ae,ve,st,Ae),nt=new Qk(ae,st,Ve,ze),Ze=new tU(ae,nt,st,Ve),V=new eU(ae,Ae,Ce),W=new Hk(Ie),Qe=new p6(g,it,Je,ve,Ae,ze,W),pt=new R6(g,Ie),wt=new g6,ee=new _6(ve,Ae),We=new Uk(g,it,Je,ye,Ze,c,n),_e=new E6(g,Ze,Ae),ke=new L6(ae,Ve,Ae,ye),Oe=new Vk(ae,ve,Ve,Ae),ut=new Zk(ae,ve,Ve,Ae),Ve.programs=Qe.programs,g.capabilities=Ae,g.extensions=ve,g.properties=Ie,g.renderLists=wt,g.shadowMap=_e,g.state=ye,g.info=Ve}dt();let ot=new O6(g,ae);this.xr=ot,this.getContext=function(){return ae},this.getContextAttributes=function(){return ae.getContextAttributes()},this.forceContextLoss=function(){let J=ve.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){let J=ve.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(J){J!==void 0&&(R=J,this.setSize(T,P,!1))},this.getSize=function(J){return J.set(T,P)},this.setSize=function(J,Se,Te){if(ot.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=J,P=Se,t.width=Math.floor(J*R),t.height=Math.floor(Se*R),Te!==!1&&(t.style.width=J+"px",t.style.height=Se+"px"),this.setViewport(0,0,J,Se)},this.getDrawingBufferSize=function(J){return J.set(T*R,P*R).floor()},this.setDrawingBufferSize=function(J,Se,Te){T=J,P=Se,R=Te,t.width=Math.floor(J*Te),t.height=Math.floor(Se*Te),this.setViewport(0,0,J,Se)},this.getCurrentViewport=function(J){return J.copy(S)},this.getViewport=function(J){return J.copy(L)},this.setViewport=function(J,Se,Te,be){J.isVector4?L.set(J.x,J.y,J.z,J.w):L.set(J,Se,Te,be),ye.viewport(S.copy(L).multiplyScalar(R).floor())},this.getScissor=function(J){return J.copy(H)},this.setScissor=function(J,Se,Te,be){J.isVector4?H.set(J.x,J.y,J.z,J.w):H.set(J,Se,Te,be),ye.scissor(E.copy(H).multiplyScalar(R).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(J){ye.setScissorTest(q=J)},this.setOpaqueSort=function(J){z=J},this.setTransparentSort=function(J){U=J},this.getClearColor=function(J){return J.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor.apply(We,arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha.apply(We,arguments)},this.clear=function(J=!0,Se=!0,Te=!0){let be=0;J&&(be|=16384),Se&&(be|=256),Te&&(be|=1024),ae.clear(be)},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",_t,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ri,!1),wt.dispose(),ee.dispose(),Ie.dispose(),it.dispose(),Je.dispose(),Ze.dispose(),ze.dispose(),ke.dispose(),Qe.dispose(),ot.dispose(),ot.removeEventListener("sessionstart",Ke),ot.removeEventListener("sessionend",vt),le&&(le.dispose(),le=null),Mt.stop()};function _t(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function bt(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let J=Ve.autoReset,Se=_e.enabled,Te=_e.autoUpdate,be=_e.needsUpdate,Be=_e.type;dt(),Ve.autoReset=J,_e.enabled=Se,_e.autoUpdate=Te,_e.needsUpdate=be,_e.type=Be}function ri(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function vi(J){let Se=J.target;Se.removeEventListener("dispose",vi),ii(Se)}function ii(J){me(J),Ie.remove(J)}function me(J){let Se=Ie.get(J).programs;Se!==void 0&&(Se.forEach(function(Te){Qe.releaseProgram(Te)}),J.isShaderMaterial&&Qe.releaseShaderCache(J))}this.renderBufferDirect=function(J,Se,Te,be,Be,rt){Se===null&&(Se=ce);let Bt=Be.isMesh&&Be.matrixWorld.determinant()<0,kt=ju(J,Se,Te,be,Be);ye.setMaterial(be,Bt);let Ft=Te.index,oi=1;be.wireframe===!0&&(Ft=nt.getWireframeAttribute(Te),oi=2);let Kt=Te.drawRange,Vt=Te.attributes.position,gi=Kt.start*oi,$i=(Kt.start+Kt.count)*oi;rt!==null&&(gi=Math.max(gi,rt.start*oi),$i=Math.min($i,(rt.start+rt.count)*oi)),Ft!==null?(gi=Math.max(gi,0),$i=Math.min($i,Ft.count)):Vt!=null&&(gi=Math.max(gi,0),$i=Math.min($i,Vt.count));let Wi=$i-gi;if(Wi<0||Wi===1/0)return;ze.setup(Be,be,kt,Te,Ft);let er,Fi=Oe;if(Ft!==null&&(er=st.get(Ft),Fi=ut,Fi.setIndex(er)),Be.isMesh)be.wireframe===!0?(ye.setLineWidth(be.wireframeLinewidth*ue()),Fi.setMode(1)):Fi.setMode(4);else if(Be.isLine){let St=be.linewidth;St===void 0&&(St=1),ye.setLineWidth(St*ue()),Be.isLineSegments?Fi.setMode(1):Be.isLineLoop?Fi.setMode(2):Fi.setMode(3)}else Be.isPoints?Fi.setMode(0):Be.isSprite&&Fi.setMode(4);if(Be.isInstancedMesh)Fi.renderInstances(gi,Wi,Be.count);else if(Te.isInstancedBufferGeometry){let St=Te._maxInstanceCount!==void 0?Te._maxInstanceCount:1/0,on=Math.min(Te.instanceCount,St);Fi.renderInstances(gi,Wi,on)}else Fi.render(gi,Wi)},this.compile=function(J,Se){function Te(be,Be,rt){be.transparent===!0&&be.side===_s&&be.forceSinglePass===!1?(be.side=$r,be.needsUpdate=!0,Pr(be,Be,rt),be.side=en,be.needsUpdate=!0,Pr(be,Be,rt),be.side=_s):Pr(be,Be,rt)}d=ee.get(J),d.init(),f.push(d),J.traverseVisible(function(be){be.isLight&&be.layers.test(Se.layers)&&(d.pushLight(be),be.castShadow&&d.pushShadow(be))}),d.setupLights(g.physicallyCorrectLights),J.traverse(function(be){let Be=be.material;if(Be)if(Array.isArray(Be))for(let rt=0;rt<Be.length;rt++){let Bt=Be[rt];Te(Bt,J,be)}else Te(Be,J,be)}),f.pop(),d=null};let Ee=null;function Xe(J){Ee&&Ee(J)}function Ke(){Mt.stop()}function vt(){Mt.start()}let Mt=new K3;Mt.setAnimationLoop(Xe),typeof self<"u"&&Mt.setContext(self),this.setAnimationLoop=function(J){Ee=J,ot.setAnimationLoop(J),J===null?Mt.stop():Mt.start()},ot.addEventListener("sessionstart",Ke),ot.addEventListener("sessionend",vt),this.render=function(J,Se){if(Se!==void 0&&Se.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(Se),Se=ot.getCamera()),J.isScene===!0&&J.onBeforeRender(g,J,Se,b),d=ee.get(J,f.length),d.init(),f.push(d),te.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),Z.setFromProjectionMatrix(te),se=this.localClippingEnabled,X=W.init(this.clippingPlanes,se),u=wt.get(J,p.length),u.init(),p.push(u),wi(J,Se,0,g.sortObjects),u.finish(),g.sortObjects===!0&&u.sort(z,U),X===!0&&W.beginShadows();let Te=d.state.shadowsArray;if(_e.render(Te,J,Se),X===!0&&W.endShadows(),this.info.autoReset===!0&&this.info.reset(),We.render(u,J),d.setupLights(g.physicallyCorrectLights),Se.isArrayCamera){let be=Se.cameras;for(let Be=0,rt=be.length;Be<rt;Be++){let Bt=be[Be];ji(u,J,Bt,Bt.viewport)}}else ji(u,J,Se);b!==null&&(Ce.updateMultisampleRenderTarget(b),Ce.updateRenderTargetMipmap(b)),J.isScene===!0&&J.onAfterRender(g,J,Se),ze.resetDefaultState(),_=-1,M=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?u=p[p.length-1]:u=null};function wi(J,Se,Te,be){if(J.visible===!1)return;if(J.layers.test(Se.layers)){if(J.isGroup)Te=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(Se);else if(J.isLight)d.pushLight(J),J.castShadow&&d.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||Z.intersectsSprite(J)){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let rt=Ze.update(J),Bt=J.material;Bt.visible&&u.push(J,rt,Bt,Te,fe.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(J.isSkinnedMesh&&J.skeleton.frame!==Ve.render.frame&&(J.skeleton.update(),J.skeleton.frame=Ve.render.frame),!J.frustumCulled||Z.intersectsObject(J))){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let rt=Ze.update(J),Bt=J.material;if(Array.isArray(Bt)){let kt=rt.groups;for(let Ft=0,oi=kt.length;Ft<oi;Ft++){let Kt=kt[Ft],Vt=Bt[Kt.materialIndex];Vt&&Vt.visible&&u.push(J,rt,Vt,Te,fe.z,Kt)}}else Bt.visible&&u.push(J,rt,Bt,Te,fe.z,null)}}let Be=J.children;for(let rt=0,Bt=Be.length;rt<Bt;rt++)wi(Be[rt],Se,Te,be)}function ji(J,Se,Te,be){let Be=J.opaque,rt=J.transmissive,Bt=J.transparent;d.setupLightsView(Te),X===!0&&W.setGlobalState(g.clippingPlanes,Te),rt.length>0&&Tr(Be,Se,Te),be&&ye.viewport(S.copy(be)),Be.length>0&&Ei(Be,Se,Te),rt.length>0&&Ei(rt,Se,Te),Bt.length>0&&Ei(Bt,Se,Te),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function Tr(J,Se,Te){let be=Ae.isWebGL2;le===null&&(le=new hi(1,1,{generateMipmaps:!0,type:ve.has("EXT_color_buffer_half_float")?Oo:As,minFilter:au,samples:be&&a===!0?4:0})),g.getDrawingBufferSize(ie),be?le.setSize(ie.x,ie.y):le.setSize(tg(ie.x),tg(ie.y));let Be=g.getRenderTarget();g.setRenderTarget(le),g.clear();let rt=g.toneMapping;g.toneMapping=Ln,Ei(J,Se,Te),g.toneMapping=rt,Ce.updateMultisampleRenderTarget(le),Ce.updateRenderTargetMipmap(le),g.setRenderTarget(Be)}function Ei(J,Se,Te){let be=Se.isScene===!0?Se.overrideMaterial:null;for(let Be=0,rt=J.length;Be<rt;Be++){let Bt=J[Be],kt=Bt.object,Ft=Bt.geometry,oi=be===null?Bt.material:be,Kt=Bt.group;kt.layers.test(Te.layers)&&ss(kt,Se,Te,Ft,oi,Kt)}}function ss(J,Se,Te,be,Be,rt){J.onBeforeRender(g,Se,Te,be,Be,rt),J.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),Be.onBeforeRender(g,Se,Te,be,J,rt),Be.transparent===!0&&Be.side===_s&&Be.forceSinglePass===!1?(Be.side=$r,Be.needsUpdate=!0,g.renderBufferDirect(Te,Se,be,Be,J,rt),Be.side=en,Be.needsUpdate=!0,g.renderBufferDirect(Te,Se,be,Be,J,rt),Be.side=_s):g.renderBufferDirect(Te,Se,be,Be,J,rt),J.onAfterRender(g,Se,Te,be,Be,rt)}function Pr(J,Se,Te){Se.isScene!==!0&&(Se=ce);let be=Ie.get(J),Be=d.state.lights,rt=d.state.shadowsArray,Bt=Be.state.version,kt=Qe.getParameters(J,Be.state,rt,Se,Te),Ft=Qe.getProgramCacheKey(kt),oi=be.programs;be.environment=J.isMeshStandardMaterial?Se.environment:null,be.fog=Se.fog,be.envMap=(J.isMeshStandardMaterial?Je:it).get(J.envMap||be.environment),oi===void 0&&(J.addEventListener("dispose",vi),oi=new Map,be.programs=oi);let Kt=oi.get(Ft);if(Kt!==void 0){if(be.currentProgram===Kt&&be.lightsStateVersion===Bt)return No(J,kt),Kt}else kt.uniforms=Qe.getUniforms(J),J.onBuild(Te,kt,g),J.onBeforeCompile(kt,g),Kt=Qe.acquireProgram(kt,Ft),oi.set(Ft,Kt),be.uniforms=kt.uniforms;let Vt=be.uniforms;(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(Vt.clippingPlanes=W.uniform),No(J,kt),be.needsLights=Wh(J),be.lightsStateVersion=Bt,be.needsLights&&(Vt.ambientLightColor.value=Be.state.ambient,Vt.lightProbe.value=Be.state.probe,Vt.directionalLights.value=Be.state.directional,Vt.directionalLightShadows.value=Be.state.directionalShadow,Vt.spotLights.value=Be.state.spot,Vt.spotLightShadows.value=Be.state.spotShadow,Vt.rectAreaLights.value=Be.state.rectArea,Vt.ltc_1.value=Be.state.rectAreaLTC1,Vt.ltc_2.value=Be.state.rectAreaLTC2,Vt.pointLights.value=Be.state.point,Vt.pointLightShadows.value=Be.state.pointShadow,Vt.hemisphereLights.value=Be.state.hemi,Vt.directionalShadowMap.value=Be.state.directionalShadowMap,Vt.directionalShadowMatrix.value=Be.state.directionalShadowMatrix,Vt.spotShadowMap.value=Be.state.spotShadowMap,Vt.spotLightMatrix.value=Be.state.spotLightMatrix,Vt.spotLightMap.value=Be.state.spotLightMap,Vt.pointShadowMap.value=Be.state.pointShadowMap,Vt.pointShadowMatrix.value=Be.state.pointShadowMatrix);let gi=Kt.getUniforms(),$i=Bm.seqWithValue(gi.seq,Vt);return be.currentProgram=Kt,be.uniformsList=$i,Kt}function No(J,Se){let Te=Ie.get(J);Te.outputEncoding=Se.outputEncoding,Te.instancing=Se.instancing,Te.skinning=Se.skinning,Te.morphTargets=Se.morphTargets,Te.morphNormals=Se.morphNormals,Te.morphColors=Se.morphColors,Te.morphTargetsCount=Se.morphTargetsCount,Te.numClippingPlanes=Se.numClippingPlanes,Te.numIntersection=Se.numClipIntersection,Te.vertexAlphas=Se.vertexAlphas,Te.vertexTangents=Se.vertexTangents,Te.toneMapping=Se.toneMapping}function ju(J,Se,Te,be,Be){Se.isScene!==!0&&(Se=ce),Ce.resetTextureUnits();let rt=Se.fog,Bt=be.isMeshStandardMaterial?Se.environment:null,kt=b===null?g.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:tn,Ft=(be.isMeshStandardMaterial?Je:it).get(be.envMap||Bt),oi=be.vertexColors===!0&&!!Te.attributes.color&&Te.attributes.color.itemSize===4,Kt=!!be.normalMap&&!!Te.attributes.tangent,Vt=!!Te.morphAttributes.position,gi=!!Te.morphAttributes.normal,$i=!!Te.morphAttributes.color,Wi=be.toneMapped?g.toneMapping:Ln,er=Te.morphAttributes.position||Te.morphAttributes.normal||Te.morphAttributes.color,Fi=er!==void 0?er.length:0,St=Ie.get(be),on=d.state.lights;if(X===!0&&(se===!0||J!==M)){let Xi=J===M&&be.id===_;W.setState(be,J,Xi)}let aa=!1;be.version===St.__version?(St.needsLights&&St.lightsStateVersion!==on.state.version||St.outputEncoding!==kt||Be.isInstancedMesh&&St.instancing===!1||!Be.isInstancedMesh&&St.instancing===!0||Be.isSkinnedMesh&&St.skinning===!1||!Be.isSkinnedMesh&&St.skinning===!0||St.envMap!==Ft||be.fog===!0&&St.fog!==rt||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==W.numPlanes||St.numIntersection!==W.numIntersection)||St.vertexAlphas!==oi||St.vertexTangents!==Kt||St.morphTargets!==Vt||St.morphNormals!==gi||St.morphColors!==$i||St.toneMapping!==Wi||Ae.isWebGL2===!0&&St.morphTargetsCount!==Fi)&&(aa=!0):(aa=!0,St.__version=be.version);let na=St.currentProgram;aa===!0&&(na=Pr(be,Se,Be));let ei=!1,vr=!1,qn=!1,or=na.getUniforms(),oa=St.uniforms;if(ye.useProgram(na.program)&&(ei=!0,vr=!0,qn=!0),be.id!==_&&(_=be.id,vr=!0),ei||M!==J){if(or.setValue(ae,"projectionMatrix",J.projectionMatrix),Ae.logarithmicDepthBuffer&&or.setValue(ae,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),M!==J&&(M=J,vr=!0,qn=!0),be.isShaderMaterial||be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshStandardMaterial||be.envMap){let Xi=or.map.cameraPosition;Xi!==void 0&&Xi.setValue(ae,fe.setFromMatrixPosition(J.matrixWorld))}(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial)&&or.setValue(ae,"isOrthographic",J.isOrthographicCamera===!0),(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial||be.isShadowMaterial||Be.isSkinnedMesh)&&or.setValue(ae,"viewMatrix",J.matrixWorldInverse)}if(Be.isSkinnedMesh){or.setOptional(ae,Be,"bindMatrix"),or.setOptional(ae,Be,"bindMatrixInverse");let Xi=Be.skeleton;Xi&&(Ae.floatVertexTextures?(Xi.boneTexture===null&&Xi.computeBoneTexture(),or.setValue(ae,"boneTexture",Xi.boneTexture,Ce),or.setValue(ae,"boneTextureSize",Xi.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 Xn=Te.morphAttributes;if((Xn.position!==void 0||Xn.normal!==void 0||Xn.color!==void 0&&Ae.isWebGL2===!0)&&V.update(Be,Te,be,na),(vr||St.receiveShadow!==Be.receiveShadow)&&(St.receiveShadow=Be.receiveShadow,or.setValue(ae,"receiveShadow",Be.receiveShadow)),be.isMeshGouraudMaterial&&be.envMap!==null&&(oa.envMap.value=Ft,oa.flipEnvMap.value=Ft.isCubeTexture&&Ft.isRenderTargetTexture===!1?-1:1),vr&&(or.setValue(ae,"toneMappingExposure",g.toneMappingExposure),St.needsLights&&Nl(oa,qn),rt&&be.fog===!0&&pt.refreshFogUniforms(oa,rt),pt.refreshMaterialUniforms(oa,be,R,P,le),Bm.upload(ae,St.uniformsList,oa,Ce)),be.isShaderMaterial&&be.uniformsNeedUpdate===!0&&(Bm.upload(ae,St.uniformsList,oa,Ce),be.uniformsNeedUpdate=!1),be.isSpriteMaterial&&or.setValue(ae,"center",Be.center),or.setValue(ae,"modelViewMatrix",Be.modelViewMatrix),or.setValue(ae,"normalMatrix",Be.normalMatrix),or.setValue(ae,"modelMatrix",Be.matrixWorld),Be.previousModelViewMatrix&&or.setValue(ae,"previousModelViewMatrix",Be.previousModelViewMatrix),J.previousProjectionMatrix&&or.setValue(ae,"previousProjectionMatrix",J.previousProjectionMatrix),be.isShaderMaterial||be.isRawShaderMaterial){let Xi=be.uniformsGroups;for(let Yt=0,Hu=Xi.length;Yt<Hu;Yt++)if(Ae.isWebGL2){let Yn=Xi[Yt];ke.update(Yn,na),ke.bind(Yn,na)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return na}function Nl(J,Se){J.ambientLightColor.needsUpdate=Se,J.lightProbe.needsUpdate=Se,J.directionalLights.needsUpdate=Se,J.directionalLightShadows.needsUpdate=Se,J.pointLights.needsUpdate=Se,J.pointLightShadows.needsUpdate=Se,J.spotLights.needsUpdate=Se,J.spotLightShadows.needsUpdate=Se,J.rectAreaLights.needsUpdate=Se,J.hemisphereLights.needsUpdate=Se}function Wh(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(J,Se,Te){Ie.get(J.texture).__webglTexture=Se,Ie.get(J.depthTexture).__webglTexture=Te;let be=Ie.get(J);be.__hasExternalTextures=!0,be.__hasExternalTextures&&(be.__autoAllocateDepthBuffer=Te===void 0,be.__autoAllocateDepthBuffer||ve.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),be.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(J,Se){let Te=Ie.get(J);Te.__webglFramebuffer=Se,Te.__useDefaultFramebuffer=Se===void 0},this.setRenderTarget=function(J,Se=0,Te=0){b=J,y=Se,x=Te;let be=!0,Be=null,rt=!1,Bt=!1;if(J){let kt=Ie.get(J);kt.__useDefaultFramebuffer!==void 0?(ye.bindFramebuffer(36160,null),be=!1):kt.__webglFramebuffer===void 0?Ce.setupRenderTarget(J):kt.__hasExternalTextures&&Ce.rebindTextures(J,Ie.get(J.texture).__webglTexture,Ie.get(J.depthTexture).__webglTexture);let Ft=J.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(Bt=!0);let oi=Ie.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Be=oi[Se],rt=!0):Ae.isWebGL2&&J.samples>0&&Ce.useMultisampledRTT(J)===!1?Be=Ie.get(J).__webglMultisampledFramebuffer:Be=oi,S.copy(J.viewport),E.copy(J.scissor),A=J.scissorTest}else S.copy(L).multiplyScalar(R).floor(),E.copy(H).multiplyScalar(R).floor(),A=q;if(ye.bindFramebuffer(36160,Be)&&Ae.drawBuffers&&be&&ye.drawBuffers(J,Be),ye.viewport(S),ye.scissor(E),ye.setScissorTest(A),rt){let kt=Ie.get(J.texture);ae.framebufferTexture2D(36160,36064,34069+Se,kt.__webglTexture,Te)}else if(Bt){let kt=Ie.get(J.texture),Ft=Se||0;ae.framebufferTextureLayer(36160,36064,kt.__webglTexture,Te||0,Ft)}_=-1},this.readRenderTargetPixels=function(J,Se,Te,be,Be,rt,Bt){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let kt=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&Bt!==void 0&&(kt=kt[Bt]),kt){ye.bindFramebuffer(36160,kt);try{let Ft=J.texture,oi=Ft.format,Kt=Ft.type;if(oi!==qi&&He.convert(oi)!==ae.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Vt=Kt===Oo&&(ve.has("EXT_color_buffer_half_float")||Ae.isWebGL2&&ve.has("EXT_color_buffer_float"));if(Kt!==As&&He.convert(Kt)!==ae.getParameter(35738)&&!(Kt===Ti&&(Ae.isWebGL2||ve.has("OES_texture_float")||ve.has("WEBGL_color_buffer_float")))&&!Vt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be&&ae.readPixels(Se,Te,be,Be,He.convert(oi),He.convert(Kt),rt)}finally{let Ft=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(36160,Ft)}}},this.readRenderTargetPixelsAsync=async function(J,Se,Te,be,Be,rt,Bt){if(!(J&&J.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let kt=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&Bt!==void 0&&(kt=kt[Bt]),kt){let Ft=J.texture,oi=Ft.format,Kt=Ft.type;if(Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be){ye.bindFramebuffer(ae.FRAMEBUFFER,kt);let Vt=ae.createBuffer();ae.bindBuffer(ae.PIXEL_PACK_BUFFER,Vt),ae.bufferData(ae.PIXEL_PACK_BUFFER,rt.byteLength,ae.STREAM_READ),ae.readPixels(Se,Te,be,Be,He.convert(oi),He.convert(Kt),0);let gi=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(ae.FRAMEBUFFER,gi);let $i=ae.fenceSync(ae.SYNC_GPU_COMMANDS_COMPLETE,0);return ae.flush(),await Nz(ae,$i,4),ae.bindBuffer(ae.PIXEL_PACK_BUFFER,Vt),ae.getBufferSubData(ae.PIXEL_PACK_BUFFER,0,rt),ae.deleteBuffer(Vt),ae.deleteSync($i),rt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(J,Se,Te=0){let be=Math.pow(2,-Te),Be=Math.floor(Se.image.width*be),rt=Math.floor(Se.image.height*be);Ce.setTexture2D(Se,0),ae.copyTexSubImage2D(3553,Te,0,0,J.x,J.y,Be,rt),ye.unbindTexture()},this.copyTextureToTexture=function(J,Se,Te,be=0){let Be=Se.image.width,rt=Se.image.height,Bt=He.convert(Te.format),kt=He.convert(Te.type);Ce.setTexture2D(Te,0),ae.pixelStorei(37440,Te.flipY),ae.pixelStorei(37441,Te.premultiplyAlpha),ae.pixelStorei(3317,Te.unpackAlignment),Se.isDataTexture?ae.texSubImage2D(3553,be,J.x,J.y,Be,rt,Bt,kt,Se.image.data):Se.isCompressedTexture?ae.compressedTexSubImage2D(3553,be,J.x,J.y,Se.mipmaps[0].width,Se.mipmaps[0].height,Bt,Se.mipmaps[0].data):ae.texSubImage2D(3553,be,J.x,J.y,Bt,kt,Se.image),be===0&&Te.generateMipmaps&&ae.generateMipmap(3553),ye.unbindTexture()},this.copyTextureToTexture3D=function(J,Se,Te,be,Be=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let rt=J.max.x-J.min.x+1,Bt=J.max.y-J.min.y+1,kt=J.max.z-J.min.z+1,Ft=He.convert(be.format),oi=He.convert(be.type),Kt;if(be.isData3DTexture)Ce.setTexture3D(be,0),Kt=32879;else if(be.isDataArrayTexture)Ce.setTexture2DArray(be,0),Kt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ae.pixelStorei(37440,be.flipY),ae.pixelStorei(37441,be.premultiplyAlpha),ae.pixelStorei(3317,be.unpackAlignment);let Vt=ae.getParameter(3314),gi=ae.getParameter(32878),$i=ae.getParameter(3316),Wi=ae.getParameter(3315),er=ae.getParameter(32877),Fi=Te.isCompressedTexture?Te.mipmaps[0]:Te.image;ae.pixelStorei(3314,Fi.width),ae.pixelStorei(32878,Fi.height),ae.pixelStorei(3316,J.min.x),ae.pixelStorei(3315,J.min.y),ae.pixelStorei(32877,J.min.z),Te.isDataTexture||Te.isData3DTexture?ae.texSubImage3D(Kt,Be,Se.x,Se.y,Se.z,rt,Bt,kt,Ft,oi,Fi.data):Te.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ae.compressedTexSubImage3D(Kt,Be,Se.x,Se.y,Se.z,rt,Bt,kt,Ft,Fi.data)):ae.texSubImage3D(Kt,Be,Se.x,Se.y,Se.z,rt,Bt,kt,Ft,oi,Fi),ae.pixelStorei(3314,Vt),ae.pixelStorei(32878,gi),ae.pixelStorei(3316,$i),ae.pixelStorei(3315,Wi),ae.pixelStorei(32877,er),Be===0&&be.generateMipmaps&&ae.generateMipmap(Kt),ye.unbindTexture()},this.initRenderTarget=function(J){Ie.get(J).__webglFramebuffer===void 0&&Ce.setupRenderTarget(J)},this.initTexture=function(J){J.isCubeTexture?Ce.setTextureCube(J,0):J.isData3DTexture?Ce.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Ce.setTexture2DArray(J,0):Ce.setTexture2D(J,0),ye.unbindTexture()},this.resetState=function(){y=0,x=0,b=null,ye.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var z6=class extends rT{};z6.prototype.isWebGL1Renderer=!0;var sT=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ct(e),this.near=t,this.far=i}clone(){return new sT(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Zs=class extends Mi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},F6=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=dy,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ca()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ds=new I,vy=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ds.fromBufferAttribute(this,t),Ds.applyMatrix4(e),this.setXYZ(t,Ds.x,Ds.y,Ds.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ds.fromBufferAttribute(this,t),Ds.applyNormalMatrix(e),this.setXYZ(t,Ds.x,Ds.y,Ds.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ds.fromBufferAttribute(this,t),Ds.transformDirection(e),this.setXYZ(t,Ds.x,Ds.y,Ds.z);return this}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Mo(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Mo(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Mo(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Mo(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),i=Bi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),i=Bi(i,this.array),r=Bi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),i=Bi(i,this.array),r=Bi(r,this.array),s=Bi(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Tt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new vy(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},aT=class extends Mi{constructor(){super(),this.isBone=!0,this.type="Bone"}},Fs=class extends Ji{constructor(e=null,t=1,i=1,r,s,a,n,o,l=$t,h=$t,c,u){super(null,a,n,o,l,h,r,s,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},TS=new je,k6=new je,Ab=class{constructor(e=[],t=[]){this.uuid=Ca(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new je;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:k6;TS.multiplyMatrices(n,t[s]),TS.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Ab(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=j3(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Fs(t,e,e,qi,Ti);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new aT),this.bones.push(a),this.boneInverses.push(new je().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},ap=class extends Tt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},PS=new je,DS=new je,Tf=[],U6=new je,od=new zi,N6=class extends zi{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ap(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,U6)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(od.geometry=this.geometry,od.material=this.material,od.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,PS),DS.multiplyMatrices(i,PS),od.matrixWorld=DS,od.raycast(e,Tf);for(let a=0,n=Tf.length;a<n;a++){let o=Tf[a];o.instanceId=s,o.object=this,t.push(o)}Tf.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ap(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},zl=class extends Cp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ct(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},IS=new I,OS=new I,RS=new je,L0=new wu,Pf=new Ks,ig=class extends Mi{constructor(e=new gt,t=new zl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)IS.fromBufferAttribute(t,r-1),OS.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=IS.distanceTo(OS);e.setAttribute("lineDistance",new at(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Pf.copy(i.boundingSphere),Pf.applyMatrix4(r),Pf.radius+=s,e.ray.intersectsSphere(Pf)===!1)return;RS.copy(r).invert(),L0.copy(e.ray).applyMatrix4(RS);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new I,h=new I,c=new I,u=new I,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,a.start),m=Math.min(p.count,a.start+a.count);for(let y=g,x=m-1;y<x;y+=d){let b=p.getX(y),_=p.getX(y+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),L0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(u);M<e.near||M>e.far||t.push({distance:M,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,a.start),m=Math.min(f.count,a.start+a.count);for(let y=g,x=m-1;y<x;y+=d){if(l.fromBufferAttribute(f,y),h.fromBufferAttribute(f,y+1),L0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(u);b<e.near||b>e.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},LS=new I,BS=new I,Tp=class extends ig{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)LS.fromBufferAttribute(t,r),BS.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+LS.distanceTo(BS);e.setAttribute("lineDistance",new at(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},V6=class extends Ji{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Xt,this.magFilter=s!==void 0?s:Xt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},j6=class extends Ji{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Hn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],c=i[r+1]-h,u=(a-h)/c;return(r+u)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new re:new I);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new I,r=[],s=[],a=[],n=new I,o=new je;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new I)}s[0]=new I,a[0]=new I;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),u=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),n.crossVectors(r[d-1],r[d]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(wr(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(n,p))}a[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(wr(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},av=class extends Hn{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new re,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),u=o-this.aX,d=l-this.aY;o=u*h-d*c+this.aX,l=u*c+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},H6=class extends av{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function Mb(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,c,u){let d=(n-a)/h-(o-a)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+u)+(l-o)/u;d*=c,p*=c,s(n,o,d,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var Df=new I,B0=new Mb,z0=new Mb,F0=new Mb,G6=class extends Hn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new I){let i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(Df.subVectors(r[0],r[1]).add(r[0]),l=Df);let c=r[n%s],u=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(Df.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Df),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),d),f=Math.pow(c.distanceToSquared(u),d),g=Math.pow(u.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),B0.initNonuniformCatmullRom(l.x,c.x,u.x,h.x,p,f,g),z0.initNonuniformCatmullRom(l.y,c.y,u.y,h.y,p,f,g),F0.initNonuniformCatmullRom(l.z,c.z,u.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(B0.initCatmullRom(l.x,c.x,u.x,h.x,this.tension),z0.initCatmullRom(l.y,c.y,u.y,h.y,this.tension),F0.initCatmullRom(l.z,c.z,u.z,h.z,this.tension));return i.set(B0.calc(o),z0.calc(o),F0.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new I().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function zS(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function W6(e,t){let i=1-e;return i*i*t}function q6(e,t){return 2*(1-e)*e*t}function X6(e,t){return e*e*t}function jd(e,t,i,r){return W6(e,t)+q6(e,i)+X6(e,r)}function Y6(e,t){let i=1-e;return i*i*i*t}function Q6(e,t){let i=1-e;return 3*i*i*e*t}function Z6(e,t){return 3*(1-e)*e*e*t}function K6(e,t){return e*e*e*t}function Hd(e,t,i,r,s){return Y6(e,t)+Q6(e,i)+Z6(e,r)+K6(e,s)}var Za=class extends Hn{constructor(e=new re,t=new re,i=new re,r=new re){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new re){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(Hd(e,r.x,s.x,a.x,n.x),Hd(e,r.y,s.y,a.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},zm=class extends Hn{constructor(e=new I,t=new I,i=new I,r=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new I){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(Hd(e,r.x,s.x,a.x,n.x),Hd(e,r.y,s.y,a.y,n.y),Hd(e,r.z,s.z,a.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},$a=class extends Hn{constructor(e=new re,t=new re){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new re){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new re;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},nT=class extends Hn{constructor(e=new I,t=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new I){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Dl=class extends Hn{constructor(e=new re,t=new re,i=new re){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new re){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(jd(e,r.x,s.x,a.x),jd(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},J6=class extends Hn{constructor(e=new I,t=new I,i=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new I){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(jd(e,r.x,s.x,a.x),jd(e,r.y,s.y,a.y),jd(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Eb=class extends Hn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new re){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],c=r[a>r.length-3?r.length-1:a+2];return i.set(zS(n,o.x,l.x,h.x,c.x),zS(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new re().fromArray(r))}return this}},$6=Object.freeze({__proto__:null,ArcCurve:H6,CatmullRomCurve3:G6,CubicBezierCurve:Za,CubicBezierCurve3:zm,EllipseCurve:av,LineCurve:$a,LineCurve3:nT,QuadraticBezierCurve:Dl,QuadraticBezierCurve3:J6,SplineCurve:Eb}),oT=class extends Hn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new $a(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new $6[r.type]().fromJSON(r))}return this}},rg=class extends oT{constructor(e){super(),this.type="Path",this.currentPoint=new re,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new $a(this.currentPoint.clone(),new re(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Dl(this.currentPoint.clone(),new re(e,t),new re(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new Za(this.currentPoint.clone(),new re(e,t),new re(i,r),new re(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Eb(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new av(e,t,i,r,s,a,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},lT=class extends gt{constructor(e=[new re(0,-.5),new re(.5,0),new re(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=wr(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,c=new I,u=new re,d=new I,p=new I,f=new I,g=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let y=0;y<=t;y++){let x=i+y*h*r,b=Math.sin(x),_=Math.cos(x);for(let M=0;M<=e.length-1;M++){c.x=e[M].x*b,c.y=e[M].y,c.z=e[M].x*_,a.push(c.x,c.y,c.z),u.x=y/t,u.y=M/(e.length-1),n.push(u.x,u.y);let S=o[3*M+0]*b,E=o[3*M+1],A=o[3*M+0]*_;l.push(S,E,A)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){let b=x+y*e.length,_=b,M=b+e.length,S=b+e.length+1,E=b+1;s.push(_,M,E),s.push(S,E,M)}this.setIndex(s),this.setAttribute("position",new at(a,3)),this.setAttribute("uv",new at(n,2)),this.setAttribute("normal",new at(l,3))}static fromJSON(e){return new lT(e.points,e.segments,e.phiStart,e.phiLength)}},Cb=class extends gt{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],c=[],u=[],d=[],p=0,f=[],g=i/2,m=0;y(),a===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new at(c,3)),this.setAttribute("normal",new at(u,3)),this.setAttribute("uv",new at(d,2));function y(){let b=new I,_=new I,M=0,S=(t-e)/i;for(let E=0;E<=s;E++){let A=[],T=E/s,P=T*(t-e)+e;for(let R=0;R<=r;R++){let z=R/r,U=z*o+n,L=Math.sin(U),H=Math.cos(U);_.x=P*L,_.y=-T*i+g,_.z=P*H,c.push(_.x,_.y,_.z),b.set(L,S,H).normalize(),u.push(b.x,b.y,b.z),d.push(z,1-T),A.push(p++)}f.push(A)}for(let E=0;E<r;E++)for(let A=0;A<s;A++){let T=f[A][E],P=f[A+1][E],R=f[A+1][E+1],z=f[A][E+1];h.push(T,P,z),h.push(P,R,z),M+=6}l.addGroup(m,M,0),m+=M}function x(b){let _=p,M=new re,S=new I,E=0,A=b===!0?e:t,T=b===!0?1:-1;for(let R=1;R<=r;R++)c.push(0,g*T,0),u.push(0,T,0),d.push(.5,.5),p++;let P=p;for(let R=0;R<=r;R++){let z=R/r*o+n,U=Math.cos(z),L=Math.sin(z);S.x=A*L,S.y=g*T,S.z=A*U,c.push(S.x,S.y,S.z),u.push(0,T,0),M.x=U*.5+.5,M.y=L*.5*T+.5,d.push(M.x,M.y),p++}for(let R=0;R<r;R++){let z=_+R,U=P+R;b===!0?h.push(U,U+1,z):h.push(U+1,U,z),E+=3}l.addGroup(m,E,b===!0?1:2),m+=E}}static fromJSON(e){return new Cb(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Tb=class extends Cb{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new Tb(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Pb=class extends gt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new at(s,3)),this.setAttribute("normal",new at(s.slice(),3)),this.setAttribute("uv",new at(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(y){let x=new I,b=new I,_=new I;for(let M=0;M<t.length;M+=3)d(t[M+0],x),d(t[M+1],b),d(t[M+2],_),o(x,b,_,y)}function o(y,x,b,_){let M=_+1,S=[];for(let E=0;E<=M;E++){S[E]=[];let A=y.clone().lerp(b,E/M),T=x.clone().lerp(b,E/M),P=M-E;for(let R=0;R<=P;R++)R===0&&E===M?S[E][R]=A:S[E][R]=A.clone().lerp(T,R/P)}for(let E=0;E<M;E++)for(let A=0;A<2*(M-E)-1;A++){let T=Math.floor(A/2);A%2===0?(u(S[E][T+1]),u(S[E+1][T]),u(S[E][T])):(u(S[E][T+1]),u(S[E+1][T+1]),u(S[E+1][T]))}}function l(y){let x=new I;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(y),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function h(){let y=new I;for(let x=0;x<s.length;x+=3){y.x=s[x+0],y.y=s[x+1],y.z=s[x+2];let b=g(y)/2/Math.PI+.5,_=m(y)/Math.PI+.5;a.push(b,1-_)}p(),c()}function c(){for(let y=0;y<a.length;y+=6){let x=a[y+0],b=a[y+2],_=a[y+4],M=Math.max(x,b,_),S=Math.min(x,b,_);M>.9&&S<.1&&(x<.2&&(a[y+0]+=1),b<.2&&(a[y+2]+=1),_<.2&&(a[y+4]+=1))}}function u(y){s.push(y.x,y.y,y.z)}function d(y,x){let b=y*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let y=new I,x=new I,b=new I,_=new I,M=new re,S=new re,E=new re;for(let A=0,T=0;A<s.length;A+=9,T+=6){y.set(s[A+0],s[A+1],s[A+2]),x.set(s[A+3],s[A+4],s[A+5]),b.set(s[A+6],s[A+7],s[A+8]),M.set(a[T+0],a[T+1]),S.set(a[T+2],a[T+3]),E.set(a[T+4],a[T+5]),_.copy(y).add(x).add(b).divideScalar(3);let P=g(_);f(M,T+0,y,P),f(S,T+2,x,P),f(E,T+4,b,P)}}function f(y,x,b,_){_<0&&y.x===1&&(a[x]=y.x-1),b.x===0&&b.z===0&&(a[x]=_/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new Pb(e.vertices,e.indices,e.radius,e.details)}},hT=class extends Pb{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],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];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new hT(e.radius,e.detail)}},sg=class extends rg{constructor(e){super(e),this.uuid=Ca(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new rg().fromJSON(r))}return this}},eN={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=cT(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,c,u,d,p;if(r&&(a=aN(e,t,a,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<s;f+=i)u=e[f],d=e[f+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return np(a,n,i,o,l,p,0),n}};function cT(e,t,i,r,s){let a,n;if(s===gN(e,t,i,r)>0)for(a=t;a<i;a+=r)n=FS(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=FS(a,e[a],e[a+1],n);return n&&nv(n,n.next)&&(lp(n),n=n.next),n}function Th(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(nv(i,i.next)||Ki(i.prev,i,i.next)===0)){if(lp(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function np(e,t,i,r,s,a,n){if(!e)return;!n&&a&&cN(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?iN(e,r,s,a):tN(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),lp(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=rN(Th(e),t,i),np(e,t,i,r,s,a,2)):n===2&&sN(e,t,i,r,s,a):np(Th(e),t,i,r,s,a,1);break}}}function tN(e){let t=e.prev,i=e,r=e.next;if(Ki(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=s<a?s<n?s:n:a<n?a:n,u=o<l?o<h?o:h:l<h?l:h,d=s>a?s>n?s:n:a>n?a:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Hc(s,o,a,l,n,h,f.x,f.y)&&Ki(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function iN(e,t,i,r){let s=e.prev,a=e,n=e.next;if(Ki(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,c=s.y,u=a.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,g=o>l?o>h?o:h:l>h?l:h,m=c>u?c>d?c:d:u>d?u:d,y=yy(p,f,t,i,r),x=yy(g,m,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==n&&Hc(o,c,l,u,h,d,b.x,b.y)&&Ki(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==n&&Hc(o,c,l,u,h,d,_.x,_.y)&&Ki(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==n&&Hc(o,c,l,u,h,d,b.x,b.y)&&Ki(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==n&&Hc(o,c,l,u,h,d,_.x,_.y)&&Ki(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function rN(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!nv(s,a)&&uT(s,r,r.next,a)&&op(s,a)&&op(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),lp(r),lp(r.next),r=e=a),r=r.next}while(r!==e);return Th(r)}function sN(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&pN(n,o)){let l=dT(n,o);n=Th(n,n.next),l=Th(l,l.next),np(n,t,i,r,s,a,0),np(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function aN(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=cT(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(dN(h));for(s.sort(nN),a=0;a<s.length;a++)i=oN(s[a],i);return i}function nN(e,t){return e.x-t.x}function oN(e,t){let i=lN(e,t);if(!i)return t;let r=dT(i,e);return Th(r,r.next),Th(i,i.next)}function lN(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let d=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=a&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===a))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,c=1/0,u;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&Hc(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(u=Math.abs(n-i.y)/(a-i.x),op(i,e)&&(u<c||u===c&&(i.x>s.x||i.x===s.x&&hN(s,i)))&&(s=i,c=u)),i=i.next;while(i!==o);return s}function hN(e,t){return Ki(e.prev,e,t.prev)<0&&Ki(t.next,e,e.next)<0}function cN(e,t,i,r){let s=e;do s.z===0&&(s.z=yy(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,uN(s)}function uN(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function yy(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function dN(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Hc(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function pN(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!fN(e,t)&&(op(e,t)&&op(t,e)&&mN(e,t)&&(Ki(e.prev,e,t.prev)||Ki(e,t.prev,t))||nv(e,t)&&Ki(e.prev,e,e.next)>0&&Ki(t.prev,t,t.next)>0)}function Ki(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function nv(e,t){return e.x===t.x&&e.y===t.y}function uT(e,t,i,r){let s=Of(Ki(e,t,i)),a=Of(Ki(e,t,r)),n=Of(Ki(i,r,e)),o=Of(Ki(i,r,t));return!!(s!==a&&n!==o||s===0&&If(e,i,t)||a===0&&If(e,r,t)||n===0&&If(i,e,r)||o===0&&If(i,t,r))}function If(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Of(e){return e>0?1:e<0?-1:0}function fN(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&uT(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function op(e,t){return Ki(e.prev,e,e.next)<0?Ki(e,t,e.next)>=0&&Ki(e,e.prev,t)>=0:Ki(e,t,e.prev)<0||Ki(e,e.next,t)<0}function mN(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function dT(e,t){let i=new xy(e.i,e.x,e.y),r=new xy(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function FS(e,t,i,r){let s=new xy(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function lp(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function xy(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function gN(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var pT=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return pT.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];kS(e),US(i,e);let a=e.length;t.forEach(kS);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,US(i,t[o]);let n=eN.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function kS(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function US(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var fT=class extends Pb{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fT(e.radius,e.detail)}},Yc=class extends gt{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],c=new I,u=new I,d=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let y=[],x=m/i,b=0;m==0&&a==0?b=.5/t:m==i&&o==Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let M=_/t;c.x=-e*Math.cos(r+M*s)*Math.sin(a+x*n),c.y=e*Math.cos(a+x*n),c.z=e*Math.sin(r+M*s)*Math.sin(a+x*n),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),g.push(M+b,1-x),y.push(l++)}h.push(y)}for(let m=0;m<i;m++)for(let y=0;y<t;y++){let x=h[m][y+1],b=h[m][y],_=h[m+1][y],M=h[m+1][y+1];(m!==0||a>0)&&d.push(x,b,M),(m!==i-1||o<Math.PI)&&d.push(b,_,M)}this.setIndex(d),this.setAttribute("position",new at(p,3)),this.setAttribute("normal",new at(f,3)),this.setAttribute("uv",new at(g,2))}static fromJSON(e){return new Yc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},mT=class extends gt{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let a=[],n=[],o=[],l=[],h=new I,c=new I,u=new I;for(let d=0;d<=i;d++)for(let p=0;p<=r;p++){let f=p/r*s,g=d/i*Math.PI*2;c.x=(e+t*Math.cos(g))*Math.cos(f),c.y=(e+t*Math.cos(g))*Math.sin(f),c.z=t*Math.sin(g),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(p/r),l.push(d/i)}for(let d=1;d<=i;d++)for(let p=1;p<=r;p++){let f=(r+1)*d+p-1,g=(r+1)*(d-1)+p-1,m=(r+1)*(d-1)+p,y=(r+1)*d+p;a.push(f,g,y),a.push(g,m,y)}this.setIndex(a),this.setAttribute("position",new at(n,3)),this.setAttribute("normal",new at(o,3)),this.setAttribute("uv",new at(l,2))}static fromJSON(e){return new mT(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},gT=class extends gt{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new I,u=new I,d=new I,p=new I,f=new I,g=new I,m=new I;for(let x=0;x<=i;++x){let b=x/i*s*Math.PI*2;y(b,s,a,e,d),y(b+.01,s,a,e,p),g.subVectors(p,d),m.addVectors(p,d),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let _=0;_<=r;++_){let M=_/r*Math.PI*2,S=-t*Math.cos(M),E=t*Math.sin(M);c.x=d.x+(S*m.x+E*f.x),c.y=d.y+(S*m.y+E*f.y),c.z=d.z+(S*m.z+E*f.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(x/i),h.push(_/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let _=(r+1)*(x-1)+(b-1),M=(r+1)*x+(b-1),S=(r+1)*x+b,E=(r+1)*(x-1)+b;n.push(_,M,E),n.push(M,S,E)}this.setIndex(n),this.setAttribute("position",new at(o,3)),this.setAttribute("normal",new at(l,3)),this.setAttribute("uv",new at(h,2));function y(x,b,_,M,S){let E=Math.cos(x),A=Math.sin(x),T=_/b*x,P=Math.cos(T);S.x=M*(2+P)*.5*E,S.y=M*(2+P)*A*.5,S.z=M*Math.sin(T)*.5}}static fromJSON(e){return new gT(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},vN=class extends ci{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function Ko(e,t,i){return vT(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Rf(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function vT(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function yN(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function NS(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function yT(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var ov=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},xN=class extends ov{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Nc,endingEnd:Nc}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case Vc:s=e,n=2*t-i;break;case $m:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case Vc:a=e,o=2*i-t;break;case $m:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-u*g+2*u*f-u*p,y=(1+u)*g+(-1.5-2*u)*f+(-.5+u)*p+1,x=(-1-d)*g+(1.5+d)*f+.5*p,b=d*g-d*f;for(let _=0;_!==n;++_)s[_]=m*a[h+_]+y*a[l+_]+x*a[o+_]+b*a[c+_];return s}},xT=class extends ov{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let u=0;u!==n;++u)s[u]=a[l+u]*c+a[o+u]*h;return s}},bN=class extends ov{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Gn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Rf(t,this.TimeBufferType),this.values=Rf(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Rf(e.times,Array),values:Rf(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new bN(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xT(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xN(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Km:t=this.InterpolantFactoryMethodDiscrete;break;case Jm:t=this.InterpolantFactoryMethodLinear;break;case l0:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Km;case this.InterpolantFactoryMethodLinear:return Jm;case this.InterpolantFactoryMethodSmooth:return l0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=Ko(i,s,a),this.values=Ko(this.values,s*n,a*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&vT(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=Ko(this.times),t=Ko(this.values),i=this.getValueSize(),r=this.getInterpolation()===l0,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,u=c-i,d=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[u+p]||f!==t[d+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let c=n*i,u=a*i;for(let d=0;d!==i;++d)t[u+d]=t[c+d]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=Ko(e,0,a),this.values=Ko(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Ko(this.times,0),t=Ko(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Gn.prototype.TimeBufferType=Float32Array;Gn.prototype.ValueBufferType=Float32Array;Gn.prototype.DefaultInterpolation=Jm;var Au=class extends Gn{};Au.prototype.ValueTypeName="bool";Au.prototype.ValueBufferType=Array;Au.prototype.DefaultInterpolation=Km;Au.prototype.InterpolantFactoryMethodLinear=void 0;Au.prototype.InterpolantFactoryMethodSmooth=void 0;var bT=class extends Gn{};bT.prototype.ValueTypeName="color";var ag=class extends Gn{};ag.prototype.ValueTypeName="number";var wN=class extends ov{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)Rt.slerpFlat(s,0,a,l-n,a,l,o);return s}},Pp=class extends Gn{InterpolantFactoryMethodLinear(e){return new wN(this.times,this.values,this.getValueSize(),e)}};Pp.prototype.ValueTypeName="quaternion";Pp.prototype.DefaultInterpolation=Jm;Pp.prototype.InterpolantFactoryMethodSmooth=void 0;var Mu=class extends Gn{};Mu.prototype.ValueTypeName="string";Mu.prototype.ValueBufferType=Array;Mu.prototype.DefaultInterpolation=Km;Mu.prototype.InterpolantFactoryMethodLinear=void 0;Mu.prototype.InterpolantFactoryMethodSmooth=void 0;var ng=class extends Gn{};ng.prototype.ValueTypeName="vector";var by=class{constructor(e,t=-1,i,r=yb){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Ca(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(SN(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Gn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=yN(o);o=NS(o,1,h),l=NS(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new ag(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let c=h[1],u=r[c];u||(r[c]=u=[]),u.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,u,d,p){if(u.length!==0){let f=[],g=[];yT(u,f,g,d),f.length!==0&&p.push(new h(c,f,g))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let u={},d;for(d=0;d<c.length;d++)if(c[d].morphTargets)for(let p=0;p<c[d].morphTargets.length;p++)u[c[d].morphTargets[p]]=-1;for(let p in u){let f=[],g=[];for(let m=0;m!==c[d].morphTargets.length;++m){let y=c[d];f.push(y.time),g.push(y.morphTarget===p?1:0)}r.push(new ag(".morphTargetInfluence["+p+"]",f,g))}o=u.length*a}else{let u=".bones["+t[h].name+"]";i(ng,u+".position",c,"pos",r),i(Pp,u+".quaternion",c,"rot",r),i(ng,u+".scale",c,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function _N(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ag;case"vector":case"vector2":case"vector3":case"vector4":return ng;case"color":return bT;case"quaternion":return Pp;case"bool":case"boolean":return Au;case"string":return Mu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function SN(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=_N(e.type);if(e.times===void 0){let i=[],r=[];yT(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var og={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},wT=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,u=l.length;c<u;c+=2){let d=l[c],p=l[c+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},AN=new wT,Dp=class{constructor(e){this.manager=e!==void 0?e:AN,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},ao={},MN=class extends Error{constructor(e,t){super(e),this.response=t}},wy=class extends Dp{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=og.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ao[e]!==void 0){ao[e].push({onLoad:t,onProgress:i,onError:r});return}ao[e]=[],ao[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=ao[e],c=l.body.getReader(),u=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=u?parseInt(u):0,p=d!==0,f=0,g=new ReadableStream({start(m){y();function y(){c.read().then(({done:x,value:b})=>{if(x)m.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let M=0,S=h.length;M<S;M++){let E=h[M];E.onProgress&&E.onProgress(_)}m.enqueue(b),y()}})}}});return new Response(g)}else throw new MN(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,u=new TextDecoder(c);return l.arrayBuffer().then(d=>u.decode(d))}}}).then(l=>{og.add(e,l);let h=ao[e];delete ao[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=ao[e];if(h===void 0)throw this.manager.itemError(e),l;delete ao[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},EN=class extends Dp{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=og.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let n=sp("img");function o(){h(),og.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(c){h(),r&&r(c),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),s.manager.itemStart(e),n.src=e,n}},CN=class extends Dp{constructor(e){super(e)}load(e,t,i,r){let s=new Ji,a=new EN(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(n){s.image=n,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Ip=class extends Mi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ct(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},TN=class extends Ip{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ct(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},k0=new je,VS=new I,jS=new I,Db=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new re(512,512),this.map=null,this.mapPass=null,this.matrix=new je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _b,this._frameExtents=new re(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;VS.setFromMatrixPosition(e.matrixWorld),t.position.copy(VS),jS.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(jS),t.updateMatrixWorld(),k0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(k0),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(k0)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},PN=class extends Db{constructor(){super(new bs(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=rp*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},DN=class extends Ip{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new PN}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},HS=new je,ld=new I,U0=new I,IN=class extends Db{constructor(){super(new bs(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new re(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(1,0,1,1)],this._cubeDirections=[new I(1,0,0),new I(-1,0,0),new I(0,0,1),new I(0,0,-1),new I(0,1,0),new I(0,-1,0)],this._cubeUps=[new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,0,1),new I(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),ld.setFromMatrixPosition(e.matrixWorld),i.position.copy(ld),U0.copy(i.position),U0.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(U0),i.updateMatrixWorld(),r.makeTranslation(-ld.x,-ld.y,-ld.z),HS.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HS)}},ON=class extends Ip{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new IN}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},RN=class extends Db{constructor(){super(new rv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},LN=class extends Ip{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.shadow=new RN}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},_T=class extends gt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},ST=class extends Dp{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new wy(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(u,d){if(t[d]!==void 0)return t[d];let p=u.interleavedBuffers[d],f=s(u,p.buffer),g=hf(p.type,f),m=new F6(g,p.stride);return m.uuid=p.uuid,t[d]=m,m}function s(u,d){if(i[d]!==void 0)return i[d];let p=u.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let a=e.isInstancedBufferGeometry?new _T:new gt,n=e.data.index;if(n!==void 0){let u=hf(n.type,n.array);a.setIndex(new Tt(u,1))}let o=e.data.attributes;for(let u in o){let d=o[u],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new vy(f,d.itemSize,d.offset,d.normalized)}else{let f=hf(d.type,d.array),g=d.isInstancedBufferAttribute?ap:Tt;p=new g(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),d.updateRange!==void 0&&(p.updateRange.offset=d.updateRange.offset,p.updateRange.count=d.updateRange.count),a.setAttribute(u,p)}let l=e.data.morphAttributes;if(l)for(let u in l){let d=l[u],p=[];for(let f=0,g=d.length;f<g;f++){let m=d[f],y;if(m.isInterleavedBufferAttribute){let x=r(e.data,m.data);y=new vy(x,m.itemSize,m.offset,m.normalized)}else{let x=hf(m.type,m.array);y=new Tt(x,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),p.push(y)}a.morphAttributes[u]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let u=0,d=h.length;u!==d;++u){let p=h[u];a.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let u=new I;c.center!==void 0&&u.fromArray(c.center),a.boundingSphere=new Ks(u,c.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},BN=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=GS(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=GS();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function GS(){return(typeof performance>"u"?Date:performance).now()}var zN=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Rt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;Rt.multiplyQuaternionsFlat(e,a,e,t,e,i),Rt.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},Ib="\\[\\]\\.:\\/",FN=new RegExp("["+Ib+"]","g"),Ob="[^"+Ib+"]",kN="[^"+Ib.replace("\\.","")+"]",UN=/((?:WC+[\/:])*)/.source.replace("WC",Ob),NN=/(WCOD+)?/.source.replace("WCOD",kN),VN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ob),jN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ob),HN=new RegExp("^"+UN+NN+VN+jN+"$"),GN=["material","materials","bones","map"],WN=class{constructor(e,t,i){let r=i||Oi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Oi=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Oi.parseTrackName(t),this.node=Oi.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Oi.Composite(e,t,i):new Oi(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(FN,"")}static parseTrackName(e){let t=HN.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);GN.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Oi.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let a=e[r];if(a===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Oi.Composite=WN;Oi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Oi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Oi.prototype.GetterByBindingType=[Oi.prototype._getValue_direct,Oi.prototype._getValue_array,Oi.prototype._getValue_arrayElement,Oi.prototype._getValue_toArray];Oi.prototype.SetterByBindingTypeAndVersioning=[[Oi.prototype._setValue_direct,Oi.prototype._setValue_direct_setNeedsUpdate,Oi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Oi.prototype._setValue_array,Oi.prototype._setValue_array_setNeedsUpdate,Oi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Oi.prototype._setValue_arrayElement,Oi.prototype._setValue_arrayElement_setNeedsUpdate,Oi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Oi.prototype._setValue_fromArray,Oi.prototype._setValue_fromArray_setNeedsUpdate,Oi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var qN=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:Nc,endingEnd:Nc};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=N3,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case wz:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case yb:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===vb;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===U3){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Vc,r.endingEnd=Vc):(e?r.endingStart=this.zeroSlopeAtStart?Vc:Nc:r.endingStart=$m,t?r.endingEnd=this.zeroSlopeAtEnd?Vc:Nc:r.endingEnd=$m)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},XN=new Float32Array(1),YN=class extends gs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==s;++c){let u=r[c],d=u.name,p=h[d];if(p!==void 0)++p.referenceCount,a[c]=p;else{if(p=a[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new zN(Oi.create(i,d,f),u.ValueTypeName,u.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),a[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,u=(e._localRoot||this._root).uuid;delete c[u],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new xT(new Float32Array(2),new Float32Array(2),1,XN),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?by.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=yb),o!==void 0){let c=o.actionByRoot[s];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new qN(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?by.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Fe=class{constructor(e){this.value=e}clone(){return new Fe(this.value.clone===void 0?this.value:this.value.clone())}},AT=class{constructor(e,t,i=0,r=1/0){this.ray=new wu(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new bb,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return _y(e,this,i,t),i.sort(WS),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)_y(e[r],this,i,t);return i.sort(WS),i}};function WS(e,t){return e.distance-t.distance}function _y(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)_y(s[a],t,i,!0)}}var qS=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(wr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},XS=new re,Rb=class{constructor(e=new re(1/0,1/0),t=new re(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=XS.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return XS.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},YS=new I,Lf=new I,Ta=class{constructor(e=new I,t=new I){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){YS.subVectors(e,this.start),Lf.subVectors(this.end,this.start);let i=Lf.dot(Lf),r=Lf.dot(YS)/i;return t&&(r=wr(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},QS=new I,QN=class extends Mi{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new gt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new at(r,3));let s=new zl({fog:!1,toneMapped:!1});this.cone=new Tp(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),QS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(QS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},ZN=class extends zi{constructor(e,t,i){let r=new Yc(t,4,2),s=new Ro({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},ZS=new I,Bf=new I,KS=new I,KN=class extends Mi{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new gt;r.setAttribute("position",new at([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zl({fog:!1,toneMapped:!1});this.lightPlane=new ig(r,s),this.add(this.lightPlane),r=new gt,r.setAttribute("position",new at([0,0,0,0,0,1],3)),this.targetLine=new ig(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),ZS.setFromMatrixPosition(this.light.matrixWorld),Bf.setFromMatrixPosition(this.light.target.matrixWorld),KS.subVectors(Bf,ZS),this.lightPlane.lookAt(Bf),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(Bf),this.targetLine.scale.z=KS.length()}},zf=new I,ir=new Bl,lg=class extends Tp{constructor(e){let t=new gt,i=new zl({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new at(r,3)),t.setAttribute("color",new at(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let l=new Ct(16755200),h=new Ct(16711680),c=new Ct(43775),u=new Ct(16777215),d=new Ct(3355443);this.setColors(l,h,c,u,d)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.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 e=this.geometry,t=this.pointMap,i=1,r=1;ir.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),cr("c",t,e,ir,0,0,-1),cr("t",t,e,ir,0,0,1),cr("n1",t,e,ir,-i,-r,-1),cr("n2",t,e,ir,i,-r,-1),cr("n3",t,e,ir,-i,r,-1),cr("n4",t,e,ir,i,r,-1),cr("f1",t,e,ir,-i,-r,1),cr("f2",t,e,ir,i,-r,1),cr("f3",t,e,ir,-i,r,1),cr("f4",t,e,ir,i,r,1),cr("u1",t,e,ir,i*.7,r*1.1,-1),cr("u2",t,e,ir,-i*.7,r*1.1,-1),cr("u3",t,e,ir,0,r*2,-1),cr("cf1",t,e,ir,-i,0,1),cr("cf2",t,e,ir,i,0,1),cr("cf3",t,e,ir,0,-r,1),cr("cf4",t,e,ir,0,r,1),cr("cn1",t,e,ir,-i,0,-1),cr("cn2",t,e,ir,i,0,-1),cr("cn3",t,e,ir,0,-r,-1),cr("cn4",t,e,ir,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function cr(e,t,i,r,s,a,n){zf.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],zf.x,zf.y,zf.z)}}var hg=class extends Tp{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new gt;s.setIndex(new Tt(i,1)),s.setAttribute("position",new at(r,3)),super(s,new zl({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},JN=class extends Tp{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new gt;r.setAttribute("position",new at(t,3)),r.setAttribute("color",new at(i,3));let s=new zl({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ct,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},wo=$N();function $N(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,a[l]=h|c}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}function e8(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=wr(e,-65504,65504),wo.floatView[0]=e;let t=wo.uint32View[0],i=t>>23&511;return wo.baseTable[i]+((t&8388607)>>wo.shiftTable[i])}function t8(e){let t=e>>10;return wo.uint32View[0]=wo.mantissaTable[wo.offsetTable[t]+(e&1023)]+wo.exponentTable[t],wo.floatView[0]}var i8=Object.freeze({__proto__:null,fromHalfFloat:t8,toHalfFloat:e8});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:bu}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=bu);var hd=".",Lb=Symbol("target"),MT=Symbol("unsubscribe");function Sy(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function r8(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Pn=Array.isArray;function Bb(e){return typeof e=="symbol"}var s8={after:(e,t)=>Pn(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Pn(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=hd),Bb(t)?e+t.toString():e+t):e,initial:e=>{if(Pn(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?"":e.slice(0,t)},last:e=>{if(Pn(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Pn(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(hd);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(hd,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},wa=s8;function a8(e){return typeof e=="object"&&typeof e.next=="function"}function n8(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[Lb].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function JS(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Bb(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var o8=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,wa.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Ay(e){return toString.call(e)==="[object Object]"}function Ff(){return!0}function fc(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var ET=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),l8=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),CT={push:Ff,pop:Ff,shift:Ff,unshift:Ff,copyWithin:fc,reverse:fc,sort:fc,splice:fc,flat:fc,fill:fc},h8=new Set([...ET,...l8,...Object.keys(CT)]);function kf(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var TT=["keys","values","entries"],PT=new Set(["has","toString"]),DT={add:kf,clear:kf,delete:kf,forEach:kf},c8=new Set([...PT,...Object.keys(DT),...TT]);function Uf(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var u8=new Set([...PT,"get"]),IT={set:Uf,clear:Uf,delete:Uf,forEach:Uf},d8=new Set([...u8,...Object.keys(IT),...TT]),Il=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return ET.has(e)}_shallowClone(e){let t=e;if(Ay(e))t={...e};else if(Pn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(Pn(r)?this._onIsChanged=CT[t]:r instanceof Set?this._onIsChanged=DT[t]:r instanceof Map&&(this._onIsChanged=IT[t]),r):i}update(e,t,i){let r=wa.after(e,this._path);if(t!=="length"){let s=this.clone;wa.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],wa.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},$S=class extends Il{static isHandledMethod(e){return h8.has(e)}},p8=class extends Il{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},eA=class extends Il{static isHandledMethod(e){return c8.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},tA=class extends Il{static isHandledMethod(e){return d8.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},f8=class extends Il{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},m8=class extends Il{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Rc=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Ay(e)||Pn(e)||Sy(e)}static isHandledMethod(e,t){return Ay(e)?Il.isHandledMethod(t):Pn(e)?$S.isHandledMethod(t):e instanceof Set?eA.isHandledMethod(t):e instanceof Map?tA.isHandledMethod(t):Sy(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Il;Pn(e)?r=$S:e instanceof Date?r=p8:e instanceof Set?r=eA:e instanceof Map?r=tA:e instanceof WeakSet?r=f8:e instanceof WeakMap&&(r=m8),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Rc.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},g8={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},zb=(e,t,i={})=>{i={...g8,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new o8(s),h=typeof i.onValidate=="function",c=new Rc(h),u=(x,b,_,M,S)=>!h||c.isCloning||i.onValidate(wa.concat(l.getPath(x),b),_,M,S)===!0,d=(x,b,_,M)=>{!JS(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,M)},p=(x,b,_,M,S)=>{c.isCloning?c.update(x,b,M):t(wa.concat(x,b),_,M,S)},f=x=>x&&(x[r]||x),g=(x,b,_,M)=>r8(x)||_==="constructor"||a&&!Rc.isHandledMethod(b,_)||JS(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(M===void 0&&(M=l.getPath(b)),l.getProxy(x,wa.concat(M,_),m,r)),m={get(x,b,_){if(Bb(b)){if(b===r||b===Lb)return x;if(b===MT&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let M=Sy(x)?Reflect.get(x,b):Reflect.get(x,b,_);return g(M,x,b)},set(x,b,_,M){_=f(_);let S=x[r]||x,E=S[b];if(s(E,_)&&b in x)return!0;let A=u(x,b,_,E);return A&&l.setProperty(S,b,_,M,E)?(d(x,b,x[b],E),!0):!A},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let M=x[b];u(x,b,_.value,M)&&l.defineProperty(x,b,_,M)&&d(x,b,_.value,M)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),M=u(x,b,void 0,_);return M&&l.deleteProperty(x,b,_)?(d(x,b,void 0,_),!0):!M},apply(x,b,_){let M=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,M,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Rc.isHandledType(M)){let S=wa.initial(l.getPath(x)),E=Rc.isHandledMethod(M,x.name);c.start(M,S,_);let A=Reflect.apply(x,c.preferredThisArg(x,b,M),E?_.map(R=>f(R)):_),T=c.isChanged(M,s),P=c.stop();if(Rc.isHandledType(A)&&E&&(b instanceof Map&&x.name==="get"&&(S=wa.concat(S,_[0])),A=l.getProxy(A,S,m)),T){let R={name:x.name,args:_,result:A},z=c.isCloning?wa.initial(S):S,U=c.isCloning?wa.last(S):"";u(wa.get(e,z),U,M,P,R)?p(z,U,M,P,R):c.undo(M)}return(b instanceof Map||b instanceof Set)&&a8(A)?n8(A,x,b,S,g):A}return Reflect.apply(x,b,_)}},y=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};zb.target=e=>e&&e[Lb]||e;zb.unsubscribe=e=>e[MT]||e;var iA=zb,v8=typeof global=="object"&&global&&global.Object===Object&&global,OT=v8,y8=typeof self=="object"&&self&&self.Object===Object&&self,x8=OT||y8||Function("return this")(),an=x8,b8=an.Symbol,Da=b8,RT=Object.prototype,w8=RT.hasOwnProperty,_8=RT.toString,cd=Da?Da.toStringTag:void 0;function S8(e){var t=w8.call(e,cd),i=e[cd];try{e[cd]=void 0;var r=!0}catch{}var s=_8.call(e);return r&&(t?e[cd]=i:delete e[cd]),s}var A8=S8,M8=Object.prototype,E8=M8.toString;function C8(e){return E8.call(e)}var T8=C8,P8="[object Null]",D8="[object Undefined]",rA=Da?Da.toStringTag:void 0;function I8(e){return e==null?e===void 0?D8:P8:rA&&rA in Object(e)?A8(e):T8(e)}var Bh=I8;function O8(e){return e!=null&&typeof e=="object"}var Lo=O8,R8="[object Symbol]";function L8(e){return typeof e=="symbol"||Lo(e)&&Bh(e)==R8}var Op=L8;function B8(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var LT=B8,z8=Array.isArray,Un=z8,F8=1/0,sA=Da?Da.prototype:void 0,aA=sA?sA.toString:void 0;function BT(e){if(typeof e=="string")return e;if(Un(e))return LT(e,BT)+"";if(Op(e))return aA?aA.call(e):"";var t=e+"";return t=="0"&&1/e==-F8?"-0":t}var zT=BT,k8=/\s/;function U8(e){for(var t=e.length;t--&&k8.test(e.charAt(t)););return t}var FT=U8,N8=/^\s+/;function V8(e){return e&&e.slice(0,FT(e)+1).replace(N8,"")}var j8=V8;function H8(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var sn=H8,nA=0/0,G8=/^[-+]0x[0-9a-f]+$/i,W8=/^0b[01]+$/i,q8=/^0o[0-7]+$/i,X8=parseInt;function Y8(e){if(typeof e=="number")return e;if(Op(e))return nA;if(sn(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=sn(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=j8(e);var i=W8.test(e);return i||q8.test(e)?X8(e.slice(2),i?2:8):G8.test(e)?nA:+e}var oA=Y8;function Q8(e){return e}var kT=Q8,Z8="[object AsyncFunction]",K8="[object Function]",J8="[object GeneratorFunction]",$8="[object Proxy]";function eV(e){if(!sn(e))return!1;var t=Bh(e);return t==K8||t==J8||t==Z8||t==$8}var UT=eV,tV=an["__core-js_shared__"],N0=tV,lA=function(){var e=/[^.]+$/.exec(N0&&N0.keys&&N0.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function iV(e){return!!lA&&lA in e}var rV=iV,sV=Function.prototype,aV=sV.toString;function nV(e){if(e!=null){try{return aV.call(e)}catch{}try{return e+""}catch{}}return""}var zh=nV,oV=/[\\^$.*+?()[\]{}|]/g,lV=/^\[object .+?Constructor\]$/,hV=Function.prototype,cV=Object.prototype,uV=hV.toString,dV=cV.hasOwnProperty,pV=RegExp("^"+uV.call(dV).replace(oV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fV(e){if(!sn(e)||rV(e))return!1;var t=UT(e)?pV:lV;return t.test(zh(e))}var mV=fV;function gV(e,t){return e?.[t]}var vV=gV;function yV(e,t){var i=vV(e,t);return mV(i)?i:void 0}var Fh=yV,xV=Fh(an,"WeakMap"),My=xV,hA=Object.create,bV=function(){function e(){}return function(t){if(!sn(t))return{};if(hA)return hA(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),wV=bV;function _V(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var SV=_V;function AV(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var MV=AV,EV=800,CV=16,TV=Date.now;function PV(e){var t=0,i=0;return function(){var r=TV(),s=CV-(r-i);if(i=r,s>0){if(++t>=EV)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var DV=PV;function IV(e){return function(){return e}}var OV=IV,RV=function(){try{var e=Fh(Object,"defineProperty");return e({},"",{}),e}catch{}}(),cg=RV,LV=cg?function(e,t){return cg(e,"toString",{configurable:!0,enumerable:!1,value:OV(t),writable:!0})}:kT,BV=LV,zV=DV(BV),FV=zV;function kV(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var UV=kV;function NV(e,t,i,r){for(var s=e.length,a=i+(r?1:-1);r?a--:++a<s;)if(t(e[a],a,e))return a;return-1}var VV=NV;function jV(e){return e!==e}var HV=jV;function GV(e,t,i){for(var r=i-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}var WV=GV;function qV(e,t,i){return t===t?WV(e,t,i):VV(e,HV,i)}var XV=qV,YV=9007199254740991,QV=/^(?:0|[1-9]\d*)$/;function ZV(e,t){var i=typeof e;return t=t??YV,!!t&&(i=="number"||i!="symbol"&&QV.test(e))&&e>-1&&e%1==0&&e<t}var Fb=ZV;function KV(e,t,i){t=="__proto__"&&cg?cg(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var NT=KV;function JV(e,t){return e===t||e!==e&&t!==t}var kb=JV,$V=Object.prototype,ej=$V.hasOwnProperty;function tj(e,t,i){var r=e[t];(!(ej.call(e,t)&&kb(r,i))||i===void 0&&!(t in e))&&NT(e,t,i)}var Ub=tj;function ij(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?NT(i,o,l):Ub(i,o,l)}return i}var Rp=ij,cA=Math.max;function rj(e,t,i){return t=cA(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=cA(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),SV(e,this,o)}}var sj=rj,aj=9007199254740991;function nj(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=aj}var Nb=nj;function oj(e){return e!=null&&Nb(e.length)&&!UT(e)}var VT=oj,lj=Object.prototype;function hj(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||lj;return e===i}var Vb=hj;function cj(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var uj=cj,dj="[object Arguments]";function pj(e){return Lo(e)&&Bh(e)==dj}var uA=pj,jT=Object.prototype,fj=jT.hasOwnProperty,mj=jT.propertyIsEnumerable,gj=uA(function(){return arguments}())?uA:function(e){return Lo(e)&&fj.call(e,"callee")&&!mj.call(e,"callee")},jb=gj;function vj(){return!1}var yj=vj,HT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dA=HT&&typeof module=="object"&&module&&!module.nodeType&&module,xj=dA&&dA.exports===HT,pA=xj?an.Buffer:void 0,bj=pA?pA.isBuffer:void 0,wj=bj||yj,ug=wj,_j="[object Arguments]",Sj="[object Array]",Aj="[object Boolean]",Mj="[object Date]",Ej="[object Error]",Cj="[object Function]",Tj="[object Map]",Pj="[object Number]",Dj="[object Object]",Ij="[object RegExp]",Oj="[object Set]",Rj="[object String]",Lj="[object WeakMap]",Bj="[object ArrayBuffer]",zj="[object DataView]",Fj="[object Float32Array]",kj="[object Float64Array]",Uj="[object Int8Array]",Nj="[object Int16Array]",Vj="[object Int32Array]",jj="[object Uint8Array]",Hj="[object Uint8ClampedArray]",Gj="[object Uint16Array]",Wj="[object Uint32Array]",Hi={};Hi[Fj]=Hi[kj]=Hi[Uj]=Hi[Nj]=Hi[Vj]=Hi[jj]=Hi[Hj]=Hi[Gj]=Hi[Wj]=!0;Hi[_j]=Hi[Sj]=Hi[Bj]=Hi[Aj]=Hi[zj]=Hi[Mj]=Hi[Ej]=Hi[Cj]=Hi[Tj]=Hi[Pj]=Hi[Dj]=Hi[Ij]=Hi[Oj]=Hi[Rj]=Hi[Lj]=!1;function qj(e){return Lo(e)&&Nb(e.length)&&!!Hi[Bh(e)]}var Xj=qj;function Yj(e){return function(t){return e(t)}}var Hb=Yj,GT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gd=GT&&typeof module=="object"&&module&&!module.nodeType&&module,Qj=Gd&&Gd.exports===GT,V0=Qj&&OT.process,Zj=function(){try{var e=Gd&&Gd.require&&Gd.require("util").types;return e||V0&&V0.binding&&V0.binding("util")}catch{}}(),lu=Zj,fA=lu&&lu.isTypedArray,Kj=fA?Hb(fA):Xj,WT=Kj,Jj=Object.prototype,$j=Jj.hasOwnProperty;function eH(e,t){var i=Un(e),r=!i&&jb(e),s=!i&&!r&&ug(e),a=!i&&!r&&!s&&WT(e),n=i||r||s||a,o=n?uj(e.length,String):[],l=o.length;for(var h in e)(t||$j.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Fb(h,l)))&&o.push(h);return o}var qT=eH;function tH(e,t){return function(i){return e(t(i))}}var XT=tH,iH=XT(Object.keys,Object),rH=iH,sH=Object.prototype,aH=sH.hasOwnProperty;function nH(e){if(!Vb(e))return rH(e);var t=[];for(var i in Object(e))aH.call(e,i)&&i!="constructor"&&t.push(i);return t}var oH=nH;function lH(e){return VT(e)?qT(e):oH(e)}var Gb=lH;function hH(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var cH=hH,uH=Object.prototype,dH=uH.hasOwnProperty;function pH(e){if(!sn(e))return cH(e);var t=Vb(e),i=[];for(var r in e)r=="constructor"&&(t||!dH.call(e,r))||i.push(r);return i}var fH=pH;function mH(e){return VT(e)?qT(e,!0):fH(e)}var ch=mH,gH=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vH=/^\w*$/;function yH(e,t){if(Un(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Op(e)?!0:vH.test(e)||!gH.test(e)||t!=null&&e in Object(t)}var xH=yH,bH=Fh(Object,"create"),hp=bH;function wH(){this.__data__=hp?hp(null):{},this.size=0}var _H=wH;function SH(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var AH=SH,MH="__lodash_hash_undefined__",EH=Object.prototype,CH=EH.hasOwnProperty;function TH(e){var t=this.__data__;if(hp){var i=t[e];return i===MH?void 0:i}return CH.call(t,e)?t[e]:void 0}var PH=TH,DH=Object.prototype,IH=DH.hasOwnProperty;function OH(e){var t=this.__data__;return hp?t[e]!==void 0:IH.call(t,e)}var RH=OH,LH="__lodash_hash_undefined__";function BH(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=hp&&t===void 0?LH:t,this}var zH=BH;function Eu(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Eu.prototype.clear=_H;Eu.prototype.delete=AH;Eu.prototype.get=PH;Eu.prototype.has=RH;Eu.prototype.set=zH;var mA=Eu;function FH(){this.__data__=[],this.size=0}var kH=FH;function UH(e,t){for(var i=e.length;i--;)if(kb(e[i][0],t))return i;return-1}var lv=UH,NH=Array.prototype,VH=NH.splice;function jH(e){var t=this.__data__,i=lv(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():VH.call(t,i,1),--this.size,!0}var HH=jH;function GH(e){var t=this.__data__,i=lv(t,e);return i<0?void 0:t[i][1]}var WH=GH;function qH(e){return lv(this.__data__,e)>-1}var XH=qH;function YH(e,t){var i=this.__data__,r=lv(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var QH=YH;function Cu(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Cu.prototype.clear=kH;Cu.prototype.delete=HH;Cu.prototype.get=WH;Cu.prototype.has=XH;Cu.prototype.set=QH;var hv=Cu,ZH=Fh(an,"Map"),cp=ZH;function KH(){this.size=0,this.__data__={hash:new mA,map:new(cp||hv),string:new mA}}var JH=KH;function $H(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var eG=$H;function tG(e,t){var i=e.__data__;return eG(t)?i[typeof t=="string"?"string":"hash"]:i.map}var cv=tG;function iG(e){var t=cv(this,e).delete(e);return this.size-=t?1:0,t}var rG=iG;function sG(e){return cv(this,e).get(e)}var aG=sG;function nG(e){return cv(this,e).has(e)}var oG=nG;function lG(e,t){var i=cv(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var hG=lG;function Tu(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Tu.prototype.clear=JH;Tu.prototype.delete=rG;Tu.prototype.get=aG;Tu.prototype.has=oG;Tu.prototype.set=hG;var uv=Tu,cG="Expected a function";function Wb(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(cG);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(Wb.Cache||uv),i}Wb.Cache=uv;var uG=Wb,dG=500;function pG(e){var t=uG(e,function(r){return i.size===dG&&i.clear(),r}),i=t.cache;return t}var fG=pG,mG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gG=/\\(\\)?/g,vG=fG(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(mG,function(i,r,s,a){t.push(s?a.replace(gG,"$1"):r||i)}),t}),yG=vG;function xG(e){return e==null?"":zT(e)}var YT=xG;function bG(e,t){return Un(e)?e:xH(e,t)?[e]:yG(YT(e))}var Pu=bG,wG=1/0;function _G(e){if(typeof e=="string"||Op(e))return e;var t=e+"";return t=="0"&&1/e==-wG?"-0":t}var dv=_G;function SG(e,t){t=Pu(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[dv(t[i++])];return i&&i==r?e:void 0}var QT=SG;function AG(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var qb=AG,gA=Da?Da.isConcatSpreadable:void 0;function MG(e){return Un(e)||jb(e)||!!(gA&&e&&e[gA])}var EG=MG;function ZT(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=EG),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?ZT(o,t-1,i,r,s):qb(s,o):r||(s[s.length]=o)}return s}var CG=ZT;function TG(e){var t=e==null?0:e.length;return t?CG(e,1):[]}var PG=TG;function DG(e){return FV(sj(e,void 0,PG),e+"")}var KT=DG,IG=XT(Object.getPrototypeOf,Object),Xb=IG,OG="[object Object]",RG=Function.prototype,LG=Object.prototype,JT=RG.toString,BG=LG.hasOwnProperty,zG=JT.call(Object);function FG(e){if(!Lo(e)||Bh(e)!=OG)return!1;var t=Xb(e);if(t===null)return!0;var i=BG.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&JT.call(i)==zG}var kG=FG;function UG(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var a=Array(s);++r<s;)a[r]=e[r+t];return a}var $T=UG;function NG(e,t,i){var r=e.length;return i=i===void 0?r:i,!t&&i>=r?e:$T(e,t,i)}var VG=NG,jG="\\ud800-\\udfff",HG="\\u0300-\\u036f",GG="\\ufe20-\\ufe2f",WG="\\u20d0-\\u20ff",qG=HG+GG+WG,XG="\\ufe0e\\ufe0f",YG="\\u200d",QG=RegExp("["+YG+jG+qG+XG+"]");function ZG(e){return QG.test(e)}var KG=ZG;function JG(e){return e.split("")}var $G=JG,eP="\\ud800-\\udfff",e9="\\u0300-\\u036f",t9="\\ufe20-\\ufe2f",i9="\\u20d0-\\u20ff",r9=e9+t9+i9,s9="\\ufe0e\\ufe0f",a9="["+eP+"]",Ey="["+r9+"]",Cy="\\ud83c[\\udffb-\\udfff]",n9="(?:"+Ey+"|"+Cy+")",tP="[^"+eP+"]",iP="(?:\\ud83c[\\udde6-\\uddff]){2}",rP="[\\ud800-\\udbff][\\udc00-\\udfff]",o9="\\u200d",sP=n9+"?",aP="["+s9+"]?",l9="(?:"+o9+"(?:"+[tP,iP,rP].join("|")+")"+aP+sP+")*",h9=aP+sP+l9,c9="(?:"+[tP+Ey+"?",Ey,iP,rP,a9].join("|")+")",u9=RegExp(Cy+"(?="+Cy+")|"+c9+h9,"g");function d9(e){return e.match(u9)||[]}var p9=d9;function f9(e){return KG(e)?p9(e):$G(e)}var vA=f9;function m9(){this.__data__=new hv,this.size=0}var g9=m9;function v9(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var y9=v9;function x9(e){return this.__data__.get(e)}var b9=x9;function w9(e){return this.__data__.has(e)}var _9=w9,S9=200;function A9(e,t){var i=this.__data__;if(i instanceof hv){var r=i.__data__;if(!cp||r.length<S9-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new uv(r)}return i.set(e,t),this.size=i.size,this}var M9=A9;function Du(e){var t=this.__data__=new hv(e);this.size=t.size}Du.prototype.clear=g9;Du.prototype.delete=y9;Du.prototype.get=b9;Du.prototype.has=_9;Du.prototype.set=M9;var Fm=Du;function E9(e,t){return e&&Rp(t,Gb(t),e)}var C9=E9;function T9(e,t){return e&&Rp(t,ch(t),e)}var P9=T9,nP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yA=nP&&typeof module=="object"&&module&&!module.nodeType&&module,D9=yA&&yA.exports===nP,xA=D9?an.Buffer:void 0,bA=xA?xA.allocUnsafe:void 0;function I9(e,t){if(t)return e.slice();var i=e.length,r=bA?bA(i):new e.constructor(i);return e.copy(r),r}var O9=I9;function R9(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var L9=R9;function B9(){return[]}var oP=B9,z9=Object.prototype,F9=z9.propertyIsEnumerable,wA=Object.getOwnPropertySymbols,k9=wA?function(e){return e==null?[]:(e=Object(e),L9(wA(e),function(t){return F9.call(e,t)}))}:oP,Yb=k9;function U9(e,t){return Rp(e,Yb(e),t)}var N9=U9,V9=Object.getOwnPropertySymbols,j9=V9?function(e){for(var t=[];e;)qb(t,Yb(e)),e=Xb(e);return t}:oP,lP=j9;function H9(e,t){return Rp(e,lP(e),t)}var G9=H9;function W9(e,t,i){var r=t(e);return Un(e)?r:qb(r,i(e))}var hP=W9;function q9(e){return hP(e,Gb,Yb)}var Ty=q9;function X9(e){return hP(e,ch,lP)}var cP=X9,Y9=Fh(an,"DataView"),Py=Y9,Q9=Fh(an,"Promise"),Dy=Q9,Z9=Fh(an,"Set"),Iy=Z9,_A="[object Map]",K9="[object Object]",SA="[object Promise]",AA="[object Set]",MA="[object WeakMap]",EA="[object DataView]",J9=zh(Py),$9=zh(cp),e7=zh(Dy),t7=zh(Iy),i7=zh(My),th=Bh;(Py&&th(new Py(new ArrayBuffer(1)))!=EA||cp&&th(new cp)!=_A||Dy&&th(Dy.resolve())!=SA||Iy&&th(new Iy)!=AA||My&&th(new My)!=MA)&&(th=function(e){var t=Bh(e),i=t==K9?e.constructor:void 0,r=i?zh(i):"";if(r)switch(r){case J9:return EA;case $9:return _A;case e7:return SA;case t7:return AA;case i7:return MA}return t});var up=th,r7=Object.prototype,s7=r7.hasOwnProperty;function a7(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&s7.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var n7=a7,o7=an.Uint8Array,dg=o7;function l7(e){var t=new e.constructor(e.byteLength);return new dg(t).set(new dg(e)),t}var Qb=l7;function h7(e,t){var i=t?Qb(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var c7=h7,u7=/\w*$/;function d7(e){var t=new e.constructor(e.source,u7.exec(e));return t.lastIndex=e.lastIndex,t}var p7=d7,CA=Da?Da.prototype:void 0,TA=CA?CA.valueOf:void 0;function f7(e){return TA?Object(TA.call(e)):{}}var m7=f7;function g7(e,t){var i=t?Qb(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var v7=g7,y7="[object Boolean]",x7="[object Date]",b7="[object Map]",w7="[object Number]",_7="[object RegExp]",S7="[object Set]",A7="[object String]",M7="[object Symbol]",E7="[object ArrayBuffer]",C7="[object DataView]",T7="[object Float32Array]",P7="[object Float64Array]",D7="[object Int8Array]",I7="[object Int16Array]",O7="[object Int32Array]",R7="[object Uint8Array]",L7="[object Uint8ClampedArray]",B7="[object Uint16Array]",z7="[object Uint32Array]";function F7(e,t,i){var r=e.constructor;switch(t){case E7:return Qb(e);case y7:case x7:return new r(+e);case C7:return c7(e,i);case T7:case P7:case D7:case I7:case O7:case R7:case L7:case B7:case z7:return v7(e,i);case b7:return new r;case w7:case A7:return new r(e);case _7:return p7(e);case S7:return new r;case M7:return m7(e)}}var k7=F7;function U7(e){return typeof e.constructor=="function"&&!Vb(e)?wV(Xb(e)):{}}var N7=U7,V7="[object Map]";function j7(e){return Lo(e)&&up(e)==V7}var H7=j7,PA=lu&&lu.isMap,G7=PA?Hb(PA):H7,W7=G7,q7="[object Set]";function X7(e){return Lo(e)&&up(e)==q7}var Y7=X7,DA=lu&&lu.isSet,Q7=DA?Hb(DA):Y7,Z7=Q7,K7=1,J7=2,$7=4,uP="[object Arguments]",eW="[object Array]",tW="[object Boolean]",iW="[object Date]",rW="[object Error]",dP="[object Function]",sW="[object GeneratorFunction]",aW="[object Map]",nW="[object Number]",pP="[object Object]",oW="[object RegExp]",lW="[object Set]",hW="[object String]",cW="[object Symbol]",uW="[object WeakMap]",dW="[object ArrayBuffer]",pW="[object DataView]",fW="[object Float32Array]",mW="[object Float64Array]",gW="[object Int8Array]",vW="[object Int16Array]",yW="[object Int32Array]",xW="[object Uint8Array]",bW="[object Uint8ClampedArray]",wW="[object Uint16Array]",_W="[object Uint32Array]",Ui={};Ui[uP]=Ui[eW]=Ui[dW]=Ui[pW]=Ui[tW]=Ui[iW]=Ui[fW]=Ui[mW]=Ui[gW]=Ui[vW]=Ui[yW]=Ui[aW]=Ui[nW]=Ui[pP]=Ui[oW]=Ui[lW]=Ui[hW]=Ui[cW]=Ui[xW]=Ui[bW]=Ui[wW]=Ui[_W]=!0;Ui[rW]=Ui[dP]=Ui[uW]=!1;function km(e,t,i,r,s,a){var n,o=t&K7,l=t&J7,h=t&$7;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!sn(e))return e;var c=Un(e);if(c){if(n=n7(e),!o)return MV(e,n)}else{var u=up(e),d=u==dP||u==sW;if(ug(e))return O9(e,o);if(u==pP||u==uP||d&&!s){if(n=l||d?{}:N7(e),!o)return l?G9(e,P9(n,e)):N9(e,C9(n,e))}else{if(!Ui[u])return s?e:{};n=k7(e,u,o)}}a||(a=new Fm);var p=a.get(e);if(p)return p;a.set(e,n),Z7(e)?e.forEach(function(m){n.add(km(m,t,i,m,e,a))}):W7(e)&&e.forEach(function(m,y){n.set(y,km(m,t,i,y,e,a))});var f=h?l?cP:Ty:l?ch:Gb,g=c?void 0:f(e);return UV(g||e,function(m,y){g&&(y=m,m=e[y]),Ub(n,y,km(m,t,i,y,e,a))}),n}var fP=km,SW=1,AW=4;function MW(e){return fP(e,SW|AW)}var pv=MW,EW="__lodash_hash_undefined__";function CW(e){return this.__data__.set(e,EW),this}var TW=CW;function PW(e){return this.__data__.has(e)}var DW=PW;function pg(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new uv;++t<i;)this.add(e[t])}pg.prototype.add=pg.prototype.push=TW;pg.prototype.has=DW;var IW=pg;function OW(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var RW=OW;function LW(e,t){return e.has(t)}var BW=LW,zW=1,FW=2;function kW(e,t,i,r,s,a){var n=i&zW,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),c=a.get(t);if(h&&c)return h==t&&c==e;var u=-1,d=!0,p=i&FW?new IW:void 0;for(a.set(e,t),a.set(t,e);++u<o;){var f=e[u],g=t[u];if(r)var m=n?r(g,f,u,t,e,a):r(f,g,u,e,t,a);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!RW(t,function(y,x){if(!BW(p,x)&&(f===y||s(f,y,i,r,a)))return p.push(x)})){d=!1;break}}else if(!(f===g||s(f,g,i,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}var mP=kW;function UW(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var NW=UW;function VW(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var jW=VW,HW=1,GW=2,WW="[object Boolean]",qW="[object Date]",XW="[object Error]",YW="[object Map]",QW="[object Number]",ZW="[object RegExp]",KW="[object Set]",JW="[object String]",$W="[object Symbol]",eq="[object ArrayBuffer]",tq="[object DataView]",IA=Da?Da.prototype:void 0,j0=IA?IA.valueOf:void 0;function iq(e,t,i,r,s,a,n){switch(i){case tq:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case eq:return!(e.byteLength!=t.byteLength||!a(new dg(e),new dg(t)));case WW:case qW:case QW:return kb(+e,+t);case XW:return e.name==t.name&&e.message==t.message;case ZW:case JW:return e==t+"";case YW:var o=NW;case KW:var l=r&HW;if(o||(o=jW),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=GW,n.set(e,t);var c=mP(o(e),o(t),r,s,a,n);return n.delete(e),c;case $W:if(j0)return j0.call(e)==j0.call(t)}return!1}var rq=iq,sq=1,aq=Object.prototype,nq=aq.hasOwnProperty;function oq(e,t,i,r,s,a){var n=i&sq,o=Ty(e),l=o.length,h=Ty(t),c=h.length;if(l!=c&&!n)return!1;for(var u=l;u--;){var d=o[u];if(!(n?d in t:nq.call(t,d)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var g=!0;a.set(e,t),a.set(t,e);for(var m=n;++u<l;){d=o[u];var y=e[d],x=t[d];if(r)var b=n?r(x,y,d,t,e,a):r(y,x,d,e,t,a);if(!(b===void 0?y===x||s(y,x,i,r,a):b)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var _=e.constructor,M=t.constructor;_!=M&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof M=="function"&&M instanceof M)&&(g=!1)}return a.delete(e),a.delete(t),g}var lq=oq,hq=1,OA="[object Arguments]",RA="[object Array]",Nf="[object Object]",cq=Object.prototype,LA=cq.hasOwnProperty;function uq(e,t,i,r,s,a){var n=Un(e),o=Un(t),l=n?RA:up(e),h=o?RA:up(t);l=l==OA?Nf:l,h=h==OA?Nf:h;var c=l==Nf,u=h==Nf,d=l==h;if(d&&ug(e)){if(!ug(t))return!1;n=!0,c=!1}if(d&&!c)return a||(a=new Fm),n||WT(e)?mP(e,t,i,r,s,a):rq(e,t,l,i,r,s,a);if(!(i&hq)){var p=c&&LA.call(e,"__wrapped__"),f=u&&LA.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return a||(a=new Fm),s(g,m,i,r,a)}}return d?(a||(a=new Fm),lq(e,t,i,r,s,a)):!1}var dq=uq;function gP(e,t,i,r,s){return e===t?!0:e==null||t==null||!Lo(e)&&!Lo(t)?e!==e&&t!==t:dq(e,t,i,r,gP,s)}var pq=gP;function fq(e,t){return e!=null&&t in Object(e)}var mq=fq;function gq(e,t,i){t=Pu(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=dv(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&Nb(s)&&Fb(n,s)&&(Un(e)||jb(e)))}var vq=gq;function yq(e,t){return e!=null&&vq(e,t,mq)}var xq=yq,bq=function(){return an.Date.now()},H0=bq,wq="Expected a function",_q=Math.max,Sq=Math.min;function Aq(e,t,i){var r,s,a,n,o,l,h=0,c=!1,u=!1,d=!0;if(typeof e!="function")throw new TypeError(wq);t=oA(t)||0,sn(i)&&(c=!!i.leading,u="maxWait"in i,a=u?_q(oA(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d);function p(S){var E=r,A=s;return r=s=void 0,h=S,n=e.apply(A,E),n}function f(S){return h=S,o=setTimeout(y,t),c?p(S):n}function g(S){var E=S-l,A=S-h,T=t-E;return u?Sq(T,a-A):T}function m(S){var E=S-l,A=S-h;return l===void 0||E>=t||E<0||u&&A>=a}function y(){var S=H0();if(m(S))return x(S);o=setTimeout(y,g(S))}function x(S){return o=void 0,d&&r?p(S):(r=s=void 0,n)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function _(){return o===void 0?n:x(H0())}function M(){var S=H0(),E=m(S);if(r=arguments,s=this,l=S,E){if(o===void 0)return f(l);if(u)return clearTimeout(o),o=setTimeout(y,t),p(l)}return o===void 0&&(o=setTimeout(y,t)),n}return M.cancel=b,M.flush=_,M}var dp=Aq;function Mq(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Eq=Mq;function Cq(e,t){return e>t}var Tq=Cq;function Pq(e,t){return t.length<2?e:QT(e,$T(t,0,-1))}var Dq=Pq;function Iq(e,t){return pq(e,t)}var Zb=Iq;function Oq(e,t,i){for(var r=-1,s=e.length;++r<s;){var a=e[r],n=t(a);if(n!=null&&(o===void 0?n===n&&!Op(n):i(n,o)))var o=n,l=a}return l}var Rq=Oq;function Lq(e){return e&&e.length?Rq(e,kT,Tq):void 0}var Bq=Lq;function zq(e,t){return t=Pu(t,e),e=Dq(e,t),e==null||delete e[dv(Eq(t))]}var Fq=zq;function kq(e){return kG(e)?void 0:e}var Uq=kq,Nq=1,Vq=2,jq=4,Hq=KT(function(e,t){var i={};if(e==null)return i;var r=!1;t=LT(t,function(a){return a=Pu(a,e),r||(r=a.length>1),a}),Rp(e,cP(e),i),r&&(i=fP(i,Nq|Vq|jq,Uq));for(var s=t.length;s--;)Fq(i,t[s]);return i}),Oy=Hq;function Gq(e,t,i,r){if(!sn(e))return e;t=Pu(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=dv(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=sn(c)?c:Fb(t[s+1])?[]:{})}Ub(o,l,h),o=o[l]}return e}var Wq=Gq;function qq(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=QT(e,n);i(o,n)&&Wq(a,Pu(n,e),o)}return a}var Xq=qq;function Yq(e,t){return Xq(e,t,function(i,r){return xq(e,r)})}var Qq=Yq,Zq=KT(function(e,t){return e==null?{}:Qq(e,t)}),Bn=Zq,Kq="Expected a function";function Jq(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(Kq);return sn(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),dp(e,t,{leading:r,maxWait:t,trailing:s})}var $q=Jq;function eX(e,t){for(var i=e.length;i--&&XV(t,e[i],0)>-1;);return i}var tX=eX;function iX(e,t,i){if(e=YT(e),e&&(i||t===void 0))return e.slice(0,FT(e)+1);if(!e||!(t=zT(t)))return e;var r=vA(e),s=tX(r,vA(t))+1;return VG(r,0,s).join("")}var rX=iX;function vP(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ia(e,t){return Object.setPrototypeOf(e,t),e}var sX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),aX=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),nX=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||fv&&"ontouchend"in document,oX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,lX=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,hX=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},cX=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},uX=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},yP=sX(),joe=yP?uX():void 0,fv=aX(),Iu=nX(),dX=oX(),ra=lX(),BA=hX(),pX=Number(cX());function xP(e){return Array.isArray(e)?e:[e]}function bP(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Vf(e){return fv?e.metaKey:e.ctrlKey}function fX(e){return e.wheelDeltaY===0||e.deltaY===0?fv&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var It=[],fg={},Od={},Um={};function wP(e){It.includes(e)||It.push(e)}function Qc(e){delete fg[e.pointerId];for(let t=0;t<It.length;t++)if(It[t].pointerId===e.pointerId){It.splice(t,1);break}}function mX(){It.splice(0,It.length)}function mg(e){if(e.pointerType!=="touch")return;let t=fg[e.pointerId];t===void 0&&(t={x:0,y:0},fg[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function G0(e){let t=e.pointerId===It[0].pointerId?It[1]:It[0];return fg[t.pointerId]}function _P(e){Od[e.key]=!0,Um[e.key]=Um[e.key]===void 0?1:Um[e.key]+1}function SP(e){if(fv&&Od.Meta)for(let t in Od)Od[t]=!1;else Od[e.key]=!1;Um={}}function gX(e){e.addEventListener("pointerdown",wP,!0),e.addEventListener("pointerdown",mg,!0),e.addEventListener("pointermove",mg,!0),e.addEventListener("pointerup",Qc,!0),e.addEventListener("pointercancel",Qc,!0),e.addEventListener("pointerleave",Qc,!0),window.addEventListener("keydown",_P,!0),window.addEventListener("keyup",SP,!0)}function vX(e){e.removeEventListener("pointerdown",wP,!0),e.removeEventListener("pointerdown",mg,!0),e.removeEventListener("pointermove",mg,!0),e.removeEventListener("pointerup",Qc,!0),e.removeEventListener("pointercancel",Qc,!0),e.removeEventListener("pointerleave",Qc,!0),window.removeEventListener("keydown",_P,!0),window.removeEventListener("keyup",SP,!0)}var AP,yX=new Promise(e=>{AP=e}),jf;function xX(e){if(jf)return jf;async function t(){let i=e??"https://unpkg.com/@splinetool/navmesh-wasm@1.10.54/build",r=import("./navmesh.js"),[s,a]=await Promise.all([r,fetch(`${i}/navmesh.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});AP(o)}return jf=t(),jf}var MP,bX=new Promise(e=>{MP=e}),Hf;function wX(){if(Hf)return Hf;async function e(){let t=await import("./physics.js");await t.init(),MP(t)}return Hf=e(),Hf}var Et=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Et.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,Et.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,Et.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Kb(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Kb(r)}return Object.freeze(e)}function _X(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var EP=class extends Error{};function W0(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function gl(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function Jb(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function SX(){return typeof process<"u"}function CP(e,t){for(let i of e)t(i.id,i.data)!==!0&&CP(i.children,t)}function TP(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)TP(i,t)}var ds=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,ds.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Kb(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&TP(i,t)}}traverse(e){CP(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,ds.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let u=t;for(;u!==null;){if(u===void 0)throw new Error;if(u===r)throw new EP("cyclic tree");u=this.parent(u)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(u=>u.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((u,d)=>u.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>_X(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return gl(0,i,i);{let s=r[0].fi;return gl(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return gl(n,n+i,i)}else return gl(s.fi,a.fi,i)}}},gg;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(gg||(gg={}));var yt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,yt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Kb(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(a=>a.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,yt.prototype);let t=e;return SX()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),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 t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return gl(0,t,t);{let r=i[0].fi;return gl(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return gl(a,a+t,t)}else return gl(r.fi,s.fi,t)}}};function hu(e){return e&&typeof e=="object"&&e instanceof Er}var Er=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!hu(i))return null;r+=1}i=i?W0(i):new Er;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=W0(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=W0(o);l[e.path[r-1]]=i,i=l}else{let l=new Er;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,Er.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},Ml;(e=>{function t(s,a){return pp(s,a)??s}e.apply=t;function i(s,a){return ew(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=kr.zoomOnce(l,o[n]),l===void 0)return a;if(!hu(l))return;n+=1}if(l===void 0)return a;if(hu(l))if(a.type===0){let h={...a.props};for(let c of Object.keys(l))delete h[c];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=$b([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(Ml||(Ml={}));function $b(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=pp(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=$b(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function AX(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=pp(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function pp(e,t){if(!hu(t))return t;if(e instanceof ds){let i=$b(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof yt)return AX(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=pp(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Er)return ew(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=pp(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function ew(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!hu(t))return t;if(!hu(e))return Ml.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new Er;for(let s of i){let a=ew(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function MX(e,t){let i={cur:[],result:[],len:0};return e=fp(e,t,i)??e,[e,i.result]}function vg(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function yg(e){e&&(e.len-=1)}function EX(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function PP(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=fp(a.data,t,vg(i,n));yg(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=PP(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function CX(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=fp(a.data,t,vg(i,n));return yg(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function fp(e,t,i){if(e instanceof ds){let r=PP(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof yt)return CX(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=fp(a,t,vg(i,n));return yg(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!Jb(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"&&a!=="variableId"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=fp(n,t,vg(i,a));yg(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&EX(i),r}else return}}var xg;(e=>{function t(i,r){let s=kr.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(xg||(xg={}));var Kr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let c=h.path;for(var u=[];;){let d;if(l instanceof Er&&h.type===0&&(d=l.runOp({...h,path:c.slice(u.length)}),d===null&&(d=void 0)),d===void 0&&u.length===c.length&&(l instanceof ds||l instanceof yt||l instanceof Et?d=l.runOp(h):d=gg.runOp(l,h)),d!==void 0)if(d!==null){let g=d.data;for(let m=u.length-1;m>=0;m--){let y=c[m],x=u[m];if(x instanceof ds){if(typeof y=="number")throw new Error("illegal arg");g=x.modifyById(y,g)}else if(x instanceof yt){if(typeof y=="number")throw new Error("illegal arg");g=x.modifyById(y,g)}else if(x instanceof Et){if(typeof y=="number")throw new Error("illegal arg");g=x.modifyById(y,g)}else if(x instanceof Er){let b={...x,[y]:g};g=Object.setPrototypeOf(b,Er.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let b=g;g=[...x],g[y]=b}else g={...x,[y]:g};else return null}return{data:g,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let p=c[u.length],f;if(l instanceof ds){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof yt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)u.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(Kr||(Kr={}));var Ry;(e=>{function t(){return[]}e.empty=t;function i(h,c){let u=[];for(let d of h){let[p,...f]=d.path;p===c&&u.push({...d,path:f})}return u}e.removePrefix=i;function r(h,c){return h.map(u=>({...u,path:[c,...u.path]}))}e.addPrefix=r;function s(h,c){return[...h,...c]}e.concat=s;function a(h,c){return[...h.filter(u=>!c.some(d=>Kr.subsumed(u,d))),...c]}e.compress=a;function n(h,c){return h.every(u=>c.every(d=>Kr.commutative(u,d)))}e.commutative=n;function o(h,c){for(let u of c){let d=l(h,u);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,c){var u=h;let d=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let g,m,y;if(f.type===3?(g=kr.zoom(u,[...f.path,f.id]),y=Kr.apply(u,{...f,type:2})):(g=kr.zoom(u,[...f.path,f.id,"value"]),y=Kr.apply(u,f)),y!==null){u=y.data;let[x,b]=MX(u,{[f.id]:g});u=x;for(let _=0;_<b.length;_++){let M=b[_],S=M.pop();if(typeof S=="number"){let E=[S];for(let T=_+1;T<b.length;T++){let P=b[T],R=P[P.length-1];if(typeof R=="number"&&kr.equal(M,P.slice(0,P.length-1)))E.push(R),b.splice(T,1);else break}let A=kr.zoom(u,M);m=A.map((T,P)=>E.includes(P)?f.id:T),g=A,S=M.pop()}else{if(S==="alphaOverride"||S==="alpha"){g/=100;let E=g,A=kr.zoom(u,M.slice(0,M.length-2)),T=A.layers.map(P=>P.id===M[M.length-1]?{...P,data:{...P.data,[S]:E}}:P);Object.setPrototypeOf(T,Object.getPrototypeOf(A.layers)),A.layers=T}m=f.id}d.push({type:0,path:M,props:{[S]:g}}),p.push({type:0,path:M,props:{[S]:m}})}p.push(y.reverse),d.push(y.actual)}}else{let g=Kr.apply(u,f);g!==null&&(d.push(g.actual),u=g.data,p.push(g.reverse))}}catch(g){if(g instanceof EP)return null;throw g}return{data:u,actual:d,reverse:p.reverse()}}e.apply=l})(Ry||(Ry={}));var DP=Symbol(),TX=Symbol(),mv=Symbol(),Lp=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof OP);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[mv];i&&i(),delete this._children[e]}}}},PX=class extends Lp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,gg.runOp(this._current,e),e.path)}},DX=class extends Lp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Et.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},IP={get(e,t){if(t===mv)return()=>{e._parent=null};if(t===DP)return e._current;if(t===TX)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let a=i[t],n=gv(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},IX={...IP,set(e,t,i){let r={type:0,props:{[t]:pr(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},OX={...IP,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},tw=class extends Lp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[mv]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,a=gv(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},iw=class extends Lp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[mv]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,a=gv(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function q0(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&kr.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var OP=class extends Lp{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){q0(this.ts,t,e),q0(this.actual,i,e),q0(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function gv(e,t,i){return i instanceof ds?new tw(e,t,i):i instanceof yt?new iw(e,t,i):i instanceof Et?new Proxy(new DX(e,t,i),OX):i!==null&&typeof i=="object"?Jb(i)?i:new Proxy(new PX(e,t,i),IX):i}function RP(e){let t=new OP(e);return[gv(t,"",e),t]}function mp(e,t){let[i,r]=RP(e);return t(i),r.result()}function pr(e){return e instanceof tw||e instanceof iw?e._current:e!==null&&typeof e=="object"?e[DP]:e}var kr;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof ds||a instanceof tw)&&typeof n=="string"||(a instanceof yt||a instanceof iw)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(kr||(kr={}));function RX(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Li(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var LP=class{},zA=class extends LP{constructor(e){super(),this.id=e}},FA=class extends LP{constructor(e){super(),this.data=e}},Ly;try{Ly=new TextDecoder}catch{}var ct,El,we=0,BP=[],By=BP,zy=0,qs={},yi,vl,_a=0,Dn=0,ia,Do,Us=[],Ai,kA={useRecords:!1,mapsAsObjects:!0},zP=class{},FP=new zP;FP.name="MessagePack 0xC1";var cu=!1,bg=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ct)return HP(()=>(ky(),this?this.unpack(e,t):bg.prototype.unpack.call(kA,e,t)));El=t>-1?t:e.length,we=0,zy=0,Dn=0,vl=null,By=BP,ia=null,ct=e;try{Ai=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw ct=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof bg){if(qs=this,this.structures)return yi=this.structures,Gf();(!yi||yi.length>0)&&(yi=[])}else qs=kA,(!yi||yi.length>0)&&(yi=[]);return Gf()}unpackMultiple(e,t){let i,r=0;try{cu=!0;let s=e.length,a=this?this.unpack(e,s):yv.unpack(e,s);if(t){for(t(a);we<s;)if(r=we,t(Gf())===!1)return}else{for(i=[a];we<s;)r=we,i.push(Gf());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{cu=!1,ky()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Gf(){try{if(!qs.trusted&&!cu){let t=yi.sharedLength||0;t<yi.length&&(yi.length=t)}let e=sr();if(we==El)yi.restoreStructures&&UA(),yi=null,ct=null,Do&&(Do=null);else if(we>El){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 e}catch(e){throw yi.restoreStructures&&UA(),ky(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function UA(){for(let e in yi.restoreStructures)yi[e]=yi.restoreStructures[e];yi.restoreStructures=null}function sr(){let e=ct[we++];if(e<160)if(e<128){if(e<64)return e;{let t=yi[e&63]||qs.getStructures&&kP()[e&63];return t?(t.read||(t.read=rw(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,qs.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NP()]=sr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(sr(),sr());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=sr();return t}else if(e<192){let t=e-160;if(Dn>=we)return vl.slice(we-_a,(we+=t)-_a);if(Dn==0&&El<140){let i=t<16?sw(t):UP(t);if(i!=null)return i}return Fy(t)}else{let t;switch(e){case 192:return null;case 193:return ia?(t=sr(),t>0?ia[1].slice(ia.position1,ia.position1+=t):ia[0].slice(ia.position0,ia.position0-=t)):FP;case 194:return!1;case 195:return!0;case 196:return X0(ct[we++]);case 197:return t=Ai.getUint16(we),we+=2,X0(t);case 198:return t=Ai.getUint32(we),we+=4,X0(t);case 199:return Yl(ct[we++]);case 200:return t=Ai.getUint16(we),we+=2,Yl(t);case 201:return t=Ai.getUint32(we),we+=4,Yl(t);case 202:if(t=Ai.getFloat32(we),qs.useFloat32>2){let i=aw[(ct[we]&127)<<1|ct[we+1]>>7];return we+=4,(i*t+(t>0?.5:-.5)>>0)/i}return we+=4,t;case 203:return t=Ai.getFloat64(we),we+=8,t;case 204:return ct[we++];case 205:return t=Ai.getUint16(we),we+=2,t;case 206:return t=Ai.getUint32(we),we+=4,t;case 207:return qs.int64AsNumber?(t=Ai.getUint32(we)*4294967296,t+=Ai.getUint32(we+4)):t=Ai.getBigUint64(we),we+=8,t;case 208:return Ai.getInt8(we++);case 209:return t=Ai.getInt16(we),we+=2,t;case 210:return t=Ai.getInt32(we),we+=4,t;case 211:return qs.int64AsNumber?(t=Ai.getInt32(we)*4294967296,t+=Ai.getUint32(we+4)):t=Ai.getBigInt64(we),we+=8,t;case 212:if(t=ct[we++],t==114)return GA(ct[we++]&63);{let i=Us[t];if(i)return i.read?(we++,i.read(sr())):i.noBuffer?(we++,i()):i(ct.subarray(we,++we));throw new Error("Unknown extension "+t)}case 213:return t=ct[we],t==114?(we++,GA(ct[we++]&63,ct[we++])):Yl(2);case 214:return Yl(4);case 215:return Yl(8);case 216:return Yl(16);case 217:return t=ct[we++],Dn>=we?vl.slice(we-_a,(we+=t)-_a):BX(t);case 218:return t=Ai.getUint16(we),we+=2,Dn>=we?vl.slice(we-_a,(we+=t)-_a):zX(t);case 219:return t=Ai.getUint32(we),we+=4,Dn>=we?vl.slice(we-_a,(we+=t)-_a):FX(t);case 220:return t=Ai.getUint16(we),we+=2,VA(t);case 221:return t=Ai.getUint32(we),we+=4,VA(t);case 222:return t=Ai.getUint16(we),we+=2,jA(t);case 223:return t=Ai.getUint32(we),we+=4,jA(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var LX=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function rw(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>LX.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(sr);return e.highByte===0&&(e.read=NA(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=sr()}return r}return i.count=0,e.highByte===0?NA(t,i):i}var NA=(e,t)=>function(){let i=ct[we++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=yi[r]||kP()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=rw(s,e)),s.read()};function kP(){let e=HP(()=>(ct=null,qs.getStructures()));return yi=qs._mergeStructures(e,yi)}var Fy=vv,BX=vv,zX=vv,FX=vv;function vv(e){let t;if(e<16&&(t=sw(e)))return t;if(e>64&&Ly)return Ly.decode(ct.subarray(we,we+=e));let i=we+e,r=[];for(t="";we<i;){let s=ct[we++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=ct[we++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=ct[we++]&63,n=ct[we++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=ct[we++]&63,n=ct[we++]&63,o=ct[we++]&63,l=(s&7)<<18|a<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=Xr.apply(String,r),r.length=0)}return r.length>0&&(t+=Xr.apply(String,r)),t}function VA(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=sr();return t}function jA(e){if(qs.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NP()]=sr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(sr(),sr());return t}}var Xr=String.fromCharCode;function UP(e){let t=we,i=new Array(e);for(let r=0;r<e;r++){let s=ct[we++];if((s&128)>0){we=t;return}i[r]=s}return Xr.apply(String,i)}function sw(e){if(e<4)if(e<2){if(e===0)return"";{let t=ct[we++];if((t&128)>1){we-=1;return}return Xr(t)}}else{let t=ct[we++],i=ct[we++];if((t&128)>0||(i&128)>0){we-=2;return}if(e<3)return Xr(t,i);let r=ct[we++];if((r&128)>0){we-=3;return}return Xr(t,i,r)}else{let t=ct[we++],i=ct[we++],r=ct[we++],s=ct[we++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){we-=4;return}if(e<6){if(e===4)return Xr(t,i,r,s);{let a=ct[we++];if((a&128)>0){we-=5;return}return Xr(t,i,r,s,a)}}else if(e<8){let a=ct[we++],n=ct[we++];if((a&128)>0||(n&128)>0){we-=6;return}if(e<7)return Xr(t,i,r,s,a,n);let o=ct[we++];if((o&128)>0){we-=7;return}return Xr(t,i,r,s,a,n,o)}else{let a=ct[we++],n=ct[we++],o=ct[we++],l=ct[we++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){we-=8;return}if(e<10){if(e===8)return Xr(t,i,r,s,a,n,o,l);{let h=ct[we++];if((h&128)>0){we-=9;return}return Xr(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=ct[we++],c=ct[we++];if((h&128)>0||(c&128)>0){we-=10;return}if(e<11)return Xr(t,i,r,s,a,n,o,l,h,c);let u=ct[we++];if((u&128)>0){we-=11;return}return Xr(t,i,r,s,a,n,o,l,h,c,u)}else{let h=ct[we++],c=ct[we++],u=ct[we++],d=ct[we++];if((h&128)>0||(c&128)>0||(u&128)>0||(d&128)>0){we-=12;return}if(e<14){if(e===12)return Xr(t,i,r,s,a,n,o,l,h,c,u,d);{let p=ct[we++];if((p&128)>0){we-=13;return}return Xr(t,i,r,s,a,n,o,l,h,c,u,d,p)}}else{let p=ct[we++],f=ct[we++];if((p&128)>0||(f&128)>0){we-=14;return}if(e<15)return Xr(t,i,r,s,a,n,o,l,h,c,u,d,p,f);let g=ct[we++];if((g&128)>0){we-=15;return}return Xr(t,i,r,s,a,n,o,l,h,c,u,d,p,f,g)}}}}}function X0(e){return qs.copyBuffers?Uint8Array.prototype.slice.call(ct,we,we+=e):ct.subarray(we,we+=e)}function Yl(e){let t=ct[we++];if(Us[t])return Us[t](ct.subarray(we,we+=e));throw new Error("Unknown extension type "+t)}var HA=new Array(4096);function NP(){let e=ct[we++];if(e>=160&&e<192){if(e=e-160,Dn>=we)return vl.slice(we-_a,(we+=e)-_a);if(!(Dn==0&&El<180))return Fy(e)}else return we--,sr();let t=(e<<5^(e>1?Ai.getUint16(we):e>0?ct[we]:0))&4095,i=HA[t],r=we,s=we+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=Ai.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=ct[r++],a!=i[n++]){r=1879048192;break}if(r===s)return we=r,i.string;s-=3,r=we}for(i=[],HA[t]=i,i.bytes=e;r<s;)a=Ai.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=ct[r++],i.push(a);let o=e<16?sw(e):UP(e);return o!=null?i.string=o:i.string=Fy(e)}var GA=(e,t)=>{var i=sr();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=yi[e];return s&&s.isShared&&((yi.restoreStructures||(yi.restoreStructures=[]))[e]=s),yi[e]=i,i.read=rw(i,r),i.read()},VP=typeof self=="object"?self:global;Us[0]=()=>{};Us[0].noBuffer=!0;Us[101]=()=>{let e=sr();return(VP[e[0]]||Error)(e[1])};Us[105]=e=>{let t=Ai.getUint32(we-4);Do||(Do=new Map);let i=ct[we],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Do.set(t,s);let a=sr();return s.used?Object.assign(r,a):(s.target=a,a)};Us[112]=e=>{let t=Ai.getUint32(we-4),i=Do.get(t);return i.used=!0,i.target};Us[115]=()=>new Set(sr());var jP=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Us[116]=e=>{let t=e[0],i=jP[t];if(!i)throw new Error("Could not find typed array for code "+t);return new VP[i](Uint8Array.prototype.slice.call(e,1).buffer)};Us[120]=()=>{let e=sr();return new RegExp(e[0],e[1])};Us[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=we;we+=t-4,ia=[sr(),sr()],ia.position0=0,ia.position1=0;let r=we;we=i;try{return sr()}finally{we=r}};Us[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function HP(e){let t=El,i=we,r=zy,s=_a,a=Dn,n=vl,o=By,l=Do,h=ia,c=new Uint8Array(ct.slice(0,El)),u=yi,d=yi.slice(0,yi.length),p=qs,f=cu,g=e();return El=t,we=i,zy=r,_a=s,Dn=a,vl=n,By=o,Do=l,ia=h,ct=c,cu=f,yi=u,yi.splice(0,yi.length,...d),qs=p,Ai=new DataView(ct.buffer,ct.byteOffset,ct.byteLength),g}function ky(){ct=null,Do=null,yi=null}function kX(e){e.unpack?Us[e.type]=e.unpack:Us[e.type]=e}var aw=new Array(147);for(let e=0;e<256;e++)aw[e]=+("1e"+Math.floor(45.15-e*.30103));var yv=new bg({useRecords:!1}),Hoe=yv.unpack,Goe=yv.unpackMultiple,Woe=yv.unpack,UX={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},NX=new Float32Array(1),qoe=new Uint8Array(NX.buffer,0,4),Nm;try{Nm=new TextEncoder}catch{}var wg,nw,xv=typeof Buffer<"u",Y0=xv?Buffer.allocUnsafeSlow:Uint8Array,GP=xv?Buffer:Uint8Array,WA=xv?4294967296:2144337920,Ue,ur,Me=0,dn,pn=null,VX=/[\u0080-\uFFFF]/,ud=Symbol("record-id"),WP=class extends bg{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=GP.prototype.utf8Write?function(E,A,T){return Ue.utf8Write(E,A,T)}:Nm&&Nm.encodeInto?function(E,A){return Nm.encodeInto(E,Ue.subarray(A)).written}:!1,h=this;e||(e={});let c=e&&e.sequential,u=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=u?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=u?32:64),c&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,g=d+64,m=d+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],x=0,b=0;this.pack=this.encode=function(E,A){if(Ue||(Ue=new Y0(8192),ur=new DataView(Ue.buffer,0,8192),Me=0),dn=Ue.length-10,dn-Me<2048?(Ue=new Y0(Ue.length),ur=new DataView(Ue.buffer,0,Ue.length),dn=Ue.length-10,Me=0):Me=Me+7&2147483640,i=Me,n=h.structuredClone?new Map:null,h.bundleStrings?(pn=["",""],Ue[Me++]=214,Ue[Me++]=98,pn.position=Me-i,Me+=4):pn=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let T=r.sharedLength||0;if(T>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let P=0;P<T;P++){let R=r[P];if(!R)continue;let z,U=r.transitions;for(let L=0,H=R.length;L<H;L++){let q=R[L];z=U[q],z||(z=U[q]=Object.create(null)),U=z}U[ud]=P+64}o=T}c||(r.nextId=T+64)}s&&(s=!1),a=r||[];try{if(_(E),pn){ur.setUint32(pn.position+i,Me-pn.position-i);let T=pn;pn=null,_(T[0]),_(T[1])}if(h.offset=Me,n&&n.idsToInsert){Me+=n.idsToInsert.length*6,Me>dn&&S(Me),h.offset=Me;let T=HX(Ue.subarray(i,Me),n.idsToInsert);return n=null,T}return A&GX?(Ue.start=i,Ue.end=Me,Ue):Ue.subarray(i,Me)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,y.length>0&&(y=[]);else if(y.length>0&&!c){for(let T=0,P=y.length;T<P;T++)y[T][ud]=0;y=[]}if(s&&h.saveStructures){let T=r.sharedLength||d;r.length>T&&(r=r.slice(0,T));let P=Ue.subarray(i,Me);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(E)):(o=T,P)}}A&WX&&(Me=i)}};let _=E=>{Me>dn&&(Ue=S(Me));var A=typeof E,T;if(A==="string"){let P=E.length;if(pn&&P>=8&&P<4096){let U=VX.test(E);pn[U?0:1]+=E,Ue[Me++]=193,_(U?-P:P);return}let R;P<32?R=1:P<256?R=2:P<65536?R=3:R=5;let z=P*3;if(Me+z>dn&&(Ue=S(Me+z)),P<64||!l){let U,L,H,q=Me+R;for(U=0;U<P;U++)L=E.charCodeAt(U),L<128?Ue[q++]=L:L<2048?(Ue[q++]=L>>6|192,Ue[q++]=L&63|128):(L&64512)===55296&&((H=E.charCodeAt(U+1))&64512)===56320?(L=65536+((L&1023)<<10)+(H&1023),U++,Ue[q++]=L>>18|240,Ue[q++]=L>>12&63|128,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128):(Ue[q++]=L>>12|224,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128);T=q-Me-R}else T=l(E,Me+R,z);T<32?Ue[Me++]=160|T:T<256?(R<2&&Ue.copyWithin(Me+2,Me+1,Me+1+T),Ue[Me++]=217,Ue[Me++]=T):T<65536?(R<3&&Ue.copyWithin(Me+3,Me+2,Me+2+T),Ue[Me++]=218,Ue[Me++]=T>>8,Ue[Me++]=T&255):(R<5&&Ue.copyWithin(Me+5,Me+3,Me+3+T),Ue[Me++]=219,ur.setUint32(Me,T),Me+=4),Me+=T}else if(A==="number")if(E>>>0===E)E<64?Ue[Me++]=E:E<256?(Ue[Me++]=204,Ue[Me++]=E):E<65536?(Ue[Me++]=205,Ue[Me++]=E>>8,Ue[Me++]=E&255):(Ue[Me++]=206,ur.setUint32(Me,E),Me+=4);else if(E>>0===E)E>=-32?Ue[Me++]=256+E:E>=-128?(Ue[Me++]=208,Ue[Me++]=E+256):E>=-32768?(Ue[Me++]=209,ur.setInt16(Me,E),Me+=2):(Ue[Me++]=210,ur.setInt32(Me,E),Me+=4);else{let P;if((P=this.useFloat32)>0&&E<4294967296&&E>=-2147483648){Ue[Me++]=202,ur.setFloat32(Me,E);let R;if(P<4||(R=E*aw[(Ue[Me]&127)<<1|Ue[Me+1]>>7])>>0===R){Me+=4;return}else Me--}Ue[Me++]=203,ur.setFloat64(Me,E),Me+=8}else if(A==="object")if(!E)Ue[Me++]=192;else{if(n){let R=n.get(E);if(R){if(!R.id){let z=n.idsToInsert||(n.idsToInsert=[]);R.id=z.push(R)}Ue[Me++]=214,Ue[Me++]=112,ur.setUint32(Me,R.id),Me+=4;return}else n.set(E,{offset:Me-i})}let P=E.constructor;if(P===Object)M(E,!0);else if(P===Array){T=E.length,T<16?Ue[Me++]=144|T:T<65536?(Ue[Me++]=220,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=221,ur.setUint32(Me,T),Me+=4);for(let R=0;R<T;R++)_(E[R])}else if(P===Map){T=E.size,T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,ur.setUint32(Me,T),Me+=4);for(let[R,z]of E)_(R),_(z)}else{for(let R=0,z=wg.length;R<z;R++){let U=nw[R];if(E instanceof U){let L=wg[R];if(L.write){L.type&&(Ue[Me++]=212,Ue[Me++]=L.type,Ue[Me++]=0),_(L.write.call(this,E));return}let H=Ue,q=ur,Z=Me;Ue=null;let X;try{X=L.pack.call(this,E,se=>(Ue=H,H=null,Me+=se,Me>dn&&S(Me),{target:Ue,targetView:ur,position:Me-se}),_)}finally{H&&(Ue=H,ur=q,Me=Z,dn=Ue.length-10)}X&&(X.length+Me>dn&&S(X.length+Me),Me=jX(X,Ue,Me,L.type));return}}M(E,!E.hasOwnProperty)}}else if(A==="boolean")Ue[Me++]=E?195:194;else if(A==="bigint"){if(E<BigInt(1)<<BigInt(63)&&E>=-(BigInt(1)<<BigInt(63)))Ue[Me++]=211,ur.setBigInt64(Me,E);else if(E<BigInt(1)<<BigInt(64)&&E>0)Ue[Me++]=207,ur.setBigUint64(Me,E);else if(this.largeBigIntToFloat)Ue[Me++]=203,ur.setFloat64(Me,Number(E));else throw new RangeError(E+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");Me+=8}else if(A==="undefined")this.encodeUndefinedAsNil?Ue[Me++]=192:(Ue[Me++]=212,Ue[Me++]=0,Ue[Me++]=0);else if(A==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},M=this.useRecords===!1?this.variableMapSize?E=>{let A=Object.keys(E),T=A.length;T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,ur.setUint32(Me,T),Me+=4);let P;for(let R=0;R<T;R++)_(P=A[R]),_(E[P])}:(E,A)=>{Ue[Me++]=222;let T=Me-i;Me+=2;let P=0;for(let R in E)(A||E.hasOwnProperty(R))&&(_(R),_(E[R]),P++);Ue[T+++i]=P>>8,Ue[T+i]=P&255}:E=>{let A=Object.keys(E),T,P=a.transitions||(a.transitions=Object.create(null)),R=0;for(let U=0,L=A.length;U<L;U++){let H=A[U];T=P[H],T||(T=P[H]=Object.create(null),R++),P=T}let z=P[ud];if(z)z>=96&&f?(Ue[Me++]=((z-=96)&31)+96,Ue[Me++]=z>>5):Ue[Me++]=z;else{z=a.nextId,z||(z=64),z<g&&this.shouldShareStructure&&!this.shouldShareStructure(A)?(z=a.nextOwnId,z<m||(z=g),a.nextOwnId=z+1):(z>=m&&(z=g),a.nextId=z+1);let U=A.highByte=z>=96&&f?z-96>>5:-1;P[ud]=z,a[z-64]=A,z<g?(A.isShared=!0,a.sharedLength=z-63,s=!0,U>=0?(Ue[Me++]=(z&31)+96,Ue[Me++]=U):Ue[Me++]=z):(U>=0?(Ue[Me++]=213,Ue[Me++]=114,Ue[Me++]=(z&31)+96,Ue[Me++]=U):(Ue[Me++]=212,Ue[Me++]=114,Ue[Me++]=z),R&&(x+=b*R),y.length>=p&&(y.shift()[ud]=0),y.push(P),_(A))}for(let U=0,L=A.length;U<L;U++)_(E[A[U]])},S=E=>{let A;if(E>16777216){if(E-i>WA)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(WA,Math.round(Math.max((E-i)*(E>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(E-i<<2,Ue.length-1)>>12)+1<<12;let T=new Y0(A);return ur=new DataView(T.buffer,0,A),Ue.copy?Ue.copy(T,0,i,E):T.set(Ue.slice(i,E)),Me-=i,i=0,dn=T.length-10,Ue=T}}useBuffer(e){Ue=e,ur=new DataView(Ue.buffer,Ue.byteOffset,Ue.byteLength),Me=0}};nw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,zP];wg=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?qA(e,16,t):XA(xv?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==GP&&this.structuredClone?qA(e,jP.indexOf(i.name),t):XA(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function qA(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function XA(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function jX(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function HX(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function Ou(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");nw.unshift(e.Class),wg.unshift(e)}kX(e)}var qP=new WP({useRecords:!1}),Xoe=qP.pack,Yoe=qP.pack,{NEVER:Qoe,ALWAYS:Zoe,DECIMAL_ROUND:Koe,DECIMAL_FIT:Joe}=UX,GX=512,WX=1024,YA=new WP({structuredClone:!0});Ou({Class:Et.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Et.prototype),e}});Ou({Class:yt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,yt.prototype),e}});Ou({Class:ds.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,ds.prototype),e}});Ou({Class:zA.prototype.constructor,type:4,write(e){return e.id},read(e){return new zA(e)}});Ou({Class:FA.prototype.constructor,type:5,write(e){return e.data},read(e){return new FA(e)}});Ou({Class:Er.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Er.prototype),e}});function qX(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function Uy(e){if(Jb(e))return e;if(Array.isArray(e))return e.map(Uy);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Uy(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Ny;(e=>{function t(s){return YA.pack(s)}e.serialize=t;function i(s){return YA.unpack(s)}e.deserialize=i;function r(s){return qX(t(Uy(s))).toString()}e.checksum=r})(Ny||(Ny={}));var QA;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(QA||(QA={}));function ZA(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var ys={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},KA;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,actions:new yt}:{type:r,disabled:!1,key:void 0,actions:new yt}}e.defaultData=i})(KA||(KA={}));var _g;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(_g||(_g={}));var Vy;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:_g.propertyDefaultData(s),rOperand:{..._g.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(Vy||(Vy={}));var JA;(e=>{function t(i){return i.find(r=>r==="ifActions"||r==="elseActions")!==void 0}e.isConditionalSubActions=t})(JA||(JA={}));var $A;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new yt,outActions:new yt,condition:Vy.distanceDefaultData(r)}}e.defaultData=i})($A||($A={}));var eM;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new yt,drop:new yt}})(eM||(eM={}));var jy;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new yt})(jy||(jy={}));var Hy;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Hy||(Hy={}));var tM;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new yt}}e.defaultData=i})(tM||(tM={}));var iM;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new yt}}e.defaultData=i})(iM||(iM={}));var rM;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new yt}}e.defaultData=i})(rM||(rM={}));var sM;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,target:"character",actions:new yt}}e.defaultData=i})(sM||(sM={}));var aM;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new yt,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(aM||(aM={}));var Gy;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new yt},o={size:"tablet",operator:"<",actions:new yt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new yt},h=new yt;return h.push({id:lt.generateUUID(),fi:0,data:n},{id:lt.generateUUID(),fi:1,data:o},{id:lt.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new yt}}e.defaultBreakpointData=a})(Gy||(Gy={}));var Wy;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new yt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(Wy||(Wy={}));var nM;(e=>{function t(r){return r.type==="API"}e.is=t;function i(){return{disabled:!1,type:"API",successActions:new yt,errorActions:new yt,userAPIId:""}}e.defaultData=i})(nM||(nM={}));var oM;(e=>{function t(r){return r.type==="WEBHOOK"}e.is=t;function i(){return{disabled:!1,type:"WEBHOOK",actions:new yt,userWebhookId:""}}e.defaultData=i})(oM||(oM={}));var lM;(e=>{function t(r){return r.type==="AIAssistantListener"}e.is=t;function i(){return{disabled:!1,type:"AIAssistantListener",actions:new yt,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=i})(lM||(lM={}));var hM;(e=>{function t(r){return r.type==="AIAssistantTrigger"}e.is=t;function i(){return{disabled:!1,description:"",type:"AIAssistantTrigger",actions:new yt}}e.defaultData=i})(hM||(hM={}));var Ru="personal camera",Wd="a218fcc3-276b-49b9-b485-49037fd14f5f",XX=2960946,sa=5526619,Co;(e=>{function t(f,g){return f[0]===g[0]&&f[1]===g[1]}e.isEqual=t;function i(f,g,m){return[f[0]+(g[0]-f[0])*m,f[1]+(g[1]-f[1])*m]}e.lerp=i;function r(f,g){return[f[0]+g[0],f[1]+g[1]]}e.add=r;function s(f,g){return[f[0]-g[0],f[1]-g[1]]}e.sub=s;function a(f,g){return[f[0]*g[0],f[1]*g[1]]}e.multiply=a;function n(f,g){return[f[0]/g[0],f[1]/g[1]]}e.divide=n;function o(f,g){return Math.pow(g[0]-f[0],2)+Math.pow(g[1]-f[1],2)}e.distanceSquared=o;function l(f,g){return Math.sqrt(o(f,g))}e.distance=l;function h(f,g){return f[0]*g[0]+f[1]*g[1]}e.dot=h;function c(f,g){return[f[0]*g,f[1]*g]}e.scalarMultiply=c;function u(f,g,m){let y=e.sub(g,f),x=e.sub(m,f),b=e.dot(y,x)/e.dot(y,y),_=e.scalarMultiply(y,b);return e.add(f,_)}e.projectionOnto=u;function d(f,g,m){return l(f,u(f,g,m))}e.projectionOntoDistance=d;function p(f,g){return[(f[0]+g[0])*.5,(f[1]+g[1])*.5]}e.center=p})(Co||(Co={}));var _h;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(_h||(_h={}));var Sg;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(Sg||(Sg={}));var cM;(e=>{let t=180/Math.PI,i=Math.PI/180;function r(o){return typeof o=="number"?o*t:o}function s(o){return typeof o=="number"?o*i:o}function a(o){return[r(o[0]),r(o[1]),r(o[2])]}e.radToDeg=a;function n(o){return[s(o[0]),s(o[1]),s(o[2])]}e.degToRad=n})(cM||(cM={}));var uu;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})(uu||(uu={}));var cs;(e=>{function t(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}e.toRgb255a1=i;function r(h){return{r:h.r,g:h.g,b:h.b}}e.clone=r;function s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}e.fromHex=s;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}e.toHex=a;function n(h,c){return h.r===c.r&&h.g===c.g&&h.b===c.b}e.equals=n;function o(h,c){return h.r.toFixed(2)===c.r.toFixed(2)&&h.g.toFixed(2)===c.g.toFixed(2)&&h.b.toFixed(2)===c.b.toFixed(2)}e.equalsFixed=o;function l(h,c,u){return{r:h.r+(c.r-h.r)*u,g:h.g+(c.g-h.g)*u,b:h.b+(c.b-h.b)*u}}e.lerp=l})(cs||(cs={}));var Di;(e=>{e.white={...cs.white,a:1},e.transparent={...cs.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}e.from0to1=t;function i(l,h){return{...cs.fromHex(l),a:h}}e.fromHexAndA=i;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}e.toRgb255a1=r;function s(l,h){return cs.equals(l,h)&&l.a===h.a}e.equals=s;function a(l,h){return cs.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)}e.equalsFixed=a;function n(l,h,c){return{r:l.r+(h.r-l.r)*c,g:l.g+(h.g-l.g)*c,b:l.b+(h.b-l.b)*c,a:l.a+(h.a-l.a)*c}}e.lerp=n;function o({r:l,g:h,b:c,a:u}=e.white){return`rgba(${l*255}, ${h*255}, ${c*255}, ${u})`}e.toStyle=o})(Di||(Di={}));var qy;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(qy||(qy={}));var YX=(e=>(e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING",e))(YX||{}),Xy;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Xy||(Xy={}));var Yy;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(Yy||(Yy={}));var ll;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(ll||(ll={}));function uM(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var Ph;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Ph||(Ph={}));var du;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}e.getZoom=t})(du||(du={}));var yl;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(a=>a*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let a={...r};if(XP.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;YP.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;QP.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;ZP.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;KP.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;JP.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(yl||(yl={}));var Qy;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(Qy||(Qy={}));var XP=["count"],YP=["radius","start","end","position","scale","rotation"],QP=["position","scale","rotation"],ZP=["count","size"],KP=["count","position","scale","rotation"],JP=["strength","scale","rotation","position","movement","seed","freqScale"],Zy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Zy||(Zy={}));var Ky;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Di.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Di.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Di.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Ky||(Ky={}));var Ag;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}))(Ag||(Ag={}));var pu;(e=>e.defaultData={enabled:"visibility",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]})(pu||(pu={}));var Jy;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Jy||(Jy={}));var $y;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})($y||($y={}));var ex;(e=>e.defaultData={...$y.defaultData,...Jy.defaultData})(ex||(ex={}));var dM;(e=>{function t(i,r){let s=[];if("material"in i){let a=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;a&&s.push(a)}else if("materials"in i)for(let a of i.materials){let n=typeof a=="string"?r.materials[a]??r.lib.materials[a]?.asset:a;n&&s.push(n)}return s}e.getMaterialData=t})(dM||(dM={}));var Mg;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Mg||(Mg={}));var pM;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(pM||(pM={}));function QX(e){return e.type!=="displace"}var fM;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(fM||(fM={}));var $P=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],ZX=["wrapping","image","video","name","minFilter","magFilter"],Yr;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,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],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Mg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...n,type:"color",color:cs.fromHex(sa)};case"depth":return{...n,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{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,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{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...cs.fromHex(6710886),a:1},colorB:{...cs.fromHex(6710886),a:1},colorC:{...cs.fromHex(16777215),a:1},colorD:{...cs.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{...n,type:"fresnel",color:Di.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,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:Di.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:Di.fromHexAndA(0,1),contourColor:Di.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...n,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{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...cs.fromHex(0),a:1},colorB:{...cs.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}}}})(Yr||(Yr={}));var Jr;(e=>{function t(c){return!c.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(c){let u="";return c.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{u+=`${p}${f}`,Array.isArray(f)?f.forEach(g=>u+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?u+=`${g.toFixed(4)}`:u+=`${g}`}):u+=`${f}`})}),u}e.getHash=i;function r(){return{layers:new yt}}e.defaultEmptyData=r;function s(c="layer1",u="layer2"){return n("phong",c,u)}e.defaultData=s;function a(c,u){return{...c,name:u}}e.withName=a;function n(c,u="layer1",d="layer2"){let p=new yt;return p.push({fi:0,data:Yr.defaultData("light",c),id:u}),p.push({fi:1,data:Yr.defaultData("color"),id:d}),{layers:p}}e.defaultTwoLayerData=n;function o(c){let u=Yr.defaultData("texture");c&&Object.assign(u.texture,{image:c});let d=new yt;return d.push({fi:0,data:u,id:"layer1"}),d.push({fi:1,data:{...Yr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Yr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}e.defaultUIObjectMaterial=o;function l(c,u="phong",d="layer1",p="layer2"){let f=Yr.defaultData("texture");Object.assign(f.texture,{image:c});let g=new yt;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:Yr.defaultData("light",u),id:p}),{layers:g}}e.defaultTwoLayerTextureData=l;function h(c,u="phong",d="layer1",p="layer2"){let f=Yr.defaultData("video");Object.assign(f.texture,{video:c});let g=new yt;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:Yr.defaultData("light",u),id:p}),{layers:g}}e.defaultTwoLayerVideoTextureData=h})(Jr||(Jr={}));var Eg;(e=>{function t(){return{points:new yt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Eg||(Eg={}));var Cg;(e=>{function t(){return{points:new yt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Cg||(Cg={}));var eD={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},tx;(e=>{function t(i,r){let s={...i};return iD.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(tx||(tx={}));var tD={shape:eD,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},iD=["depth","offset","angle","twist","startScale","endScale"],Tg;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=i})(Tg||(Tg={}));var ix;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,tx.merge(s.extrusion,r.extrusion))),s}e.merge=t})(ix||(ix={}));var cl;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Cg.defaultData(),extrusion:tD};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Eg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(cl||(cl={}));var Q0=["width","height","depth"],rx;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:cs.white,near:.1,far:2e3})(rx||(rx={}));var Pg;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(Pg||(Pg={}));var sx;(e=>e.defaultData={softShadowQuality:"low"})(sx||(sx={}));var ax;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(ax||(ax={}));var nx;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(nx||(nx={}));var fu;(e=>e.defaultData={usePhysics:!1,gravity:-10})(fu||(fu={}));var ox;(e=>e.defaultData={playCamera:Ru,gameControlObject:null})(ox||(ox={}));var lx;(e=>e.defaultData={backgroundColor:Di.fromHexAndA(XX,1),postprocessing:Pg.defaultData,fog:rx.defaultData,globalPhysics:fu.defaultData,ambient:ax.defaultData,ao:nx.defaultData,shadow:sx.defaultData,publish:ox.defaultData})(lx||(lx={}));var hx;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(hx||(hx={}));var mM;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(mM||(mM={}));var mu;(e=>{e.identity={...qy.identity,hiddenMatrix:uu.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:a?.position||s.position,rotation:a?.rotation||s.rotation,scale:a?.scale||s.scale,hiddenMatrix:a?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,a){return vP({position:_h.isEqual(s.position,a.position)?void 0:a.position,rotation:_h.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:_h.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:uu.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(mu||(mu={}));var Ur;(e=>e.defaultData={states:new yt,events:new yt,visible:!0,raycastLock:!1,physics:pu.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...mu.identity,cloner:null})(Ur||(Ur={}));var cx;(e=>e.defaultData={type:"Empty",...Ur.defaultData})(cx||(cx={}));var gM;(e=>e.defaultData={type:"ParticleCollider",...hx.defaultData,...Ur.defaultData})(gM||(gM={}));var vM;(e=>e.defaultData={type:"Component",...Ur.defaultData})(vM||(vM={}));var yM;(e=>e.defaultData={type:"Particle",...Ur.defaultData,...Ag.defaultData})(yM||(yM={}));var ul;(e=>e.defaultData={type:"Mesh",...Ur.defaultData,...ex.defaultData})(ul||(ul={}));var gp;(e=>e.defaultData={...Ur.defaultData,...mu.identity,position:[0,0,du.DefaultTargetOffset],...du.defaultData})(gp||(gp={}));var ux;(e=>{function t(i){return{...Ur.defaultData,...Ky.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(ux||(ux={}));var Dg;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(Dg||(Dg={}));var xl;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Ur.defaultData,...s,component:r,overrides:new Er,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=mu.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(xl||(xl={}));var gu;(e=>{e.defaultData={type:"Page",...Ur.defaultData,physics:{...pu.defaultData,fusedBody:!1},...lx.defaultData,camera:gp.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(gu||(gu={}));var dx;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:uu.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:pu.defaultData,states:new yt,events:new yt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...du.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("RectangleGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("BooleanGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultShapeBlendObject={name:"Shape Blend",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("ShapeBlendGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("TextGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultInputObject={name:"Input",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("InputGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")}))(dx||(dx={}));var uh;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new Er}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new Er})))):Ph.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=mp(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let u=l.layers.data(h);u&&Yr.patch(u,c)}}).data),o.materials&&n.materials&&(o.materials=mp(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let c=n.materials[h];if(typeof c!="string")for(let[u,d]of Object.entries(c.layers)){let p=l[h]?.layers?.data(u);p&&Yr.patch(p,d)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(u,d){for(let[p,f]of Object.entries(d.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let y={path:[...u,"layers",p,"texture"],props:g,type:0};l.push(y)}if(Object.keys(m).length>0){let y={path:[...u,"layers",p],props:m,type:0};l.push(y)}}}for(let[u,d]of Object.entries(n))if(u!=="name")if(u==="cloner")l.push(...Qy.toOps(d,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:d.slide,offset:d.offset},type:0});else if(u==="material")c(["material"],d);else if(u==="materials")for(let[p,f]of Object.entries(d))c(["materials",p],f);else if(h[u]===0){if(u==="geometry"&&d.extrusion!==void 0){let p={path:[u,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[u],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[u]=d;return l}e.toOps=r;function s(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,mu.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Ph.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:ix.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:yl.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:yl.merge(o.cloner,n.cloner)});else if(Zy.is(a.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=cs.clone(l.color))}return o}e.patch=s})(uh||(uh={}));var Ig;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Ig||(Ig={}));var To;(e=>e.defaultData={orbitControls:Ig.defaultData,playPage:Wd,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3},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,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(To||(To={}));var px;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(px||(px={}));var fx;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(fx||(fx={}));var dh;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...px.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:fx.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(dh||(dh={}));var vp;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{if(o.type==="Instance"){let l=Lg.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(vp||(vp={}));var ph;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:ux.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function t(s=!0,a=[]){let n=[],o=dx.defaultMeshObject;s&&(n.push({...e.defaultLight}),n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:o,children:[]})),n.push(...a);let l=new ds;return l.push({fi:1,id:Wd,data:{...gu.defaultData,name:"Scene 1"},children:n}),l}e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:To.defaultData,styles:dh.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new ds,publish:To.defaultData,styles:dh.defaultData()}},e.emptyDataWithPage=function(s=!0){return{objects:t(s),publish:To.defaultData,styles:dh.defaultData()}},e.emptyData=function(){return{objects:new ds,publish:{...To.defaultData},styles:dh.defaultData()}};function i(s){return{...e.defaultData,objects:Ia(s,ds.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(ph||(ph={}));var qd;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(qd||(qd={}));var mx;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new yt}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(mx||(mx={}));var xM;(e=>e.defaultData=(t,i="GET")=>({url:t,method:i,name:"New API",headers:new yt,queries:new yt,autoStart:!0}))(xM||(xM={}));var ps;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(ps||(ps={}));var gx;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(gx||(gx={}));var bM;(e=>e.all=[...gx.all,"components"])(bM||(bM={}));var wM;(e=>{function t(){return{images:new Et,videos:new Et,colors:new Et,audios:new Et,particles:new Et,fonts:new Et,materials:new Et,components:new Et,variables:new Et,userAPIs:new Et,userWebhooks:new Et}}e.defaultData=t})(wM||(wM={}));var Bo;(e=>{function t(){return{images:new Et,videos:new Et,colors:new Et,audios:new Et,particles:new Et,fonts:new Et,materials:new Et,components:new Et,variables:new Et,userAPIs:new Et,userWebhooks:new Et}}e.defaultData=t})(Bo||(Bo={}));var Sa;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ia(n,Et.prototype)}e.defaultColors=t;function i(){return Ia({},Et.prototype)}e.defaultImages=i;function r(){return{catelogs:new Et,materials:new Et,images:new Et,videos:new Et,colors:new Et,audios:new Et,particles:new Et,fonts:new Et,variables:new yt,userAPIs:new Et,userWebhooks:new Et,lib:Bo.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(Sa||(Sa={}));var Og;(e=>e.list=["idle","move","jump","run"])(Og||(Og={}));var Rg;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,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"],["run","\u21E7"],["none","Ctrl"]],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 yt,move:new yt,jump:new yt,run:new yt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Di.fromHexAndA(3728051,1)}}))(Rg||(Rg={}));function _M(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...Bn(pr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...pr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function dl(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function pl(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=Jr.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Jr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Jr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Er.prototype&&t(s.material)})})}function KX(e){Object.assign(e.scene.publish,{orbitControls:{...Ig.defaultData,...pr(e.scene.publish.orbitControls)}})}function JX(e){Object.assign(e.scene.publish.settings,{video:{...To.defaultData.settings.video,...pr(e.scene.publish.settings.video)}})}function $X(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if(($P.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(ZX.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function eY(e){e.scene.publish.withBackground=!0}function tY(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function iY(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function rY(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function sY(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=pr(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=pr(i).booleanExclude!==!0)}})}function aY(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function nY(e){function t(r){Object.setPrototypeOf(r,Er.prototype),r.texture&&Object.setPrototypeOf(r.texture,Er.prototype)}function i(r){Object.setPrototypeOf(r,Er.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(a=>{let n=a;if(n.material){let o=pr(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=pr(l).layers;i(h),l.layers=h}})})}function SM(e){e.layers===void 0&&Object.assign(e,Jr.defaultTwoLayerData("lambert"))}function Z0(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...pr(t),colors:i,steps:r};Object.assign(t,s)}})}function oY(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function AM(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Z0(r)}):"material"in i&&typeof i.material!="string"&&Z0(i.material)}),Object.values(e.shared.materials).forEach(t=>Z0(t))}function lY(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function hY(e){e.shared.audios=Ia({},Et.prototype)}function cY(e){e.shared.videos=Ia({},Et.prototype)}function uY(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function dY(e){Object.entries(pr(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(pr(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function pY(e){e.scene.publish.settings.web.preload=!1}function MM(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function EM(e){e.layers&&e.layers.forEach(t=>{QX(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 fY(e){e.shared.fonts=Ia({},Et.prototype)}function mY(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function gY(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=Jr.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=mY(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Ur.defaultData,...ul.defaultData,flatShading:!1,wireframe:!1,geometry:{...cl.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:a,states:pr(s.states),events:pr(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=pr(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function vY(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new yt,move:new yt,jump:new yt}});else{let a=new yt;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:lt.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Bn(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let u={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},d={state:n.state,...u,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new yt({fi:0,id:lt.generateUUID(),data:h},{fi:1,id:lt.generateUUID(),data:d})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function yY(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new yt,o=[];if(i.events.forEach((l,h,c)=>{if(l.type==="Audio"&&l.trigger===a){let u;o.push(h),l.interaction==="play"?u={...Bn(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")&&(u={...Bn(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&n.push({fi:c,id:h,data:u})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:lt.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function CM(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Yr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function TM(e){dl(e,CM),pl(e,CM)}function xY(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function bY(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function wY(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=Jr.defaultTwoLayerData("phong"))})}function _Y(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function SY(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function AY(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function MY(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function EY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function CY(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function TY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Rg.defaultDataThirdPerson.navmesh)})})}function PY(e){e.scene.styles||(e.scene.styles=dh.defaultData())}function PM(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function DY(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),pl(e,PM),dl(e,PM)}function IY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new yt})})})}function OY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function DM(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function RY(e,t){if(t<1&&(pl(e,_M),dl(e,_M),e.schema=1),t<2&&(KX(e),e.schema=2),t<3&&($X(e),e.schema=3),t<4&&(eY(e),e.schema=4),t<5&&(tY(e),e.schema=5),t<6&&(iY(e),e.schema=6),t<7&&(rY(e),e.schema=7),t<8&&(e.schema=8),t<9&&(AM(e),e.schema=9),t<10&&(oY(e),e.schema=10),t<11&&(lY(e),e.schema=11),t<12&&(AM(e),e.schema=12),t<13&&(hY(e),e.schema=13),t<14&&(uY(e),e.schema=14),t<15&&(dY(e),e.schema=15),t<16&&(pY(e),e.schema=16),t<17&&(pl(e,MM),dl(e,MM),e.schema=17),t<18&&(pl(e,SM),dl(e,SM),e.schema=18),t<19&&(JX(e),e.schema=19),t<20&&(fY(e),gY(e),e.schema=20),t<21&&(vY(e),yY(e),e.schema=21),t<22&&(TM(e),e.schema=22),t<23&&(xY(e),e.schema=23),t<24&&(bY(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(cY(e),t<25&&(e.schema=25)),t<26&&(sY(e),e.schema=26),t<27&&(aY(e),e.schema=27),t<28&&(TM(e),e.schema=28),t<29&&(nY(e),e.schema=29),t<30&&(wY(e),e.schema=30),t<31&&(_Y(e),e.schema=31),t<33&&(SY(e),e.schema=33),t<34&&(AY(e),e.schema=34),t<35&&(MY(e),e.schema=35),t<36&&(EY(e),e.schema=36),t<37&&(CY(e),e.schema=37),t<38&&(pl(e,EM),dl(e,EM),e.schema=38),t<39&&(TY(e),e.schema=39),t<40&&(PY(e),e.schema=40),t<41&&(DY(e),e.schema=41),t<42&&(IY(e),e.schema=42),t<43&&(OY(e),e.schema=43),t<99){pl(e,DM),dl(e,DM),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Ru);let i=pr(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Wd,r.insertBefore(null,null,[{id:Wd,data:{...gu.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Bn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Bn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...fu.defaultData,...Bn(e.scene.environment,"usePhysics","gravity")},camera:pr(e.scene.ownerCamera)??gu.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==ph.TRASH_CAN_ID&&r.move(Wd,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,pu.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function IM(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function LY(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function BY(e){Array.isArray(pr(e.events))&&e.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Lc=180/Math.PI;function OM(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Lc)}function rD(e){OM(e),e.type==="Page"&&OM(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Lc))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Lc),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Lc),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Lc,t.extrusion.twist*=Lc),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(pr(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function zY(e){e.shared.variables=Ia({},Et.prototype)}function FY(e){let t=pr(e.shared.variables);e.shared.variables=Ia(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),yt.prototype)}var vo=117;function sD(e,t){t(e.data);for(let i of e.children)sD(i,t)}function kY(e){let t=e.schema??104;t!==vo&&t<105&&(sD(e.asset,rD),e.schema=105)}function UY(e){e.shared.particles=Ia({},Et.prototype),e.shared.lib&&(e.shared.lib.particles=Bo.defaultData().particles)}function NY(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function VY(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function jY(e){e.scene.objects.traverse((t,i)=>{Array.isArray(pr(i.events))!==!1&&i.events?.forEach(r=>{let s=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(a=>{a.type==="Transition"&&(a.runMode=s??"Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode=s==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),n.type==="Animation"&&(n.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(a=>{a.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Once"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}),r.outActions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}))})})}function HY(e){e.shared.userAPIs=Ia({},Et.prototype),e.shared.userWebhooks=Ia({},Et.prototype),e.shared.lib&&(e.shared.lib.userAPIs=Bo.defaultData().userAPIs,e.shared.lib.userWebhooks=Bo.defaultData().userWebhooks)}function GY(e){e.scene.publish.settings.videoStatic===void 0&&(e.scene.publish.settings.videoStatic=To.defaultData.settings.videoStatic)}function aD(e){let t=e.schema??0;if(t!==vo){console.warn("updating from ",t,"to ",vo),RY(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=To.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(pl(e,IM),dl(e,IM),e.schema=101),t<102&&(LY(e),e.schema=102),t<104&&(e.shared.catelogs=new Et,e.shared.lib=Bo.defaultData(),e.schema=104),t<105&&(zY(e),e.scene.objects.traverse((i,r)=>{rD(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))kY(i);t<106&&(FY(e),e.schema=106),t<107&&(e.shared.lib.variables=Bo.defaultData().variables,e.schema=107),t<109&&(UY(e),e.schema=109),t<110&&(NY(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{BY(r)}),e.schema=111),t<112&&(VY(e),e.schema=112),t<113&&(jY(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(HY(e),e.schema=115),t<116&&(GY(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117)}}var Lg;(e=>{e.defaultData={schema:vo,scene:ph.defaultData,frames:new Et().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qd.defaultData),shared:{...Sa.emptyData(),colors:Sa.defaultColors()}},e.emptyDataForImports=function(){let a=ph.emptyDataWithPage();return{schema:vo,scene:a,frames:new Et().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qd.defaultData),shared:{...Sa.emptyData(),colors:Sa.defaultColors(),images:Sa.defaultImages()}}},e.emptyData=function(){return{schema:vo,scene:ph.emptyDataWithPage(),frames:new Et().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qd.defaultData),shared:Sa.emptyData()}},e.clipboard2dData=function(){return{schema:vo,scene:ph.emptyData(),frames:new Et,shared:Sa.emptyData()}},e.collabHelper={...Ry,updateSchema(a){return(a.schema??0)<vo?mp(a,aD):(a.schema??0)-vo}};function t(a){let n=e.collabHelper.updateSchema(a);return typeof n=="number"?n===0?a:null:n.data}e.updateSchemaDirectly=t;function i(a){return{...a,shared:{...a.shared,lib:Bo.defaultData()}}}e.withoutLib=i;function r(a,n){let o=a.scene.objects.get(n);if(o&&o.data.type==="Component")return o;{let l=a.shared.lib.components[n];if(l)return l.asset}}e.getComponentData=r;function s(a){let n=Object.values(a.shared.userAPIs);for(let o of n){let l=o.headers;for(let h of l)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}e.hasSensitiveData=s})(Lg||(Lg={}));var vx;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(vx||(vx={}));var RM;(e=>{function t(i){return!0}e.is=t})(RM||(RM={}));var Bg;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}}e.merge=t;function i(r,s){return vP({position:Co.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:Co.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&Co.isEqual(r.shear,s.shear)?void 0:s.shear})}e.diff=i})(Bg||(Bg={}));var yx;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(yx||(yx={}));var LM;(e=>e.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(LM||(LM={}));var zg;(e=>e.defaultData={opacity:1,fill:{color:Di.fromHexAndA(sa,1),enabled:!0},stroke:{color:Di.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Di.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Di.from0to1([0,0,0,1]),enabled:!1,spread:0}})(zg||(zg={}));var fh;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function s(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,Bg.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=s;function a(n,o){let l,h=[];for(let[c,u]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=u);return h}e.toOps=a})(fh||(fh={}));var yp;(e=>e.defaultData={...Bg.defaultData,...yx.defaultData,states:new yt,events:new yt,visible:!0,raycastLock:!1})(yp||(yp={}));var vu;(e=>e.defaultData={...yp.defaultData,...zg.defaultData})(vu||(vu={}));var Fg;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Fg||(Fg={}));var xx;(e=>e.defaultData={...vu.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(xx||(xx={}));var xp;(e=>e.defaultData={...vu.defaultData,...Fg.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(xp||(xp={}));var bx;(e=>e.defaultData={...vu.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(bx||(bx={}));var wx;(e=>e.defaultData={...vu.defaultData,type:"path2d",path:"",name:"Path"})(wx||(wx={}));var BM;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(BM||(BM={}));var kg;(e=>e.defaultData={...yp.defaultData,name:"Group",type:"group2d"})(kg||(kg={}));var _x;(e=>e.defaultData=()=>({...yp.defaultData,...Fg.defaultData,...zg.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Di.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Di.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(_x||(_x={}));var Sh;(e=>{function t(n){switch(n){case"rectangle2d":return{...xp.defaultData};case"ellipse2d":return{...xx.defaultData};case"text2d":return{...bx.defaultData};case"vector2d":return{...xp.defaultData};case"path2d":return{...wx.defaultData};case"frame2d":return{..._x.defaultData()};case"group2d":return{...kg.defaultData}}}e.defaultData=t;function i(n){return"width"in n&&"height"in n?[typeof n.width=="number"?n.width*.5:0,typeof n.height=="number"?n.height*.5:0]:[0,0]}e.getPivot=i;function r(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"}e.isResizeable=r;function s(n){return n.type==="frame2d"&&n.autoLayout!==void 0}e.isAutoLayoutable=s;function a(n){return n.type==="rectangle2d"||n.type==="frame2d"}e.hasCorners=a})(Sh||(Sh={}));var Sx;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ds},e.emptyData=function(){return{type:"scene2d",objects:new ds}}))(Sx||(Sx={}));function mh(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),a={},n={},o=e[0].morphTargetsRelative,l=new gt,h=0;for(let c=0;c<e.length;++c){let u=e[c],d=0;if(i!==(u.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 p in u.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(u.attributes[p]),d++}if(d!==r.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(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in u.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(u.morphAttributes[p])}if(t){let p;if(i)p=u.index.count;else if(u.attributes.position!==void 0)p=u.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(h,p,c),h+=p}}if(i){let c=0,u=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+c);c+=e[d].attributes.position.count}l.setIndex(u)}for(let c in a){let u=zM(a[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(let c in n){let u=n[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<u;++d){let p=[];for(let g=0;g<n[c].length;++g)p.push(n[c][g][d]);let f=zM(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function zM(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new Tt(a,i,r)}var WY=Math.pow(2,-24),Wf=class{constructor(){}};function In(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function FM(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function kM(e,t){t.set(e)}function UM(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function qf(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function dd(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function qY(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Tt(s,1));for(let a=0;a<i;a++)s[a]=a}}function XY(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function K0(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,y=s!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],M=e[x+1],S=_-M,E=_+M;S<a&&(a=S),E>l&&(l=E),y&&_<u&&(u=_),y&&_>f&&(f=_);let A=e[x+2],T=e[x+3],P=A-T,R=A+T;P<n&&(n=P),R>h&&(h=R),y&&A<d&&(d=A),y&&A>g&&(g=A);let z=e[x+4],U=e[x+5],L=z-U,H=z+U;L<o&&(o=L),H>c&&(c=H),y&&z<p&&(p=z),y&&z>m&&(m=z)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,y&&(s[0]=u,s[1]=d,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function YY(e,t,i,r){let s=1/0,a=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,u=(t+i)*6;c<u;c+=6){let d=e[c+0];d<s&&(s=d),d>o&&(o=d);let p=e[c+2];p<a&&(a=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function QY(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let c=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=c;let u=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=u;let d=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=d}a++,n--}else return a}}var uo=32,ZY=(e,t)=>e.candidate-t.candidate,Jo=new Array(uo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Xf=new Float32Array(6);function KY(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=FM(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=FM(e),n!==-1&&(o=JY(i,r,s,n));else if(a===2){let l=dd(e),h=1.25*s,c=r*6,u=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/uo;if(s<uo/4){let g=[...Jo];g.length=s;let m=0;for(let x=c;x<u;x+=6,m++){let b=g[m];b.candidate=i[x+2*d],b.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:S}=b;for(let E=0;E<3;E++)S[E]=1/0,S[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;qf(x,i,_)}g.sort(ZY);let y=s;for(let x=0;x<y;x++){let b=g[x];for(;x+1<y&&g[x+1].candidate===b.candidate;)g.splice(x+1,1),y--}for(let x=c;x<u;x+=6){let b=i[x+2*d];for(let _=0;_<y;_++){let M=g[_];b>=M.candidate?qf(x,i,M.rightCacheBounds):(qf(x,i,M.leftCacheBounds),M.count++)}}for(let x=0;x<y;x++){let b=g[x],_=b.count,M=s-b.count,S=b.leftCacheBounds,E=b.rightCacheBounds,A=0;_!==0&&(A=dd(S)/l);let T=0;M!==0&&(T=dd(E)/l);let P=1+1.25*(A*_+T*M);P<h&&(n=d,h=P,o=b.candidate)}}else{for(let y=0;y<uo;y++){let x=Jo[y];x.count=0,x.candidate=p+f+y*f;let b=x.bounds;for(let _=0;_<3;_++)b[_]=1/0,b[_+3]=-1/0}for(let y=c;y<u;y+=6){let x=~~((i[y+2*d]-p)/f);x>=uo&&(x=uo-1);let b=Jo[x];b.count++,qf(y,i,b.bounds)}let g=Jo[uo-1];kM(g.bounds,g.rightCacheBounds);for(let y=uo-2;y>=0;y--){let x=Jo[y],b=Jo[y+1];UM(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let m=0;for(let y=0;y<uo-1;y++){let x=Jo[y],b=x.count,_=x.bounds,M=Jo[y+1].rightCacheBounds;b!==0&&(m===0?kM(_,Xf):UM(_,Xf,Xf)),m+=b;let S=0,E=0;m!==0&&(S=dd(Xf)/l);let A=s-m;A!==0&&(E=dd(M)/l);let T=1+1.25*(S*m+E*A);T<h&&(n=d,h=T,o=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function JY(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function $Y(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let u=0;u<s;u++){let d=u*3,p=u*6,f,g,m;n?(f=r[d+0],g=r[d+1],m=r[d+2]):(f=r[d+0]*h+l,g=r[d+1]*h+l,m=r[d+2]*h+l);for(let y=0;y<3;y++){let x,b,_;n?(x=i[c[y]](f),b=i[c[y]](g),_=i[c[y]](m)):(x=o[f+y],b=o[g+y],_=o[m+y]);let M=x;b<M&&(M=b),_<M&&(M=_);let S=x;b>S&&(S=b),_>S&&(S=_);let E=(S-M)/2,A=y*2;a[p+A+0]=M+E,a[p+A+1]=E+(Math.abs(M)+E)*WY,M<t[y]&&(t[y]=M),S>t[y+3]&&(t[y+3]=S)}}return a}function eQ(e,t){function i(y){d&&d(y/p)}function r(y,x,b,_=null,M=0){if(!f&&M>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=c||M>=l)return i(x+b),y.offset=x,y.count=b,y;let S=KY(y.boundingData,_,n,x,b,u);if(S.axis===-1)return i(x+b),y.offset=x,y.count=b,y;let E=QY(o,n,x,b,S);if(E===x||E===x+b)i(x+b),y.offset=x,y.count=b;else{y.splitAxis=S.axis;let A=new Wf,T=x,P=E-x;y.left=A,A.boundingData=new Float32Array(6),K0(n,T,P,A.boundingData,a),r(A,T,P,a,M+1);let R=new Wf,z=E,U=b-P;y.right=R,R.boundingData=new Float32Array(6),K0(n,z,U,R.boundingData,a),r(R,z,U,a,M+1)}return y}qY(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=$Y(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,g=[],m=XY(e);if(m.length===1){let y=m[0],x=new Wf;x.boundingData=s,YY(n,y.offset,y.count,a),r(x,y.offset,y.count,a),g.push(x)}else for(let y of m){let x=new Wf;x.boundingData=new Float32Array(6),K0(n,y.offset,y.count,x.boundingData,a),r(x,y.offset,y.count,a),g.push(x)}return g}function tQ(e,t){let i=eQ(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let u=i[c],d=l(u),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,u),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,u){let d=c/4,p=c/2,f=!!u.count,g=u.boundingData;for(let m=0;m<6;m++)r[d+m]=g[m];if(f){let m=u.offset,y=u.count;return s[d+6]=m,a[p+14]=y,a[p+15]=65535,c+32}else{let m=u.left,y=u.right,x=u.splitAxis,b;if(b=h(c+32,m),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=b/4,b=h(b,y),s[d+7]=x,b}}}var Nn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};Nn.prototype.setFromBox=function(){let e=new I;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let c=t.dot(e);a=Math.min(c,a),n=Math.max(c,n)}this.min=a,this.max=n}}();var $oe=function(){let e=new Nn;return function(t,i){let r=t.points,s=t.satAxes,a=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let c=a[h],u=s[h];if(e.setFromPoints(u,n),c.isSeparated(e))return!1}for(let h=0;h<3;h++){let c=l[h],u=o[h];if(e.setFromPoints(u,r),c.isSeparated(e))return!1}}}(),iQ=function(){let e=new I,t=new I,i=new I;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let c=i.dot(h),u=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-u*u,g,m;f!==0?g=(c*u-p*d)/f:g=0,m=(c+g*u)/d,a.x=g,a.y=m}}(),ow=function(){let e=new re,t=new I,i=new I;return function(r,s,a,n){iQ(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=s.start:c=s.end;let u=t,d=i;if(r.closestPointToPoint(c,!0,t),s.closestPointToPoint(h,!0,i),u.distanceToSquared(c)<=d.distanceToSquared(h)){a.copy(u),n.copy(c);return}else{a.copy(h),n.copy(d);return}}}}(),rQ=function(){let e=new I,t=new I,i=new Gs,r=new Ta;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let u=a.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=n){let d=u.projectPoint(o,t);if(a.containsPoint(d))return!0}return!1}}(),sQ=1e-15;function mc(e){return Math.abs(e)<sQ}var zo=class extends us{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new Nn),this.points=[this.a,this.b,this.c],this.sphere=new Ks,this.plane=new Gs,this.needsUpdate=!0}intersectsSphere(e){return rQ(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=s[2],u=a[2];c.subVectors(t,i),u.setFromPoints(c,r);let d=s[3],p=a[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};zo.prototype.closestPointToSegment=function(){let e=new I,t=new I,i=new Ta;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let u=0;u<3;u++){let d=(u+1)%3;i.start.copy(l[u]),i.end.copy(l[d]),ow(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(c)}}();zo.prototype.intersectsTriangle=function(){let e=new zo,t=new Array(3),i=new Array(3),r=new Nn,s=new Nn,a=new I,n=new I,o=new I,l=new I,h=new Ta,c=new Ta,u=new Ta;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let g=this.plane,m=d.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let y=this.satBounds,x=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let M=0;M<4;M++){let S=y[M],E=x[M];if(r.setFromPoints(E,i),S.isSeparated(r))return!1}let b=d.satBounds,_=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let M=0;M<4;M++){let S=b[M],E=_[M];if(r.setFromPoints(E,t),S.isSeparated(r))return!1}for(let M=0;M<4;M++){let S=x[M];for(let E=0;E<4;E++){let A=_[E];if(a.crossVectors(S,A),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let y=this.points,x=!1,b=0;for(let U=0;U<3;U++){let L=y[U],H=y[(U+1)%3];h.start.copy(L),h.end.copy(H),h.delta(n);let q=x?c.start:c.end,Z=mc(m.distanceToPoint(L));if(mc(m.normal.dot(n))&&Z){c.copy(h),b=2;break}if((m.intersectLine(h,q)||Z)&&!mc(q.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let _=d.points,M=!1,S=0;for(let U=0;U<3;U++){let L=_[U],H=_[(U+1)%3];h.start.copy(L),h.end.copy(H),h.delta(o);let q=M?u.start:u.end,Z=mc(g.distanceToPoint(L));if(mc(g.normal.dot(o))&&Z){u.copy(h),S=2;break}if((g.intersectLine(h,q)||Z)&&!mc(q.distanceTo(H))){if(S++,M)break;M=!0}}if(S===1&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(S!==2)return!1;if(c.delta(n),u.delta(o),n.dot(o)<0){let U=u.start;u.start=u.end,u.end=U}let E=c.start.dot(n),A=c.end.dot(n),T=u.start.dot(n),P=u.end.dot(n),R=A<T,z=E<P;return E!==P&&T!==A&&R===z?!1:(p&&(l.subVectors(c.start,u.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}();zo.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();zo.prototype.distanceToTriangle=function(){let e=new I,t=new I,i=["a","b","c"],r=new Ta,s=new Ta;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let u,d=i[c],p=a[d];this.closestPointToPoint(p,e),u=p.distanceToSquared(e),u<h&&(h=u,n&&n.copy(e),o&&o.copy(p));let f=this[d];a.closestPointToPoint(f,e),u=f.distanceToSquared(e),u<h&&(h=u,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let u=i[c],d=i[(c+1)%3];r.set(this[u],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(a[f],a[g]),ow(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Vn=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new je,this.invMatrix=new je,this.points=new Array(8).fill().map(()=>new I),this.satAxes=new Array(3).fill().map(()=>new I),this.satBounds=new Array(3).fill().map(()=>new Nn),this.alignedSatBounds=new Array(3).fill().map(()=>new Nn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Vn.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let u=1*l|2*h|4*c,d=r[u];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=c?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],c=s[l],u=1<<l,d=r[u];h.subVectors(n,d),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Vn.prototype.intersectsBox=function(){let e=new Nn;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Vn.prototype.intersectsTriangle=function(){let e=new zo,t=new Array(3),i=new Nn,r=new Nn,s=new I;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let u=0;u<3;u++){let d=n[u],p=o[u];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,c=this.points;for(let u=0;u<3;u++){let d=l[u],p=h[u];if(i.setFromPoints(p,c),d.isSeparated(i))return!1}for(let u=0;u<3;u++){let d=o[u];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,c),i.isSeparated(r))return!1}}return!0}}();Vn.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Vn.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Vn.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Ta),i=new Array(12).fill().map(()=>new Ta),r=new I,s=new I;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,c=a.min,u=a.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];s.copy(m).clamp(c,u);let y=m.distanceToSquared(s);if(y<p&&(p=y,o&&o.copy(m),l&&l.copy(s),y<h))return Math.sqrt(y)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){let x=(g+1)%3,b=(g+2)%3,_=m<<x|y<<b,M=1<<g|m<<x|y<<b,S=d[_],E=d[M];t[f].set(S,E);let A=e[g],T=e[x],P=e[b],R=i[f],z=R.start,U=R.end;z[A]=c[A],z[T]=m?c[T]:u[T],z[P]=y?c[P]:u[T],U[A]=u[A],U[T]=m?c[T]:u[T],U[P]=y?c[P]:u[T],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){s.x=g?u.x:c.x,s.y=m?u.y:c.y,s.z=y?u.z:c.z,this.closestPointToPoint(s,r);let x=s.distanceToSquared(r);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}for(let g=0;g<12;g++){let m=t[g];for(let y=0;y<12;y++){let x=i[y];ow(m,x,r,s);let b=r.distanceToSquared(s);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(s),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var gc=new I,vc=new I,yc=new I,Yf=new re,Qf=new re,Zf=new re,NM=new I,VM=new I,jM=new I,Kf=new I;function aQ(e,t,i,r,s,a){let n;return a===$r?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==_s,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function nQ(e,t,i,r,s,a,n,o,l){gc.fromBufferAttribute(t,a),vc.fromBufferAttribute(t,n),yc.fromBufferAttribute(t,o);let h=aQ(e,gc,vc,yc,Kf,l);if(h){r&&(Yf.fromBufferAttribute(r,a),Qf.fromBufferAttribute(r,n),Zf.fromBufferAttribute(r,o),h.uv=us.getInterpolation(Kf,gc,vc,yc,Yf,Qf,Zf,new re)),s&&(Yf.fromBufferAttribute(s,a),Qf.fromBufferAttribute(s,n),Zf.fromBufferAttribute(s,o),h.uv1=us.getInterpolation(Kf,gc,vc,yc,Yf,Qf,Zf,new re)),i&&(NM.fromBufferAttribute(i,a),VM.fromBufferAttribute(i,n),jM.fromBufferAttribute(i,o),h.normal=us.getInterpolation(Kf,gc,vc,yc,NM,VM,jM,new I),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a,b:n,c:o,normal:new I,materialIndex:0};us.getNormal(gc,vc,yc,c.normal),h.face=c,h.faceIndex=a}return h}function nD(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:c,uv:u,uv1:d}=e.attributes,p=nQ(i,h,c,u,d,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function oQ(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)nD(e,t,i,n,a)}function lQ(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=nD(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function Tn(e,t,i,r){let s=e.a,a=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function HM(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(Tn(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var oD=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function fl(e,t){return t[e+15]===65535}function Zc(e,t){return t[e+6]}function bp(e,t){return t[e+14]}function wp(e){return e+8}function _p(e,t){return t[e+6]}function hQ(e,t){return t[e+7]}var Gc=new mr,Ug=new I,cQ=["x","y","z"];function Ax(e,t,i,r,s){let a=e*2,n=Lu,o=Cl,l=Tl;if(fl(a,o)){let h=Zc(e,l),c=bp(a,o);oQ(t,i,r,h,c,s)}else{let h=wp(e);Ng(h,n,r,Ug)&&Ax(h,t,i,r,s);let c=_p(e,l);Ng(c,n,r,Ug)&&Ax(c,t,i,r,s)}}function Mx(e,t,i,r){let s=e*2,a=Lu,n=Cl,o=Tl;if(fl(s,n)){let l=Zc(e,o),h=bp(s,n);return lQ(t,i,r,l,h)}else{let l=hQ(e,o),h=cQ[l],c=r.direction[h]>=0,u,d;c?(u=wp(e),d=_p(e,o)):(u=_p(e,o),d=wp(e));let p=Ng(u,a,r,Ug)?Mx(u,t,i,r):null;if(p){let g=p.point[h];if(c?g<=a[d+l]:g>=a[d+l+3])return p}let f=Ng(d,a,r,Ug)?Mx(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var uQ=function(){let e,t,i=[],r=new oD(()=>new mr);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function s(a,n,o,l,h=null,c=0,u=0){function d(x){let b=x*2,_=Cl,M=Tl;for(;!fl(b,_);)x=wp(x),b=x*2;return Zc(x,M)}function p(x){let b=x*2,_=Cl,M=Tl;for(;!fl(b,_);)x=_p(x,M),b=x*2;return Zc(x,M)+bp(b,_)}let f=a*2,g=Lu,m=Cl,y=Tl;if(fl(f,m)){let x=Zc(a,y),b=bp(f,m);return In(a,g,e),l(x,b,!1,u,c+a,e)}else{let x=wp(a),b=_p(a,y),_=x,M=b,S,E,A,T;if(h&&(A=e,T=t,In(_,g,A),In(M,g,T),S=h(A),E=h(T),E<S)){_=b,M=x;let q=S;S=E,E=q,A=T}A||(A=e,In(_,g,A));let P=fl(_*2,m),R=o(A,P,S,u+1,c+_),z;if(R===2){let q=d(_),Z=p(_)-q;z=l(q,Z,!0,u+1,c+_,A)}else z=R&&s(_,n,o,l,h,c,u+1);if(z)return!0;T=t,In(M,g,T);let U=fl(M*2,m),L=o(T,U,E,u+1,c+M),H;if(L===2){let q=d(M),Z=p(M)-q;H=l(q,Z,!0,u+1,c+M,T)}else H=L&&s(M,n,o,l,h,c,u+1);return!!H}}}(),dQ=function(){let e=new zo,t=new zo,i=new je,r=new Vn,s=new Vn;return function a(n,o,l,h,c=null){let u=n*2,d=Lu,p=Cl,f=Tl;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),fl(u,p)){let g=o,m=g.index,y=g.attributes.position,x=l.index,b=l.attributes.position,_=Zc(n,f),M=bp(u,p);if(i.copy(h).invert(),l.boundsTree)return In(n,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>s.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(h),S.b.applyMatrix4(h),S.c.applyMatrix4(h),S.needsUpdate=!0;for(let E=_*3,A=(M+_)*3;E<A;E+=3)if(Tn(t,E,m,y),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let S=_*3,E=M+_*3;S<E;S+=3){Tn(e,S,m,y),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let A=0,T=x.count;A<T;A+=3)if(Tn(t,A,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=n+8,m=f[n+6];return In(g,d,Gc),!!(c.intersectsBox(Gc)&&a(g,o,l,h,c)||(In(m,d,Gc),c.intersectsBox(Gc)&&a(m,o,l,h,c)))}}}();function Ng(e,t,i,r){return In(e,t,Gc),i.intersectBox(Gc,r)}var Ex=[],Vm,Lu,Cl,Tl;function Rd(e){Vm&&Ex.push(Vm),Vm=e,Lu=new Float32Array(e),Cl=new Uint16Array(e),Tl=new Uint32Array(e)}function Jf(){Vm=null,Lu=null,Cl=null,Tl=null,Ex.length&&Rd(Ex.pop())}var J0=Symbol("skip tree generation"),$0=new mr,e1=new mr,xc=new je,Ql=new Vn,pd=new Vn,fd=new I,$f=new I,pQ=new I,fQ=new I,mQ=new I,GM=new mr,fn=new oD(()=>new zo),Xd=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Xd.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Xd.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new Xd(t,{...i,[J0]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new Tt(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[J0]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[J0]||(this._roots=tQ(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new mr))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s,a,n,o,l=0,h=this._roots;for(let u=0,d=h.length;u<d;u++)s=h[u],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),c(0,l),l+=s.byteLength;function c(u,d,p=!1){let f=u*2;if(n[f+15]===65535){let g=a[u+6],m=n[f+14],y=1/0,x=1/0,b=1/0,_=-1/0,M=-1/0,S=-1/0;for(let E=3*g,A=3*(g+m);E<A;E++){let T=i[E],P=r.getX(T),R=r.getY(T),z=r.getZ(T);P<y&&(y=P),P>_&&(_=P),R<x&&(x=R),R>M&&(M=R),z<b&&(b=z),z>S&&(S=z)}return o[u+0]!==y||o[u+1]!==x||o[u+2]!==b||o[u+3]!==_||o[u+4]!==M||o[u+5]!==S?(o[u+0]=y,o[u+1]=x,o[u+2]=b,o[u+3]=_,o[u+4]=M,o[u+5]=S,!0):!1}else{let g=u+8,m=a[u+6],y=g+d,x=m+d,b=p,_=!1,M=!1;e?b||(_=e.has(y),M=e.has(x),b=!_&&!M):(_=!0,M=!0);let S=b||_,E=b||M,A=!1;S&&(A=c(g,d,b));let T=!1;E&&(T=c(m,d,b));let P=A||T;if(P)for(let R=0;R<3;R++){let z=g+R,U=m+R,L=o[z],H=o[z+3],q=o[U],Z=o[U+3];o[u+R]=L<q?L:q,o[u+R+3]=H>Z?H:Z}return P}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let c=r[n+6],u=s[l+14];e(o,h,new Float32Array(i,n*4,6),c,u)}else{let c=n+8,u=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(a(c,o+1),a(u,o+1))}}}raycast(e,t=en){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=n?t[o[h].materialIndex].side:l,d=s.length;if(Rd(i[h]),Ax(0,r,u,e,s),Jf(),n){let p=o[h].materialIndex;for(let f=d,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=en){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=a?t[o[h].materialIndex].side:l;Rd(i[h]);let d=Mx(0,r,u,e);Jf(),d!=null&&(n==null||d.distance<n.distance)&&(n=d,a&&(d.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Rd(s),r=dQ(0,i,e,t),Jf(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let u=t;t=(d,p,f,g)=>{let m=p*3;return u(d,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=fn.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let u=o;o=(d,p,f,g,m)=>u(d,p,f,g,m)?!0:HM(d,p,r,l,f,g,s)}else o||(l?o=(u,d,p,f)=>HM(u,d,r,l,p,f,s):o=(u,d,p)=>p);let h=!1,c=0;for(let u of this._roots){if(Rd(u),h=uQ(0,r,n,o,a,c),Jf(),h)break;c+=u.byteLength}return fn.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;xc.copy(t).invert();let h=fn.getPrimitive(),c=fn.getPrimitive();if(s){let d=function(p,f,g,m,y,x,b,_){for(let M=g,S=g+m;M<S;M++){Tn(c,M*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let E=p,A=p+f;E<A;E++)if(Tn(h,E*3,a,n),h.needsUpdate=!0,s(h,c,E,M,y,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,g,m,y,x,b,_,M){return p(f,g,m,y,x,b,_,M)?!0:d(f,g,m,y,x,b,_,M)}}else r=d}e.getBoundingBox(e1),e1.applyMatrix4(t);let u=this.shapecast({intersectsBounds:d=>e1.intersectsBox(d),intersectsRange:(d,p,f,g,m,y)=>($0.copy(y),$0.applyMatrix4(xc),e.shapecast({intersectsBounds:x=>$0.intersectsBox(x),intersectsRange:(x,b,_,M,S)=>r(d,p,x,b,g,m,M,S)}))});return fn.releasePrimitive(h),fn.releasePrimitive(c),u}intersectsBox(e,t){return Ql.set(e.min,e.max,t),Ql.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Ql.intersectsBox(i),intersectsTriangle:i=>Ql.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ql.set(e.boundingBox.min,e.boundingBox.max,t),Ql.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,u=fn.getPrimitive(),d=fn.getPrimitive(),p=$f,f=pQ,g=null,m=null;r&&(g=fQ,m=mQ);let y=1/0,x=null,b=null;return xc.copy(t).invert(),pd.matrix.copy(xc),this.shapecast({boundsTraverseOrder:_=>Ql.distanceToBox(_),intersectsBounds:(_,M,S)=>S<y&&S<a?(M&&(pd.min.copy(_.min),pd.max.copy(_.max),pd.needsUpdate=!0),!0):!1,intersectsRange:(_,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>pd.distanceToBox(S),intersectsBounds:(S,E,A)=>A<y&&A<a,intersectsRange:(S,E)=>{for(let A=S*3,T=(S+E)*3;A<T;A+=3){Tn(d,A,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=_*3,R=(_+M)*3;P<R;P+=3){Tn(u,P,l,o),u.needsUpdate=!0;let z=u.distanceToTriangle(d,p,g);if(z<y&&(f.copy(p),m&&m.copy(g),y=z,x=P/3,b=A/3),z<s)return!0}}}});{let S=c?c.count:h.count;for(let E=0,A=S;E<A;E+=3){Tn(d,E,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let T=_*3,P=(_+M)*3;T<P;T+=3){Tn(u,T,l,o),u.needsUpdate=!0;let R=u.distanceToTriangle(d,p,g);if(R<y&&(f.copy(p),m&&m.copy(g),y=R,x=T/3,b=E/3),R<s)return!0}}}}}),fn.releasePrimitive(u),fn.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=y,i.faceIndex=x,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(xc),f.applyMatrix4(xc),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(fd.copy(e).clamp(h.min,h.max),fd.distanceToSquared(e)),intersectsBounds:(h,c,u)=>u<n&&u<a,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,fd);let u=e.distanceToSquared(fd);return u<n&&($f.copy(fd),n=u,o=c),u<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy($f):t.point=$f.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{In(0,new Float32Array(t),GM),e.union(GM)}),e}},Cx=Ll(TB()),gQ=.5*(Math.sqrt(3)-1),md=(3-Math.sqrt(3))/6,vQ=1/3,mn=1/6,ele=(Math.sqrt(5)-1)/4,tle=(5-Math.sqrt(5))/20,Yd=e=>Math.floor(e)|0,WM=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]),t1=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 yQ(e=Math.random){let t=lD(e),i=new Float64Array(t).map(s=>WM[s%12*2]),r=new Float64Array(t).map(s=>WM[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*gQ,c=Yd(s+h),u=Yd(a+h),d=(c+u)*md,p=c-d,f=u-d,g=s-p,m=a-f,y,x;g>m?(y=1,x=0):(y=0,x=1);let b=g-y+md,_=m-x+md,M=g-1+2*md,S=m-1+2*md,E=c&255,A=u&255,T=.5-g*g-m*m;if(T>=0){let z=E+t[A],U=i[z],L=r[z];T*=T,n=T*T*(U*g+L*m)}let P=.5-b*b-_*_;if(P>=0){let z=E+y+t[A+x],U=i[z],L=r[z];P*=P,o=P*P*(U*b+L*_)}let R=.5-M*M-S*S;if(R>=0){let z=E+1+t[A+1],U=i[z],L=r[z];R*=R,l=R*R*(U*M+L*S)}return 70*(n+o+l)}}function xQ(e=Math.random){let t=lD(e),i=new Float64Array(t).map(a=>t1[a%12*3]),r=new Float64Array(t).map(a=>t1[a%12*3+1]),s=new Float64Array(t).map(a=>t1[a%12*3+2]);return function(a,n,o){let l,h,c,u,d=(a+n+o)*vQ,p=Yd(a+d),f=Yd(n+d),g=Yd(o+d),m=(p+f+g)*mn,y=p-m,x=f-m,b=g-m,_=a-y,M=n-x,S=o-b,E,A,T,P,R,z;_>=M?M>=S?(E=1,A=0,T=0,P=1,R=1,z=0):_>=S?(E=1,A=0,T=0,P=1,R=0,z=1):(E=0,A=0,T=1,P=1,R=0,z=1):M<S?(E=0,A=0,T=1,P=0,R=1,z=1):_<S?(E=0,A=1,T=0,P=0,R=1,z=1):(E=0,A=1,T=0,P=1,R=1,z=0);let U=_-E+mn,L=M-A+mn,H=S-T+mn,q=_-P+2*mn,Z=M-R+2*mn,X=S-z+2*mn,se=_-1+3*mn,le=M-1+3*mn,te=S-1+3*mn,ie=p&255,fe=f&255,ce=g&255,ue=.6-_*_-M*M-S*S;if(ue<0)l=0;else{let Ae=ie+t[fe+t[ce]];ue*=ue,l=ue*ue*(i[Ae]*_+r[Ae]*M+s[Ae]*S)}let ae=.6-U*U-L*L-H*H;if(ae<0)h=0;else{let Ae=ie+E+t[fe+A+t[ce+T]];ae*=ae,h=ae*ae*(i[Ae]*U+r[Ae]*L+s[Ae]*H)}let Pe=.6-q*q-Z*Z-X*X;if(Pe<0)c=0;else{let Ae=ie+P+t[fe+R+t[ce+z]];Pe*=Pe,c=Pe*Pe*(i[Ae]*q+r[Ae]*Z+s[Ae]*X)}let ve=.6-se*se-le*le-te*te;if(ve<0)u=0;else{let Ae=ie+1+t[fe+1+t[ce+1]];ve*=ve,u=ve*ve*(i[Ae]*se+r[Ae]*le+s[Ae]*te)}return 32*(l+h+c+u)}}function lD(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Na=new us,bQ=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Na.a.fromBufferAttribute(e,r),Na.b.fromBufferAttribute(e,r+1),Na.c.fromBufferAttribute(e,r+2),s*=Na.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Na.a.fromBufferAttribute(this.positionAttribute,e*3),Na.b.fromBufferAttribute(this.positionAttribute,e*3+1),Na.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Na.a,r).addScaledVector(Na.b,s).addScaledVector(Na.c,1-(r+s)),Na.getNormal(i),this}},wQ=Ll(I3()),_Q=new je,SQ=new je,AQ=new je,Dh;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Dh||(Dh={}));var lw=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new je,this.copyPreviousMatrix=!0,this.hiddenMatrix=new je,this.matrixWorldRigid=new je,this.shearScale=new je,this.shearScaleInv=new je}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Mi&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)Dh.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Dh.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:a}=(0,wQ.SVD)(i),n=_Q.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=SQ.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=AQ.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new je().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof je?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},MQ=class extends lw(Mi){},EQ=e=>e.type==="Mesh",fs=class extends MQ{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new fs(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return EQ(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}},ah=new I,nh=new I,Kc=new je,hD=[new I(-1,1,1),new I(-1,-1,1),new I(1,-1,1),new I(1,1,1),new I(-1,1,-1),new I(-1,-1,-1),new I(1,-1,-1),new I(1,1,-1)],CQ=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],TQ=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],qM=(e,t,i)=>{e.updateEntityBoxSize(ah,nh),Kc.copy(t).multiply(e.matrixWorld),nh.x===0&&nh.y===0&&nh.z===0?i.push(new I(ah.x,ah.y,ah.z).applyMatrix4(Kc)):hD.forEach(r=>{i.push(r.clone().multiply(nh).add(ah).applyMatrix4(Kc))})},XM=class extends mr{constructor(){super(...arguments),this.matrix=new je,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new je().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new I);return}qM(s,t,r)}}):qM(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Kc.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(nh).multiplyScalar(.5),this.getCenter(ah),Kc.copy(this.matrix).setPosition(ah),this.vertices=hD.map(e=>e.clone().multiply(nh).applyMatrix4(Kc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=CQ.map(([e,t])=>new Ta(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new I))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=TQ.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},bl={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},PQ=class extends oT{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(e*l/s),c=o.getPoints(h);for(let u=0;u<c.length;u++){let d=c[u];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Tx=.001;function Px(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Tx}function i1(e,t){let i=new I(...e.position),r=new I(...e.controlNext.position),s=new I(...t.controlPrevious.position),a=new I(...t.position);return Px(i,r,a)&&Px(i,s,a)}function cD(e){let t=e.points.map(c=>new I(...c.data.position)),i=[e.points[0]],r=new I(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)Px(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let u=i[c].data,d=new I(...u.position),p=new I(...u.controlPrevious.position),f=new I(...u.controlNext.position),g={position:d,baseRoundness:u.roundness,controlPrevious:p,controlNext:f};if(u.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...g,removedLength:0};continue}let m=s&&c==0?n-1:c-1,y=s&&c==n-1?0:c+1,x=i[m].data,b=i[y].data,_=new I(...x.position),M=new I(...b.position),S=_.clone().sub(d).normalize(),E=M.clone().sub(d).normalize();Object.assign(g,{prevDir:S,nextDir:E});let A=i1(x,u),T=i1(u,b);if(!A||!T)o[c]={...g,removedLength:0};else{let P=S.clone().add(E).normalize(),R=P.clone().cross(S).length()/S.dot(P);o[c]={...g,tan:R,removedLength:u.roundness/R}}}for(let c=0;c<a;c++){let u=c,d=s&&c===n-1?0:c+1,p=o[u],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let c=0;c<a;c++){let u=c,d=s&&c===n-1?0:c+1,p=o[u],f=o[d],g=null;if(!i1(i[u].data,i[d].data))p.position.distanceTo(f.position)>Tx&&(g=new zm(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),y=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&y.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(y)>Tx&&(g=new zm(m,m.clone().lerp(y,.3),y.clone().lerp(m,.3),y))}l[2*c+1]=g}for(let c=0;c<n;c++){let u=o[c];if(u.removedLength===0){l[2*c]=null;continue}let d=u.position,p=u.prevDir.clone().multiplyScalar(u.removedLength).add(d),f=u.nextDir.clone().multiplyScalar(u.removedLength).add(d),g=u.tan*u.removedLength,m=u.prevDir.clone().add(u.nextDir).normalize(),y=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(x,2))).add(y),_=m.clone().multiplyScalar(-g).add(b),M=d.distanceTo(_)/d.distanceTo(y),S=u.prevDir.clone().multiplyScalar(M*d.distanceTo(p)).add(d),E=S.clone().lerp(_,2),A=p.clone().lerp(S,4/3),T=f.clone().lerp(E,4/3);l[2*c]=new zm(p,A,T,f)}let h=new PQ;return l.forEach(c=>{c&&h.add(c)}),h}var ni;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ni||(ni={}));var yo=e=>ni.is(e),DQ={type:"completeState",isfromEntity:!0},IQ=["x","y","z"],r1=new I,OQ=new I().set(0,1,0),hw=e=>class extends lw(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new XM,this._recursiveBBox=new XM,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(ni.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ni.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ni.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)uh.toOps(this.data,s.data).forEach(a=>{let n=xg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=uh.patch(this.data,s),uh.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{yo(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(ni.is(i[r]))return i[r];if(ni.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ni.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)yo(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{ni.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)yo(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)yo(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)yo(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>yo(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*lt.RAD2DEG,this.rotation.y*lt.RAD2DEG,this.rotation.z*lt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Oy(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,IQ[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(r1.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(lt.DEG2RAD),this.rotation.setFromVector3(r1),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??uu.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)ni.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ni.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Oy(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=Li(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let u=kr.zoom(c,t.path.slice(2));if(u)for(let d in t.props)t.props[d]===void 0&&d in u&&(h[d]=u[d])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...u}=l;l=u}if(t.props.material!==void 0&&"material"in l){let{material:c,...u}=l;l=u}let h=kr.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,uh.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Li(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let u=r.scene.findInstance([this.uuid,...l]);u&&(u.overrideData=t.props[c],u.updateState(Ml.apply(u.component.data,u.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let u=kr.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(u)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=u[p]);t={...t,props:d}}c.overrideData=Dg.resolve(i.overrides,l),c.updateByOp(t,Kr.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of xl.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of xl.rootOverrideProps)if(Li(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=Ml.filterOp(h.overrideData,l);c&&h.updateByOp(c,Kr.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=Ml.filterOp(h.overrideData,t);if(c){let u;a===h.data&&t===c?u=i:u=Kr.applySimple(h.data,c),h.updateByOp(c,u,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ph.is(t.props.type)&&bl.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){bl.changeEntityProptotype(this,i,r);for(let s of this.children)ni.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let s=i.morphTargetInfluences.get(t.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Li(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Li(t.path,["cloner"])!==null){let s=Kr.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=cD(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let c=null;try{c=l.curves.length?l.getPointAt(h):null}catch{}if(c===null)return;let u=this.parent?this.parent?.matrixWorld:new je;n.updateMatrixWorld();let d=new je().multiplyMatrices(u.clone().invert(),n.matrixWorld);c.applyMatrix4(d);let p={position:c.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new je().extractRotation(n.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(c),m=new je().lookAt(c,g,OQ),y=r1.setFromEuler(new Fr().setFromRotationMatrix(m)).multiplyScalar(lt.RAD2DEG);p={...p,rotation:y.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(DQ)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof bl.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new bl.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},uD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,s=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);s.thetaLength=lt.clamp(s.thetaLength,0,360);let a=s.width/2,n=s.radiusTop??a,o=s.radiusBottom??a;if(n===o?(n=a,o=a):n>o?(n=a,o=o*a/n):(n=n*a/o,o=a),s.shapeBlendNode){n=i??a,o=r??a;let l=Math.max(n,o)*2;s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:n,radiusBottom:o})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:u,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new gt,f.setAttribute("position",new at([],3))):u||p?f=new dD(h,c,r,s,a,n,o,l*Math.PI/180,u,u,d,p):f=new Cb(h,c,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function $o(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function YM(e){return new re(e.y,-e.x)}var dD=class extends gt{constructor(e,t,i,r,s,a,n,o,l,h,c,u,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],g=[],m=[],y=0,x=i/2,b=new I,_=new I;d&&e==0&&(e=l),d&&t==0&&(t=h);let M=new re(e,x),S=new re(t,-x),E=null,A=null,T=null,P=null,R=M.clone().sub(S),z=0,U=0,L=0;u>0&&(z=Math.min(e,t)*(1-u),U=e-z,L=t-z);let H=M.clone();H.x-=z;let q=Math.PI-R.angle(),Z=R.angle(),X=Math.tan(Z/2),se=Math.tan(q/2),le=X+se,te=u?le:se,ie=u?le:X;if(l=Math.min(l,(e-U)/te,R.length()/le),h=Math.min(h,(t-L)/ie,R.length()/le),l>0){let ve=l/X;E=M.clone().sub(new re(ve,l)),u&&(T=E.clone(),T.x-=z-le*l),M.sub(R.clone().setLength(ve))}if(h>0){let ve=h/se;A=S.clone().sub(new re(ve,-h)),S.add(R.clone().setLength(ve)),u&&(P=A.clone(),P.x-=z-le*h,H.sub(R.clone().setLength(ve)))}R=M.clone().sub(S);let fe=R.length()<.5,ce=[];for(let ve=0;ve<=r;ve++){let Ae=[],ye=ve/r,Ve=ye*o+n,Ie=new re(Math.sin(Ve),Math.cos(Ve));P&&A?(ue(Ae,ye,Ie,q,h,P,-1,!0),ue(Ae,ye,Ie,Z,h,A,-1,!1)):A?(ae(Ae,Ie,A.x,0,-1),ue(Ae,ye,Ie,Z,h,A,-1,!1)):a||ae(Ae,Ie,t,L,-1);let Ce=YM(R).normalize();if($o(Ce,Ie,b),!fe)for(let it=0;it<=s;it++){let Je=it/s,st=R.clone().multiplyScalar(Je).add(S);$o(st,Ie,_),f.push(_.x,_.y,_.z),g.push(b.x,b.y,b.z),m.push(ye,.5+_.y/i),Ae.push(y++)}if(T&&E?(ue(Ae,ye,Ie,q,l,E,1,!1),ue(Ae,ye,Ie,Z,l,T,1,!0)):E?(ue(Ae,ye,Ie,q,l,E,1,!1),ae(Ae,Ie,E.x,0,1)):a||ae(Ae,Ie,e,U,1),u&&!fe){let it=YM(R).multiplyScalar(-1).normalize();$o(it,Ie,b);for(let Je=0;Je<=s;Je++){let st=Je/s,nt=R.clone().multiplyScalar(-st).add(H);$o(nt,Ie,_),f.push(_.x,_.y,_.z),g.push(b.x,b.y,b.z),m.push(ye,.5+_.y/i),Ae.push(y++)}}u&&!a&&Ae.push(Ae[0]),ce.push(Ae)}for(let ve=0;ve<ce.length-1;ve++)for(let Ae=0;Ae<ce[0].length-1;Ae++){if(a&&u&&Ae==s)continue;let ye=ce[ve][Ae],Ve=ce[ve+1][Ae],Ie=ce[ve+1][Ae+1],Ce=ce[ve][Ae+1],it=f[Ie*3+0],Je=f[Ie*3+2];p.push(ye,Ve,Ce),(it!=0||Je!=0)&&p.push(Ve,Ie,Ce)}o<Math.PI*2&&(Pe(-1,ce[0],n),Pe(1,ce[ce.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new at(f,3)),this.setAttribute("normal",new at(g,3)),this.setAttribute("uv",new at(m,2));function ue(ve,Ae,ye,Ve,Ie,Ce,it,Je){for(let st=0;st<c+1;st++){let nt=st/c,Ze=it<0?nt:1-nt;Je&&(Ze-=1),Ze*=Ve;let Qe=new re(Math.sin(Ze),Math.cos(Ze)*it),pt=Qe.clone().multiplyScalar(Ie).add(Ce);$o(pt,ye,_),f.push(_.x,_.y,_.z),$o(Qe,ye,b),g.push(b.x,b.y,b.z),m.push(Ae,.5+_.y/i),ve.push(y++)}}function ae(ve,Ae,ye,Ve,Ie){let Ce=new I,it=new re,Je=[ye,Ve];Ie<0&&Je.reverse();for(let st of Je)it.set(st,x*Ie),$o(it,Ae,Ce),f.push(Ce.x,Ce.y,Ce.z),g.push(0,Ie,0),m.push(.5,.5),ve.push(y++)}function Pe(ve,Ae,ye){let Ve=new re(Math.sin(ye),Math.cos(ye)),Ie=new re(-Math.cos(ye),Math.sin(ye)),Ce=new I,it=ve<0?(nt,Ze,Qe)=>p.push(nt,Ze,Qe):(nt,Ze,Qe)=>p.push(nt,Qe,Ze),Je=new re((e+t+U+L)/4,0);$o(Je,Ve,Ce),f.push(Ce.x,Ce.y,Ce.z),g.push(Ie.x,0,Ie.y),m.push(.5,.5);let st=y++;for(let nt of Ae){let Ze=f.slice(nt*3,nt*3+3);f.push(...Ze),g.push(Ie.x,0,Ie.y);let Qe=m.slice(nt*2,nt*2+2);m.push(...Qe),y++}for(let nt=st+1;nt<y-1;nt++)it(st,nt,nt+1);it(st,y-1,st+1)}}},RQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=lt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:u}=e.parameters,d;return l===0?(d=new gt,d.setAttribute("position",new at([],3))):h>0||c>0||l<360?d=new dD(0,t/2,r,s,a,n,o,l*Math.PI/180,h,c,u,0,!0):d=new Tb(t/2,r,s,a,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},LQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o===0?h=new rn(t,i,r,s,a,n):h=new BQ(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},s1=Math.PI/2,BQ=class extends gt{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let l=[],h=[],c=[],u=[],d=0;p("z","y","x",-1,-1,i,t,e,a,s),p("z","y","x",1,-1,i,t,-e,a,s),p("x","z","y",1,1,e,i,t,r,a),p("x","z","y",1,-1,e,i,-t,r,a),p("x","y","z",1,-1,e,t,i,r,s),p("x","y","z",-1,-1,e,t,-i,r,s),n>0&&(f("z","y","x",-1,-1,1,i,t,e,a),f("z","y","x",1,-1,-1,i,t,e,a),f("z","y","x",-1,1,-1,i,t,e,a),f("z","y","x",1,1,1,i,t,e,a),f("x","y","z",-1,-1,-1,e,t,i,r),f("x","y","z",1,-1,1,e,t,i,r),f("x","y","z",-1,1,1,e,t,i,r),f("x","y","z",1,1,-1,e,t,i,r),f("y","x","z",-1,-1,1,t,e,i,s),f("y","x","z",1,-1,-1,t,e,i,s),f("y","x","z",1,1,1,t,e,i,s),f("y","x","z",-1,1,-1,t,e,i,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new at(h,3)),this.setAttribute("normal",new at(c,3)),this.setAttribute("uv",new at(u,2));function p(m,y,x,b,_,M,S,E,A,T){let P=(M-2*n)/A,R=(S-2*n)/T,z=M/2-n,U=S/2-n,L=E/2,H=A+1,q=T+1,Z=0,X=new I;for(let se=0;se<q;se++){let le=se*R-U;for(let te=0;te<H;te++){let ie=te*P-z;X[m]=ie*b,X[y]=le*_,X[x]=L,h.push(X.x,X.y,X.z),X[m]=0,X[y]=0,X[x]=E>0?1:-1,c.push(X.x,X.y,X.z),u.push(te/A),u.push(1-se/T),Z+=1}}for(let se=0;se<T;se++)for(let le=0;le<A;le++){let te=d+le+H*se,ie=d+le+H*(se+1),fe=d+(le+1)+H*(se+1),ce=d+(le+1)+H*se;l.push(te,ie,ce),l.push(ie,fe,ce)}d+=Z}function f(m,y,x,b,_,M,S,E,A,T){let P=(S-2*n)/T,R=S/2-n,z=E/2-n,U=A/2,L=T+1,H=0,q=new I,Z=new I;for(let X=0;X<o+1;X++){let se=X/o*s1,le=Math.sin(se)*n,te=(1-Math.cos(se))*n,ie=Math.sin(se),fe=Math.cos(se);q[y]=(z+le)*_,q[x]=(U-te)*M,Z[m]=0,Z[y]=ie*Math.sign(q[y]),Z[x]=fe*Math.sign(q[x]);for(let ce=0;ce<L;ce++){let ue=ce*P-R;q[m]=ue*b,h.push(q.x,q.y,q.z),c.push(Z.x,Z.y,Z.z),u.push(ce/T),u.push(0),H+=1}}for(let X=0;X<o;X++)for(let se=0;se<T;se++){let le=d+se+L*X,te=d+se+L*(X+1),ie=d+(se+1)+L*(X+1),fe=d+(se+1)+L*X;l.push(le,te,fe),l.push(te,ie,fe)}d+=H}function g(m,y,x){let b=new I,_=new I(e/2,t/2,i/2);_.subScalar(n);let M=[],S=m*y*x>0?(A,T,P)=>l.push(A,T,P):(A,T,P)=>l.push(A,P,T);for(let A=0;A<=o;A++){let T=[],P=s1*(1-A/o),R=Math.cos(P),z=Math.sin(P),U=0;for(let L=0;L<=A;L++){let H=Math.cos(U),q=Math.sin(U);b.x=R*H,b.y=z,b.z=R*q;let Z=_.clone().addScaledVector(b,n);h.push(m*Z.x,y*Z.y,x*Z.z),c.push(m*b.x,y*b.y,x*b.z),u.push(0,0),T.push(d++),U+=s1/A}M.push(T)}let E=M.length-1;for(let A=0;A<E;A++){let T=M[A],P=M[A+1],R=T.length-1;S(T[0],P[1],P[0]);for(let z=1;z<=R;z++)S(T[z-1],T[z],P[z]),S(T[z],P[z+1],P[z])}}}},cw=class extends gt{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new at(n,3)),this.setAttribute("normal",new at(l,3)),this.setAttribute("uv",new at(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new I,p=d.clone(),f=new us,g=s*r,m=r-g,y=a+1,x=new I,b=(Z,X)=>x.subVectors(Z,X).normalize(),_=(Z,X)=>Array(Z).fill(void 0).map(X),M=_(e.length/3,(Z,X)=>new I().fromArray(e,X*3).setLength(r)),S=[],E=1e6;for(let Z=0;Z<M.length;Z++){let X=M[Z],se=[],le,te,ie,fe=1e10,ce=-1;for(;(ce=t.indexOf(Z,ce+1))!=-1;){let ve=ce-ce%3;le=t[ve+(ce+1)%3],te=t[ve+(ce+2)%3],ie=X.distanceToSquared(M[le]),fe=Math.min(fe,ie),se.push([le,te,ie])}fe+=1e-6;let ue=[],ae=0,Pe=se.length;for(let ve=0;ve<Pe;ve++){[le,te,ie]=se[ae];let Ae=S[le]?.includes(Z)==!0;ie<=fe&&ue.push(le+ +Ae*E),ae=se.findIndex(ye=>ye[0]==te)}S.push(ue)}let A=[];{let Z=0,X=0,se,le,te=u==3;for(let ie=0;ie<=a;ie++){se=ie*(ie+1)/2,le=(ie+1)*(ie+2)/2;for(let fe=0;fe<a-ie;fe++)[Z,X]=[se+fe+ie+2,le+fe+ie+3],A.push(se,le,...te?[X,se]:[Z,le],X,Z),[se,le]=[Z,X];A.push(se,le,se+a+2)}}let T=d.clone(),P=d.clone(),R=d.clone(),z=d.clone(),U=d.clone(),L=[],H=_(M.length,()=>_(u,()=>d.clone()));for(let Z=0;Z<M.length;Z++){d.copy(M[Z]).normalize(),T.copy(d).multiplyScalar(m);let X=S[Z];for(let ue=0;ue<X.length;ue++){let ae=X[ue],Pe=X[(ue+1)%u];f.setFromPointsAndIndices(M,Z,ae%E,Pe%E),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(T,H[Z][ue])}let se=[],le=[],te=[],ie=new I;a==0&&[...H[Z]].reduce((ue,ae)=>ue.add(ae),ie).multiplyScalar(1/u);for(let ue=0;ue<u;ue++){let ae=[],Pe=(ue-1+u)%u,ve=H[Z][Pe],Ae=H[Z][ue];d.copy(ve).sub(T),p.copy(Ae).sub(T);let ye=T.angleTo(d),Ve=d.angleTo(p),Ie=Math.cos(ye)*g;a==0?P.copy(ie):P.copy(T).setLength(m+Ie),le.push(Ie);let Ce=[P,ve,Ae];for(let it=0;it<2;it++){let Je=Ce[it],st=Ce[it+1];z.subVectors(Je,T),U.subVectors(st,T),R.crossVectors(z,U).normalize();for(let nt=0;nt<y;nt++){let Ze=[ye,Ve][it]*nt/y;d.copy(z).applyAxisAngle(R,Ze).add(T),se.push(d.clone()),it&&(b(d,T),ae.push([nt==0?Je:d.clone(),x.clone()]))}it&&(b(st,T),ae.push([st,x.clone()]))}te.push(ae)}L.push(te);let fe=2*y,ce=2;for(let ue=0;ue<u;ue++){let ae=fe*ue,Pe=fe*((ue+1)%u),ve=[se[ae]];for(let ye=1;ye<y;ye++){z=se[ae+ye],U=se[Pe+ye],ve.push(z);for(let Ve=1,Ie=ye-ce+1;Ve<=Ie;Ve++)d.lerpVectors(z,U,Ve/(Ie+1)),d.sub(T).setLength(le[ue]).add(T),ve.push(d.clone());ve.push(U)}for(let ye=0;ye<y;ye++)ve.push(se[ye+y+ae]);ve.push(se[Pe+y]);let Ae=A.map(ye=>ve[ye]);n.push(...Ae.map(ye=>[ye.x,ye.y,ye.z]).flat()),l.push(...Ae.map(ye=>(b(ye,T),[x.x,x.y,x.z])).flat())}}let q=[];for(let Z=0;Z<S.length;Z++)for(let X=0;X<u;X++){let se=S[Z][X];if(se<E){let le=S[se].findIndex(fe=>fe%E==Z),te=L[Z][X],ie=L[se][le];for(let fe=0;fe<y;fe++){let ce=te[fe],ue=ie[y-fe],ae=te[fe+1],Pe=ie[y-(fe+1)];[ce,ue,ae,ae,ue,Pe].forEach(ve=>{n.push(ve[0].x,ve[0].y,ve[0].z),l.push(ve[1].x,ve[1].y,ve[1].z)})}q.push(te[0][0],ie[y][0],te[y][0],ie[0][0])}}for(;q.length;){let Z,X,se,le;[Z,X]=q.splice(0,2);let te=[Z];for(;Z!=X;)te.push(X),se=q.indexOf(X),le=se%2,X=q.splice(se-le,2)[1-le];x.subVectors(te[0],te[1]).cross(d.subVectors(te[0],te[2])).normalize();let ie=x.dot(te[0])<0;ie&&x.negate();for(let fe=1;fe<=te.length-2;fe++)[te[fe+ +ie],te[fe+1-+ie],te[0]].forEach(ce=>{n.push(ce.x,ce.y,ce.z),l.push(x.x,x.y,x.z)})}}function c(){let u=new I;for(let S=0;S<n.length;S+=3){u.x=n[S+0],u.y=n[S+1],u.z=n[S+2];let E=_(u)/2/Math.PI+.5,A=M(u)/Math.PI+.5;o.push(E,1-A)}let d=new I,p=new I,f=new I,g=new I,m=new re,y=new re,x=new re,b=(S,E,A,T)=>{T<0&&S.x===1&&(o[E]=S.x-1),A.x===0&&A.z===0&&(o[E]=T/2/Math.PI+.5)};for(let S=0,E=0;S<n.length;S+=9,E+=6){d.set(n[S+0],n[S+1],n[S+2]),p.set(n[S+3],n[S+4],n[S+5]),f.set(n[S+6],n[S+7],n[S+8]),m.set(o[E+0],o[E+1]),y.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),g.copy(d).add(p).add(f).divideScalar(3);let A=_(g);b(m,E+0,d,A),b(y,E+2,p,A),b(x,E+4,f,A)}for(let S=0;S<o.length;S+=6){let E=o[S+0],A=o[S+2],T=o[S+4],P=Math.max(E,A,T),R=Math.min(E,A,T);P>.9&&R<.1&&(E<.2&&(o[S+0]+=1),A<.2&&(o[S+2]+=1),T<.2&&(o[S+4]+=1))}function _(S){return Math.atan2(S.z,-S.x)}function M(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new cw(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},zQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new pD(t*.5,a,n):new hT(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},pD=class extends cw{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new pD(e.radius,e.corner,e.cornerSides)}},gd=1e-12,uw=class{constructor(e){this.position=new re,this.startPosition=new re,this.uuid=lt.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new uw(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Dx=class extends uw{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Dx(this.parent).copy(this)}},Jc=class extends uw{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Dx(this),new Dx(this))}static create(e,t){let i=new Jc(e,new re(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Jc(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new re,t=new re){let[i,r]=this.computeTangents();return i&&r&&(QM(i,e),QM(r,t)),[e,t]}computeTangent(e=new re){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new re){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function QM(e,t=new re){let i=e.length();return t.set(-e.y/i,e.x/i)}var dw=e=>e,Bu=new re,bv=new re,FQ=new re,kQ=new re,UQ=new re,NQ=new re,fD=new I,mD=new I;function VQ(e){let t=new re;t.addVectors(e.v0,Bu.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new re;return i.addVectors(e.v2,bv.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Za(e.v0,t,i,e.v2)}function Ld(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function jQ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function HQ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function gD(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function GQ(e,t,i){return KM(e,t)&&KM(t,i)&&Ix(e.position,t.position,i.position)}function Ix(e,t,i){return Bu.copy(t).sub(e).cross(bv.copy(i).sub(e))===0}function WQ(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function qQ(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function XQ(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),u;return gD(t,e,i)>Math.PI&&(c*=-1),Ld(h,o)?u=(o+h)*(r/c-.5)*8/3/(n-l):u=(n+l)*(r/c-.5)*8/3/(h-o),s.set(t.x-u*o,t.y+u*n),a.set(i.x+u*h,i.y-u*l),[s,a]}function ZM(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function KM(e,t){return Ix(e.position,e.controls[1].position,t.position)&&Ix(e.position,t.controls[0].position,t.position)}function YQ(e,t,i,r,s=.5){let a=Bu.subVectors(t,e).multiplyScalar(s).add(e),n=bv.subVectors(i,t).multiplyScalar(s).add(t),o=FQ.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=kQ.subVectors(n,a).multiplyScalar(s).add(a),c=UQ.subVectors(o,n).multiplyScalar(s).add(n),u=o,d=NQ.subVectors(c,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,c.x,c.y,u.x,u.y,r.x,r.y]}function QQ(e,t,i=12,r=!0){let s=mD.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=dw(t[l]),c=Bu,u=Ah(h,i);o.push(u);for(let d=0;d<=u;d++)if(h instanceof Za||h instanceof Dl||h instanceof $a){if(h.getPoint(d/u,c),s.set(c.x,c.y,0),a!==void 0&&HQ(a,s))continue;a===void 0&&(a=fD),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function ZQ(e,t,i,r=12,s=!0){let a=mD.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=dw(t[l]),u=Bu,d=Ah(c,r);o.push(d);for(let p=0;p<=d;p++)if(c instanceof Za||c instanceof Dl||c instanceof $a){if(c.getPoint(p/d,u),a.set(u.x,u.y,0),h?.equals(a))continue;h===void 0?h=fD:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function JM(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=Ah(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=Ah(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Ah(e[0].roundedCurveCorner,t)*.5),r}function Ah(e,t=12){return e&&e instanceof av?t*2:e&&(e instanceof $a||e instanceof nT)?1:e&&e instanceof Eb?t*e.points.length:t}function KQ(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=dw(t[n]),l=Ah(o,i),h=Bu;for(let c=0;c<=l;c++)if(o instanceof Za||o instanceof Dl||o instanceof $a){if(o.getPoint(c/l,h),s!==void 0&&jQ(s,h,gd))continue;s===void 0&&(s=bv),s.copy(h),e.push(h.x,h.y),a++}}return Ld(e[0],e[e.length-2],gd)&&Ld(e[1],e[e.length-1],gd)&&(e.pop(),e.pop()),r&&a>1&&!(Ld(e[a-1],e[1],gd)&&Ld(e[a-2],e[0],gd))&&(e.push(e[0],e[1]),a++),e}var a1=new re,JQ=new re,$Q=new re,eZ=new re,tZ=new re,iZ=new re,ar=class extends sg{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Gs(new I(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=lt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new ar;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Jc.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>ar.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],a=e-t;if(a<=s.points.length-1)return s.points[a];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],a=s.points.indexOf(e);if(a>=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=a1.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=lt.generateUUID()){let r;e instanceof re?r=e:r=new re(e,t);let s=new Jc(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return QQ(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=JM(this.points,e,!1),this.roundedCurveDivisions=JM(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return ZQ(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),KQ(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Ah(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,n=a[e];if(ZM(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(a1.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){ZM(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&GQ(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,c=s.curveAfter;if(h===void 0||c===void 0)continue;let u=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=c.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),y=Math.min(g,m),x=1-y/p,b=y/f,_=h.getPointAt(x,a1),M=c.getPointAt(b,JQ);this._subSplitCurve(h,u,x,_,void 0),this._subSplitCurve(c,d,b,void 0,M);let S;if(this.useCubicForRoundedCorners){let E=gD(_,s.position,M)/2,A=Math.tan(E)*_.distanceTo(s.position),[T,P]=WQ(_,M,A,$Q,eZ),R=qQ(T,P,s.position),[z,U]=XQ(R,_,M,A,tZ,iZ);S=new Za(_.clone(),z.clone(),U.clone(),M.clone())}else S=new Dl(_.clone(),s.position.clone(),M.clone());s.roundedCurveCorner=S,this.roundedCurves.splice(i+t,0,S),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof $a)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=YQ(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new ar(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],a=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],c=e.points[r+6],u=new Jc(lt.generateUUID(),new re(s,a));u.controls[0].position.set(n,o),u.controls[1].position.set(l,h),u.roundness=c,this.points.push(u)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new ar;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof Za&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof Dl&&(s[n]=VQ(s[n]));for(n=0,o=s.length;n<o;n++){let c=s[n],u=n>0?s[n-1]:null,d;c instanceof Za?(d=this.createPoint(c.v0),d.controls[1].position.copy(c.v1)):c instanceof $a&&(d=this.createPoint(c.v1)),d!==void 0&&(u!==null&&i(d,u),a.push(d))}let l=s[s.length-1],h=!1;return l instanceof Za?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof $a&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof sg&&(this.shapeHoles=e.holes.map(s=>{let a=new ar;return a.fromShape(s),a})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Ox=Math.PI*2;function n1({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function rZ(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function $M(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function sZ(e,t,i,r,s,a,n,o,l,h){let c=Math.pow(s,2),u=Math.pow(a,2),d=Math.pow(n,2),p=Math.pow(o,2),f=c*u-c*p-u*d;f<0&&(f=0),f/=c*p+u*d,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/a*o,m=f*-a/s*n,y=g+(e+i)/2,x=m+(t+r)/2,b=(n-g)/s,_=(o-m)/a,M=(-n-g)/s,S=(-o-m)/a,E=$M(1,0,b,_),A=$M(b,_,M,S);return!h&&A>0&&(A-=Ox),h&&A<0&&(A+=Ox),{centerx:y,centery:x,ang1:E,ang2:A}}function aZ({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];s=Math.abs(s),a=Math.abs(a);let u=Math.pow(h,2)/Math.pow(s,2)+Math.pow(c,2)/Math.pow(a,2);u>1&&(s*=Math.sqrt(u),a*=Math.sqrt(u));let d=sZ(e,t,i,r,s,a,h,c,n,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,y=Math.abs(f)/(Ox/4);Math.abs(1-y)<1e-7&&(y=1);let x=Math.max(Math.ceil(y),1);f/=x;for(let b=0;b<x;b++)l.push(rZ(p,f)),p+=f;return l.map(b=>{let{x:_,y:M}=n1(b[0],s,a,g,m),{x:S,y:E}=n1(b[1],s,a,g,m),{x:A,y:T}=n1(b[2],s,a,g,m);return{x1:_,y1:M,x2:S,y2:E,x:A,y:T}})}var Pi;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Pi||(Pi={}));var _r;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(_r||(_r={}));function Ot(e,t){if(!e)throw t||"Assertion Failed!"}var At=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Ot(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){Ot(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){Ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){Ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,a){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),vd=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),em=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Bc=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),eE=function(){function e(){var t=new Bc,i=new vd,r=new em(0),s=new em(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new em(0),r=new em(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;Ot(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Ot(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new Bc,i=new Bc,r=new vd,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var a=new Bc;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new vd;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new vd;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new Bc;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new vd;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&At.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&At.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){Ot(s.prev===a),l=s.anEdge;do Ot(l.Sym!==l),Ot(l.Sym.Sym===l),Ot(l.Lnext.Onext.Sym===l),Ot(l.Onext.Sym.Lnext===l),Ot(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Ot(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Ot(n.prev===o),l=n.anEdge;do Ot(l.Sym!==l),Ot(l.Sym.Sym===l),Ot(l.Lnext.Onext.Sym===l),Ot(l.Onext.Sym.Lnext===l),Ot(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Ot(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Ot(l.Sym.next===h.Sym),Ot(l.Sym!==l),Ot(l.Sym.Sym===l),Ot(l.Org!==null),Ot(l.Dst!==null),Ot(l.Lnext.Onext.Sym===l),Ot(l.Onext.Sym.Lnext===l);Ot(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),tE=function(){function e(){this.handle=null}return e}(),iE=function(){function e(){this.key=null,this.node=0}return e}(),nZ=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new tE,this.handles[r]=new iE;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Ot(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new tE;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new iE}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;Ot(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),o1=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),rE=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),oZ=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new rE,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new rE;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),lZ=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?At.vertLeq(a.Org,n.Org)?At.edgeSign(n.Dst,a.Org,n.Org)<=0:At.edgeSign(a.Dst,n.Org,a.Org)>=0:At.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return At.edgeSign(a.Dst,s,a.Org)>=0;var o=At.edgeEval(a.Dst,s,a.Org),l=At.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Ot(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Ot(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new o1;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case Pi.ODD:return(i&1)!==0;case Pi.NONZERO:return i!==0;case Pi.POSITIVE:return i>0;case Pi.NEGATIVE:return i<0;case Pi.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,c,u=!0;h=r;do Ot(At.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,c=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!u&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),u=!1,l=o,c=h;l.dirty=!0,Ot(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=At.vertL1dist(i,t),a=At.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(At.vertLeq(s.Org,a.Org)){if(At.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;At.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(At.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(Ot(!At.vertEq(s.Dst,a.Dst)),At.vertLeq(s.Dst,a.Dst)){if(At.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(At.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,c,u,d=new Bc,p,f;if(Ot(!At.vertEq(h,l)),Ot(At.edgeSign(l,t.event,n)<=0),Ot(At.edgeSign(h,t.event,o)>=0),Ot(n!==t.event&&o!==t.event),Ot(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),u=Math.max(o.t,h.t),c>u))return!1;if(At.vertLeq(n,o)){if(At.edgeSign(h,n,o)>0)return!1}else if(At.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),At.intersect(l,n,h,o,d),Ot(Math.min(n.t,l.t)<=d.t),Ot(d.t<=Math.max(o.t,h.t)),Ot(Math.min(h.s,l.s)<=d.s),Ot(d.s<=Math.max(o.s,n.s)),At.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=At.vertLeq(n,o)?n:o,At.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),At.vertEq(d,n)||At.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!At.vertEq(l,t.event)&&At.edgeSign(l,t.event,d)>=0||!At.vertEq(h,t.event)&&At.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(At.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),At.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,s),s.Org.s=d.s,s.Org.t=d.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,a;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),At.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),At.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}At.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;if(s=i.eUp,At.vertEq(s.Org,r)){Ot(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!At.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Ot(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(Ot(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),At.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new o1;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,At.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=At.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);Ot(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new o1,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new oZ(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Ot(i.fixUpperEdge),Ot(++r===1)),Ot(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,At.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new nZ(a,At.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,Ot(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!At.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),hZ=function(){function e(){this.mesh=new eE,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=Pi.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,a,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)a=i.coords[m],h[m]=a,f[m]=i,l[m]=a,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var y=0;y<3;++y)a=i.coords[y],a<h[y]&&(h[y]=a,f[y]=i),a>l[y]&&(l[y]=a,p[y]=i);var x=0;if(l[1]-h[1]>l[0]-h[0]&&(x=1),l[2]-h[2]>l[x]-h[x]&&(x=2),h[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[x],s=p[x],c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)u[0]=i.coords[0]-s.coords[0],u[1]=i.coords[1]-s.coords[1],u[2]=i.coords[2]-s.coords[2],d[0]=c[1]*u[2]-c[2]*u[1],d[1]=c[2]*u[0]-c[0]*u[2],d[2]=c[0]*u[1]-c[1]*u[0],n=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],n>o&&(o=n,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,a=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);a&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;At.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;At.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(At.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(At.edgeGoesLeft(s.Lnext)||At.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(At.edgeGoesRight(r.Lprev)||At.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var a,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){a=c.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===_r.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var u=h.n*s;this.vertices[u+0]=h.coords[0],this.vertices[u+1]=h.coords[1],s>2&&(this.vertices[u+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){a=c.anEdge,l=0;do{var h=a.Org;this.elements[d++]=h.n,l++,a=a.Lnext}while(a!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===_r.CONNECTED_POLYGONS){a=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==s);this.elements[c++]=a,this.elements[c++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new eE),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,a,n){if(t===void 0&&(t=Pi.ODD),i===void 0&&(i=_r.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),lZ.computeInterior(this,n);var o=this.mesh;return i===_r.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===_r.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function wl(e){var t=e.windingRule,i=t===void 0?Pi.ODD:t,r=e.elementType,s=r===void 0?_r.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,u=e.contours,d=u===void 0?[]:u,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var y=new hZ;e.edgeCreateCallback&&(y.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(y.vertexIdCallback=e.vertexIdCallback);for(var x=0;x<d.length;x++)y.addContour(l||2,d[x]);return y.tesselate(i,s,n,l,c,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:m?y.mesh:void 0}}}var ile=Pi.ODD,rle=Pi.NONZERO,sle=Pi.POSITIVE,ale=Pi.NEGATIVE,nle=Pi.ABS_GEQ_TWO,ole=_r.POLYGONS,lle=_r.CONNECTED_POLYGONS,hle=_r.BOUNDARY_CONTOURS,Rx=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*Rx.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*Rx.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},vD=Rx;vD.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var cZ=class{constructor(e=[],t=(i,r)=>i<r?-1:i>r?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let s=e-1>>1,a=t[s];if(i(r,a)>=0)break;t[e]=a,e=s}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,s=t[e];for(;e<r;){let a=(e<<1)+1,n=a+1;if(n<this.length&&i(t[n],t[a])<0&&(a=n),i(t[a],s)>=0)break;t[e]=t[a],e=a}t[e]=s}};function uZ(e,t,i=1,r=!1){let s=1/0,a=1/0,n=-1/0,o=-1/0;for(let[x,b]of e[0])x<s&&(s=x),b<a&&(a=b),x>n&&(n=x),b>o&&(o=b);let l=n-s,h=o-a,c=Math.max(i,Math.min(l,h));if(c===i){let x=[s,a];return x.distance=0,x.distance}let u=new cZ([],(x,b)=>b.max-x.max),d=pZ(e),p=new Vg(s+l/2,a+h/2,0,e);p.d>d.d&&(d=p);let f=2;function g(x,b,_){let M=new Vg(x,b,_,e);if(f++,M.max>d.d+i&&u.push(M),M.d>d.d&&(d=M,r&&console.log(`found best ${Math.round(1e4*M.d)/1e4} after ${f} probes`),d.d>t))return t}let m=c/2;for(let x=s;x<n;x+=c)for(let b=a;b<o;b+=c)g(x+m,b+m,m);for(;u.length;){let{max:x,x:b,y:_,h:M}=u.pop();if(x-d.d<=i)break;m=M/2,g(b-m,_-m,m),g(b+m,_-m,m),g(b-m,_+m,m),g(b+m,_+m,m)}r&&console.log(`num probes: ${f}
3175
+ }`;function E6(e,t,i){let r=new _b,s=new re,a=new re,n=new zt,o=new iT({depthPacking:V3}),l=new S6,h={},c=i.maxTextureSize,u={[en]:$r,[$r]:en,[_s]:_s},d=new ci({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new re},radius:{value:4}},vertexShader:A6,fragmentShader:M6}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new gt;f.setAttribute("position",new Tt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new zi(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gb,this.render=function(_,M,S){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||_.length===0)return;let E=e.getRenderTarget(),A=e.getActiveCubeFace(),T=e.getActiveMipmapLevel(),P=e.state;P.setBlending(Mr),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);for(let R=0,z=_.length;R<z;R++){let U=_[R],L=U.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",U,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;s.copy(L.mapSize);let H=L.getFrameExtents();if(s.multiply(H),a.copy(L.mapSize),(s.x>c||s.y>c)&&(s.x>c&&(a.x=Math.floor(c/H.x),s.x=a.x*H.x,L.mapSize.x=a.x),s.y>c&&(a.y=Math.floor(c/H.y),s.y=a.y*H.y,L.mapSize.y=a.y)),L.map===null){let Z=this.type!==Dd?{minFilter:$t,magFilter:$t}:{};L.map=new hi(s.x,s.y,Z),L.map.texture.name=U.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let q=L.getViewportCount();for(let Z=0;Z<q;Z++){let X=L.getViewport(Z);n.set(a.x*X.x,a.y*X.y,a.x*X.z,a.y*X.w),P.viewport(n),L.updateMatrices(U,Z),r=L.getFrustum(),b(M,S,L.camera,U,this.type)}L.isPointLightShadow!==!0&&this.type===Dd&&y(L,S),L.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(E,A,T)};function y(_,M){let S=t.update(g);d.defines.VSM_SAMPLES!==_.blurSamples&&(d.defines.VSM_SAMPLES=_.blurSamples,p.defines.VSM_SAMPLES=_.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),_.mapPass===null&&(_.mapPass=new hi(s.x,s.y)),d.uniforms.shadow_pass.value=_.map.texture,d.uniforms.resolution.value=_.mapSize,d.uniforms.radius.value=_.radius,e.setRenderTarget(_.mapPass),e.clear(),e.renderBufferDirect(M,null,S,d,g,null),p.uniforms.shadow_pass.value=_.mapPass.texture,p.uniforms.resolution.value=_.mapSize,p.uniforms.radius.value=_.radius,e.setRenderTarget(_.map),e.clear(),e.renderBufferDirect(M,null,S,p,g,null)}function x(_,M,S,E,A,T){let P=null,R=S.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)P=R;else if(P=S.isPointLight===!0?l:o,e.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0){let z=P.uuid,U=M.uuid,L=h[z];L===void 0&&(L={},h[z]=L);let H=L[U];H===void 0&&(H=P.clone(),L[U]=H),P=H}return P.visible=M.visible,P.wireframe=M.wireframe,T===Dd?P.side=M.shadowSide!==null?M.shadowSide:M.side:P.side=M.shadowSide!==null?M.shadowSide:u[M.side],P.alphaMap=M.alphaMap,P.alphaTest=M.alphaTest,P.map=M.map,P.clipShadows=M.clipShadows,P.clippingPlanes=M.clippingPlanes,P.clipIntersection=M.clipIntersection,P.displacementMap=M.displacementMap,P.displacementScale=M.displacementScale,P.displacementBias=M.displacementBias,P.wireframeLinewidth=M.wireframeLinewidth,P.linewidth=M.linewidth,S.isPointLight===!0&&P.isMeshDistanceMaterial===!0&&(P.referencePosition.setFromMatrixPosition(S.matrixWorld),P.nearDistance=E,P.farDistance=A),P}function b(_,M,S,E,A){if(_.visible===!1)return;if(_.layers.test(M.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&A===Dd)&&(!_.frustumCulled||r.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,_.matrixWorld);let P=t.update(_),R=_.material;if(Array.isArray(R)){let z=P.groups;for(let U=0,L=z.length;U<L;U++){let H=z[U],q=R[H.materialIndex];if(q&&q.visible){let Z=x(_,q,E,S.near,S.far,A);e.renderBufferDirect(S,null,P,Z,_,H)}}}else if(R.visible){let z=x(_,R,E,S.near,S.far,A);e.renderBufferDirect(S,null,P,z,_,null)}}let T=_.children;for(let P=0,R=T.length;P<R;P++)b(T[P],M,S,E,A)}}function C6(e,t,i){let r=i.isWebGL2;function s(){let me=!1,Ee=new zt,Xe=null,Ke=new zt(0,0,0,0);return{setMask:function(vt){Xe!==vt&&!me&&(e.colorMask(vt,vt,vt,vt),Xe=vt)},setLocked:function(vt){me=vt},setClear:function(vt,Mt,wi,ji,Tr){Tr===!0&&(vt*=ji,Mt*=ji,wi*=ji),Ee.set(vt,Mt,wi,ji),Ke.equals(Ee)===!1&&(e.clearColor(vt,Mt,wi,ji),Ke.copy(Ee))},reset:function(){me=!1,Xe=null,Ke.set(-1,0,0,0)}}}function a(){let me=!1,Ee=null,Xe=null,Ke=null;return{setTest:function(vt){vt?Pe(2929):ve(2929)},setMask:function(vt){Ee!==vt&&!me&&(e.depthMask(vt),Ee=vt)},setFunc:function(vt){if(Xe!==vt){switch(vt){case YB:e.depthFunc(512);break;case QB:e.depthFunc(519);break;case ZB:e.depthFunc(513);break;case ly:e.depthFunc(515);break;case KB:e.depthFunc(514);break;case JB:e.depthFunc(518);break;case $B:e.depthFunc(516);break;case ez:e.depthFunc(517);break;default:e.depthFunc(515)}Xe=vt}},setLocked:function(vt){me=vt},setClear:function(vt){Ke!==vt&&(e.clearDepth(vt),Ke=vt)},reset:function(){me=!1,Ee=null,Xe=null,Ke=null}}}function n(){let me=!1,Ee=null,Xe=null,Ke=null,vt=null,Mt=null,wi=null,ji=null,Tr=null;return{setTest:function(Ei){me||(Ei?Pe(2960):ve(2960))},setMask:function(Ei){Ee!==Ei&&!me&&(e.stencilMask(Ei),Ee=Ei)},setFunc:function(Ei,ss,Pr){(Xe!==Ei||Ke!==ss||vt!==Pr)&&(e.stencilFunc(Ei,ss,Pr),Xe=Ei,Ke=ss,vt=Pr)},setOp:function(Ei,ss,Pr){(Mt!==Ei||wi!==ss||ji!==Pr)&&(e.stencilOp(Ei,ss,Pr),Mt=Ei,wi=ss,ji=Pr)},setLocked:function(Ei){me=Ei},setClear:function(Ei){Tr!==Ei&&(e.clearStencil(Ei),Tr=Ei)},reset:function(){me=!1,Ee=null,Xe=null,Ke=null,vt=null,Mt=null,wi=null,ji=null,Tr=null}}}let o=new s,l=new a,h=new n,c=new WeakMap,u=new WeakMap,d={},p={},f=new WeakMap,g=[],m=null,y=!1,x=null,b=null,_=null,M=null,S=null,E=null,A=null,T=!1,P=null,R=null,z=null,U=null,L=null,H=e.getParameter(35661),q=!1,Z=0,X=e.getParameter(7938);X.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(X)[1]),q=Z>=1):X.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),q=Z>=2);let se=null,le={},te=e.getParameter(3088),ie=e.getParameter(2978),fe=new zt().fromArray(te),ce=new zt().fromArray(ie);function ue(me,Ee,Xe){let Ke=new Uint8Array(4),vt=e.createTexture();e.bindTexture(me,vt),e.texParameteri(me,10241,9728),e.texParameteri(me,10240,9728);for(let Mt=0;Mt<Xe;Mt++)e.texImage2D(Ee+Mt,0,6408,1,1,0,6408,5121,Ke);return vt}let ae={};ae[3553]=ue(3553,3553,1),ae[34067]=ue(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),Pe(2929),l.setFunc(ly),st(!1),nt(x2),Pe(2884),it(Mr);function Pe(me){d[me]!==!0&&(e.enable(me),d[me]=!0)}function ve(me){d[me]!==!1&&(e.disable(me),d[me]=!1)}function Ae(me,Ee){return p[me]!==Ee?(e.bindFramebuffer(me,Ee),p[me]=Ee,r&&(me===36009&&(p[36160]=Ee),me===36160&&(p[36009]=Ee)),!0):!1}function ye(me,Ee){let Xe=g,Ke=!1;if(me)if(Xe=f.get(Ee),Xe===void 0&&(Xe=[],f.set(Ee,Xe)),me.isWebGLMultipleRenderTargets){let vt=me.texture;if(Xe.length!==vt.length||Xe[0]!==36064){for(let Mt=0,wi=vt.length;Mt<wi;Mt++)Xe[Mt]=36064+Mt;Xe.length=vt.length,Ke=!0}}else Xe[0]!==36064&&(Xe[0]=36064,Ke=!0);else Xe[0]!==1029&&(Xe[0]=1029,Ke=!0);Ke&&(i.isWebGL2?e.drawBuffers(Xe):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Xe))}function Ve(me){return m!==me?(e.useProgram(me),m=me,!0):!1}let Ie={[Oc]:32774,[FB]:32778,[kB]:32779};if(r)Ie[S2]=32775,Ie[A2]=32776;else{let me=t.get("EXT_blend_minmax");me!==null&&(Ie[S2]=me.MIN_EXT,Ie[A2]=me.MAX_EXT)}let Ce={[UB]:0,[NB]:1,[VB]:768,[R3]:770,[XB]:776,[WB]:774,[HB]:772,[jB]:769,[L3]:771,[qB]:775,[GB]:773};function it(me,Ee,Xe,Ke,vt,Mt,wi,ji){if(me===Mr){y===!0&&(ve(3042),y=!1);return}if(y===!1&&(Pe(3042),y=!0),me!==zB){if(me!==x||ji!==T){if((b!==Oc||S!==Oc)&&(e.blendEquation(32774),b=Oc,S=Oc),ji)switch(me){case yh:e.blendFuncSeparate(1,771,1,771);break;case b2:e.blendFunc(1,1);break;case w2:e.blendFuncSeparate(0,769,0,1);break;case _2:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}else switch(me){case yh:e.blendFuncSeparate(770,771,1,771);break;case b2:e.blendFunc(770,1);break;case w2:e.blendFuncSeparate(0,769,0,1);break;case _2:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",me);break}_=null,M=null,E=null,A=null,x=me,T=ji}return}vt=vt||Ee,Mt=Mt||Xe,wi=wi||Ke,(Ee!==b||vt!==S)&&(e.blendEquationSeparate(Ie[Ee],Ie[vt]),b=Ee,S=vt),(Xe!==_||Ke!==M||Mt!==E||wi!==A)&&(e.blendFuncSeparate(Ce[Xe],Ce[Ke],Ce[Mt],Ce[wi]),_=Xe,M=Ke,E=Mt,A=wi),x=me,T=!1}function Je(me,Ee){me.side===_s?ve(2884):Pe(2884);let Xe=me.side===$r;Ee&&(Xe=!Xe),st(Xe),me.blending===yh&&me.transparent===!1?it(Mr):it(me.blending,me.blendEquation,me.blendSrc,me.blendDst,me.blendEquationAlpha,me.blendSrcAlpha,me.blendDstAlpha,me.premultipliedAlpha),l.setFunc(me.depthFunc),l.setTest(me.depthTest),l.setMask(me.depthWrite),o.setMask(me.colorWrite);let Ke=me.stencilWrite;h.setTest(Ke),Ke&&(h.setMask(me.stencilWriteMask),h.setFunc(me.stencilFunc,me.stencilRef,me.stencilFuncMask),h.setOp(me.stencilFail,me.stencilZFail,me.stencilZPass)),Qe(me.polygonOffset,me.polygonOffsetFactor,me.polygonOffsetUnits),me.alphaToCoverage===!0?Pe(32926):ve(32926)}function st(me){P!==me&&(me?e.frontFace(2304):e.frontFace(2305),P=me)}function nt(me){me!==RB?(Pe(2884),me!==R&&(me===x2?e.cullFace(1029):me===LB?e.cullFace(1028):e.cullFace(1032))):ve(2884),R=me}function Ze(me){me!==z&&(q&&e.lineWidth(me),z=me)}function Qe(me,Ee,Xe){me?(Pe(32823),(U!==Ee||L!==Xe)&&(e.polygonOffset(Ee,Xe),U=Ee,L=Xe)):ve(32823)}function pt(me){me?Pe(3089):ve(3089)}function wt(me){me===void 0&&(me=33984+H-1),se!==me&&(e.activeTexture(me),se=me)}function ee(me,Ee,Xe){Xe===void 0&&(se===null?Xe=33984+H-1:Xe=se);let Ke=le[Xe];Ke===void 0&&(Ke={type:void 0,texture:void 0},le[Xe]=Ke),(Ke.type!==me||Ke.texture!==Ee)&&(se!==Xe&&(e.activeTexture(Xe),se=Xe),e.bindTexture(me,Ee||ae[me]),Ke.type=me,Ke.texture=Ee)}function W(){let me=le[se];me!==void 0&&me.type!==void 0&&(e.bindTexture(me.type,null),me.type=void 0,me.texture=void 0)}function _e(){try{e.compressedTexImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function We(){try{e.compressedTexImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function V(){try{e.texSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function Oe(){try{e.texSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ut(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function He(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ze(){try{e.texStorage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ke(){try{e.texStorage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function dt(){try{e.texImage2D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function ot(){try{e.texImage3D.apply(e,arguments)}catch(me){console.error("THREE.WebGLState:",me)}}function _t(me){fe.equals(me)===!1&&(e.scissor(me.x,me.y,me.z,me.w),fe.copy(me))}function bt(me){ce.equals(me)===!1&&(e.viewport(me.x,me.y,me.z,me.w),ce.copy(me))}function ri(me,Ee){let Xe=u.get(Ee);Xe===void 0&&(Xe=new WeakMap,u.set(Ee,Xe));let Ke=Xe.get(me);Ke===void 0&&(Ke=e.getUniformBlockIndex(Ee,me.name),Xe.set(me,Ke))}function vi(me,Ee){let Xe=u.get(Ee).get(me);c.get(Ee)!==Xe&&(e.uniformBlockBinding(Ee,Xe,me.__bindingPointIndex),c.set(Ee,Xe))}function ii(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},se=null,le={},p={},f=new WeakMap,g=[],m=null,y=!1,x=null,b=null,_=null,M=null,S=null,E=null,A=null,T=!1,P=null,R=null,z=null,U=null,L=null,fe.set(0,0,e.canvas.width,e.canvas.height),ce.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:Pe,disable:ve,bindFramebuffer:Ae,drawBuffers:ye,useProgram:Ve,setBlending:it,setMaterial:Je,setFlipSided:st,setCullFace:nt,setLineWidth:Ze,setPolygonOffset:Qe,setScissorTest:pt,activeTexture:wt,bindTexture:ee,unbindTexture:W,compressedTexImage2D:_e,compressedTexImage3D:We,texImage2D:dt,texImage3D:ot,updateUBOMapping:ri,uniformBlockBinding:vi,texStorage2D:ze,texStorage3D:ke,texSubImage2D:V,texSubImage3D:Oe,compressedTexSubImage2D:ut,compressedTexSubImage3D:He,scissor:_t,viewport:bt,reset:ii}}function T6(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,c=s.maxTextureSize,u=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(ee,W){return y?new OffscreenCanvas(ee,W):sp("canvas")}function b(ee,W,_e,We){let V=1;if((ee.width>We||ee.height>We)&&(V=We/Math.max(ee.width,ee.height)),V<1||W===!0)if(typeof HTMLImageElement<"u"&&ee instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ee instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ee instanceof ImageBitmap){let Oe=W?tg:Math.floor,ut=Oe(V*ee.width),He=Oe(V*ee.height);g===void 0&&(g=x(ut,He));let ze=_e?x(ut,He):g;return ze.width=ut,ze.height=He,ze.getContext("2d").drawImage(ee,0,0,ut,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ee.width+"x"+ee.height+") to ("+ut+"x"+He+")."),ze}else return"data"in ee&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ee.width+"x"+ee.height+")."),ee;return ee}function _(ee){return my(ee.width)&&my(ee.height)}function M(ee){return o?!1:ee.wrapS!==Gi||ee.wrapT!==Gi||ee.minFilter!==$t&&ee.minFilter!==Xt}function S(ee,W){return ee.generateMipmaps&&W&&ee.minFilter!==$t&&ee.minFilter!==Xt}function E(ee){e.generateMipmap(ee)}function A(ee,W,_e,We,V=!1){if(o===!1)return W;if(ee!==null){if(e[ee]!==void 0)return e[ee];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ee+"'")}let Oe=W;return W===6403&&(_e===5126&&(Oe=33326),_e===5131&&(Oe=33325),_e===5121&&(Oe=33321)),W===33319&&(_e===5126&&(Oe=33328),_e===5131&&(Oe=33327),_e===5121&&(Oe=33323)),W===6408&&(_e===5126&&(Oe=34836),_e===5131&&(Oe=34842),_e===5121&&(Oe=We===Gt&&V===!1?35907:32856),_e===32819&&(Oe=32854),_e===32820&&(Oe=32855)),(Oe===33325||Oe===33326||Oe===33327||Oe===33328||Oe===34842||Oe===34836)&&t.get("EXT_color_buffer_float"),Oe}function T(ee,W,_e){return S(ee,_e)===!0||ee.isFramebufferTexture&&ee.minFilter!==$t&&ee.minFilter!==Xt?Math.log2(Math.max(W.width,W.height))+1:ee.mipmaps!==void 0&&ee.mipmaps.length>0?ee.mipmaps.length:ee.isCompressedTexture&&Array.isArray(ee.image)?W.mipmaps.length:1}function P(ee){return ee===$t||ee===M2||ee===i0?9728:9729}function R(ee){let W=ee.target;W.removeEventListener("dispose",R),U(W),W.isVideoTexture&&f.delete(W)}function z(ee){let W=ee.target;W.removeEventListener("dispose",z),H(W)}function U(ee){let W=r.get(ee);if(W.__webglInit===void 0)return;let _e=ee.source,We=m.get(_e);if(We){let V=We[W.__cacheKey];V.usedTimes--,V.usedTimes===0&&L(ee),Object.keys(We).length===0&&m.delete(_e)}r.remove(ee)}function L(ee){let W=r.get(ee);e.deleteTexture(W.__webglTexture);let _e=ee.source,We=m.get(_e);delete We[W.__cacheKey],n.memory.textures--}function H(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);if(We.__webglTexture!==void 0&&(e.deleteTexture(We.__webglTexture),n.memory.textures--),ee.depthTexture&&ee.depthTexture.dispose(),ee.isWebGLCubeRenderTarget)for(let V=0;V<6;V++)e.deleteFramebuffer(_e.__webglFramebuffer[V]),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer[V]);else{if(e.deleteFramebuffer(_e.__webglFramebuffer),_e.__webglDepthbuffer&&e.deleteRenderbuffer(_e.__webglDepthbuffer),_e.__webglMultisampledFramebuffer&&e.deleteFramebuffer(_e.__webglMultisampledFramebuffer),_e.__webglColorRenderbuffer)for(let V=0;V<_e.__webglColorRenderbuffer.length;V++)_e.__webglColorRenderbuffer[V]&&e.deleteRenderbuffer(_e.__webglColorRenderbuffer[V]);_e.__webglDepthRenderbuffer&&e.deleteRenderbuffer(_e.__webglDepthRenderbuffer)}if(ee.isWebGLMultipleRenderTargets)for(let V=0,Oe=W.length;V<Oe;V++){let ut=r.get(W[V]);ut.__webglTexture&&(e.deleteTexture(ut.__webglTexture),n.memory.textures--),r.remove(W[V])}r.remove(W),r.remove(ee)}let q=0;function Z(){q=0}function X(){let ee=q;return ee>=l&&console.warn("THREE.WebGLTextures: Trying to use "+ee+" texture units while this GPU supports only "+l),q+=1,ee}function se(ee){let W=[];return W.push(ee.wrapS),W.push(ee.wrapT),W.push(ee.wrapR||0),W.push(ee.magFilter),W.push(ee.minFilter),W.push(ee.anisotropy),W.push(ee.internalFormat),W.push(ee.format),W.push(ee.type),W.push(ee.generateMipmaps),W.push(ee.premultiplyAlpha),W.push(ee.flipY),W.push(ee.unpackAlignment),W.push(ee.encoding),W.join()}function le(ee,W){let _e=r.get(ee);if(ee.isVideoTexture&&pt(ee),ee.isRenderTargetTexture===!1&&ee.version>0&&_e.__version!==ee.version){let We=ee.image;if(We===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(We.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ve(_e,ee,W);return}}i.bindTexture(3553,_e.__webglTexture,33984+W)}function te(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(35866,_e.__webglTexture,33984+W)}function ie(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){ve(_e,ee,W);return}i.bindTexture(32879,_e.__webglTexture,33984+W)}function fe(ee,W){let _e=r.get(ee);if(ee.version>0&&_e.__version!==ee.version){Ae(_e,ee,W);return}i.bindTexture(34067,_e.__webglTexture,33984+W)}let ce={[So]:10497,[Gi]:33071,[uy]:33648},ue={[$t]:9728,[M2]:9984,[i0]:9986,[Xt]:9729,[lz]:9985,[au]:9987};function ae(ee,W,_e){if(_e?(e.texParameteri(ee,10242,ce[W.wrapS]),e.texParameteri(ee,10243,ce[W.wrapT]),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,ce[W.wrapR]),e.texParameteri(ee,10240,ue[W.magFilter]),e.texParameteri(ee,10241,ue[W.minFilter])):(e.texParameteri(ee,10242,33071),e.texParameteri(ee,10243,33071),(ee===32879||ee===35866)&&e.texParameteri(ee,32882,33071),(W.wrapS!==Gi||W.wrapT!==Gi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(ee,10240,P(W.magFilter)),e.texParameteri(ee,10241,P(W.minFilter)),W.minFilter!==$t&&W.minFilter!==Xt&&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 We=t.get("EXT_texture_filter_anisotropic");if(W.magFilter===$t||W.minFilter!==i0&&W.minFilter!==au||W.type===Ti&&t.has("OES_texture_float_linear")===!1||o===!1&&W.type===Oo&&t.has("OES_texture_half_float_linear")===!1)return;(W.anisotropy>1||r.get(W).__currentAnisotropy)&&(e.texParameterf(ee,We.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(W.anisotropy,s.getMaxAnisotropy())),r.get(W).__currentAnisotropy=W.anisotropy)}}function Pe(ee,W){let _e=!1;ee.__webglInit===void 0&&(ee.__webglInit=!0,W.addEventListener("dispose",R));let We=W.source,V=m.get(We);V===void 0&&(V={},m.set(We,V));let Oe=se(W);if(Oe!==ee.__cacheKey){V[Oe]===void 0&&(V[Oe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,_e=!0),V[Oe].usedTimes++;let ut=V[ee.__cacheKey];ut!==void 0&&(V[ee.__cacheKey].usedTimes--,ut.usedTimes===0&&L(W)),ee.__cacheKey=Oe,ee.__webglTexture=V[Oe].texture}return _e}function ve(ee,W,_e){let We=3553;(W.isDataArrayTexture||W.isCompressedArrayTexture)&&(We=35866),W.isData3DTexture&&(We=32879);let V=Pe(ee,W),Oe=W.source;i.bindTexture(We,ee.__webglTexture,33984+_e);let ut=r.get(Oe);if(Oe.version!==ut.__version||V===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let He=M(W)&&_(W.image)===!1,ze=b(W.image,He,!1,c);ze=wt(W,ze);let ke=_(ze)||o,dt=a.convert(W.format,W.encoding),ot=a.convert(W.type),_t=A(W.internalFormat,dt,ot,W.encoding,W.isVideoTexture);ae(We,W,ke);let bt,ri=W.mipmaps,vi=o&&W.isVideoTexture!==!0,ii=ut.__version===void 0||V===!0,me=T(W,ze,ke);if(W.isDepthTexture)_t=6402,o?W.type===Ti?_t=36012:W.type===Ao?_t=33190:W.type===xh?_t=35056:_t=33189:W.type===Ti&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),W.format===bh&&_t===6402&&W.type!==F3&&W.type!==Ao&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),W.type=Ao,ot=a.convert(W.type)),W.format===Ch&&_t===6402&&(_t=34041,W.type!==xh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),W.type=xh,ot=a.convert(W.type))),ii&&(vi?i.texStorage2D(3553,1,_t,ze.width,ze.height):i.texImage2D(3553,0,_t,ze.width,ze.height,0,dt,ot,null));else if(W.isDataTexture)if(ri.length>0&&ke){vi&&ii&&i.texStorage2D(3553,me,_t,ri[0].width,ri[0].height);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],vi?i.texSubImage2D(3553,Ee,0,0,bt.width,bt.height,dt,ot,bt.data):i.texImage2D(3553,Ee,_t,bt.width,bt.height,0,dt,ot,bt.data);W.generateMipmaps=!1}else vi?(ii&&i.texStorage2D(3553,me,_t,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,ze.width,ze.height,dt,ot,ze.data)):i.texImage2D(3553,0,_t,ze.width,ze.height,0,dt,ot,ze.data);else if(W.isCompressedTexture)if(W.isCompressedArrayTexture){vi&&ii&&i.texStorage3D(35866,me,_t,ri[0].width,ri[0].height,ze.depth);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],W.format!==qi?dt!==null?vi?i.compressedTexSubImage3D(35866,Ee,0,0,0,bt.width,bt.height,ze.depth,dt,bt.data,0,0):i.compressedTexImage3D(35866,Ee,_t,bt.width,bt.height,ze.depth,0,bt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):vi?i.texSubImage3D(35866,Ee,0,0,0,bt.width,bt.height,ze.depth,dt,ot,bt.data):i.texImage3D(35866,Ee,_t,bt.width,bt.height,ze.depth,0,dt,ot,bt.data)}else{vi&&ii&&i.texStorage2D(3553,me,_t,ri[0].width,ri[0].height);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],W.format!==qi?dt!==null?vi?i.compressedTexSubImage2D(3553,Ee,0,0,bt.width,bt.height,dt,bt.data):i.compressedTexImage2D(3553,Ee,_t,bt.width,bt.height,0,bt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):vi?i.texSubImage2D(3553,Ee,0,0,bt.width,bt.height,dt,ot,bt.data):i.texImage2D(3553,Ee,_t,bt.width,bt.height,0,dt,ot,bt.data)}else if(W.isDataArrayTexture)vi?(ii&&i.texStorage3D(35866,me,_t,ze.width,ze.height,ze.depth),i.texSubImage3D(35866,0,0,0,0,ze.width,ze.height,ze.depth,dt,ot,ze.data)):i.texImage3D(35866,0,_t,ze.width,ze.height,ze.depth,0,dt,ot,ze.data);else if(W.isData3DTexture)vi?(ii&&i.texStorage3D(32879,me,_t,ze.width,ze.height,ze.depth),i.texSubImage3D(32879,0,0,0,0,ze.width,ze.height,ze.depth,dt,ot,ze.data)):i.texImage3D(32879,0,_t,ze.width,ze.height,ze.depth,0,dt,ot,ze.data);else if(W.isFramebufferTexture){if(ii)if(vi)i.texStorage2D(3553,me,_t,ze.width,ze.height);else{let Ee=ze.width,Xe=ze.height;for(let Ke=0;Ke<me;Ke++)i.texImage2D(3553,Ke,_t,Ee,Xe,0,dt,ot,null),Ee>>=1,Xe>>=1}}else if(ri.length>0&&ke){vi&&ii&&i.texStorage2D(3553,me,_t,ri[0].width,ri[0].height);for(let Ee=0,Xe=ri.length;Ee<Xe;Ee++)bt=ri[Ee],vi?i.texSubImage2D(3553,Ee,0,0,dt,ot,bt):i.texImage2D(3553,Ee,_t,dt,ot,bt);W.generateMipmaps=!1}else vi?(ii&&i.texStorage2D(3553,me,_t,ze.width,ze.height),i.texSubImage2D(3553,0,0,0,dt,ot,ze)):i.texImage2D(3553,0,_t,dt,ot,ze);S(W,ke)&&E(We),ut.__version=Oe.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function Ae(ee,W,_e){if(W.image.length!==6)return;let We=Pe(ee,W),V=W.source;i.bindTexture(34067,ee.__webglTexture,33984+_e);let Oe=r.get(V);if(V.version!==Oe.__version||We===!0){i.activeTexture(33984+_e),e.pixelStorei(37440,W.flipY),e.pixelStorei(37441,W.premultiplyAlpha),e.pixelStorei(3317,W.unpackAlignment),e.pixelStorei(37443,0);let ut=W.isCompressedTexture||W.image[0].isCompressedTexture,He=W.image[0]&&W.image[0].isDataTexture,ze=[];for(let Ee=0;Ee<6;Ee++)!ut&&!He?ze[Ee]=b(W.image[Ee],!1,!0,h):ze[Ee]=He?W.image[Ee].image:W.image[Ee],ze[Ee]=wt(W,ze[Ee]);let ke=ze[0],dt=_(ke)||o,ot=a.convert(W.format,W.encoding),_t=a.convert(W.type),bt=A(W.internalFormat,ot,_t,W.encoding),ri=o&&W.isVideoTexture!==!0,vi=Oe.__version===void 0||We===!0,ii=T(W,ke,dt);ae(34067,W,dt);let me;if(ut){ri&&vi&&i.texStorage2D(34067,ii,bt,ke.width,ke.height);for(let Ee=0;Ee<6;Ee++){me=ze[Ee].mipmaps;for(let Xe=0;Xe<me.length;Xe++){let Ke=me[Xe];W.format!==qi?ot!==null?ri?i.compressedTexSubImage2D(34069+Ee,Xe,0,0,Ke.width,Ke.height,ot,Ke.data):i.compressedTexImage2D(34069+Ee,Xe,bt,Ke.width,Ke.height,0,Ke.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ri?i.texSubImage2D(34069+Ee,Xe,0,0,Ke.width,Ke.height,ot,_t,Ke.data):i.texImage2D(34069+Ee,Xe,bt,Ke.width,Ke.height,0,ot,_t,Ke.data)}}}else{me=W.mipmaps,ri&&vi&&(me.length>0&&ii++,i.texStorage2D(34067,ii,bt,ze[0].width,ze[0].height));for(let Ee=0;Ee<6;Ee++)if(He){ri?i.texSubImage2D(34069+Ee,0,0,0,ze[Ee].width,ze[Ee].height,ot,_t,ze[Ee].data):i.texImage2D(34069+Ee,0,bt,ze[Ee].width,ze[Ee].height,0,ot,_t,ze[Ee].data);for(let Xe=0;Xe<me.length;Xe++){let Ke=me[Xe].image[Ee].image;ri?i.texSubImage2D(34069+Ee,Xe+1,0,0,Ke.width,Ke.height,ot,_t,Ke.data):i.texImage2D(34069+Ee,Xe+1,bt,Ke.width,Ke.height,0,ot,_t,Ke.data)}}else{ri?i.texSubImage2D(34069+Ee,0,0,0,ot,_t,ze[Ee]):i.texImage2D(34069+Ee,0,bt,ot,_t,ze[Ee]);for(let Xe=0;Xe<me.length;Xe++){let Ke=me[Xe];ri?i.texSubImage2D(34069+Ee,Xe+1,0,0,ot,_t,Ke.image[Ee]):i.texImage2D(34069+Ee,Xe+1,bt,ot,_t,Ke.image[Ee])}}}S(W,dt)&&E(34067),Oe.__version=V.version,W.onUpdate&&W.onUpdate(W)}ee.__version=W.version}function ye(ee,W,_e,We,V){let Oe=a.convert(_e.format,_e.encoding),ut=a.convert(_e.type),He=A(_e.internalFormat,Oe,ut,_e.encoding);r.get(W).__hasExternalTextures||(V===32879||V===35866?i.texImage3D(V,0,He,W.width,W.height,W.depth,0,Oe,ut,null):i.texImage2D(V,0,He,W.width,W.height,0,Oe,ut,null)),i.bindFramebuffer(36160,ee),Qe(W)?d.framebufferTexture2DMultisampleEXT(36160,We,V,r.get(_e).__webglTexture,0,Ze(W)):(V===3553||V>=34069&&V<=34074)&&e.framebufferTexture2D(36160,We,V,r.get(_e).__webglTexture,0),i.bindFramebuffer(36160,null)}function Ve(ee,W,_e){if(e.bindRenderbuffer(36161,ee),W.depthBuffer&&!W.stencilBuffer){let We=33189;if(_e||Qe(W)){let V=W.depthTexture;V&&V.isDepthTexture&&(V.type===Ti?We=36012:V.type===Ao&&(We=33190));let Oe=Ze(W);Qe(W)?d.renderbufferStorageMultisampleEXT(36161,Oe,We,W.width,W.height):e.renderbufferStorageMultisample(36161,Oe,We,W.width,W.height)}else e.renderbufferStorage(36161,We,W.width,W.height);e.framebufferRenderbuffer(36160,36096,36161,ee)}else if(W.depthBuffer&&W.stencilBuffer){let We=Ze(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,We,35056,W.width,W.height):Qe(W)?d.renderbufferStorageMultisampleEXT(36161,We,35056,W.width,W.height):e.renderbufferStorage(36161,34041,W.width,W.height),e.framebufferRenderbuffer(36160,33306,36161,ee)}else{let We=W.isWebGLMultipleRenderTargets===!0?W.texture:[W.texture];for(let V=0;V<We.length;V++){let Oe=We[V],ut=a.convert(Oe.format,Oe.encoding),He=a.convert(Oe.type),ze=A(Oe.internalFormat,ut,He,Oe.encoding),ke=Ze(W);_e&&Qe(W)===!1?e.renderbufferStorageMultisample(36161,ke,ze,W.width,W.height):Qe(W)?d.renderbufferStorageMultisampleEXT(36161,ke,ze,W.width,W.height):e.renderbufferStorage(36161,ze,W.width,W.height)}}e.bindRenderbuffer(36161,null)}function Ie(ee,W){if(W&&W.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,ee),!(W.depthTexture&&W.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(W.depthTexture).__webglTexture||W.depthTexture.image.width!==W.width||W.depthTexture.image.height!==W.height)&&(W.depthTexture.image.width=W.width,W.depthTexture.image.height=W.height,W.depthTexture.needsUpdate=!0),le(W.depthTexture,0);let _e=r.get(W.depthTexture).__webglTexture,We=Ze(W);if(W.depthTexture.format===bh)Qe(W)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,_e,0,We):e.framebufferTexture2D(36160,36096,3553,_e,0);else if(W.depthTexture.format===Ch)Qe(W)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,_e,0,We):e.framebufferTexture2D(36160,33306,3553,_e,0);else throw new Error("Unknown depthTexture format")}function Ce(ee){let W=r.get(ee),_e=ee.isWebGLCubeRenderTarget===!0;if(ee.depthTexture&&!W.__autoAllocateDepthBuffer){if(_e)throw new Error("target.depthTexture not supported in Cube render targets");Ie(W.__webglFramebuffer,ee)}else if(_e){W.__webglDepthbuffer=[];for(let We=0;We<6;We++)i.bindFramebuffer(36160,W.__webglFramebuffer[We]),W.__webglDepthbuffer[We]=e.createRenderbuffer(),Ve(W.__webglDepthbuffer[We],ee,!1)}else i.bindFramebuffer(36160,W.__webglFramebuffer),W.__webglDepthbuffer=e.createRenderbuffer(),Ve(W.__webglDepthbuffer,ee,!1);i.bindFramebuffer(36160,null)}function it(ee,W,_e){let We=r.get(ee);W!==void 0&&ye(We.__webglFramebuffer,ee,ee.texture,36064,3553),_e!==void 0&&Ce(ee)}function Je(ee){let W=ee.texture,_e=r.get(ee),We=r.get(W);ee.addEventListener("dispose",z),ee.isWebGLMultipleRenderTargets!==!0&&(We.__webglTexture===void 0&&(We.__webglTexture=e.createTexture()),We.__version=W.version,n.memory.textures++);let V=ee.isWebGLCubeRenderTarget===!0,Oe=ee.isWebGLMultipleRenderTargets===!0,ut=_(ee)||o;if(V){_e.__webglFramebuffer=[];for(let He=0;He<6;He++)_e.__webglFramebuffer[He]=e.createFramebuffer()}else{if(_e.__webglFramebuffer=e.createFramebuffer(),Oe)if(s.drawBuffers){let He=ee.texture;for(let ze=0,ke=He.length;ze<ke;ze++){let dt=r.get(He[ze]);dt.__webglTexture===void 0&&(dt.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&ee.samples>0&&Qe(ee)===!1){let He=Oe?W:[W];_e.__webglMultisampledFramebuffer=e.createFramebuffer(),_e.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,_e.__webglMultisampledFramebuffer);for(let ze=0;ze<He.length;ze++){let ke=He[ze];_e.__webglColorRenderbuffer[ze]=e.createRenderbuffer(),e.bindRenderbuffer(36161,_e.__webglColorRenderbuffer[ze]);let dt=a.convert(ke.format,ke.encoding),ot=a.convert(ke.type),_t=A(ke.internalFormat,dt,ot,ke.encoding,ee.isXRRenderTarget===!0),bt=Ze(ee);e.renderbufferStorageMultisample(36161,bt,_t,ee.width,ee.height),e.framebufferRenderbuffer(36160,36064+ze,36161,_e.__webglColorRenderbuffer[ze])}e.bindRenderbuffer(36161,null),ee.depthBuffer&&(_e.__webglDepthRenderbuffer=e.createRenderbuffer(),Ve(_e.__webglDepthRenderbuffer,ee,!0)),i.bindFramebuffer(36160,null)}}if(V){i.bindTexture(34067,We.__webglTexture),ae(34067,W,ut);for(let He=0;He<6;He++)ye(_e.__webglFramebuffer[He],ee,W,36064,34069+He);S(W,ut)&&E(34067),i.unbindTexture()}else if(Oe){let He=ee.texture;for(let ze=0,ke=He.length;ze<ke;ze++){let dt=He[ze],ot=r.get(dt);i.bindTexture(3553,ot.__webglTexture),ae(3553,dt,ut),ye(_e.__webglFramebuffer,ee,dt,36064+ze,3553),S(dt,ut)&&E(3553)}i.unbindTexture()}else{let He=3553;(ee.isWebGL3DRenderTarget||ee.isWebGLArrayRenderTarget)&&(o?He=ee.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(He,We.__webglTexture),ae(He,W,ut),ye(_e.__webglFramebuffer,ee,W,36064,He),S(W,ut)&&E(He),i.unbindTexture()}ee.depthBuffer&&Ce(ee)}function st(ee){let W=_(ee)||o,_e=ee.isWebGLMultipleRenderTargets===!0?ee.texture:[ee.texture];for(let We=0,V=_e.length;We<V;We++){let Oe=_e[We];if(S(Oe,W)){let ut=ee.isWebGLCubeRenderTarget?34067:3553,He=r.get(Oe).__webglTexture;i.bindTexture(ut,He),E(ut),i.unbindTexture()}}}function nt(ee){if(o&&ee.samples>0&&Qe(ee)===!1){let W=ee.isWebGLMultipleRenderTargets?ee.texture:[ee.texture],_e=ee.width,We=ee.height,V=16384,Oe=[],ut=ee.stencilBuffer?33306:36096,He=r.get(ee),ze=ee.isWebGLMultipleRenderTargets===!0;if(ze)for(let ke=0;ke<W.length;ke++)i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+ke,36161,null),i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+ke,3553,null,0);i.bindFramebuffer(36008,He.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,He.__webglFramebuffer);for(let ke=0;ke<W.length;ke++){Oe.push(36064+ke),ee.depthBuffer&&Oe.push(ut);let dt=He.__ignoreDepthValues!==void 0?He.__ignoreDepthValues:!1;if(dt===!1&&(ee.depthBuffer&&(V|=256),ee.stencilBuffer&&(V|=1024)),ze&&e.framebufferRenderbuffer(36008,36064,36161,He.__webglColorRenderbuffer[ke]),dt===!0&&(e.invalidateFramebuffer(36008,[ut]),e.invalidateFramebuffer(36009,[ut])),ze){let ot=r.get(W[ke]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,ot,0)}e.blitFramebuffer(0,0,_e,We,0,0,_e,We,V,9728),p&&e.invalidateFramebuffer(36008,Oe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ze)for(let ke=0;ke<W.length;ke++){i.bindFramebuffer(36160,He.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+ke,36161,He.__webglColorRenderbuffer[ke]);let dt=r.get(W[ke]).__webglTexture;i.bindFramebuffer(36160,He.__webglFramebuffer),e.framebufferTexture2D(36009,36064+ke,3553,dt,0)}i.bindFramebuffer(36009,He.__webglMultisampledFramebuffer)}}function Ze(ee){return Math.min(u,ee.samples)}function Qe(ee){let W=r.get(ee);return o&&ee.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&W.__useRenderToTexture!==!1}function pt(ee){let W=n.render.frame;f.get(ee)!==W&&(f.set(ee,W),ee.update())}function wt(ee,W){let _e=ee.encoding,We=ee.format,V=ee.type;return ee.isCompressedTexture===!0||ee.isVideoTexture===!0||ee.format===fy||_e!==tn&&(_e===Gt?o===!1?t.has("EXT_sRGB")===!0&&We===qi?(ee.format=fy,ee.minFilter=Xt,ee.generateMipmaps=!1):W=W3.sRGBToLinear(W):(We!==qi||V!==As)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",_e)),W}this.allocateTextureUnit=X,this.resetTextureUnits=Z,this.setTexture2D=le,this.setTexture2DArray=te,this.setTexture3D=ie,this.setTextureCube=fe,this.rebindTextures=it,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=nt,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=Qe}function P6(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===As)return 5121;if(a===dz)return 32819;if(a===pz)return 32820;if(a===hz)return 5120;if(a===cz)return 5122;if(a===F3)return 5123;if(a===uz)return 5124;if(a===Ao)return 5125;if(a===Ti)return 5126;if(a===Oo)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===fz)return 6406;if(a===qi)return 6408;if(a===mz)return 6409;if(a===gz)return 6410;if(a===bh)return 6402;if(a===Ch)return 34041;if(a===fy)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===Rm)return 6403;if(a===vz)return 36244;if(a===Zm)return 33319;if(a===yz)return 33320;if(a===k3)return 36249;if(a===r0||a===s0||a===a0||a===n0)if(n===Gt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===r0)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===s0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===a0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===n0)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===r0)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===s0)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===a0)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===n0)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===E2||a===C2||a===T2||a===P2)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===E2)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===C2)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===T2)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===P2)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===xz)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===D2||a===I2)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===D2)return n===Gt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===I2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===O2||a===R2||a===L2||a===B2||a===z2||a===F2||a===k2||a===U2||a===N2||a===V2||a===j2||a===H2||a===G2||a===W2)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===O2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===R2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===L2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===B2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===z2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===F2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===k2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===U2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===N2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===V2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===j2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===H2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===G2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===W2)return n===Gt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===o0)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===o0)return n===Gt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===bz||a===q2||a===X2||a===Y2)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===o0)return o.COMPRESSED_RED_RGTC1_EXT;if(a===q2)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===X2)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===Y2)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===xh?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var D6=class extends bs{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Eo=class extends Mi{constructor(){super(),this.isGroup=!0,this.type="Group"}},I6={type:"move"},R0=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Eo,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 Eo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new I,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new I),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Eo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new I,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new I),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],c=l.joints["thumb-tip"],u=h.position.distanceTo(c.position),d=.02,p=.005;l.inputState.pinching&&u>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(I6)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Eo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},ou=class extends Ji{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:bh,h!==bh&&h!==Ch)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===bh&&(i=Ao),i===void 0&&h===Ch&&(i=xh),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:$t,this.minFilter=o!==void 0?o:$t,this.flipY=!1,this.generateMipmaps=!1}},O6=class extends gs{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=t.getContextAttributes(),g=null,m=null,y=[],x=[],b=new Set,_=new Map,M=new bs;M.layers.enable(1),M.viewport=new zt;let S=new bs;S.layers.enable(2),S.viewport=new zt;let E=[M,S],A=new D6;A.layers.enable(1),A.layers.enable(2);let T=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let ie=y[te];return ie===void 0&&(ie=new R0,y[te]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(te){let ie=y[te];return ie===void 0&&(ie=new R0,y[te]=ie),ie.getGripSpace()},this.getHand=function(te){let ie=y[te];return ie===void 0&&(ie=new R0,y[te]=ie),ie.getHandSpace()};function R(te){let ie=x.indexOf(te.inputSource);if(ie===-1)return;let fe=y[ie];fe!==void 0&&fe.dispatchEvent({type:te.type,data:te.inputSource})}function z(){r.removeEventListener("select",R),r.removeEventListener("selectstart",R),r.removeEventListener("selectend",R),r.removeEventListener("squeeze",R),r.removeEventListener("squeezestart",R),r.removeEventListener("squeezeend",R),r.removeEventListener("end",z),r.removeEventListener("inputsourceschange",U);for(let te=0;te<y.length;te++){let ie=x[te];ie!==null&&(x[te]=null,y[te].disconnect(ie))}T=null,P=null,e.setRenderTarget(g),d=null,u=null,c=null,r=null,m=null,le.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){s=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){n=te,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(te){l=te},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(te){if(r=te,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",R),r.addEventListener("selectstart",R),r.addEventListener("selectend",R),r.addEventListener("squeeze",R),r.addEventListener("squeezestart",R),r.addEventListener("squeezeend",R),r.addEventListener("end",z),r.addEventListener("inputsourceschange",U),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let ie={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,ie),r.updateRenderState({baseLayer:d}),m=new hi(d.framebufferWidth,d.framebufferHeight,{format:qi,type:As,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let ie=null,fe=null,ce=null;f.depth&&(ce=f.stencil?35056:33190,ie=f.stencil?Ch:bh,fe=f.stencil?xh:Ao);let ue={colorFormat:32856,depthFormat:ce,scaleFactor:s};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(ue),r.updateRenderState({layers:[u]}),m=new hi(u.textureWidth,u.textureHeight,{format:qi,type:As,depthTexture:new ou(u.textureWidth,u.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let ae=e.properties.get(m);ae.__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),le.setContext(r),le.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function U(te){for(let ie=0;ie<te.removed.length;ie++){let fe=te.removed[ie],ce=x.indexOf(fe);ce>=0&&(x[ce]=null,y[ce].disconnect(fe))}for(let ie=0;ie<te.added.length;ie++){let fe=te.added[ie],ce=x.indexOf(fe);if(ce===-1){for(let ae=0;ae<y.length;ae++)if(ae>=x.length){x.push(fe),ce=ae;break}else if(x[ae]===null){x[ae]=fe,ce=ae;break}if(ce===-1)break}let ue=y[ce];ue&&ue.connect(fe)}}let L=new I,H=new I;function q(te,ie,fe){L.setFromMatrixPosition(ie.matrixWorld),H.setFromMatrixPosition(fe.matrixWorld);let ce=L.distanceTo(H),ue=ie.projectionMatrix.elements,ae=fe.projectionMatrix.elements,Pe=ue[14]/(ue[10]-1),ve=ue[14]/(ue[10]+1),Ae=(ue[9]+1)/ue[5],ye=(ue[9]-1)/ue[5],Ve=(ue[8]-1)/ue[0],Ie=(ae[8]+1)/ae[0],Ce=Pe*Ve,it=Pe*Ie,Je=ce/(-Ve+Ie),st=Je*-Ve;ie.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(st),te.translateZ(Je),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();let nt=Pe+Je,Ze=ve+Je,Qe=Ce-st,pt=it+(ce-st),wt=Ae*ve/Ze*nt,ee=ye*ve/Ze*nt;te.projectionMatrix.makePerspective(Qe,pt,wt,ee,nt,Ze)}function Z(te,ie){ie===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(ie.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(r===null)return;A.near=S.near=M.near=te.near,A.far=S.far=M.far=te.far,(T!==A.near||P!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),T=A.near,P=A.far);let ie=te.parent,fe=A.cameras;Z(A,ie);for(let ue=0;ue<fe.length;ue++)Z(fe[ue],ie);A.matrixWorld.decompose(A.position,A.quaternion,A.scale),te.matrix.copy(A.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale);let ce=te.children;for(let ue=0,ae=ce.length;ue<ae;ue++)ce[ue].updateMatrixWorld(!0);fe.length===2?q(A,M,S):A.projectionMatrix.copy(M.projectionMatrix)},this.getCamera=function(){return A},this.getFoveation=function(){if(!(u===null&&d===null))return o},this.setFoveation=function(te){o=te,u!==null&&(u.fixedFoveation=te),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=te)},this.getPlanes=function(){return b};let X=null;function se(te,ie){if(h=ie.getViewerPose(l||a),p=ie,h!==null){let fe=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let ce=!1;fe.length!==A.cameras.length&&(A.cameras.length=0,ce=!0);for(let ue=0;ue<fe.length;ue++){let ae=fe[ue],Pe=null;if(d!==null)Pe=d.getViewport(ae);else{let Ae=c.getViewSubImage(u,ae);Pe=Ae.viewport,ue===0&&(e.setRenderTargetTextures(m,Ae.colorTexture,u.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(m))}let ve=E[ue];ve===void 0&&(ve=new bs,ve.layers.enable(ue),ve.viewport=new zt,E[ue]=ve),ve.matrix.fromArray(ae.transform.matrix),ve.projectionMatrix.fromArray(ae.projectionMatrix),ve.viewport.set(Pe.x,Pe.y,Pe.width,Pe.height),ue===0&&A.matrix.copy(ve.matrix),ce===!0&&A.cameras.push(ve)}}for(let fe=0;fe<y.length;fe++){let ce=x[fe],ue=y[fe];ce!==null&&ue!==void 0&&ue.update(ce,ie,l||a)}if(X&&X(te,ie),ie.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:ie.detectedPlanes});let fe=null;for(let ce of b)ie.detectedPlanes.has(ce)||(fe===null&&(fe=[]),fe.push(ce));if(fe!==null)for(let ce of fe)b.delete(ce),_.delete(ce),i.dispatchEvent({type:"planeremoved",data:ce});for(let ce of ie.detectedPlanes)if(!b.has(ce))b.add(ce),_.set(ce,ie.lastChangedTime),i.dispatchEvent({type:"planeadded",data:ce});else{let ue=_.get(ce);ce.lastChangedTime>ue&&(_.set(ce,ce.lastChangedTime),i.dispatchEvent({type:"planechanged",data:ce}))}}p=null}let le=new K3;le.setAnimationLoop(se),this.setAnimationLoop=function(te){X=te},this.dispose=function(){}}};function R6(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,Z3(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,y,x,b){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),c(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),u(g,m),m.isMeshPhysicalMaterial&&d(g,m,b)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&n(g,m)):m.isPointsMaterial?o(g,m,y,x):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===$r&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===$r&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let y=t.get(m).envMap;if(y&&(g.envMap.value=y,g.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let _=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*_}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let x;m.map?x=m.map:m.specularMap?x=m.specularMap:m.displacementMap?x=m.displacementMap:m.normalMap?x=m.normalMap:m.bumpMap?x=m.bumpMap:m.roughnessMap?x=m.roughnessMap:m.metalnessMap?x=m.metalnessMap:m.alphaMap?x=m.alphaMap:m.emissiveMap?x=m.emissiveMap:m.clearcoatMap?x=m.clearcoatMap:m.clearcoatNormalMap?x=m.clearcoatNormalMap:m.clearcoatRoughnessMap?x=m.clearcoatRoughnessMap:m.iridescenceMap?x=m.iridescenceMap:m.iridescenceThicknessMap?x=m.iridescenceThicknessMap:m.specularIntensityMap?x=m.specularIntensityMap:m.specularColorMap?x=m.specularColorMap:m.transmissionMap?x=m.transmissionMap:m.thicknessMap?x=m.thicknessMap:m.sheenColorMap?x=m.sheenColorMap:m.sheenRoughnessMap&&(x=m.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix));let b;m.aoMap?b=m.aoMap:m.lightMap&&(b=m.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uv2Transform.value.copy(b.matrix))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function n(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,y,x){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=x*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let b;m.map?b=m.map:m.alphaMap&&(b=m.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uvTransform.value.copy(b.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let y;m.map?y=m.map:m.alphaMap&&(y=m.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function c(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function u(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===$r&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function L6(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(x,b){let _=b.program;r.uniformBlockBinding(x,_)}function h(x,b){let _=s[x.id];_===void 0&&(f(x),_=c(x),s[x.id]=_,x.addEventListener("dispose",m));let M=b.program;r.updateUBOMapping(x,M);let S=t.render.frame;a[x.id]!==S&&(d(x),a[x.id]=S)}function c(x){let b=u();x.__bindingPointIndex=b;let _=e.createBuffer(),M=x.__size,S=x.usage;return e.bindBuffer(35345,_),e.bufferData(35345,M,S),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,_),_}function u(){for(let x=0;x<o;x++)if(n.indexOf(x)===-1)return n.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){let b=s[x.id],_=x.uniforms,M=x.__cache;e.bindBuffer(35345,b);for(let S=0,E=_.length;S<E;S++){let A=_[S];if(p(A,S,M)===!0){let T=A.__offset,P=Array.isArray(A.value)?A.value:[A.value],R=0;for(let z=0;z<P.length;z++){let U=P[z],L=g(U);typeof U=="number"?(A.__data[0]=U,e.bufferSubData(35345,T+R,A.__data)):U.isMatrix3?(A.__data[0]=U.elements[0],A.__data[1]=U.elements[1],A.__data[2]=U.elements[2],A.__data[3]=U.elements[0],A.__data[4]=U.elements[3],A.__data[5]=U.elements[4],A.__data[6]=U.elements[5],A.__data[7]=U.elements[0],A.__data[8]=U.elements[6],A.__data[9]=U.elements[7],A.__data[10]=U.elements[8],A.__data[11]=U.elements[0]):(U.toArray(A.__data,R),R+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,T,A.__data)}}e.bindBuffer(35345,null)}function p(x,b,_){let M=x.value;if(_[b]===void 0){if(typeof M=="number")_[b]=M;else{let S=Array.isArray(M)?M:[M],E=[];for(let A=0;A<S.length;A++)E.push(S[A].clone());_[b]=E}return!0}else if(typeof M=="number"){if(_[b]!==M)return _[b]=M,!0}else{let S=Array.isArray(_[b])?_[b]:[_[b]],E=Array.isArray(M)?M:[M];for(let A=0;A<S.length;A++){let T=S[A];if(T.equals(E[A])===!1)return T.copy(E[A]),!0}}return!1}function f(x){let b=x.uniforms,_=0,M=16,S=0;for(let E=0,A=b.length;E<A;E++){let T=b[E],P={boundary:0,storage:0},R=Array.isArray(T.value)?T.value:[T.value];for(let z=0,U=R.length;z<U;z++){let L=R[z],H=g(L);P.boundary+=H.boundary,P.storage+=H.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=_,E>0){S=_%M;let z=M-S;S!==0&&z-P.boundary<0&&(_+=M-S,T.__offset=_)}_+=P.storage}return S=_%M,S>0&&(_+=M-S),x.__size=_,x.__cache={},this}function g(x){let b={boundary:0,storage:0};return typeof x=="number"?(b.boundary=4,b.storage=4):x.isVector2?(b.boundary=8,b.storage=8):x.isVector3||x.isColor?(b.boundary=16,b.storage=12):x.isVector4?(b.boundary=16,b.storage=16):x.isMatrix3?(b.boundary=48,b.storage=48):x.isMatrix4?(b.boundary=64,b.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),b}function m(x){let b=x.target;b.removeEventListener("dispose",m);let _=n.indexOf(b.__bindingPointIndex);n.splice(_,1),e.deleteBuffer(s[b.id]),delete s[b.id],delete a[b.id]}function y(){for(let x in s)e.deleteBuffer(s[x]);n=[],s={},a={}}return{bind:l,update:h,dispose:y}}function B6(){let e=sp("canvas");return e.style.display="block",e}function rT(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:B6(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,c;i!==null?c=i.getContextAttributes().alpha:c=e.alpha!==void 0?e.alpha:!1;let u=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=tn,this.physicallyCorrectLights=!1,this.toneMapping=Ln,this.toneMappingExposure=1;let g=this,m=!1,y=0,x=0,b=null,_=-1,M=null,S=new zt,E=new zt,A=null,T=t.width,P=t.height,R=1,z=null,U=null,L=new zt(0,0,T,P),H=new zt(0,0,T,P),q=!1,Z=new _b,X=!1,se=!1,le=null,te=new je,ie=new re,fe=new I,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ue(){return b===null?R:1}let ae=i;function Pe(J,Se){for(let Te=0;Te<J.length;Te++){let be=J[Te],Be=t.getContext(be,Se);if(Be!==null)return Be}return null}try{let J={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${bu}`),t.addEventListener("webglcontextlost",_t,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",ri,!1),ae===null){let Se=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&Se.shift(),ae=Pe(Se,J),ae===null)throw Pe(Se)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ae.getShaderPrecisionFormat===void 0&&(ae.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let ve,Ae,ye,Ve,Ie,Ce,it,Je,st,nt,Ze,Qe,pt,wt,ee,W,_e,We,V,Oe,ut,He,ze,ke;function dt(){ve=new Yk(ae),Ae=new jk(ae,ve,e),ve.init(Ae),He=new P6(ae,ve,Ae),ye=new C6(ae,ve,Ae),Ve=new Kk,Ie=new f6,Ce=new T6(ae,ve,ye,Ie,Ae,He,Ve),it=new Gk(g),Je=new Xk(g),st=new n5(ae,Ae),ze=new Nk(ae,ve,st,Ae),nt=new Qk(ae,st,Ve,ze),Ze=new tU(ae,nt,st,Ve),V=new eU(ae,Ae,Ce),W=new Hk(Ie),Qe=new p6(g,it,Je,ve,Ae,ze,W),pt=new R6(g,Ie),wt=new g6,ee=new _6(ve,Ae),We=new Uk(g,it,Je,ye,Ze,c,n),_e=new E6(g,Ze,Ae),ke=new L6(ae,Ve,Ae,ye),Oe=new Vk(ae,ve,Ve,Ae),ut=new Zk(ae,ve,Ve,Ae),Ve.programs=Qe.programs,g.capabilities=Ae,g.extensions=ve,g.properties=Ie,g.renderLists=wt,g.shadowMap=_e,g.state=ye,g.info=Ve}dt();let ot=new O6(g,ae);this.xr=ot,this.getContext=function(){return ae},this.getContextAttributes=function(){return ae.getContextAttributes()},this.forceContextLoss=function(){let J=ve.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){let J=ve.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(J){J!==void 0&&(R=J,this.setSize(T,P,!1))},this.getSize=function(J){return J.set(T,P)},this.setSize=function(J,Se,Te){if(ot.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=J,P=Se,t.width=Math.floor(J*R),t.height=Math.floor(Se*R),Te!==!1&&(t.style.width=J+"px",t.style.height=Se+"px"),this.setViewport(0,0,J,Se)},this.getDrawingBufferSize=function(J){return J.set(T*R,P*R).floor()},this.setDrawingBufferSize=function(J,Se,Te){T=J,P=Se,R=Te,t.width=Math.floor(J*Te),t.height=Math.floor(Se*Te),this.setViewport(0,0,J,Se)},this.getCurrentViewport=function(J){return J.copy(S)},this.getViewport=function(J){return J.copy(L)},this.setViewport=function(J,Se,Te,be){J.isVector4?L.set(J.x,J.y,J.z,J.w):L.set(J,Se,Te,be),ye.viewport(S.copy(L).multiplyScalar(R).floor())},this.getScissor=function(J){return J.copy(H)},this.setScissor=function(J,Se,Te,be){J.isVector4?H.set(J.x,J.y,J.z,J.w):H.set(J,Se,Te,be),ye.scissor(E.copy(H).multiplyScalar(R).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(J){ye.setScissorTest(q=J)},this.setOpaqueSort=function(J){z=J},this.setTransparentSort=function(J){U=J},this.getClearColor=function(J){return J.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor.apply(We,arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha.apply(We,arguments)},this.clear=function(J=!0,Se=!0,Te=!0){let be=0;J&&(be|=16384),Se&&(be|=256),Te&&(be|=1024),ae.clear(be)},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",_t,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",ri,!1),wt.dispose(),ee.dispose(),Ie.dispose(),it.dispose(),Je.dispose(),Ze.dispose(),ze.dispose(),ke.dispose(),Qe.dispose(),ot.dispose(),ot.removeEventListener("sessionstart",Ke),ot.removeEventListener("sessionend",vt),le&&(le.dispose(),le=null),Mt.stop()};function _t(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function bt(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let J=Ve.autoReset,Se=_e.enabled,Te=_e.autoUpdate,be=_e.needsUpdate,Be=_e.type;dt(),Ve.autoReset=J,_e.enabled=Se,_e.autoUpdate=Te,_e.needsUpdate=be,_e.type=Be}function ri(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function vi(J){let Se=J.target;Se.removeEventListener("dispose",vi),ii(Se)}function ii(J){me(J),Ie.remove(J)}function me(J){let Se=Ie.get(J).programs;Se!==void 0&&(Se.forEach(function(Te){Qe.releaseProgram(Te)}),J.isShaderMaterial&&Qe.releaseShaderCache(J))}this.renderBufferDirect=function(J,Se,Te,be,Be,rt){Se===null&&(Se=ce);let Bt=Be.isMesh&&Be.matrixWorld.determinant()<0,kt=ju(J,Se,Te,be,Be);ye.setMaterial(be,Bt);let Ft=Te.index,oi=1;be.wireframe===!0&&(Ft=nt.getWireframeAttribute(Te),oi=2);let Kt=Te.drawRange,Vt=Te.attributes.position,gi=Kt.start*oi,$i=(Kt.start+Kt.count)*oi;rt!==null&&(gi=Math.max(gi,rt.start*oi),$i=Math.min($i,(rt.start+rt.count)*oi)),Ft!==null?(gi=Math.max(gi,0),$i=Math.min($i,Ft.count)):Vt!=null&&(gi=Math.max(gi,0),$i=Math.min($i,Vt.count));let Wi=$i-gi;if(Wi<0||Wi===1/0)return;ze.setup(Be,be,kt,Te,Ft);let er,Fi=Oe;if(Ft!==null&&(er=st.get(Ft),Fi=ut,Fi.setIndex(er)),Be.isMesh)be.wireframe===!0?(ye.setLineWidth(be.wireframeLinewidth*ue()),Fi.setMode(1)):Fi.setMode(4);else if(Be.isLine){let St=be.linewidth;St===void 0&&(St=1),ye.setLineWidth(St*ue()),Be.isLineSegments?Fi.setMode(1):Be.isLineLoop?Fi.setMode(2):Fi.setMode(3)}else Be.isPoints?Fi.setMode(0):Be.isSprite&&Fi.setMode(4);if(Be.isInstancedMesh)Fi.renderInstances(gi,Wi,Be.count);else if(Te.isInstancedBufferGeometry){let St=Te._maxInstanceCount!==void 0?Te._maxInstanceCount:1/0,on=Math.min(Te.instanceCount,St);Fi.renderInstances(gi,Wi,on)}else Fi.render(gi,Wi)},this.compile=function(J,Se){function Te(be,Be,rt){be.transparent===!0&&be.side===_s&&be.forceSinglePass===!1?(be.side=$r,be.needsUpdate=!0,Pr(be,Be,rt),be.side=en,be.needsUpdate=!0,Pr(be,Be,rt),be.side=_s):Pr(be,Be,rt)}d=ee.get(J),d.init(),f.push(d),J.traverseVisible(function(be){be.isLight&&be.layers.test(Se.layers)&&(d.pushLight(be),be.castShadow&&d.pushShadow(be))}),d.setupLights(g.physicallyCorrectLights),J.traverse(function(be){let Be=be.material;if(Be)if(Array.isArray(Be))for(let rt=0;rt<Be.length;rt++){let Bt=Be[rt];Te(Bt,J,be)}else Te(Be,J,be)}),f.pop(),d=null};let Ee=null;function Xe(J){Ee&&Ee(J)}function Ke(){Mt.stop()}function vt(){Mt.start()}let Mt=new K3;Mt.setAnimationLoop(Xe),typeof self<"u"&&Mt.setContext(self),this.setAnimationLoop=function(J){Ee=J,ot.setAnimationLoop(J),J===null?Mt.stop():Mt.start()},ot.addEventListener("sessionstart",Ke),ot.addEventListener("sessionend",vt),this.render=function(J,Se){if(Se!==void 0&&Se.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Se.parent===null&&Se.matrixWorldAutoUpdate===!0&&Se.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(Se),Se=ot.getCamera()),J.isScene===!0&&J.onBeforeRender(g,J,Se,b),d=ee.get(J,f.length),d.init(),f.push(d),te.multiplyMatrices(Se.projectionMatrix,Se.matrixWorldInverse),Z.setFromProjectionMatrix(te),se=this.localClippingEnabled,X=W.init(this.clippingPlanes,se),u=wt.get(J,p.length),u.init(),p.push(u),wi(J,Se,0,g.sortObjects),u.finish(),g.sortObjects===!0&&u.sort(z,U),X===!0&&W.beginShadows();let Te=d.state.shadowsArray;if(_e.render(Te,J,Se),X===!0&&W.endShadows(),this.info.autoReset===!0&&this.info.reset(),We.render(u,J),d.setupLights(g.physicallyCorrectLights),Se.isArrayCamera){let be=Se.cameras;for(let Be=0,rt=be.length;Be<rt;Be++){let Bt=be[Be];ji(u,J,Bt,Bt.viewport)}}else ji(u,J,Se);b!==null&&(Ce.updateMultisampleRenderTarget(b),Ce.updateRenderTargetMipmap(b)),J.isScene===!0&&J.onAfterRender(g,J,Se),ze.resetDefaultState(),_=-1,M=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?u=p[p.length-1]:u=null};function wi(J,Se,Te,be){if(J.visible===!1)return;if(J.layers.test(Se.layers)){if(J.isGroup)Te=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(Se);else if(J.isLight)d.pushLight(J),J.castShadow&&d.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||Z.intersectsSprite(J)){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let rt=Ze.update(J),Bt=J.material;Bt.visible&&u.push(J,rt,Bt,Te,fe.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(J.isSkinnedMesh&&J.skeleton.frame!==Ve.render.frame&&(J.skeleton.update(),J.skeleton.frame=Ve.render.frame),!J.frustumCulled||Z.intersectsObject(J))){be&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(te);let rt=Ze.update(J),Bt=J.material;if(Array.isArray(Bt)){let kt=rt.groups;for(let Ft=0,oi=kt.length;Ft<oi;Ft++){let Kt=kt[Ft],Vt=Bt[Kt.materialIndex];Vt&&Vt.visible&&u.push(J,rt,Vt,Te,fe.z,Kt)}}else Bt.visible&&u.push(J,rt,Bt,Te,fe.z,null)}}let Be=J.children;for(let rt=0,Bt=Be.length;rt<Bt;rt++)wi(Be[rt],Se,Te,be)}function ji(J,Se,Te,be){let Be=J.opaque,rt=J.transmissive,Bt=J.transparent;d.setupLightsView(Te),X===!0&&W.setGlobalState(g.clippingPlanes,Te),rt.length>0&&Tr(Be,Se,Te),be&&ye.viewport(S.copy(be)),Be.length>0&&Ei(Be,Se,Te),rt.length>0&&Ei(rt,Se,Te),Bt.length>0&&Ei(Bt,Se,Te),ye.buffers.depth.setTest(!0),ye.buffers.depth.setMask(!0),ye.buffers.color.setMask(!0),ye.setPolygonOffset(!1)}function Tr(J,Se,Te){let be=Ae.isWebGL2;le===null&&(le=new hi(1,1,{generateMipmaps:!0,type:ve.has("EXT_color_buffer_half_float")?Oo:As,minFilter:au,samples:be&&a===!0?4:0})),g.getDrawingBufferSize(ie),be?le.setSize(ie.x,ie.y):le.setSize(tg(ie.x),tg(ie.y));let Be=g.getRenderTarget();g.setRenderTarget(le),g.clear();let rt=g.toneMapping;g.toneMapping=Ln,Ei(J,Se,Te),g.toneMapping=rt,Ce.updateMultisampleRenderTarget(le),Ce.updateRenderTargetMipmap(le),g.setRenderTarget(Be)}function Ei(J,Se,Te){let be=Se.isScene===!0?Se.overrideMaterial:null;for(let Be=0,rt=J.length;Be<rt;Be++){let Bt=J[Be],kt=Bt.object,Ft=Bt.geometry,oi=be===null?Bt.material:be,Kt=Bt.group;kt.layers.test(Te.layers)&&ss(kt,Se,Te,Ft,oi,Kt)}}function ss(J,Se,Te,be,Be,rt){J.onBeforeRender(g,Se,Te,be,Be,rt),J.modelViewMatrix.multiplyMatrices(Te.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),Be.onBeforeRender(g,Se,Te,be,J,rt),Be.transparent===!0&&Be.side===_s&&Be.forceSinglePass===!1?(Be.side=$r,Be.needsUpdate=!0,g.renderBufferDirect(Te,Se,be,Be,J,rt),Be.side=en,Be.needsUpdate=!0,g.renderBufferDirect(Te,Se,be,Be,J,rt),Be.side=_s):g.renderBufferDirect(Te,Se,be,Be,J,rt),J.onAfterRender(g,Se,Te,be,Be,rt)}function Pr(J,Se,Te){Se.isScene!==!0&&(Se=ce);let be=Ie.get(J),Be=d.state.lights,rt=d.state.shadowsArray,Bt=Be.state.version,kt=Qe.getParameters(J,Be.state,rt,Se,Te),Ft=Qe.getProgramCacheKey(kt),oi=be.programs;be.environment=J.isMeshStandardMaterial?Se.environment:null,be.fog=Se.fog,be.envMap=(J.isMeshStandardMaterial?Je:it).get(J.envMap||be.environment),oi===void 0&&(J.addEventListener("dispose",vi),oi=new Map,be.programs=oi);let Kt=oi.get(Ft);if(Kt!==void 0){if(be.currentProgram===Kt&&be.lightsStateVersion===Bt)return No(J,kt),Kt}else kt.uniforms=Qe.getUniforms(J),J.onBuild(Te,kt,g),J.onBeforeCompile(kt,g),Kt=Qe.acquireProgram(kt,Ft),oi.set(Ft,Kt),be.uniforms=kt.uniforms;let Vt=be.uniforms;(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(Vt.clippingPlanes=W.uniform),No(J,kt),be.needsLights=Wh(J),be.lightsStateVersion=Bt,be.needsLights&&(Vt.ambientLightColor.value=Be.state.ambient,Vt.lightProbe.value=Be.state.probe,Vt.directionalLights.value=Be.state.directional,Vt.directionalLightShadows.value=Be.state.directionalShadow,Vt.spotLights.value=Be.state.spot,Vt.spotLightShadows.value=Be.state.spotShadow,Vt.rectAreaLights.value=Be.state.rectArea,Vt.ltc_1.value=Be.state.rectAreaLTC1,Vt.ltc_2.value=Be.state.rectAreaLTC2,Vt.pointLights.value=Be.state.point,Vt.pointLightShadows.value=Be.state.pointShadow,Vt.hemisphereLights.value=Be.state.hemi,Vt.directionalShadowMap.value=Be.state.directionalShadowMap,Vt.directionalShadowMatrix.value=Be.state.directionalShadowMatrix,Vt.spotShadowMap.value=Be.state.spotShadowMap,Vt.spotLightMatrix.value=Be.state.spotLightMatrix,Vt.spotLightMap.value=Be.state.spotLightMap,Vt.pointShadowMap.value=Be.state.pointShadowMap,Vt.pointShadowMatrix.value=Be.state.pointShadowMatrix);let gi=Kt.getUniforms(),$i=Bm.seqWithValue(gi.seq,Vt);return be.currentProgram=Kt,be.uniformsList=$i,Kt}function No(J,Se){let Te=Ie.get(J);Te.outputEncoding=Se.outputEncoding,Te.instancing=Se.instancing,Te.skinning=Se.skinning,Te.morphTargets=Se.morphTargets,Te.morphNormals=Se.morphNormals,Te.morphColors=Se.morphColors,Te.morphTargetsCount=Se.morphTargetsCount,Te.numClippingPlanes=Se.numClippingPlanes,Te.numIntersection=Se.numClipIntersection,Te.vertexAlphas=Se.vertexAlphas,Te.vertexTangents=Se.vertexTangents,Te.toneMapping=Se.toneMapping}function ju(J,Se,Te,be,Be){Se.isScene!==!0&&(Se=ce),Ce.resetTextureUnits();let rt=Se.fog,Bt=be.isMeshStandardMaterial?Se.environment:null,kt=b===null?g.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:tn,Ft=(be.isMeshStandardMaterial?Je:it).get(be.envMap||Bt),oi=be.vertexColors===!0&&!!Te.attributes.color&&Te.attributes.color.itemSize===4,Kt=!!be.normalMap&&!!Te.attributes.tangent,Vt=!!Te.morphAttributes.position,gi=!!Te.morphAttributes.normal,$i=!!Te.morphAttributes.color,Wi=be.toneMapped?g.toneMapping:Ln,er=Te.morphAttributes.position||Te.morphAttributes.normal||Te.morphAttributes.color,Fi=er!==void 0?er.length:0,St=Ie.get(be),on=d.state.lights;if(X===!0&&(se===!0||J!==M)){let Xi=J===M&&be.id===_;W.setState(be,J,Xi)}let aa=!1;be.version===St.__version?(St.needsLights&&St.lightsStateVersion!==on.state.version||St.outputEncoding!==kt||Be.isInstancedMesh&&St.instancing===!1||!Be.isInstancedMesh&&St.instancing===!0||Be.isSkinnedMesh&&St.skinning===!1||!Be.isSkinnedMesh&&St.skinning===!0||St.envMap!==Ft||be.fog===!0&&St.fog!==rt||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==W.numPlanes||St.numIntersection!==W.numIntersection)||St.vertexAlphas!==oi||St.vertexTangents!==Kt||St.morphTargets!==Vt||St.morphNormals!==gi||St.morphColors!==$i||St.toneMapping!==Wi||Ae.isWebGL2===!0&&St.morphTargetsCount!==Fi)&&(aa=!0):(aa=!0,St.__version=be.version);let na=St.currentProgram;aa===!0&&(na=Pr(be,Se,Be));let ei=!1,vr=!1,qn=!1,or=na.getUniforms(),oa=St.uniforms;if(ye.useProgram(na.program)&&(ei=!0,vr=!0,qn=!0),be.id!==_&&(_=be.id,vr=!0),ei||M!==J){if(or.setValue(ae,"projectionMatrix",J.projectionMatrix),Ae.logarithmicDepthBuffer&&or.setValue(ae,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),M!==J&&(M=J,vr=!0,qn=!0),be.isShaderMaterial||be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshStandardMaterial||be.envMap){let Xi=or.map.cameraPosition;Xi!==void 0&&Xi.setValue(ae,fe.setFromMatrixPosition(J.matrixWorld))}(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial)&&or.setValue(ae,"isOrthographic",J.isOrthographicCamera===!0),(be.isMeshPhongMaterial||be.isMeshToonMaterial||be.isMeshLambertMaterial||be.isMeshBasicMaterial||be.isMeshStandardMaterial||be.isShaderMaterial||be.isShadowMaterial||Be.isSkinnedMesh)&&or.setValue(ae,"viewMatrix",J.matrixWorldInverse)}if(Be.isSkinnedMesh){or.setOptional(ae,Be,"bindMatrix"),or.setOptional(ae,Be,"bindMatrixInverse");let Xi=Be.skeleton;Xi&&(Ae.floatVertexTextures?(Xi.boneTexture===null&&Xi.computeBoneTexture(),or.setValue(ae,"boneTexture",Xi.boneTexture,Ce),or.setValue(ae,"boneTextureSize",Xi.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 Xn=Te.morphAttributes;if((Xn.position!==void 0||Xn.normal!==void 0||Xn.color!==void 0&&Ae.isWebGL2===!0)&&V.update(Be,Te,be,na),(vr||St.receiveShadow!==Be.receiveShadow)&&(St.receiveShadow=Be.receiveShadow,or.setValue(ae,"receiveShadow",Be.receiveShadow)),be.isMeshGouraudMaterial&&be.envMap!==null&&(oa.envMap.value=Ft,oa.flipEnvMap.value=Ft.isCubeTexture&&Ft.isRenderTargetTexture===!1?-1:1),vr&&(or.setValue(ae,"toneMappingExposure",g.toneMappingExposure),St.needsLights&&Nl(oa,qn),rt&&be.fog===!0&&pt.refreshFogUniforms(oa,rt),pt.refreshMaterialUniforms(oa,be,R,P,le),Bm.upload(ae,St.uniformsList,oa,Ce)),be.isShaderMaterial&&be.uniformsNeedUpdate===!0&&(Bm.upload(ae,St.uniformsList,oa,Ce),be.uniformsNeedUpdate=!1),be.isSpriteMaterial&&or.setValue(ae,"center",Be.center),or.setValue(ae,"modelViewMatrix",Be.modelViewMatrix),or.setValue(ae,"normalMatrix",Be.normalMatrix),or.setValue(ae,"modelMatrix",Be.matrixWorld),Be.previousModelViewMatrix&&or.setValue(ae,"previousModelViewMatrix",Be.previousModelViewMatrix),J.previousProjectionMatrix&&or.setValue(ae,"previousProjectionMatrix",J.previousProjectionMatrix),be.isShaderMaterial||be.isRawShaderMaterial){let Xi=be.uniformsGroups;for(let Yt=0,Hu=Xi.length;Yt<Hu;Yt++)if(Ae.isWebGL2){let Yn=Xi[Yt];ke.update(Yn,na),ke.bind(Yn,na)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return na}function Nl(J,Se){J.ambientLightColor.needsUpdate=Se,J.lightProbe.needsUpdate=Se,J.directionalLights.needsUpdate=Se,J.directionalLightShadows.needsUpdate=Se,J.pointLights.needsUpdate=Se,J.pointLightShadows.needsUpdate=Se,J.spotLights.needsUpdate=Se,J.spotLightShadows.needsUpdate=Se,J.rectAreaLights.needsUpdate=Se,J.hemisphereLights.needsUpdate=Se}function Wh(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(J,Se,Te){Ie.get(J.texture).__webglTexture=Se,Ie.get(J.depthTexture).__webglTexture=Te;let be=Ie.get(J);be.__hasExternalTextures=!0,be.__hasExternalTextures&&(be.__autoAllocateDepthBuffer=Te===void 0,be.__autoAllocateDepthBuffer||ve.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),be.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(J,Se){let Te=Ie.get(J);Te.__webglFramebuffer=Se,Te.__useDefaultFramebuffer=Se===void 0},this.setRenderTarget=function(J,Se=0,Te=0){b=J,y=Se,x=Te;let be=!0,Be=null,rt=!1,Bt=!1;if(J){let kt=Ie.get(J);kt.__useDefaultFramebuffer!==void 0?(ye.bindFramebuffer(36160,null),be=!1):kt.__webglFramebuffer===void 0?Ce.setupRenderTarget(J):kt.__hasExternalTextures&&Ce.rebindTextures(J,Ie.get(J.texture).__webglTexture,Ie.get(J.depthTexture).__webglTexture);let Ft=J.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(Bt=!0);let oi=Ie.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Be=oi[Se],rt=!0):Ae.isWebGL2&&J.samples>0&&Ce.useMultisampledRTT(J)===!1?Be=Ie.get(J).__webglMultisampledFramebuffer:Be=oi,S.copy(J.viewport),E.copy(J.scissor),A=J.scissorTest}else S.copy(L).multiplyScalar(R).floor(),E.copy(H).multiplyScalar(R).floor(),A=q;if(ye.bindFramebuffer(36160,Be)&&Ae.drawBuffers&&be&&ye.drawBuffers(J,Be),ye.viewport(S),ye.scissor(E),ye.setScissorTest(A),rt){let kt=Ie.get(J.texture);ae.framebufferTexture2D(36160,36064,34069+Se,kt.__webglTexture,Te)}else if(Bt){let kt=Ie.get(J.texture),Ft=Se||0;ae.framebufferTextureLayer(36160,36064,kt.__webglTexture,Te||0,Ft)}_=-1},this.readRenderTargetPixels=function(J,Se,Te,be,Be,rt,Bt){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let kt=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&Bt!==void 0&&(kt=kt[Bt]),kt){ye.bindFramebuffer(36160,kt);try{let Ft=J.texture,oi=Ft.format,Kt=Ft.type;if(oi!==qi&&He.convert(oi)!==ae.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Vt=Kt===Oo&&(ve.has("EXT_color_buffer_half_float")||Ae.isWebGL2&&ve.has("EXT_color_buffer_float"));if(Kt!==As&&He.convert(Kt)!==ae.getParameter(35738)&&!(Kt===Ti&&(Ae.isWebGL2||ve.has("OES_texture_float")||ve.has("WEBGL_color_buffer_float")))&&!Vt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be&&ae.readPixels(Se,Te,be,Be,He.convert(oi),He.convert(Kt),rt)}finally{let Ft=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(36160,Ft)}}},this.readRenderTargetPixelsAsync=async function(J,Se,Te,be,Be,rt,Bt){if(!(J&&J.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let kt=Ie.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&Bt!==void 0&&(kt=kt[Bt]),kt){let Ft=J.texture,oi=Ft.format,Kt=Ft.type;if(Se>=0&&Se<=J.width-be&&Te>=0&&Te<=J.height-Be){ye.bindFramebuffer(ae.FRAMEBUFFER,kt);let Vt=ae.createBuffer();ae.bindBuffer(ae.PIXEL_PACK_BUFFER,Vt),ae.bufferData(ae.PIXEL_PACK_BUFFER,rt.byteLength,ae.STREAM_READ),ae.readPixels(Se,Te,be,Be,He.convert(oi),He.convert(Kt),0);let gi=b!==null?Ie.get(b).__webglFramebuffer:null;ye.bindFramebuffer(ae.FRAMEBUFFER,gi);let $i=ae.fenceSync(ae.SYNC_GPU_COMMANDS_COMPLETE,0);return ae.flush(),await Nz(ae,$i,4),ae.bindBuffer(ae.PIXEL_PACK_BUFFER,Vt),ae.getBufferSubData(ae.PIXEL_PACK_BUFFER,0,rt),ae.deleteBuffer(Vt),ae.deleteSync($i),rt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(J,Se,Te=0){let be=Math.pow(2,-Te),Be=Math.floor(Se.image.width*be),rt=Math.floor(Se.image.height*be);Ce.setTexture2D(Se,0),ae.copyTexSubImage2D(3553,Te,0,0,J.x,J.y,Be,rt),ye.unbindTexture()},this.copyTextureToTexture=function(J,Se,Te,be=0){let Be=Se.image.width,rt=Se.image.height,Bt=He.convert(Te.format),kt=He.convert(Te.type);Ce.setTexture2D(Te,0),ae.pixelStorei(37440,Te.flipY),ae.pixelStorei(37441,Te.premultiplyAlpha),ae.pixelStorei(3317,Te.unpackAlignment),Se.isDataTexture?ae.texSubImage2D(3553,be,J.x,J.y,Be,rt,Bt,kt,Se.image.data):Se.isCompressedTexture?ae.compressedTexSubImage2D(3553,be,J.x,J.y,Se.mipmaps[0].width,Se.mipmaps[0].height,Bt,Se.mipmaps[0].data):ae.texSubImage2D(3553,be,J.x,J.y,Bt,kt,Se.image),be===0&&Te.generateMipmaps&&ae.generateMipmap(3553),ye.unbindTexture()},this.copyTextureToTexture3D=function(J,Se,Te,be,Be=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let rt=J.max.x-J.min.x+1,Bt=J.max.y-J.min.y+1,kt=J.max.z-J.min.z+1,Ft=He.convert(be.format),oi=He.convert(be.type),Kt;if(be.isData3DTexture)Ce.setTexture3D(be,0),Kt=32879;else if(be.isDataArrayTexture)Ce.setTexture2DArray(be,0),Kt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ae.pixelStorei(37440,be.flipY),ae.pixelStorei(37441,be.premultiplyAlpha),ae.pixelStorei(3317,be.unpackAlignment);let Vt=ae.getParameter(3314),gi=ae.getParameter(32878),$i=ae.getParameter(3316),Wi=ae.getParameter(3315),er=ae.getParameter(32877),Fi=Te.isCompressedTexture?Te.mipmaps[0]:Te.image;ae.pixelStorei(3314,Fi.width),ae.pixelStorei(32878,Fi.height),ae.pixelStorei(3316,J.min.x),ae.pixelStorei(3315,J.min.y),ae.pixelStorei(32877,J.min.z),Te.isDataTexture||Te.isData3DTexture?ae.texSubImage3D(Kt,Be,Se.x,Se.y,Se.z,rt,Bt,kt,Ft,oi,Fi.data):Te.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ae.compressedTexSubImage3D(Kt,Be,Se.x,Se.y,Se.z,rt,Bt,kt,Ft,Fi.data)):ae.texSubImage3D(Kt,Be,Se.x,Se.y,Se.z,rt,Bt,kt,Ft,oi,Fi),ae.pixelStorei(3314,Vt),ae.pixelStorei(32878,gi),ae.pixelStorei(3316,$i),ae.pixelStorei(3315,Wi),ae.pixelStorei(32877,er),Be===0&&be.generateMipmaps&&ae.generateMipmap(Kt),ye.unbindTexture()},this.initRenderTarget=function(J){Ie.get(J).__webglFramebuffer===void 0&&Ce.setupRenderTarget(J)},this.initTexture=function(J){J.isCubeTexture?Ce.setTextureCube(J,0):J.isData3DTexture?Ce.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Ce.setTexture2DArray(J,0):Ce.setTexture2D(J,0),ye.unbindTexture()},this.resetState=function(){y=0,x=0,b=null,ye.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var z6=class extends rT{};z6.prototype.isWebGL1Renderer=!0;var sT=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ct(e),this.near=t,this.far=i}clone(){return new sT(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Zs=class extends Mi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},F6=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=dy,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ca()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ds=new I,vy=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ds.fromBufferAttribute(this,t),Ds.applyMatrix4(e),this.setXYZ(t,Ds.x,Ds.y,Ds.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ds.fromBufferAttribute(this,t),Ds.applyNormalMatrix(e),this.setXYZ(t,Ds.x,Ds.y,Ds.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ds.fromBufferAttribute(this,t),Ds.transformDirection(e),this.setXYZ(t,Ds.x,Ds.y,Ds.z);return this}setX(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Bi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Mo(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Mo(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Mo(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Mo(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),i=Bi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),i=Bi(i,this.array),r=Bi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Bi(t,this.array),i=Bi(i,this.array),r=Bi(r,this.array),s=Bi(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Tt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new vy(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},aT=class extends Mi{constructor(){super(),this.isBone=!0,this.type="Bone"}},Fs=class extends Ji{constructor(e=null,t=1,i=1,r,s,a,n,o,l=$t,h=$t,c,u){super(null,a,n,o,l,h,r,s,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},TS=new je,k6=new je,Ab=class{constructor(e=[],t=[]){this.uuid=Ca(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new je)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new je;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:k6;TS.multiplyMatrices(n,t[s]),TS.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Ab(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=j3(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Fs(t,e,e,qi,Ti);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new aT),this.bones.push(a),this.boneInverses.push(new je().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},ap=class extends Tt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},PS=new je,DS=new je,Tf=[],U6=new je,od=new zi,N6=class extends zi{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ap(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,U6)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(od.geometry=this.geometry,od.material=this.material,od.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,PS),DS.multiplyMatrices(i,PS),od.matrixWorld=DS,od.raycast(e,Tf);for(let a=0,n=Tf.length;a<n;a++){let o=Tf[a];o.instanceId=s,o.object=this,t.push(o)}Tf.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ap(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}},zl=class extends Cp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ct(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},IS=new I,OS=new I,RS=new je,L0=new wu,Pf=new Ks,ig=class extends Mi{constructor(e=new gt,t=new zl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)IS.fromBufferAttribute(t,r-1),OS.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=IS.distanceTo(OS);e.setAttribute("lineDistance",new at(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Pf.copy(i.boundingSphere),Pf.applyMatrix4(r),Pf.radius+=s,e.ray.intersectsSphere(Pf)===!1)return;RS.copy(r).invert(),L0.copy(e.ray).applyMatrix4(RS);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new I,h=new I,c=new I,u=new I,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,a.start),m=Math.min(p.count,a.start+a.count);for(let y=g,x=m-1;y<x;y+=d){let b=p.getX(y),_=p.getX(y+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),L0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(u);M<e.near||M>e.far||t.push({distance:M,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,a.start),m=Math.min(f.count,a.start+a.count);for(let y=g,x=m-1;y<x;y+=d){if(l.fromBufferAttribute(f,y),h.fromBufferAttribute(f,y+1),L0.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(u);b<e.near||b>e.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},LS=new I,BS=new I,Tp=class extends ig{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)LS.fromBufferAttribute(t,r),BS.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+LS.distanceTo(BS);e.setAttribute("lineDistance",new at(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},V6=class extends Ji{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Xt,this.magFilter=s!==void 0?s:Xt,this.generateMipmaps=!1;let h=this;function c(){h.needsUpdate=!0,e.requestVideoFrameCallback(c)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(c)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},j6=class extends Ji{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Hn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],c=i[r+1]-h,u=(a-h)/c;return(r+u)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new re:new I);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new I,r=[],s=[],a=[],n=new I,o=new je;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new I)}s[0]=new I,a[0]=new I;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),c=Math.abs(r[0].y),u=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),n.crossVectors(r[d-1],r[d]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(wr(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(n,p))}a[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(wr(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},av=class extends Hn{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new re,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),c=Math.sin(this.aRotation),u=o-this.aX,d=l-this.aY;o=u*h-d*c+this.aX,l=u*c+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},H6=class extends av{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function Mb(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,c,u){let d=(n-a)/h-(o-a)/(h+c)+(o-n)/c,p=(o-n)/c-(l-n)/(c+u)+(l-o)/u;d*=c,p*=c,s(n,o,d,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var Df=new I,B0=new Mb,z0=new Mb,F0=new Mb,G6=class extends Hn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new I){let i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(Df.subVectors(r[0],r[1]).add(r[0]),l=Df);let c=r[n%s],u=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(Df.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Df),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(c),d),f=Math.pow(c.distanceToSquared(u),d),g=Math.pow(u.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),B0.initNonuniformCatmullRom(l.x,c.x,u.x,h.x,p,f,g),z0.initNonuniformCatmullRom(l.y,c.y,u.y,h.y,p,f,g),F0.initNonuniformCatmullRom(l.z,c.z,u.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(B0.initCatmullRom(l.x,c.x,u.x,h.x,this.tension),z0.initCatmullRom(l.y,c.y,u.y,h.y,this.tension),F0.initCatmullRom(l.z,c.z,u.z,h.z,this.tension));return i.set(B0.calc(o),z0.calc(o),F0.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new I().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function zS(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function W6(e,t){let i=1-e;return i*i*t}function q6(e,t){return 2*(1-e)*e*t}function X6(e,t){return e*e*t}function jd(e,t,i,r){return W6(e,t)+q6(e,i)+X6(e,r)}function Y6(e,t){let i=1-e;return i*i*i*t}function Q6(e,t){let i=1-e;return 3*i*i*e*t}function Z6(e,t){return 3*(1-e)*e*e*t}function K6(e,t){return e*e*e*t}function Hd(e,t,i,r,s){return Y6(e,t)+Q6(e,i)+Z6(e,r)+K6(e,s)}var Za=class extends Hn{constructor(e=new re,t=new re,i=new re,r=new re){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new re){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(Hd(e,r.x,s.x,a.x,n.x),Hd(e,r.y,s.y,a.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},zm=class extends Hn{constructor(e=new I,t=new I,i=new I,r=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new I){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(Hd(e,r.x,s.x,a.x,n.x),Hd(e,r.y,s.y,a.y,n.y),Hd(e,r.z,s.z,a.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},$a=class extends Hn{constructor(e=new re,t=new re){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new re){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new re;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},nT=class extends Hn{constructor(e=new I,t=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new I){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Dl=class extends Hn{constructor(e=new re,t=new re,i=new re){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new re){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(jd(e,r.x,s.x,a.x),jd(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},J6=class extends Hn{constructor(e=new I,t=new I,i=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new I){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(jd(e,r.x,s.x,a.x),jd(e,r.y,s.y,a.y),jd(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Eb=class extends Hn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new re){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],c=r[a>r.length-3?r.length-1:a+2];return i.set(zS(n,o.x,l.x,h.x,c.x),zS(n,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new re().fromArray(r))}return this}},$6=Object.freeze({__proto__:null,ArcCurve:H6,CatmullRomCurve3:G6,CubicBezierCurve:Za,CubicBezierCurve3:zm,EllipseCurve:av,LineCurve:$a,LineCurve3:nT,QuadraticBezierCurve:Dl,QuadraticBezierCurve3:J6,SplineCurve:Eb}),oT=class extends Hn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new $a(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new $6[r.type]().fromJSON(r))}return this}},rg=class extends oT{constructor(e){super(),this.type="Path",this.currentPoint=new re,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new $a(this.currentPoint.clone(),new re(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Dl(this.currentPoint.clone(),new re(e,t),new re(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new Za(this.currentPoint.clone(),new re(e,t),new re(i,r),new re(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Eb(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new av(e,t,i,r,s,a,n,o);if(this.curves.length>0){let c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},lT=class extends gt{constructor(e=[new re(0,-.5),new re(.5,0),new re(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=wr(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,c=new I,u=new re,d=new I,p=new I,f=new I,g=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let y=0;y<=t;y++){let x=i+y*h*r,b=Math.sin(x),_=Math.cos(x);for(let M=0;M<=e.length-1;M++){c.x=e[M].x*b,c.y=e[M].y,c.z=e[M].x*_,a.push(c.x,c.y,c.z),u.x=y/t,u.y=M/(e.length-1),n.push(u.x,u.y);let S=o[3*M+0]*b,E=o[3*M+1],A=o[3*M+0]*_;l.push(S,E,A)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){let b=x+y*e.length,_=b,M=b+e.length,S=b+e.length+1,E=b+1;s.push(_,M,E),s.push(S,E,M)}this.setIndex(s),this.setAttribute("position",new at(a,3)),this.setAttribute("uv",new at(n,2)),this.setAttribute("normal",new at(l,3))}static fromJSON(e){return new lT(e.points,e.segments,e.phiStart,e.phiLength)}},Cb=class extends gt{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],c=[],u=[],d=[],p=0,f=[],g=i/2,m=0;y(),a===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new at(c,3)),this.setAttribute("normal",new at(u,3)),this.setAttribute("uv",new at(d,2));function y(){let b=new I,_=new I,M=0,S=(t-e)/i;for(let E=0;E<=s;E++){let A=[],T=E/s,P=T*(t-e)+e;for(let R=0;R<=r;R++){let z=R/r,U=z*o+n,L=Math.sin(U),H=Math.cos(U);_.x=P*L,_.y=-T*i+g,_.z=P*H,c.push(_.x,_.y,_.z),b.set(L,S,H).normalize(),u.push(b.x,b.y,b.z),d.push(z,1-T),A.push(p++)}f.push(A)}for(let E=0;E<r;E++)for(let A=0;A<s;A++){let T=f[A][E],P=f[A+1][E],R=f[A+1][E+1],z=f[A][E+1];h.push(T,P,z),h.push(P,R,z),M+=6}l.addGroup(m,M,0),m+=M}function x(b){let _=p,M=new re,S=new I,E=0,A=b===!0?e:t,T=b===!0?1:-1;for(let R=1;R<=r;R++)c.push(0,g*T,0),u.push(0,T,0),d.push(.5,.5),p++;let P=p;for(let R=0;R<=r;R++){let z=R/r*o+n,U=Math.cos(z),L=Math.sin(z);S.x=A*L,S.y=g*T,S.z=A*U,c.push(S.x,S.y,S.z),u.push(0,T,0),M.x=U*.5+.5,M.y=L*.5*T+.5,d.push(M.x,M.y),p++}for(let R=0;R<r;R++){let z=_+R,U=P+R;b===!0?h.push(U,U+1,z):h.push(U+1,U,z),E+=3}l.addGroup(m,E,b===!0?1:2),m+=E}}static fromJSON(e){return new Cb(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Tb=class extends Cb{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new Tb(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Pb=class extends gt{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new at(s,3)),this.setAttribute("normal",new at(s.slice(),3)),this.setAttribute("uv",new at(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(y){let x=new I,b=new I,_=new I;for(let M=0;M<t.length;M+=3)d(t[M+0],x),d(t[M+1],b),d(t[M+2],_),o(x,b,_,y)}function o(y,x,b,_){let M=_+1,S=[];for(let E=0;E<=M;E++){S[E]=[];let A=y.clone().lerp(b,E/M),T=x.clone().lerp(b,E/M),P=M-E;for(let R=0;R<=P;R++)R===0&&E===M?S[E][R]=A:S[E][R]=A.clone().lerp(T,R/P)}for(let E=0;E<M;E++)for(let A=0;A<2*(M-E)-1;A++){let T=Math.floor(A/2);A%2===0?(u(S[E][T+1]),u(S[E+1][T]),u(S[E][T])):(u(S[E][T+1]),u(S[E+1][T+1]),u(S[E+1][T]))}}function l(y){let x=new I;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(y),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function h(){let y=new I;for(let x=0;x<s.length;x+=3){y.x=s[x+0],y.y=s[x+1],y.z=s[x+2];let b=g(y)/2/Math.PI+.5,_=m(y)/Math.PI+.5;a.push(b,1-_)}p(),c()}function c(){for(let y=0;y<a.length;y+=6){let x=a[y+0],b=a[y+2],_=a[y+4],M=Math.max(x,b,_),S=Math.min(x,b,_);M>.9&&S<.1&&(x<.2&&(a[y+0]+=1),b<.2&&(a[y+2]+=1),_<.2&&(a[y+4]+=1))}}function u(y){s.push(y.x,y.y,y.z)}function d(y,x){let b=y*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function p(){let y=new I,x=new I,b=new I,_=new I,M=new re,S=new re,E=new re;for(let A=0,T=0;A<s.length;A+=9,T+=6){y.set(s[A+0],s[A+1],s[A+2]),x.set(s[A+3],s[A+4],s[A+5]),b.set(s[A+6],s[A+7],s[A+8]),M.set(a[T+0],a[T+1]),S.set(a[T+2],a[T+3]),E.set(a[T+4],a[T+5]),_.copy(y).add(x).add(b).divideScalar(3);let P=g(_);f(M,T+0,y,P),f(S,T+2,x,P),f(E,T+4,b,P)}}function f(y,x,b,_){_<0&&y.x===1&&(a[x]=y.x-1),b.x===0&&b.z===0&&(a[x]=_/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new Pb(e.vertices,e.indices,e.radius,e.details)}},hT=class extends Pb{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],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];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new hT(e.radius,e.detail)}},sg=class extends rg{constructor(e){super(e),this.uuid=Ca(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new rg().fromJSON(r))}return this}},eN={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=cT(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,c,u,d,p;if(r&&(a=aN(e,t,a,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let f=i;f<s;f+=i)u=e[f],d=e[f+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=Math.max(h-o,c-l),p=p!==0?32767/p:0}return np(a,n,i,o,l,p,0),n}};function cT(e,t,i,r,s){let a,n;if(s===gN(e,t,i,r)>0)for(a=t;a<i;a+=r)n=FS(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=FS(a,e[a],e[a+1],n);return n&&nv(n,n.next)&&(lp(n),n=n.next),n}function Th(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(nv(i,i.next)||Ki(i.prev,i,i.next)===0)){if(lp(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function np(e,t,i,r,s,a,n){if(!e)return;!n&&a&&cN(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?iN(e,r,s,a):tN(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),lp(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=rN(Th(e),t,i),np(e,t,i,r,s,a,2)):n===2&&sN(e,t,i,r,s,a):np(Th(e),t,i,r,s,a,1);break}}}function tN(e){let t=e.prev,i=e,r=e.next;if(Ki(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,c=s<a?s<n?s:n:a<n?a:n,u=o<l?o<h?o:h:l<h?l:h,d=s>a?s>n?s:n:a>n?a:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Hc(s,o,a,l,n,h,f.x,f.y)&&Ki(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function iN(e,t,i,r){let s=e.prev,a=e,n=e.next;if(Ki(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,c=s.y,u=a.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,g=o>l?o>h?o:h:l>h?l:h,m=c>u?c>d?c:d:u>d?u:d,y=yy(p,f,t,i,r),x=yy(g,m,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==n&&Hc(o,c,l,u,h,d,b.x,b.y)&&Ki(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==n&&Hc(o,c,l,u,h,d,_.x,_.y)&&Ki(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==n&&Hc(o,c,l,u,h,d,b.x,b.y)&&Ki(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=g&&_.y>=f&&_.y<=m&&_!==s&&_!==n&&Hc(o,c,l,u,h,d,_.x,_.y)&&Ki(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function rN(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!nv(s,a)&&uT(s,r,r.next,a)&&op(s,a)&&op(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),lp(r),lp(r.next),r=e=a),r=r.next}while(r!==e);return Th(r)}function sN(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&pN(n,o)){let l=dT(n,o);n=Th(n,n.next),l=Th(l,l.next),np(n,t,i,r,s,a,0),np(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function aN(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=cT(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(dN(h));for(s.sort(nN),a=0;a<s.length;a++)i=oN(s[a],i);return i}function nN(e,t){return e.x-t.x}function oN(e,t){let i=lN(e,t);if(!i)return t;let r=dT(i,e);return Th(r,r.next),Th(i,i.next)}function lN(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let d=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=a&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===a))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,c=1/0,u;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&Hc(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(u=Math.abs(n-i.y)/(a-i.x),op(i,e)&&(u<c||u===c&&(i.x>s.x||i.x===s.x&&hN(s,i)))&&(s=i,c=u)),i=i.next;while(i!==o);return s}function hN(e,t){return Ki(e.prev,e,t.prev)<0&&Ki(t.next,e,e.next)<0}function cN(e,t,i,r){let s=e;do s.z===0&&(s.z=yy(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,uN(s)}function uN(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function yy(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function dN(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Hc(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function pN(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!fN(e,t)&&(op(e,t)&&op(t,e)&&mN(e,t)&&(Ki(e.prev,e,t.prev)||Ki(e,t.prev,t))||nv(e,t)&&Ki(e.prev,e,e.next)>0&&Ki(t.prev,t,t.next)>0)}function Ki(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function nv(e,t){return e.x===t.x&&e.y===t.y}function uT(e,t,i,r){let s=Of(Ki(e,t,i)),a=Of(Ki(e,t,r)),n=Of(Ki(i,r,e)),o=Of(Ki(i,r,t));return!!(s!==a&&n!==o||s===0&&If(e,i,t)||a===0&&If(e,r,t)||n===0&&If(i,e,r)||o===0&&If(i,t,r))}function If(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Of(e){return e>0?1:e<0?-1:0}function fN(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&uT(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function op(e,t){return Ki(e.prev,e,e.next)<0?Ki(e,t,e.next)>=0&&Ki(e,e.prev,t)>=0:Ki(e,t,e.prev)<0||Ki(e,e.next,t)<0}function mN(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function dT(e,t){let i=new xy(e.i,e.x,e.y),r=new xy(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function FS(e,t,i,r){let s=new xy(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function lp(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function xy(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function gN(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var pT=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return pT.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];kS(e),US(i,e);let a=e.length;t.forEach(kS);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,US(i,t[o]);let n=eN.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function kS(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function US(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var fT=class extends Pb{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fT(e.radius,e.detail)}},Yc=class extends gt{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],c=new I,u=new I,d=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let y=[],x=m/i,b=0;m==0&&a==0?b=.5/t:m==i&&o==Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let M=_/t;c.x=-e*Math.cos(r+M*s)*Math.sin(a+x*n),c.y=e*Math.cos(a+x*n),c.z=e*Math.sin(r+M*s)*Math.sin(a+x*n),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),g.push(M+b,1-x),y.push(l++)}h.push(y)}for(let m=0;m<i;m++)for(let y=0;y<t;y++){let x=h[m][y+1],b=h[m][y],_=h[m+1][y],M=h[m+1][y+1];(m!==0||a>0)&&d.push(x,b,M),(m!==i-1||o<Math.PI)&&d.push(b,_,M)}this.setIndex(d),this.setAttribute("position",new at(p,3)),this.setAttribute("normal",new at(f,3)),this.setAttribute("uv",new at(g,2))}static fromJSON(e){return new Yc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},mT=class extends gt{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);let a=[],n=[],o=[],l=[],h=new I,c=new I,u=new I;for(let d=0;d<=i;d++)for(let p=0;p<=r;p++){let f=p/r*s,g=d/i*Math.PI*2;c.x=(e+t*Math.cos(g))*Math.cos(f),c.y=(e+t*Math.cos(g))*Math.sin(f),c.z=t*Math.sin(g),n.push(c.x,c.y,c.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(p/r),l.push(d/i)}for(let d=1;d<=i;d++)for(let p=1;p<=r;p++){let f=(r+1)*d+p-1,g=(r+1)*(d-1)+p-1,m=(r+1)*(d-1)+p,y=(r+1)*d+p;a.push(f,g,y),a.push(g,m,y)}this.setIndex(a),this.setAttribute("position",new at(n,3)),this.setAttribute("normal",new at(o,3)),this.setAttribute("uv",new at(l,2))}static fromJSON(e){return new mT(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},gT=class extends gt{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],c=new I,u=new I,d=new I,p=new I,f=new I,g=new I,m=new I;for(let x=0;x<=i;++x){let b=x/i*s*Math.PI*2;y(b,s,a,e,d),y(b+.01,s,a,e,p),g.subVectors(p,d),m.addVectors(p,d),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let _=0;_<=r;++_){let M=_/r*Math.PI*2,S=-t*Math.cos(M),E=t*Math.sin(M);c.x=d.x+(S*m.x+E*f.x),c.y=d.y+(S*m.y+E*f.y),c.z=d.z+(S*m.z+E*f.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(x/i),h.push(_/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let _=(r+1)*(x-1)+(b-1),M=(r+1)*x+(b-1),S=(r+1)*x+b,E=(r+1)*(x-1)+b;n.push(_,M,E),n.push(M,S,E)}this.setIndex(n),this.setAttribute("position",new at(o,3)),this.setAttribute("normal",new at(l,3)),this.setAttribute("uv",new at(h,2));function y(x,b,_,M,S){let E=Math.cos(x),A=Math.sin(x),T=_/b*x,P=Math.cos(T);S.x=M*(2+P)*.5*E,S.y=M*(2+P)*A*.5,S.z=M*Math.sin(T)*.5}}static fromJSON(e){return new gT(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},vN=class extends ci{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};function Ko(e,t,i){return vT(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Rf(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function vT(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function yN(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function NS(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function yT(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var ov=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},xN=class extends ov{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Nc,endingEnd:Nc}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case Vc:s=e,n=2*t-i;break;case $m:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case Vc:a=e,o=2*i-t;break;case $m:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-u*g+2*u*f-u*p,y=(1+u)*g+(-1.5-2*u)*f+(-.5+u)*p+1,x=(-1-d)*g+(1.5+d)*f+.5*p,b=d*g-d*f;for(let _=0;_!==n;++_)s[_]=m*a[h+_]+y*a[l+_]+x*a[o+_]+b*a[c+_];return s}},xT=class extends ov{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),c=1-h;for(let u=0;u!==n;++u)s[u]=a[l+u]*c+a[o+u]*h;return s}},bN=class extends ov{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Gn=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Rf(t,this.TimeBufferType),this.values=Rf(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Rf(e.times,Array),values:Rf(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new bN(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xT(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xN(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Km:t=this.InterpolantFactoryMethodDiscrete;break;case Jm:t=this.InterpolantFactoryMethodLinear;break;case l0:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Km;case this.InterpolantFactoryMethodLinear:return Jm;case this.InterpolantFactoryMethodSmooth:return l0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=Ko(i,s,a),this.values=Ko(this.values,s*n,a*n)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&vT(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=Ko(this.times),t=Ko(this.values),i=this.getValueSize(),r=this.getInterpolation()===l0,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let c=n*i,u=c-i,d=c+i;for(let p=0;p!==i;++p){let f=t[c+p];if(f!==t[u+p]||f!==t[d+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let c=n*i,u=a*i;for(let d=0;d!==i;++d)t[u+d]=t[c+d]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=Ko(e,0,a),this.values=Ko(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Ko(this.times,0),t=Ko(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Gn.prototype.TimeBufferType=Float32Array;Gn.prototype.ValueBufferType=Float32Array;Gn.prototype.DefaultInterpolation=Jm;var Au=class extends Gn{};Au.prototype.ValueTypeName="bool";Au.prototype.ValueBufferType=Array;Au.prototype.DefaultInterpolation=Km;Au.prototype.InterpolantFactoryMethodLinear=void 0;Au.prototype.InterpolantFactoryMethodSmooth=void 0;var bT=class extends Gn{};bT.prototype.ValueTypeName="color";var ag=class extends Gn{};ag.prototype.ValueTypeName="number";var wN=class extends ov{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)Rt.slerpFlat(s,0,a,l-n,a,l,o);return s}},Pp=class extends Gn{InterpolantFactoryMethodLinear(e){return new wN(this.times,this.values,this.getValueSize(),e)}};Pp.prototype.ValueTypeName="quaternion";Pp.prototype.DefaultInterpolation=Jm;Pp.prototype.InterpolantFactoryMethodSmooth=void 0;var Mu=class extends Gn{};Mu.prototype.ValueTypeName="string";Mu.prototype.ValueBufferType=Array;Mu.prototype.DefaultInterpolation=Km;Mu.prototype.InterpolantFactoryMethodLinear=void 0;Mu.prototype.InterpolantFactoryMethodSmooth=void 0;var ng=class extends Gn{};ng.prototype.ValueTypeName="vector";var by=class{constructor(e,t=-1,i,r=yb){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Ca(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(SN(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Gn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=yN(o);o=NS(o,1,h),l=NS(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new ag(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let c=h[1],u=r[c];u||(r[c]=u=[]),u.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,c,u,d,p){if(u.length!==0){let f=[],g=[];yT(u,f,g,d),f.length!==0&&p.push(new h(c,f,g))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let c=l[h].keys;if(!(!c||c.length===0))if(c[0].morphTargets){let u={},d;for(d=0;d<c.length;d++)if(c[d].morphTargets)for(let p=0;p<c[d].morphTargets.length;p++)u[c[d].morphTargets[p]]=-1;for(let p in u){let f=[],g=[];for(let m=0;m!==c[d].morphTargets.length;++m){let y=c[d];f.push(y.time),g.push(y.morphTarget===p?1:0)}r.push(new ag(".morphTargetInfluence["+p+"]",f,g))}o=u.length*a}else{let u=".bones["+t[h].name+"]";i(ng,u+".position",c,"pos",r),i(Pp,u+".quaternion",c,"rot",r),i(ng,u+".scale",c,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function _N(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ag;case"vector":case"vector2":case"vector3":case"vector4":return ng;case"color":return bT;case"quaternion":return Pp;case"bool":case"boolean":return Au;case"string":return Mu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function SN(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=_N(e.type);if(e.times===void 0){let i=[],r=[];yT(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var og={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},wT=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,c){return l.push(h,c),this},this.removeHandler=function(h){let c=l.indexOf(h);return c!==-1&&l.splice(c,2),this},this.getHandler=function(h){for(let c=0,u=l.length;c<u;c+=2){let d=l[c],p=l[c+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},AN=new wT,Dp=class{constructor(e){this.manager=e!==void 0?e:AN,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},ao={},MN=class extends Error{constructor(e,t){super(e),this.response=t}},wy=class extends Dp{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=og.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ao[e]!==void 0){ao[e].push({onLoad:t,onProgress:i,onError:r});return}ao[e]=[],ao[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=ao[e],c=l.body.getReader(),u=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=u?parseInt(u):0,p=d!==0,f=0,g=new ReadableStream({start(m){y();function y(){c.read().then(({done:x,value:b})=>{if(x)m.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let M=0,S=h.length;M<S;M++){let E=h[M];E.onProgress&&E.onProgress(_)}m.enqueue(b),y()}})}}});return new Response(g)}else throw new MN(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),c=h&&h[1]?h[1].toLowerCase():void 0,u=new TextDecoder(c);return l.arrayBuffer().then(d=>u.decode(d))}}}).then(l=>{og.add(e,l);let h=ao[e];delete ao[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=ao[e];if(h===void 0)throw this.manager.itemError(e),l;delete ao[e];for(let c=0,u=h.length;c<u;c++){let d=h[c];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},EN=class extends Dp{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,a=og.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let n=sp("img");function o(){h(),og.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(c){h(),r&&r(c),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){n.removeEventListener("load",o,!1),n.removeEventListener("error",l,!1)}return n.addEventListener("load",o,!1),n.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(n.crossOrigin=this.crossOrigin),s.manager.itemStart(e),n.src=e,n}},CN=class extends Dp{constructor(e){super(e)}load(e,t,i,r){let s=new Ji,a=new EN(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(n){s.image=n,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},Ip=class extends Mi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ct(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},TN=class extends Ip{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ct(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},k0=new je,VS=new I,jS=new I,Db=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new re(512,512),this.map=null,this.mapPass=null,this.matrix=new je,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _b,this._frameExtents=new re(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;VS.setFromMatrixPosition(e.matrixWorld),t.position.copy(VS),jS.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(jS),t.updateMatrixWorld(),k0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(k0),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(k0)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},PN=class extends Db{constructor(){super(new bs(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=rp*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},DN=class extends Ip{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new PN}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},HS=new je,ld=new I,U0=new I,IN=class extends Db{constructor(){super(new bs(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new re(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(1,0,1,1)],this._cubeDirections=[new I(1,0,0),new I(-1,0,0),new I(0,0,1),new I(0,0,-1),new I(0,1,0),new I(0,-1,0)],this._cubeUps=[new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,0,1),new I(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),ld.setFromMatrixPosition(e.matrixWorld),i.position.copy(ld),U0.copy(i.position),U0.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(U0),i.updateMatrixWorld(),r.makeTranslation(-ld.x,-ld.y,-ld.z),HS.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HS)}},ON=class extends Ip{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new IN}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},RN=class extends Db{constructor(){super(new rv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},LN=class extends Ip{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Mi.DEFAULT_UP),this.updateMatrix(),this.target=new Mi,this.shadow=new RN}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},_T=class extends gt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},ST=class extends Dp{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new wy(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(u,d){if(t[d]!==void 0)return t[d];let p=u.interleavedBuffers[d],f=s(u,p.buffer),g=hf(p.type,f),m=new F6(g,p.stride);return m.uuid=p.uuid,t[d]=m,m}function s(u,d){if(i[d]!==void 0)return i[d];let p=u.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let a=e.isInstancedBufferGeometry?new _T:new gt,n=e.data.index;if(n!==void 0){let u=hf(n.type,n.array);a.setIndex(new Tt(u,1))}let o=e.data.attributes;for(let u in o){let d=o[u],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new vy(f,d.itemSize,d.offset,d.normalized)}else{let f=hf(d.type,d.array),g=d.isInstancedBufferAttribute?ap:Tt;p=new g(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),d.updateRange!==void 0&&(p.updateRange.offset=d.updateRange.offset,p.updateRange.count=d.updateRange.count),a.setAttribute(u,p)}let l=e.data.morphAttributes;if(l)for(let u in l){let d=l[u],p=[];for(let f=0,g=d.length;f<g;f++){let m=d[f],y;if(m.isInterleavedBufferAttribute){let x=r(e.data,m.data);y=new vy(x,m.itemSize,m.offset,m.normalized)}else{let x=hf(m.type,m.array);y=new Tt(x,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),p.push(y)}a.morphAttributes[u]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let u=0,d=h.length;u!==d;++u){let p=h[u];a.addGroup(p.start,p.count,p.materialIndex)}let c=e.data.boundingSphere;if(c!==void 0){let u=new I;c.center!==void 0&&u.fromArray(c.center),a.boundingSphere=new Ks(u,c.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},BN=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=GS(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=GS();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function GS(){return(typeof performance>"u"?Date:performance).now()}var zN=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){Rt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;Rt.multiplyQuaternionsFlat(e,a,e,t,e,i),Rt.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},Ib="\\[\\]\\.:\\/",FN=new RegExp("["+Ib+"]","g"),Ob="[^"+Ib+"]",kN="[^"+Ib.replace("\\.","")+"]",UN=/((?:WC+[\/:])*)/.source.replace("WC",Ob),NN=/(WCOD+)?/.source.replace("WCOD",kN),VN=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ob),jN=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ob),HN=new RegExp("^"+UN+NN+VN+jN+"$"),GN=["material","materials","bones","map"],WN=class{constructor(e,t,i){let r=i||Oi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Oi=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Oi.parseTrackName(t),this.node=Oi.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Oi.Composite(e,t,i):new Oi(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(FN,"")}static parseTrackName(e){let t=HN.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);GN.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Oi.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let a=e[r];if(a===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Oi.Composite=WN;Oi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Oi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Oi.prototype.GetterByBindingType=[Oi.prototype._getValue_direct,Oi.prototype._getValue_array,Oi.prototype._getValue_arrayElement,Oi.prototype._getValue_toArray];Oi.prototype.SetterByBindingTypeAndVersioning=[[Oi.prototype._setValue_direct,Oi.prototype._setValue_direct_setNeedsUpdate,Oi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Oi.prototype._setValue_array,Oi.prototype._setValue_array_setNeedsUpdate,Oi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Oi.prototype._setValue_arrayElement,Oi.prototype._setValue_arrayElement_setNeedsUpdate,Oi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Oi.prototype._setValue_fromArray,Oi.prototype._setValue_fromArray_setNeedsUpdate,Oi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var qN=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:Nc,endingEnd:Nc};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=N3,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case wz:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case yb:default:for(let h=0,c=o.length;h!==c;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===vb;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===U3){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Vc,r.endingEnd=Vc):(e?r.endingStart=this.zeroSlopeAtStart?Vc:Nc:r.endingStart=$m,t?r.endingEnd=this.zeroSlopeAtEnd?Vc:Nc:r.endingEnd=$m)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},XN=new Float32Array(1),YN=class extends gs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let c=0;c!==s;++c){let u=r[c],d=u.name,p=h[d];if(p!==void 0)++p.referenceCount,a[c]=p;else{if(p=a[c],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[c].binding.parsedPath;p=new zN(Oi.create(i,d,f),u.ValueTypeName,u.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),a[c]=p}n[c].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let c=n.actionByRoot,u=(e._localRoot||this._root).uuid;delete c[u],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new xT(new Float32Array(2),new Float32Array(2),1,XN),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?by.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=yb),o!==void 0){let c=o.actionByRoot[s];if(c!==void 0&&c.blendMode===i)return c;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new qN(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?by.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=h,t[h]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Fe=class{constructor(e){this.value=e}clone(){return new Fe(this.value.clone===void 0?this.value:this.value.clone())}},AT=class{constructor(e,t,i=0,r=1/0){this.ray=new wu(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new bb,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return _y(e,this,i,t),i.sort(WS),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)_y(e[r],this,i,t);return i.sort(WS),i}};function WS(e,t){return e.distance-t.distance}function _y(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)_y(s[a],t,i,!0)}}var qS=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(wr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},XS=new re,Rb=class{constructor(e=new re(1/0,1/0),t=new re(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=XS.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return XS.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},YS=new I,Lf=new I,Ta=class{constructor(e=new I,t=new I){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){YS.subVectors(e,this.start),Lf.subVectors(this.end,this.start);let i=Lf.dot(Lf),r=Lf.dot(YS)/i;return t&&(r=wr(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},QS=new I,QN=class extends Mi{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new gt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new at(r,3));let s=new zl({fog:!1,toneMapped:!1});this.cone=new Tp(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),QS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(QS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},ZN=class extends zi{constructor(e,t,i){let r=new Yc(t,4,2),s=new Ro({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},ZS=new I,Bf=new I,KS=new I,KN=class extends Mi{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new gt;r.setAttribute("position",new at([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zl({fog:!1,toneMapped:!1});this.lightPlane=new ig(r,s),this.add(this.lightPlane),r=new gt,r.setAttribute("position",new at([0,0,0,0,0,1],3)),this.targetLine=new ig(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),ZS.setFromMatrixPosition(this.light.matrixWorld),Bf.setFromMatrixPosition(this.light.target.matrixWorld),KS.subVectors(Bf,ZS),this.lightPlane.lookAt(Bf),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(Bf),this.targetLine.scale.z=KS.length()}},zf=new I,ir=new Bl,lg=class extends Tp{constructor(e){let t=new gt,i=new zl({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new at(r,3)),t.setAttribute("color",new at(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();let l=new Ct(16755200),h=new Ct(16711680),c=new Ct(43775),u=new Ct(16777215),d=new Ct(3355443);this.setColors(l,h,c,u,d)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.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 e=this.geometry,t=this.pointMap,i=1,r=1;ir.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),cr("c",t,e,ir,0,0,-1),cr("t",t,e,ir,0,0,1),cr("n1",t,e,ir,-i,-r,-1),cr("n2",t,e,ir,i,-r,-1),cr("n3",t,e,ir,-i,r,-1),cr("n4",t,e,ir,i,r,-1),cr("f1",t,e,ir,-i,-r,1),cr("f2",t,e,ir,i,-r,1),cr("f3",t,e,ir,-i,r,1),cr("f4",t,e,ir,i,r,1),cr("u1",t,e,ir,i*.7,r*1.1,-1),cr("u2",t,e,ir,-i*.7,r*1.1,-1),cr("u3",t,e,ir,0,r*2,-1),cr("cf1",t,e,ir,-i,0,1),cr("cf2",t,e,ir,i,0,1),cr("cf3",t,e,ir,0,-r,1),cr("cf4",t,e,ir,0,r,1),cr("cn1",t,e,ir,-i,0,-1),cr("cn2",t,e,ir,i,0,-1),cr("cn3",t,e,ir,0,-r,-1),cr("cn4",t,e,ir,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function cr(e,t,i,r,s,a,n){zf.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,c=o.length;h<c;h++)l.setXYZ(o[h],zf.x,zf.y,zf.z)}}var hg=class extends Tp{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new gt;s.setIndex(new Tt(i,1)),s.setAttribute("position",new at(r,3)),super(s,new zl({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},JN=class extends Tp{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new gt;r.setAttribute("position",new at(t,3)),r.setAttribute("color",new at(i,3));let s=new zl({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ct,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},wo=$N();function $N(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),r=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){let h=l-127;h<-27?(r[l]=0,r[l|256]=32768,s[l]=24,s[l|256]=24):h<-14?(r[l]=1024>>-h-14,r[l|256]=1024>>-h-14|32768,s[l]=-h-1,s[l|256]=-h-1):h<=15?(r[l]=h+15<<10,r[l|256]=h+15<<10|32768,s[l]=13,s[l|256]=13):h<128?(r[l]=31744,r[l|256]=64512,s[l]=24,s[l|256]=24):(r[l]=31744,r[l|256]=64512,s[l]=13,s[l|256]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,a[l]=h|c}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)n[l]=l<<23;n[31]=1199570944,n[32]=2147483648;for(let l=33;l<63;++l)n[l]=2147483648+(l-32<<23);n[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:i,baseTable:r,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}function e8(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=wr(e,-65504,65504),wo.floatView[0]=e;let t=wo.uint32View[0],i=t>>23&511;return wo.baseTable[i]+((t&8388607)>>wo.shiftTable[i])}function t8(e){let t=e>>10;return wo.uint32View[0]=wo.mantissaTable[wo.offsetTable[t]+(e&1023)]+wo.exponentTable[t],wo.floatView[0]}var i8=Object.freeze({__proto__:null,fromHalfFloat:t8,toHalfFloat:e8});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:bu}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=bu);var hd=".",Lb=Symbol("target"),MT=Symbol("unsubscribe");function Sy(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function r8(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Pn=Array.isArray;function Bb(e){return typeof e=="symbol"}var s8={after:(e,t)=>Pn(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Pn(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=hd),Bb(t)?e+t.toString():e+t):e,initial:e=>{if(Pn(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?"":e.slice(0,t)},last:e=>{if(Pn(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(hd);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Pn(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(hd);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(hd,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},wa=s8;function a8(e){return typeof e=="object"&&typeof e.next=="function"}function n8(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[Lb].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function JS(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Bb(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var o8=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,wa.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function Ay(e){return toString.call(e)==="[object Object]"}function Ff(){return!0}function fc(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var ET=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),l8=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),CT={push:Ff,pop:Ff,shift:Ff,unshift:Ff,copyWithin:fc,reverse:fc,sort:fc,splice:fc,flat:fc,fill:fc},h8=new Set([...ET,...l8,...Object.keys(CT)]);function kf(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var TT=["keys","values","entries"],PT=new Set(["has","toString"]),DT={add:kf,clear:kf,delete:kf,forEach:kf},c8=new Set([...PT,...Object.keys(DT),...TT]);function Uf(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var u8=new Set([...PT,"get"]),IT={set:Uf,clear:Uf,delete:Uf,forEach:Uf},d8=new Set([...u8,...Object.keys(IT),...TT]),Il=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return ET.has(e)}_shallowClone(e){let t=e;if(Ay(e))t={...e};else if(Pn(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(Pn(r)?this._onIsChanged=CT[t]:r instanceof Set?this._onIsChanged=DT[t]:r instanceof Map&&(this._onIsChanged=IT[t]),r):i}update(e,t,i){let r=wa.after(e,this._path);if(t!=="length"){let s=this.clone;wa.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],wa.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},$S=class extends Il{static isHandledMethod(e){return h8.has(e)}},p8=class extends Il{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},eA=class extends Il{static isHandledMethod(e){return c8.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},tA=class extends Il{static isHandledMethod(e){return d8.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},f8=class extends Il{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},m8=class extends Il{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Rc=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Ay(e)||Pn(e)||Sy(e)}static isHandledMethod(e,t){return Ay(e)?Il.isHandledMethod(t):Pn(e)?$S.isHandledMethod(t):e instanceof Set?eA.isHandledMethod(t):e instanceof Map?tA.isHandledMethod(t):Sy(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Il;Pn(e)?r=$S:e instanceof Date?r=p8:e instanceof Set?r=eA:e instanceof Map?r=tA:e instanceof WeakSet?r=f8:e instanceof WeakMap&&(r=m8),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Rc.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},g8={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},zb=(e,t,i={})=>{i={...g8,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new o8(s),h=typeof i.onValidate=="function",c=new Rc(h),u=(x,b,_,M,S)=>!h||c.isCloning||i.onValidate(wa.concat(l.getPath(x),b),_,M,S)===!0,d=(x,b,_,M)=>{!JS(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,M)},p=(x,b,_,M,S)=>{c.isCloning?c.update(x,b,M):t(wa.concat(x,b),_,M,S)},f=x=>x&&(x[r]||x),g=(x,b,_,M)=>r8(x)||_==="constructor"||a&&!Rc.isHandledMethod(b,_)||JS(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(M===void 0&&(M=l.getPath(b)),l.getProxy(x,wa.concat(M,_),m,r)),m={get(x,b,_){if(Bb(b)){if(b===r||b===Lb)return x;if(b===MT&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let M=Sy(x)?Reflect.get(x,b):Reflect.get(x,b,_);return g(M,x,b)},set(x,b,_,M){_=f(_);let S=x[r]||x,E=S[b];if(s(E,_)&&b in x)return!0;let A=u(x,b,_,E);return A&&l.setProperty(S,b,_,M,E)?(d(x,b,x[b],E),!0):!A},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let M=x[b];u(x,b,_.value,M)&&l.defineProperty(x,b,_,M)&&d(x,b,_.value,M)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),M=u(x,b,void 0,_);return M&&l.deleteProperty(x,b,_)?(d(x,b,void 0,_),!0):!M},apply(x,b,_){let M=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,M,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Rc.isHandledType(M)){let S=wa.initial(l.getPath(x)),E=Rc.isHandledMethod(M,x.name);c.start(M,S,_);let A=Reflect.apply(x,c.preferredThisArg(x,b,M),E?_.map(R=>f(R)):_),T=c.isChanged(M,s),P=c.stop();if(Rc.isHandledType(A)&&E&&(b instanceof Map&&x.name==="get"&&(S=wa.concat(S,_[0])),A=l.getProxy(A,S,m)),T){let R={name:x.name,args:_,result:A},z=c.isCloning?wa.initial(S):S,U=c.isCloning?wa.last(S):"";u(wa.get(e,z),U,M,P,R)?p(z,U,M,P,R):c.undo(M)}return(b instanceof Map||b instanceof Set)&&a8(A)?n8(A,x,b,S,g):A}return Reflect.apply(x,b,_)}},y=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};zb.target=e=>e&&e[Lb]||e;zb.unsubscribe=e=>e[MT]||e;var iA=zb,v8=typeof global=="object"&&global&&global.Object===Object&&global,OT=v8,y8=typeof self=="object"&&self&&self.Object===Object&&self,x8=OT||y8||Function("return this")(),an=x8,b8=an.Symbol,Da=b8,RT=Object.prototype,w8=RT.hasOwnProperty,_8=RT.toString,cd=Da?Da.toStringTag:void 0;function S8(e){var t=w8.call(e,cd),i=e[cd];try{e[cd]=void 0;var r=!0}catch{}var s=_8.call(e);return r&&(t?e[cd]=i:delete e[cd]),s}var A8=S8,M8=Object.prototype,E8=M8.toString;function C8(e){return E8.call(e)}var T8=C8,P8="[object Null]",D8="[object Undefined]",rA=Da?Da.toStringTag:void 0;function I8(e){return e==null?e===void 0?D8:P8:rA&&rA in Object(e)?A8(e):T8(e)}var Bh=I8;function O8(e){return e!=null&&typeof e=="object"}var Lo=O8,R8="[object Symbol]";function L8(e){return typeof e=="symbol"||Lo(e)&&Bh(e)==R8}var Op=L8;function B8(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var LT=B8,z8=Array.isArray,Un=z8,F8=1/0,sA=Da?Da.prototype:void 0,aA=sA?sA.toString:void 0;function BT(e){if(typeof e=="string")return e;if(Un(e))return LT(e,BT)+"";if(Op(e))return aA?aA.call(e):"";var t=e+"";return t=="0"&&1/e==-F8?"-0":t}var zT=BT,k8=/\s/;function U8(e){for(var t=e.length;t--&&k8.test(e.charAt(t)););return t}var FT=U8,N8=/^\s+/;function V8(e){return e&&e.slice(0,FT(e)+1).replace(N8,"")}var j8=V8;function H8(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var sn=H8,nA=0/0,G8=/^[-+]0x[0-9a-f]+$/i,W8=/^0b[01]+$/i,q8=/^0o[0-7]+$/i,X8=parseInt;function Y8(e){if(typeof e=="number")return e;if(Op(e))return nA;if(sn(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=sn(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=j8(e);var i=W8.test(e);return i||q8.test(e)?X8(e.slice(2),i?2:8):G8.test(e)?nA:+e}var oA=Y8;function Q8(e){return e}var kT=Q8,Z8="[object AsyncFunction]",K8="[object Function]",J8="[object GeneratorFunction]",$8="[object Proxy]";function eV(e){if(!sn(e))return!1;var t=Bh(e);return t==K8||t==J8||t==Z8||t==$8}var UT=eV,tV=an["__core-js_shared__"],N0=tV,lA=function(){var e=/[^.]+$/.exec(N0&&N0.keys&&N0.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function iV(e){return!!lA&&lA in e}var rV=iV,sV=Function.prototype,aV=sV.toString;function nV(e){if(e!=null){try{return aV.call(e)}catch{}try{return e+""}catch{}}return""}var zh=nV,oV=/[\\^$.*+?()[\]{}|]/g,lV=/^\[object .+?Constructor\]$/,hV=Function.prototype,cV=Object.prototype,uV=hV.toString,dV=cV.hasOwnProperty,pV=RegExp("^"+uV.call(dV).replace(oV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fV(e){if(!sn(e)||rV(e))return!1;var t=UT(e)?pV:lV;return t.test(zh(e))}var mV=fV;function gV(e,t){return e?.[t]}var vV=gV;function yV(e,t){var i=vV(e,t);return mV(i)?i:void 0}var Fh=yV,xV=Fh(an,"WeakMap"),My=xV,hA=Object.create,bV=function(){function e(){}return function(t){if(!sn(t))return{};if(hA)return hA(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),wV=bV;function _V(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var SV=_V;function AV(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var MV=AV,EV=800,CV=16,TV=Date.now;function PV(e){var t=0,i=0;return function(){var r=TV(),s=CV-(r-i);if(i=r,s>0){if(++t>=EV)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var DV=PV;function IV(e){return function(){return e}}var OV=IV,RV=function(){try{var e=Fh(Object,"defineProperty");return e({},"",{}),e}catch{}}(),cg=RV,LV=cg?function(e,t){return cg(e,"toString",{configurable:!0,enumerable:!1,value:OV(t),writable:!0})}:kT,BV=LV,zV=DV(BV),FV=zV;function kV(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var UV=kV;function NV(e,t,i,r){for(var s=e.length,a=i+(r?1:-1);r?a--:++a<s;)if(t(e[a],a,e))return a;return-1}var VV=NV;function jV(e){return e!==e}var HV=jV;function GV(e,t,i){for(var r=i-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}var WV=GV;function qV(e,t,i){return t===t?WV(e,t,i):VV(e,HV,i)}var XV=qV,YV=9007199254740991,QV=/^(?:0|[1-9]\d*)$/;function ZV(e,t){var i=typeof e;return t=t??YV,!!t&&(i=="number"||i!="symbol"&&QV.test(e))&&e>-1&&e%1==0&&e<t}var Fb=ZV;function KV(e,t,i){t=="__proto__"&&cg?cg(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var NT=KV;function JV(e,t){return e===t||e!==e&&t!==t}var kb=JV,$V=Object.prototype,ej=$V.hasOwnProperty;function tj(e,t,i){var r=e[t];(!(ej.call(e,t)&&kb(r,i))||i===void 0&&!(t in e))&&NT(e,t,i)}var Ub=tj;function ij(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?NT(i,o,l):Ub(i,o,l)}return i}var Rp=ij,cA=Math.max;function rj(e,t,i){return t=cA(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=cA(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),SV(e,this,o)}}var sj=rj,aj=9007199254740991;function nj(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=aj}var Nb=nj;function oj(e){return e!=null&&Nb(e.length)&&!UT(e)}var VT=oj,lj=Object.prototype;function hj(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||lj;return e===i}var Vb=hj;function cj(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var uj=cj,dj="[object Arguments]";function pj(e){return Lo(e)&&Bh(e)==dj}var uA=pj,jT=Object.prototype,fj=jT.hasOwnProperty,mj=jT.propertyIsEnumerable,gj=uA(function(){return arguments}())?uA:function(e){return Lo(e)&&fj.call(e,"callee")&&!mj.call(e,"callee")},jb=gj;function vj(){return!1}var yj=vj,HT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dA=HT&&typeof module=="object"&&module&&!module.nodeType&&module,xj=dA&&dA.exports===HT,pA=xj?an.Buffer:void 0,bj=pA?pA.isBuffer:void 0,wj=bj||yj,ug=wj,_j="[object Arguments]",Sj="[object Array]",Aj="[object Boolean]",Mj="[object Date]",Ej="[object Error]",Cj="[object Function]",Tj="[object Map]",Pj="[object Number]",Dj="[object Object]",Ij="[object RegExp]",Oj="[object Set]",Rj="[object String]",Lj="[object WeakMap]",Bj="[object ArrayBuffer]",zj="[object DataView]",Fj="[object Float32Array]",kj="[object Float64Array]",Uj="[object Int8Array]",Nj="[object Int16Array]",Vj="[object Int32Array]",jj="[object Uint8Array]",Hj="[object Uint8ClampedArray]",Gj="[object Uint16Array]",Wj="[object Uint32Array]",Hi={};Hi[Fj]=Hi[kj]=Hi[Uj]=Hi[Nj]=Hi[Vj]=Hi[jj]=Hi[Hj]=Hi[Gj]=Hi[Wj]=!0;Hi[_j]=Hi[Sj]=Hi[Bj]=Hi[Aj]=Hi[zj]=Hi[Mj]=Hi[Ej]=Hi[Cj]=Hi[Tj]=Hi[Pj]=Hi[Dj]=Hi[Ij]=Hi[Oj]=Hi[Rj]=Hi[Lj]=!1;function qj(e){return Lo(e)&&Nb(e.length)&&!!Hi[Bh(e)]}var Xj=qj;function Yj(e){return function(t){return e(t)}}var Hb=Yj,GT=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gd=GT&&typeof module=="object"&&module&&!module.nodeType&&module,Qj=Gd&&Gd.exports===GT,V0=Qj&&OT.process,Zj=function(){try{var e=Gd&&Gd.require&&Gd.require("util").types;return e||V0&&V0.binding&&V0.binding("util")}catch{}}(),lu=Zj,fA=lu&&lu.isTypedArray,Kj=fA?Hb(fA):Xj,WT=Kj,Jj=Object.prototype,$j=Jj.hasOwnProperty;function eH(e,t){var i=Un(e),r=!i&&jb(e),s=!i&&!r&&ug(e),a=!i&&!r&&!s&&WT(e),n=i||r||s||a,o=n?uj(e.length,String):[],l=o.length;for(var h in e)(t||$j.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Fb(h,l)))&&o.push(h);return o}var qT=eH;function tH(e,t){return function(i){return e(t(i))}}var XT=tH,iH=XT(Object.keys,Object),rH=iH,sH=Object.prototype,aH=sH.hasOwnProperty;function nH(e){if(!Vb(e))return rH(e);var t=[];for(var i in Object(e))aH.call(e,i)&&i!="constructor"&&t.push(i);return t}var oH=nH;function lH(e){return VT(e)?qT(e):oH(e)}var Gb=lH;function hH(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var cH=hH,uH=Object.prototype,dH=uH.hasOwnProperty;function pH(e){if(!sn(e))return cH(e);var t=Vb(e),i=[];for(var r in e)r=="constructor"&&(t||!dH.call(e,r))||i.push(r);return i}var fH=pH;function mH(e){return VT(e)?qT(e,!0):fH(e)}var ch=mH,gH=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vH=/^\w*$/;function yH(e,t){if(Un(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Op(e)?!0:vH.test(e)||!gH.test(e)||t!=null&&e in Object(t)}var xH=yH,bH=Fh(Object,"create"),hp=bH;function wH(){this.__data__=hp?hp(null):{},this.size=0}var _H=wH;function SH(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var AH=SH,MH="__lodash_hash_undefined__",EH=Object.prototype,CH=EH.hasOwnProperty;function TH(e){var t=this.__data__;if(hp){var i=t[e];return i===MH?void 0:i}return CH.call(t,e)?t[e]:void 0}var PH=TH,DH=Object.prototype,IH=DH.hasOwnProperty;function OH(e){var t=this.__data__;return hp?t[e]!==void 0:IH.call(t,e)}var RH=OH,LH="__lodash_hash_undefined__";function BH(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=hp&&t===void 0?LH:t,this}var zH=BH;function Eu(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Eu.prototype.clear=_H;Eu.prototype.delete=AH;Eu.prototype.get=PH;Eu.prototype.has=RH;Eu.prototype.set=zH;var mA=Eu;function FH(){this.__data__=[],this.size=0}var kH=FH;function UH(e,t){for(var i=e.length;i--;)if(kb(e[i][0],t))return i;return-1}var lv=UH,NH=Array.prototype,VH=NH.splice;function jH(e){var t=this.__data__,i=lv(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():VH.call(t,i,1),--this.size,!0}var HH=jH;function GH(e){var t=this.__data__,i=lv(t,e);return i<0?void 0:t[i][1]}var WH=GH;function qH(e){return lv(this.__data__,e)>-1}var XH=qH;function YH(e,t){var i=this.__data__,r=lv(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var QH=YH;function Cu(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Cu.prototype.clear=kH;Cu.prototype.delete=HH;Cu.prototype.get=WH;Cu.prototype.has=XH;Cu.prototype.set=QH;var hv=Cu,ZH=Fh(an,"Map"),cp=ZH;function KH(){this.size=0,this.__data__={hash:new mA,map:new(cp||hv),string:new mA}}var JH=KH;function $H(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var eG=$H;function tG(e,t){var i=e.__data__;return eG(t)?i[typeof t=="string"?"string":"hash"]:i.map}var cv=tG;function iG(e){var t=cv(this,e).delete(e);return this.size-=t?1:0,t}var rG=iG;function sG(e){return cv(this,e).get(e)}var aG=sG;function nG(e){return cv(this,e).has(e)}var oG=nG;function lG(e,t){var i=cv(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var hG=lG;function Tu(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Tu.prototype.clear=JH;Tu.prototype.delete=rG;Tu.prototype.get=aG;Tu.prototype.has=oG;Tu.prototype.set=hG;var uv=Tu,cG="Expected a function";function Wb(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(cG);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(Wb.Cache||uv),i}Wb.Cache=uv;var uG=Wb,dG=500;function pG(e){var t=uG(e,function(r){return i.size===dG&&i.clear(),r}),i=t.cache;return t}var fG=pG,mG=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gG=/\\(\\)?/g,vG=fG(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(mG,function(i,r,s,a){t.push(s?a.replace(gG,"$1"):r||i)}),t}),yG=vG;function xG(e){return e==null?"":zT(e)}var YT=xG;function bG(e,t){return Un(e)?e:xH(e,t)?[e]:yG(YT(e))}var Pu=bG,wG=1/0;function _G(e){if(typeof e=="string"||Op(e))return e;var t=e+"";return t=="0"&&1/e==-wG?"-0":t}var dv=_G;function SG(e,t){t=Pu(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[dv(t[i++])];return i&&i==r?e:void 0}var QT=SG;function AG(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var qb=AG,gA=Da?Da.isConcatSpreadable:void 0;function MG(e){return Un(e)||jb(e)||!!(gA&&e&&e[gA])}var EG=MG;function ZT(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=EG),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?ZT(o,t-1,i,r,s):qb(s,o):r||(s[s.length]=o)}return s}var CG=ZT;function TG(e){var t=e==null?0:e.length;return t?CG(e,1):[]}var PG=TG;function DG(e){return FV(sj(e,void 0,PG),e+"")}var KT=DG,IG=XT(Object.getPrototypeOf,Object),Xb=IG,OG="[object Object]",RG=Function.prototype,LG=Object.prototype,JT=RG.toString,BG=LG.hasOwnProperty,zG=JT.call(Object);function FG(e){if(!Lo(e)||Bh(e)!=OG)return!1;var t=Xb(e);if(t===null)return!0;var i=BG.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&JT.call(i)==zG}var kG=FG;function UG(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var a=Array(s);++r<s;)a[r]=e[r+t];return a}var $T=UG;function NG(e,t,i){var r=e.length;return i=i===void 0?r:i,!t&&i>=r?e:$T(e,t,i)}var VG=NG,jG="\\ud800-\\udfff",HG="\\u0300-\\u036f",GG="\\ufe20-\\ufe2f",WG="\\u20d0-\\u20ff",qG=HG+GG+WG,XG="\\ufe0e\\ufe0f",YG="\\u200d",QG=RegExp("["+YG+jG+qG+XG+"]");function ZG(e){return QG.test(e)}var KG=ZG;function JG(e){return e.split("")}var $G=JG,eP="\\ud800-\\udfff",e9="\\u0300-\\u036f",t9="\\ufe20-\\ufe2f",i9="\\u20d0-\\u20ff",r9=e9+t9+i9,s9="\\ufe0e\\ufe0f",a9="["+eP+"]",Ey="["+r9+"]",Cy="\\ud83c[\\udffb-\\udfff]",n9="(?:"+Ey+"|"+Cy+")",tP="[^"+eP+"]",iP="(?:\\ud83c[\\udde6-\\uddff]){2}",rP="[\\ud800-\\udbff][\\udc00-\\udfff]",o9="\\u200d",sP=n9+"?",aP="["+s9+"]?",l9="(?:"+o9+"(?:"+[tP,iP,rP].join("|")+")"+aP+sP+")*",h9=aP+sP+l9,c9="(?:"+[tP+Ey+"?",Ey,iP,rP,a9].join("|")+")",u9=RegExp(Cy+"(?="+Cy+")|"+c9+h9,"g");function d9(e){return e.match(u9)||[]}var p9=d9;function f9(e){return KG(e)?p9(e):$G(e)}var vA=f9;function m9(){this.__data__=new hv,this.size=0}var g9=m9;function v9(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var y9=v9;function x9(e){return this.__data__.get(e)}var b9=x9;function w9(e){return this.__data__.has(e)}var _9=w9,S9=200;function A9(e,t){var i=this.__data__;if(i instanceof hv){var r=i.__data__;if(!cp||r.length<S9-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new uv(r)}return i.set(e,t),this.size=i.size,this}var M9=A9;function Du(e){var t=this.__data__=new hv(e);this.size=t.size}Du.prototype.clear=g9;Du.prototype.delete=y9;Du.prototype.get=b9;Du.prototype.has=_9;Du.prototype.set=M9;var Fm=Du;function E9(e,t){return e&&Rp(t,Gb(t),e)}var C9=E9;function T9(e,t){return e&&Rp(t,ch(t),e)}var P9=T9,nP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yA=nP&&typeof module=="object"&&module&&!module.nodeType&&module,D9=yA&&yA.exports===nP,xA=D9?an.Buffer:void 0,bA=xA?xA.allocUnsafe:void 0;function I9(e,t){if(t)return e.slice();var i=e.length,r=bA?bA(i):new e.constructor(i);return e.copy(r),r}var O9=I9;function R9(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var L9=R9;function B9(){return[]}var oP=B9,z9=Object.prototype,F9=z9.propertyIsEnumerable,wA=Object.getOwnPropertySymbols,k9=wA?function(e){return e==null?[]:(e=Object(e),L9(wA(e),function(t){return F9.call(e,t)}))}:oP,Yb=k9;function U9(e,t){return Rp(e,Yb(e),t)}var N9=U9,V9=Object.getOwnPropertySymbols,j9=V9?function(e){for(var t=[];e;)qb(t,Yb(e)),e=Xb(e);return t}:oP,lP=j9;function H9(e,t){return Rp(e,lP(e),t)}var G9=H9;function W9(e,t,i){var r=t(e);return Un(e)?r:qb(r,i(e))}var hP=W9;function q9(e){return hP(e,Gb,Yb)}var Ty=q9;function X9(e){return hP(e,ch,lP)}var cP=X9,Y9=Fh(an,"DataView"),Py=Y9,Q9=Fh(an,"Promise"),Dy=Q9,Z9=Fh(an,"Set"),Iy=Z9,_A="[object Map]",K9="[object Object]",SA="[object Promise]",AA="[object Set]",MA="[object WeakMap]",EA="[object DataView]",J9=zh(Py),$9=zh(cp),e7=zh(Dy),t7=zh(Iy),i7=zh(My),th=Bh;(Py&&th(new Py(new ArrayBuffer(1)))!=EA||cp&&th(new cp)!=_A||Dy&&th(Dy.resolve())!=SA||Iy&&th(new Iy)!=AA||My&&th(new My)!=MA)&&(th=function(e){var t=Bh(e),i=t==K9?e.constructor:void 0,r=i?zh(i):"";if(r)switch(r){case J9:return EA;case $9:return _A;case e7:return SA;case t7:return AA;case i7:return MA}return t});var up=th,r7=Object.prototype,s7=r7.hasOwnProperty;function a7(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&s7.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var n7=a7,o7=an.Uint8Array,dg=o7;function l7(e){var t=new e.constructor(e.byteLength);return new dg(t).set(new dg(e)),t}var Qb=l7;function h7(e,t){var i=t?Qb(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var c7=h7,u7=/\w*$/;function d7(e){var t=new e.constructor(e.source,u7.exec(e));return t.lastIndex=e.lastIndex,t}var p7=d7,CA=Da?Da.prototype:void 0,TA=CA?CA.valueOf:void 0;function f7(e){return TA?Object(TA.call(e)):{}}var m7=f7;function g7(e,t){var i=t?Qb(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var v7=g7,y7="[object Boolean]",x7="[object Date]",b7="[object Map]",w7="[object Number]",_7="[object RegExp]",S7="[object Set]",A7="[object String]",M7="[object Symbol]",E7="[object ArrayBuffer]",C7="[object DataView]",T7="[object Float32Array]",P7="[object Float64Array]",D7="[object Int8Array]",I7="[object Int16Array]",O7="[object Int32Array]",R7="[object Uint8Array]",L7="[object Uint8ClampedArray]",B7="[object Uint16Array]",z7="[object Uint32Array]";function F7(e,t,i){var r=e.constructor;switch(t){case E7:return Qb(e);case y7:case x7:return new r(+e);case C7:return c7(e,i);case T7:case P7:case D7:case I7:case O7:case R7:case L7:case B7:case z7:return v7(e,i);case b7:return new r;case w7:case A7:return new r(e);case _7:return p7(e);case S7:return new r;case M7:return m7(e)}}var k7=F7;function U7(e){return typeof e.constructor=="function"&&!Vb(e)?wV(Xb(e)):{}}var N7=U7,V7="[object Map]";function j7(e){return Lo(e)&&up(e)==V7}var H7=j7,PA=lu&&lu.isMap,G7=PA?Hb(PA):H7,W7=G7,q7="[object Set]";function X7(e){return Lo(e)&&up(e)==q7}var Y7=X7,DA=lu&&lu.isSet,Q7=DA?Hb(DA):Y7,Z7=Q7,K7=1,J7=2,$7=4,uP="[object Arguments]",eW="[object Array]",tW="[object Boolean]",iW="[object Date]",rW="[object Error]",dP="[object Function]",sW="[object GeneratorFunction]",aW="[object Map]",nW="[object Number]",pP="[object Object]",oW="[object RegExp]",lW="[object Set]",hW="[object String]",cW="[object Symbol]",uW="[object WeakMap]",dW="[object ArrayBuffer]",pW="[object DataView]",fW="[object Float32Array]",mW="[object Float64Array]",gW="[object Int8Array]",vW="[object Int16Array]",yW="[object Int32Array]",xW="[object Uint8Array]",bW="[object Uint8ClampedArray]",wW="[object Uint16Array]",_W="[object Uint32Array]",Ui={};Ui[uP]=Ui[eW]=Ui[dW]=Ui[pW]=Ui[tW]=Ui[iW]=Ui[fW]=Ui[mW]=Ui[gW]=Ui[vW]=Ui[yW]=Ui[aW]=Ui[nW]=Ui[pP]=Ui[oW]=Ui[lW]=Ui[hW]=Ui[cW]=Ui[xW]=Ui[bW]=Ui[wW]=Ui[_W]=!0;Ui[rW]=Ui[dP]=Ui[uW]=!1;function km(e,t,i,r,s,a){var n,o=t&K7,l=t&J7,h=t&$7;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!sn(e))return e;var c=Un(e);if(c){if(n=n7(e),!o)return MV(e,n)}else{var u=up(e),d=u==dP||u==sW;if(ug(e))return O9(e,o);if(u==pP||u==uP||d&&!s){if(n=l||d?{}:N7(e),!o)return l?G9(e,P9(n,e)):N9(e,C9(n,e))}else{if(!Ui[u])return s?e:{};n=k7(e,u,o)}}a||(a=new Fm);var p=a.get(e);if(p)return p;a.set(e,n),Z7(e)?e.forEach(function(m){n.add(km(m,t,i,m,e,a))}):W7(e)&&e.forEach(function(m,y){n.set(y,km(m,t,i,y,e,a))});var f=h?l?cP:Ty:l?ch:Gb,g=c?void 0:f(e);return UV(g||e,function(m,y){g&&(y=m,m=e[y]),Ub(n,y,km(m,t,i,y,e,a))}),n}var fP=km,SW=1,AW=4;function MW(e){return fP(e,SW|AW)}var pv=MW,EW="__lodash_hash_undefined__";function CW(e){return this.__data__.set(e,EW),this}var TW=CW;function PW(e){return this.__data__.has(e)}var DW=PW;function pg(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new uv;++t<i;)this.add(e[t])}pg.prototype.add=pg.prototype.push=TW;pg.prototype.has=DW;var IW=pg;function OW(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var RW=OW;function LW(e,t){return e.has(t)}var BW=LW,zW=1,FW=2;function kW(e,t,i,r,s,a){var n=i&zW,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),c=a.get(t);if(h&&c)return h==t&&c==e;var u=-1,d=!0,p=i&FW?new IW:void 0;for(a.set(e,t),a.set(t,e);++u<o;){var f=e[u],g=t[u];if(r)var m=n?r(g,f,u,t,e,a):r(f,g,u,e,t,a);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!RW(t,function(y,x){if(!BW(p,x)&&(f===y||s(f,y,i,r,a)))return p.push(x)})){d=!1;break}}else if(!(f===g||s(f,g,i,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}var mP=kW;function UW(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var NW=UW;function VW(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var jW=VW,HW=1,GW=2,WW="[object Boolean]",qW="[object Date]",XW="[object Error]",YW="[object Map]",QW="[object Number]",ZW="[object RegExp]",KW="[object Set]",JW="[object String]",$W="[object Symbol]",eq="[object ArrayBuffer]",tq="[object DataView]",IA=Da?Da.prototype:void 0,j0=IA?IA.valueOf:void 0;function iq(e,t,i,r,s,a,n){switch(i){case tq:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case eq:return!(e.byteLength!=t.byteLength||!a(new dg(e),new dg(t)));case WW:case qW:case QW:return kb(+e,+t);case XW:return e.name==t.name&&e.message==t.message;case ZW:case JW:return e==t+"";case YW:var o=NW;case KW:var l=r&HW;if(o||(o=jW),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=GW,n.set(e,t);var c=mP(o(e),o(t),r,s,a,n);return n.delete(e),c;case $W:if(j0)return j0.call(e)==j0.call(t)}return!1}var rq=iq,sq=1,aq=Object.prototype,nq=aq.hasOwnProperty;function oq(e,t,i,r,s,a){var n=i&sq,o=Ty(e),l=o.length,h=Ty(t),c=h.length;if(l!=c&&!n)return!1;for(var u=l;u--;){var d=o[u];if(!(n?d in t:nq.call(t,d)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var g=!0;a.set(e,t),a.set(t,e);for(var m=n;++u<l;){d=o[u];var y=e[d],x=t[d];if(r)var b=n?r(x,y,d,t,e,a):r(y,x,d,e,t,a);if(!(b===void 0?y===x||s(y,x,i,r,a):b)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var _=e.constructor,M=t.constructor;_!=M&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof M=="function"&&M instanceof M)&&(g=!1)}return a.delete(e),a.delete(t),g}var lq=oq,hq=1,OA="[object Arguments]",RA="[object Array]",Nf="[object Object]",cq=Object.prototype,LA=cq.hasOwnProperty;function uq(e,t,i,r,s,a){var n=Un(e),o=Un(t),l=n?RA:up(e),h=o?RA:up(t);l=l==OA?Nf:l,h=h==OA?Nf:h;var c=l==Nf,u=h==Nf,d=l==h;if(d&&ug(e)){if(!ug(t))return!1;n=!0,c=!1}if(d&&!c)return a||(a=new Fm),n||WT(e)?mP(e,t,i,r,s,a):rq(e,t,l,i,r,s,a);if(!(i&hq)){var p=c&&LA.call(e,"__wrapped__"),f=u&&LA.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return a||(a=new Fm),s(g,m,i,r,a)}}return d?(a||(a=new Fm),lq(e,t,i,r,s,a)):!1}var dq=uq;function gP(e,t,i,r,s){return e===t?!0:e==null||t==null||!Lo(e)&&!Lo(t)?e!==e&&t!==t:dq(e,t,i,r,gP,s)}var pq=gP;function fq(e,t){return e!=null&&t in Object(e)}var mq=fq;function gq(e,t,i){t=Pu(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=dv(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&Nb(s)&&Fb(n,s)&&(Un(e)||jb(e)))}var vq=gq;function yq(e,t){return e!=null&&vq(e,t,mq)}var xq=yq,bq=function(){return an.Date.now()},H0=bq,wq="Expected a function",_q=Math.max,Sq=Math.min;function Aq(e,t,i){var r,s,a,n,o,l,h=0,c=!1,u=!1,d=!0;if(typeof e!="function")throw new TypeError(wq);t=oA(t)||0,sn(i)&&(c=!!i.leading,u="maxWait"in i,a=u?_q(oA(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d);function p(S){var E=r,A=s;return r=s=void 0,h=S,n=e.apply(A,E),n}function f(S){return h=S,o=setTimeout(y,t),c?p(S):n}function g(S){var E=S-l,A=S-h,T=t-E;return u?Sq(T,a-A):T}function m(S){var E=S-l,A=S-h;return l===void 0||E>=t||E<0||u&&A>=a}function y(){var S=H0();if(m(S))return x(S);o=setTimeout(y,g(S))}function x(S){return o=void 0,d&&r?p(S):(r=s=void 0,n)}function b(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function _(){return o===void 0?n:x(H0())}function M(){var S=H0(),E=m(S);if(r=arguments,s=this,l=S,E){if(o===void 0)return f(l);if(u)return clearTimeout(o),o=setTimeout(y,t),p(l)}return o===void 0&&(o=setTimeout(y,t)),n}return M.cancel=b,M.flush=_,M}var dp=Aq;function Mq(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var Eq=Mq;function Cq(e,t){return e>t}var Tq=Cq;function Pq(e,t){return t.length<2?e:QT(e,$T(t,0,-1))}var Dq=Pq;function Iq(e,t){return pq(e,t)}var Zb=Iq;function Oq(e,t,i){for(var r=-1,s=e.length;++r<s;){var a=e[r],n=t(a);if(n!=null&&(o===void 0?n===n&&!Op(n):i(n,o)))var o=n,l=a}return l}var Rq=Oq;function Lq(e){return e&&e.length?Rq(e,kT,Tq):void 0}var Bq=Lq;function zq(e,t){return t=Pu(t,e),e=Dq(e,t),e==null||delete e[dv(Eq(t))]}var Fq=zq;function kq(e){return kG(e)?void 0:e}var Uq=kq,Nq=1,Vq=2,jq=4,Hq=KT(function(e,t){var i={};if(e==null)return i;var r=!1;t=LT(t,function(a){return a=Pu(a,e),r||(r=a.length>1),a}),Rp(e,cP(e),i),r&&(i=fP(i,Nq|Vq|jq,Uq));for(var s=t.length;s--;)Fq(i,t[s]);return i}),Oy=Hq;function Gq(e,t,i,r){if(!sn(e))return e;t=Pu(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=dv(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var c=o[l];h=r?r(c,l,o):void 0,h===void 0&&(h=sn(c)?c:Fb(t[s+1])?[]:{})}Ub(o,l,h),o=o[l]}return e}var Wq=Gq;function qq(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=QT(e,n);i(o,n)&&Wq(a,Pu(n,e),o)}return a}var Xq=qq;function Yq(e,t){return Xq(e,t,function(i,r){return xq(e,r)})}var Qq=Yq,Zq=KT(function(e,t){return e==null?{}:Qq(e,t)}),Bn=Zq,Kq="Expected a function";function Jq(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(Kq);return sn(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),dp(e,t,{leading:r,maxWait:t,trailing:s})}var $q=Jq;function eX(e,t){for(var i=e.length;i--&&XV(t,e[i],0)>-1;);return i}var tX=eX;function iX(e,t,i){if(e=YT(e),e&&(i||t===void 0))return e.slice(0,FT(e)+1);if(!e||!(t=zT(t)))return e;var r=vA(e),s=tX(r,vA(t))+1;return VG(r,0,s).join("")}var rX=iX;function vP(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ia(e,t){return Object.setPrototypeOf(e,t),e}var sX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),aX=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),nX=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||fv&&"ontouchend"in document,oX=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,lX=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,hX=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},cX=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},uX=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},yP=sX(),joe=yP?uX():void 0,fv=aX(),Iu=nX(),dX=oX(),ra=lX(),BA=hX(),pX=Number(cX());function xP(e){return Array.isArray(e)?e:[e]}function bP(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function Vf(e){return fv?e.metaKey:e.ctrlKey}function fX(e){return e.wheelDeltaY===0||e.deltaY===0?fv&&e.shiftKey&&Math.abs(e.wheelDeltaX)>=120?!1:e.wheelDeltaX?e.wheelDeltaX===-3*e.deltaX||e.wheelDeltaX===-3*window.devicePixelRatio*e.deltaX:e.deltaMode===0:e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY||e.wheelDeltaY===-3*window.devicePixelRatio*e.deltaY:e.deltaMode===0}var It=[],fg={},Od={},Um={};function wP(e){It.includes(e)||It.push(e)}function Qc(e){delete fg[e.pointerId];for(let t=0;t<It.length;t++)if(It[t].pointerId===e.pointerId){It.splice(t,1);break}}function mX(){It.splice(0,It.length)}function mg(e){if(e.pointerType!=="touch")return;let t=fg[e.pointerId];t===void 0&&(t={x:0,y:0},fg[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function G0(e){let t=e.pointerId===It[0].pointerId?It[1]:It[0];return fg[t.pointerId]}function _P(e){Od[e.key]=!0,Um[e.key]=Um[e.key]===void 0?1:Um[e.key]+1}function SP(e){if(fv&&Od.Meta)for(let t in Od)Od[t]=!1;else Od[e.key]=!1;Um={}}function gX(e){e.addEventListener("pointerdown",wP,!0),e.addEventListener("pointerdown",mg,!0),e.addEventListener("pointermove",mg,!0),e.addEventListener("pointerup",Qc,!0),e.addEventListener("pointercancel",Qc,!0),e.addEventListener("pointerleave",Qc,!0),window.addEventListener("keydown",_P,!0),window.addEventListener("keyup",SP,!0)}function vX(e){e.removeEventListener("pointerdown",wP,!0),e.removeEventListener("pointerdown",mg,!0),e.removeEventListener("pointermove",mg,!0),e.removeEventListener("pointerup",Qc,!0),e.removeEventListener("pointercancel",Qc,!0),e.removeEventListener("pointerleave",Qc,!0),window.removeEventListener("keydown",_P,!0),window.removeEventListener("keyup",SP,!0)}var AP,yX=new Promise(e=>{AP=e}),jf;function xX(e){if(jf)return jf;async function t(){let i=e??"https://unpkg.com/@splinetool/navmesh-wasm@1.10.56/build",r=import("./navmesh.js"),[s,a]=await Promise.all([r,fetch(`${i}/navmesh.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});AP(o)}return jf=t(),jf}var MP,bX=new Promise(e=>{MP=e}),Hf;function wX(){if(Hf)return Hf;async function e(){let t=await import("./physics.js");await t.init(),MP(t)}return Hf=e(),Hf}var Et=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,Et.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,Et.prototype),{data:n,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,Et.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Kb(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&Kb(r)}return Object.freeze(e)}function _X(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var EP=class extends Error{};function W0(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function gl(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function Jb(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function SX(){return typeof process<"u"}function CP(e,t){for(let i of e)t(i.id,i.data)!==!0&&CP(i.children,t)}function TP(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)TP(i,t)}var ds=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,ds.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Kb(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&TP(i,t)}}traverse(e){CP(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,ds.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,c)=>h.fi-c.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let u=t;for(;u!==null;){if(u===void 0)throw new Error;if(u===r)throw new EP("cyclic tree");u=this.parent(u)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(u=>u.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let c=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((u,d)=>u.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:c,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>_X(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return gl(0,i,i);{let s=r[0].fi;return gl(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return gl(n,n+i,i)}else return gl(s.fi,a.fi,i)}}},gg;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(gg||(gg={}));var yt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,yt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Kb(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(a=>a.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,yt.prototype);let t=e;return SX()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),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 t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return gl(0,t,t);{let r=i[0].fi;return gl(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return gl(a,a+t,t)}else return gl(r.fi,s.fi,t)}}};function hu(e){return e&&typeof e=="object"&&e instanceof Er}var Er=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!hu(i))return null;r+=1}i=i?W0(i):new Er;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=W0(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=W0(o);l[e.path[r-1]]=i,i=l}else{let l=new Er;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,Er.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},Ml;(e=>{function t(s,a){return pp(s,a)??s}e.apply=t;function i(s,a){return ew(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=kr.zoomOnce(l,o[n]),l===void 0)return a;if(!hu(l))return;n+=1}if(l===void 0)return a;if(hu(l))if(a.type===0){let h={...a.props};for(let c of Object.keys(l))delete h[c];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=$b([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(Ml||(Ml={}));function $b(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=pp(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=$b(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function AX(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=pp(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function pp(e,t){if(!hu(t))return t;if(e instanceof ds){let i=$b(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof yt)return AX(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=pp(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof Er)return ew(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=pp(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function ew(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!hu(t))return t;if(!hu(e))return Ml.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new Er;for(let s of i){let a=ew(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function MX(e,t){let i={cur:[],result:[],len:0};return e=fp(e,t,i)??e,[e,i.result]}function vg(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function yg(e){e&&(e.len-=1)}function EX(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function PP(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=fp(a.data,t,vg(i,n));yg(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=PP(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function CX(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=fp(a.data,t,vg(i,n));return yg(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function fp(e,t,i){if(e instanceof ds){let r=PP(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof yt)return CX(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=fp(a,t,vg(i,n));return yg(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!Jb(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"&&a!=="variableId"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=fp(n,t,vg(i,a));yg(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&EX(i),r}else return}}var xg;(e=>{function t(i,r){let s=kr.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(xg||(xg={}));var Kr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let c=h.path;for(var u=[];;){let d;if(l instanceof Er&&h.type===0&&(d=l.runOp({...h,path:c.slice(u.length)}),d===null&&(d=void 0)),d===void 0&&u.length===c.length&&(l instanceof ds||l instanceof yt||l instanceof Et?d=l.runOp(h):d=gg.runOp(l,h)),d!==void 0)if(d!==null){let g=d.data;for(let m=u.length-1;m>=0;m--){let y=c[m],x=u[m];if(x instanceof ds){if(typeof y=="number")throw new Error("illegal arg");g=x.modifyById(y,g)}else if(x instanceof yt){if(typeof y=="number")throw new Error("illegal arg");g=x.modifyById(y,g)}else if(x instanceof Et){if(typeof y=="number")throw new Error("illegal arg");g=x.modifyById(y,g)}else if(x instanceof Er){let b={...x,[y]:g};g=Object.setPrototypeOf(b,Er.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof y=="string"&&(y=parseInt(y),isNaN(y)))throw new Error("Invalid path");let b=g;g=[...x],g[y]=b}else g={...x,[y]:g};else return null}return{data:g,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let p=c[u.length],f;if(l instanceof ds){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof yt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)u.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let c=0;c<l.length&&c<h.length;c++)if(l[c]!==h[c])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==h[c])return!1;return!0}e.pathEq=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(c=>h.props[c]!==void 0):!1}e.subsumed=o})(Kr||(Kr={}));var Ry;(e=>{function t(){return[]}e.empty=t;function i(h,c){let u=[];for(let d of h){let[p,...f]=d.path;p===c&&u.push({...d,path:f})}return u}e.removePrefix=i;function r(h,c){return h.map(u=>({...u,path:[c,...u.path]}))}e.addPrefix=r;function s(h,c){return[...h,...c]}e.concat=s;function a(h,c){return[...h.filter(u=>!c.some(d=>Kr.subsumed(u,d))),...c]}e.compress=a;function n(h,c){return h.every(u=>c.every(d=>Kr.commutative(u,d)))}e.commutative=n;function o(h,c){for(let u of c){let d=l(h,u);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,c){var u=h;let d=[],p=[];for(let f of c)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let g,m,y;if(f.type===3?(g=kr.zoom(u,[...f.path,f.id]),y=Kr.apply(u,{...f,type:2})):(g=kr.zoom(u,[...f.path,f.id,"value"]),y=Kr.apply(u,f)),y!==null){u=y.data;let[x,b]=MX(u,{[f.id]:g});u=x;for(let _=0;_<b.length;_++){let M=b[_],S=M.pop();if(typeof S=="number"){let E=[S];for(let T=_+1;T<b.length;T++){let P=b[T],R=P[P.length-1];if(typeof R=="number"&&kr.equal(M,P.slice(0,P.length-1)))E.push(R),b.splice(T,1);else break}let A=kr.zoom(u,M);m=A.map((T,P)=>E.includes(P)?f.id:T),g=A,S=M.pop()}else{if(S==="alphaOverride"||S==="alpha"){g/=100;let E=g,A=kr.zoom(u,M.slice(0,M.length-2)),T=A.layers.map(P=>P.id===M[M.length-1]?{...P,data:{...P.data,[S]:E}}:P);Object.setPrototypeOf(T,Object.getPrototypeOf(A.layers)),A.layers=T}m=f.id}d.push({type:0,path:M,props:{[S]:g}}),p.push({type:0,path:M,props:{[S]:m}})}p.push(y.reverse),d.push(y.actual)}}else{let g=Kr.apply(u,f);g!==null&&(d.push(g.actual),u=g.data,p.push(g.reverse))}}catch(g){if(g instanceof EP)return null;throw g}return{data:u,actual:d,reverse:p.reverse()}}e.apply=l})(Ry||(Ry={}));var DP=Symbol(),TX=Symbol(),mv=Symbol(),Lp=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof OP);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[mv];i&&i(),delete this._children[e]}}}},PX=class extends Lp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,gg.runOp(this._current,e),e.path)}},DX=class extends Lp{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,Et.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},IP={get(e,t){if(t===mv)return()=>{e._parent=null};if(t===DP)return e._current;if(t===TX)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let a=i[t],n=gv(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},IX={...IP,set(e,t,i){let r={type:0,props:{[t]:pr(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},OX={...IP,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},tw=class extends Lp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[mv]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,a=gv(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},iw=class extends Lp{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[mv]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,a=gv(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function q0(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&kr.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var OP=class extends Lp{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){q0(this.ts,t,e),q0(this.actual,i,e),q0(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function gv(e,t,i){return i instanceof ds?new tw(e,t,i):i instanceof yt?new iw(e,t,i):i instanceof Et?new Proxy(new DX(e,t,i),OX):i!==null&&typeof i=="object"?Jb(i)?i:new Proxy(new PX(e,t,i),IX):i}function RP(e){let t=new OP(e);return[gv(t,"",e),t]}function mp(e,t){let[i,r]=RP(e);return t(i),r.result()}function pr(e){return e instanceof tw||e instanceof iw?e._current:e!==null&&typeof e=="object"?e[DP]:e}var kr;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(c=>{delete h[c]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof ds||a instanceof tw)&&typeof n=="string"||(a instanceof yt||a instanceof iw)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(kr||(kr={}));function RX(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Li(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var LP=class{},zA=class extends LP{constructor(e){super(),this.id=e}},FA=class extends LP{constructor(e){super(),this.data=e}},Ly;try{Ly=new TextDecoder}catch{}var ct,El,we=0,BP=[],By=BP,zy=0,qs={},yi,vl,_a=0,Dn=0,ia,Do,Us=[],Ai,kA={useRecords:!1,mapsAsObjects:!0},zP=class{},FP=new zP;FP.name="MessagePack 0xC1";var cu=!1,bg=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ct)return HP(()=>(ky(),this?this.unpack(e,t):bg.prototype.unpack.call(kA,e,t)));El=t>-1?t:e.length,we=0,zy=0,Dn=0,vl=null,By=BP,ia=null,ct=e;try{Ai=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw ct=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof bg){if(qs=this,this.structures)return yi=this.structures,Gf();(!yi||yi.length>0)&&(yi=[])}else qs=kA,(!yi||yi.length>0)&&(yi=[]);return Gf()}unpackMultiple(e,t){let i,r=0;try{cu=!0;let s=e.length,a=this?this.unpack(e,s):yv.unpack(e,s);if(t){for(t(a);we<s;)if(r=we,t(Gf())===!1)return}else{for(i=[a];we<s;)r=we,i.push(Gf());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{cu=!1,ky()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Gf(){try{if(!qs.trusted&&!cu){let t=yi.sharedLength||0;t<yi.length&&(yi.length=t)}let e=sr();if(we==El)yi.restoreStructures&&UA(),yi=null,ct=null,Do&&(Do=null);else if(we>El){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 e}catch(e){throw yi.restoreStructures&&UA(),ky(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function UA(){for(let e in yi.restoreStructures)yi[e]=yi.restoreStructures[e];yi.restoreStructures=null}function sr(){let e=ct[we++];if(e<160)if(e<128){if(e<64)return e;{let t=yi[e&63]||qs.getStructures&&kP()[e&63];return t?(t.read||(t.read=rw(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,qs.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NP()]=sr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(sr(),sr());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=sr();return t}else if(e<192){let t=e-160;if(Dn>=we)return vl.slice(we-_a,(we+=t)-_a);if(Dn==0&&El<140){let i=t<16?sw(t):UP(t);if(i!=null)return i}return Fy(t)}else{let t;switch(e){case 192:return null;case 193:return ia?(t=sr(),t>0?ia[1].slice(ia.position1,ia.position1+=t):ia[0].slice(ia.position0,ia.position0-=t)):FP;case 194:return!1;case 195:return!0;case 196:return X0(ct[we++]);case 197:return t=Ai.getUint16(we),we+=2,X0(t);case 198:return t=Ai.getUint32(we),we+=4,X0(t);case 199:return Yl(ct[we++]);case 200:return t=Ai.getUint16(we),we+=2,Yl(t);case 201:return t=Ai.getUint32(we),we+=4,Yl(t);case 202:if(t=Ai.getFloat32(we),qs.useFloat32>2){let i=aw[(ct[we]&127)<<1|ct[we+1]>>7];return we+=4,(i*t+(t>0?.5:-.5)>>0)/i}return we+=4,t;case 203:return t=Ai.getFloat64(we),we+=8,t;case 204:return ct[we++];case 205:return t=Ai.getUint16(we),we+=2,t;case 206:return t=Ai.getUint32(we),we+=4,t;case 207:return qs.int64AsNumber?(t=Ai.getUint32(we)*4294967296,t+=Ai.getUint32(we+4)):t=Ai.getBigUint64(we),we+=8,t;case 208:return Ai.getInt8(we++);case 209:return t=Ai.getInt16(we),we+=2,t;case 210:return t=Ai.getInt32(we),we+=4,t;case 211:return qs.int64AsNumber?(t=Ai.getInt32(we)*4294967296,t+=Ai.getUint32(we+4)):t=Ai.getBigInt64(we),we+=8,t;case 212:if(t=ct[we++],t==114)return GA(ct[we++]&63);{let i=Us[t];if(i)return i.read?(we++,i.read(sr())):i.noBuffer?(we++,i()):i(ct.subarray(we,++we));throw new Error("Unknown extension "+t)}case 213:return t=ct[we],t==114?(we++,GA(ct[we++]&63,ct[we++])):Yl(2);case 214:return Yl(4);case 215:return Yl(8);case 216:return Yl(16);case 217:return t=ct[we++],Dn>=we?vl.slice(we-_a,(we+=t)-_a):BX(t);case 218:return t=Ai.getUint16(we),we+=2,Dn>=we?vl.slice(we-_a,(we+=t)-_a):zX(t);case 219:return t=Ai.getUint32(we),we+=4,Dn>=we?vl.slice(we-_a,(we+=t)-_a):FX(t);case 220:return t=Ai.getUint16(we),we+=2,VA(t);case 221:return t=Ai.getUint32(we),we+=4,VA(t);case 222:return t=Ai.getUint16(we),we+=2,jA(t);case 223:return t=Ai.getUint32(we),we+=4,jA(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var LX=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function rw(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>LX.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(sr);return e.highByte===0&&(e.read=NA(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=sr()}return r}return i.count=0,e.highByte===0?NA(t,i):i}var NA=(e,t)=>function(){let i=ct[we++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=yi[r]||kP()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=rw(s,e)),s.read()};function kP(){let e=HP(()=>(ct=null,qs.getStructures()));return yi=qs._mergeStructures(e,yi)}var Fy=vv,BX=vv,zX=vv,FX=vv;function vv(e){let t;if(e<16&&(t=sw(e)))return t;if(e>64&&Ly)return Ly.decode(ct.subarray(we,we+=e));let i=we+e,r=[];for(t="";we<i;){let s=ct[we++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=ct[we++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=ct[we++]&63,n=ct[we++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=ct[we++]&63,n=ct[we++]&63,o=ct[we++]&63,l=(s&7)<<18|a<<12|n<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=Xr.apply(String,r),r.length=0)}return r.length>0&&(t+=Xr.apply(String,r)),t}function VA(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=sr();return t}function jA(e){if(qs.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NP()]=sr();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(sr(),sr());return t}}var Xr=String.fromCharCode;function UP(e){let t=we,i=new Array(e);for(let r=0;r<e;r++){let s=ct[we++];if((s&128)>0){we=t;return}i[r]=s}return Xr.apply(String,i)}function sw(e){if(e<4)if(e<2){if(e===0)return"";{let t=ct[we++];if((t&128)>1){we-=1;return}return Xr(t)}}else{let t=ct[we++],i=ct[we++];if((t&128)>0||(i&128)>0){we-=2;return}if(e<3)return Xr(t,i);let r=ct[we++];if((r&128)>0){we-=3;return}return Xr(t,i,r)}else{let t=ct[we++],i=ct[we++],r=ct[we++],s=ct[we++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){we-=4;return}if(e<6){if(e===4)return Xr(t,i,r,s);{let a=ct[we++];if((a&128)>0){we-=5;return}return Xr(t,i,r,s,a)}}else if(e<8){let a=ct[we++],n=ct[we++];if((a&128)>0||(n&128)>0){we-=6;return}if(e<7)return Xr(t,i,r,s,a,n);let o=ct[we++];if((o&128)>0){we-=7;return}return Xr(t,i,r,s,a,n,o)}else{let a=ct[we++],n=ct[we++],o=ct[we++],l=ct[we++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){we-=8;return}if(e<10){if(e===8)return Xr(t,i,r,s,a,n,o,l);{let h=ct[we++];if((h&128)>0){we-=9;return}return Xr(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=ct[we++],c=ct[we++];if((h&128)>0||(c&128)>0){we-=10;return}if(e<11)return Xr(t,i,r,s,a,n,o,l,h,c);let u=ct[we++];if((u&128)>0){we-=11;return}return Xr(t,i,r,s,a,n,o,l,h,c,u)}else{let h=ct[we++],c=ct[we++],u=ct[we++],d=ct[we++];if((h&128)>0||(c&128)>0||(u&128)>0||(d&128)>0){we-=12;return}if(e<14){if(e===12)return Xr(t,i,r,s,a,n,o,l,h,c,u,d);{let p=ct[we++];if((p&128)>0){we-=13;return}return Xr(t,i,r,s,a,n,o,l,h,c,u,d,p)}}else{let p=ct[we++],f=ct[we++];if((p&128)>0||(f&128)>0){we-=14;return}if(e<15)return Xr(t,i,r,s,a,n,o,l,h,c,u,d,p,f);let g=ct[we++];if((g&128)>0){we-=15;return}return Xr(t,i,r,s,a,n,o,l,h,c,u,d,p,f,g)}}}}}function X0(e){return qs.copyBuffers?Uint8Array.prototype.slice.call(ct,we,we+=e):ct.subarray(we,we+=e)}function Yl(e){let t=ct[we++];if(Us[t])return Us[t](ct.subarray(we,we+=e));throw new Error("Unknown extension type "+t)}var HA=new Array(4096);function NP(){let e=ct[we++];if(e>=160&&e<192){if(e=e-160,Dn>=we)return vl.slice(we-_a,(we+=e)-_a);if(!(Dn==0&&El<180))return Fy(e)}else return we--,sr();let t=(e<<5^(e>1?Ai.getUint16(we):e>0?ct[we]:0))&4095,i=HA[t],r=we,s=we+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=Ai.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=ct[r++],a!=i[n++]){r=1879048192;break}if(r===s)return we=r,i.string;s-=3,r=we}for(i=[],HA[t]=i,i.bytes=e;r<s;)a=Ai.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=ct[r++],i.push(a);let o=e<16?sw(e):UP(e);return o!=null?i.string=o:i.string=Fy(e)}var GA=(e,t)=>{var i=sr();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=yi[e];return s&&s.isShared&&((yi.restoreStructures||(yi.restoreStructures=[]))[e]=s),yi[e]=i,i.read=rw(i,r),i.read()},VP=typeof self=="object"?self:global;Us[0]=()=>{};Us[0].noBuffer=!0;Us[101]=()=>{let e=sr();return(VP[e[0]]||Error)(e[1])};Us[105]=e=>{let t=Ai.getUint32(we-4);Do||(Do=new Map);let i=ct[we],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Do.set(t,s);let a=sr();return s.used?Object.assign(r,a):(s.target=a,a)};Us[112]=e=>{let t=Ai.getUint32(we-4),i=Do.get(t);return i.used=!0,i.target};Us[115]=()=>new Set(sr());var jP=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Us[116]=e=>{let t=e[0],i=jP[t];if(!i)throw new Error("Could not find typed array for code "+t);return new VP[i](Uint8Array.prototype.slice.call(e,1).buffer)};Us[120]=()=>{let e=sr();return new RegExp(e[0],e[1])};Us[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=we;we+=t-4,ia=[sr(),sr()],ia.position0=0,ia.position1=0;let r=we;we=i;try{return sr()}finally{we=r}};Us[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function HP(e){let t=El,i=we,r=zy,s=_a,a=Dn,n=vl,o=By,l=Do,h=ia,c=new Uint8Array(ct.slice(0,El)),u=yi,d=yi.slice(0,yi.length),p=qs,f=cu,g=e();return El=t,we=i,zy=r,_a=s,Dn=a,vl=n,By=o,Do=l,ia=h,ct=c,cu=f,yi=u,yi.splice(0,yi.length,...d),qs=p,Ai=new DataView(ct.buffer,ct.byteOffset,ct.byteLength),g}function ky(){ct=null,Do=null,yi=null}function kX(e){e.unpack?Us[e.type]=e.unpack:Us[e.type]=e}var aw=new Array(147);for(let e=0;e<256;e++)aw[e]=+("1e"+Math.floor(45.15-e*.30103));var yv=new bg({useRecords:!1}),Hoe=yv.unpack,Goe=yv.unpackMultiple,Woe=yv.unpack,UX={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},NX=new Float32Array(1),qoe=new Uint8Array(NX.buffer,0,4),Nm;try{Nm=new TextEncoder}catch{}var wg,nw,xv=typeof Buffer<"u",Y0=xv?Buffer.allocUnsafeSlow:Uint8Array,GP=xv?Buffer:Uint8Array,WA=xv?4294967296:2144337920,Ue,ur,Me=0,dn,pn=null,VX=/[\u0080-\uFFFF]/,ud=Symbol("record-id"),WP=class extends bg{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=GP.prototype.utf8Write?function(E,A,T){return Ue.utf8Write(E,A,T)}:Nm&&Nm.encodeInto?function(E,A){return Nm.encodeInto(E,Ue.subarray(A)).written}:!1,h=this;e||(e={});let c=e&&e.sequential,u=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=u?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=u?32:64),c&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,g=d+64,m=d+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],x=0,b=0;this.pack=this.encode=function(E,A){if(Ue||(Ue=new Y0(8192),ur=new DataView(Ue.buffer,0,8192),Me=0),dn=Ue.length-10,dn-Me<2048?(Ue=new Y0(Ue.length),ur=new DataView(Ue.buffer,0,Ue.length),dn=Ue.length-10,Me=0):Me=Me+7&2147483640,i=Me,n=h.structuredClone?new Map:null,h.bundleStrings?(pn=["",""],Ue[Me++]=214,Ue[Me++]=98,pn.position=Me-i,Me+=4):pn=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let T=r.sharedLength||0;if(T>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let P=0;P<T;P++){let R=r[P];if(!R)continue;let z,U=r.transitions;for(let L=0,H=R.length;L<H;L++){let q=R[L];z=U[q],z||(z=U[q]=Object.create(null)),U=z}U[ud]=P+64}o=T}c||(r.nextId=T+64)}s&&(s=!1),a=r||[];try{if(_(E),pn){ur.setUint32(pn.position+i,Me-pn.position-i);let T=pn;pn=null,_(T[0]),_(T[1])}if(h.offset=Me,n&&n.idsToInsert){Me+=n.idsToInsert.length*6,Me>dn&&S(Me),h.offset=Me;let T=HX(Ue.subarray(i,Me),n.idsToInsert);return n=null,T}return A&GX?(Ue.start=i,Ue.end=Me,Ue):Ue.subarray(i,Me)}finally{if(r){if(b<10&&b++,x>1e4)r.transitions=null,b=0,x=0,y.length>0&&(y=[]);else if(y.length>0&&!c){for(let T=0,P=y.length;T<P;T++)y[T][ud]=0;y=[]}if(s&&h.saveStructures){let T=r.sharedLength||d;r.length>T&&(r=r.slice(0,T));let P=Ue.subarray(i,Me);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(E)):(o=T,P)}}A&WX&&(Me=i)}};let _=E=>{Me>dn&&(Ue=S(Me));var A=typeof E,T;if(A==="string"){let P=E.length;if(pn&&P>=8&&P<4096){let U=VX.test(E);pn[U?0:1]+=E,Ue[Me++]=193,_(U?-P:P);return}let R;P<32?R=1:P<256?R=2:P<65536?R=3:R=5;let z=P*3;if(Me+z>dn&&(Ue=S(Me+z)),P<64||!l){let U,L,H,q=Me+R;for(U=0;U<P;U++)L=E.charCodeAt(U),L<128?Ue[q++]=L:L<2048?(Ue[q++]=L>>6|192,Ue[q++]=L&63|128):(L&64512)===55296&&((H=E.charCodeAt(U+1))&64512)===56320?(L=65536+((L&1023)<<10)+(H&1023),U++,Ue[q++]=L>>18|240,Ue[q++]=L>>12&63|128,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128):(Ue[q++]=L>>12|224,Ue[q++]=L>>6&63|128,Ue[q++]=L&63|128);T=q-Me-R}else T=l(E,Me+R,z);T<32?Ue[Me++]=160|T:T<256?(R<2&&Ue.copyWithin(Me+2,Me+1,Me+1+T),Ue[Me++]=217,Ue[Me++]=T):T<65536?(R<3&&Ue.copyWithin(Me+3,Me+2,Me+2+T),Ue[Me++]=218,Ue[Me++]=T>>8,Ue[Me++]=T&255):(R<5&&Ue.copyWithin(Me+5,Me+3,Me+3+T),Ue[Me++]=219,ur.setUint32(Me,T),Me+=4),Me+=T}else if(A==="number")if(E>>>0===E)E<64?Ue[Me++]=E:E<256?(Ue[Me++]=204,Ue[Me++]=E):E<65536?(Ue[Me++]=205,Ue[Me++]=E>>8,Ue[Me++]=E&255):(Ue[Me++]=206,ur.setUint32(Me,E),Me+=4);else if(E>>0===E)E>=-32?Ue[Me++]=256+E:E>=-128?(Ue[Me++]=208,Ue[Me++]=E+256):E>=-32768?(Ue[Me++]=209,ur.setInt16(Me,E),Me+=2):(Ue[Me++]=210,ur.setInt32(Me,E),Me+=4);else{let P;if((P=this.useFloat32)>0&&E<4294967296&&E>=-2147483648){Ue[Me++]=202,ur.setFloat32(Me,E);let R;if(P<4||(R=E*aw[(Ue[Me]&127)<<1|Ue[Me+1]>>7])>>0===R){Me+=4;return}else Me--}Ue[Me++]=203,ur.setFloat64(Me,E),Me+=8}else if(A==="object")if(!E)Ue[Me++]=192;else{if(n){let R=n.get(E);if(R){if(!R.id){let z=n.idsToInsert||(n.idsToInsert=[]);R.id=z.push(R)}Ue[Me++]=214,Ue[Me++]=112,ur.setUint32(Me,R.id),Me+=4;return}else n.set(E,{offset:Me-i})}let P=E.constructor;if(P===Object)M(E,!0);else if(P===Array){T=E.length,T<16?Ue[Me++]=144|T:T<65536?(Ue[Me++]=220,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=221,ur.setUint32(Me,T),Me+=4);for(let R=0;R<T;R++)_(E[R])}else if(P===Map){T=E.size,T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,ur.setUint32(Me,T),Me+=4);for(let[R,z]of E)_(R),_(z)}else{for(let R=0,z=wg.length;R<z;R++){let U=nw[R];if(E instanceof U){let L=wg[R];if(L.write){L.type&&(Ue[Me++]=212,Ue[Me++]=L.type,Ue[Me++]=0),_(L.write.call(this,E));return}let H=Ue,q=ur,Z=Me;Ue=null;let X;try{X=L.pack.call(this,E,se=>(Ue=H,H=null,Me+=se,Me>dn&&S(Me),{target:Ue,targetView:ur,position:Me-se}),_)}finally{H&&(Ue=H,ur=q,Me=Z,dn=Ue.length-10)}X&&(X.length+Me>dn&&S(X.length+Me),Me=jX(X,Ue,Me,L.type));return}}M(E,!E.hasOwnProperty)}}else if(A==="boolean")Ue[Me++]=E?195:194;else if(A==="bigint"){if(E<BigInt(1)<<BigInt(63)&&E>=-(BigInt(1)<<BigInt(63)))Ue[Me++]=211,ur.setBigInt64(Me,E);else if(E<BigInt(1)<<BigInt(64)&&E>0)Ue[Me++]=207,ur.setBigUint64(Me,E);else if(this.largeBigIntToFloat)Ue[Me++]=203,ur.setFloat64(Me,Number(E));else throw new RangeError(E+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");Me+=8}else if(A==="undefined")this.encodeUndefinedAsNil?Ue[Me++]=192:(Ue[Me++]=212,Ue[Me++]=0,Ue[Me++]=0);else if(A==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},M=this.useRecords===!1?this.variableMapSize?E=>{let A=Object.keys(E),T=A.length;T<16?Ue[Me++]=128|T:T<65536?(Ue[Me++]=222,Ue[Me++]=T>>8,Ue[Me++]=T&255):(Ue[Me++]=223,ur.setUint32(Me,T),Me+=4);let P;for(let R=0;R<T;R++)_(P=A[R]),_(E[P])}:(E,A)=>{Ue[Me++]=222;let T=Me-i;Me+=2;let P=0;for(let R in E)(A||E.hasOwnProperty(R))&&(_(R),_(E[R]),P++);Ue[T+++i]=P>>8,Ue[T+i]=P&255}:E=>{let A=Object.keys(E),T,P=a.transitions||(a.transitions=Object.create(null)),R=0;for(let U=0,L=A.length;U<L;U++){let H=A[U];T=P[H],T||(T=P[H]=Object.create(null),R++),P=T}let z=P[ud];if(z)z>=96&&f?(Ue[Me++]=((z-=96)&31)+96,Ue[Me++]=z>>5):Ue[Me++]=z;else{z=a.nextId,z||(z=64),z<g&&this.shouldShareStructure&&!this.shouldShareStructure(A)?(z=a.nextOwnId,z<m||(z=g),a.nextOwnId=z+1):(z>=m&&(z=g),a.nextId=z+1);let U=A.highByte=z>=96&&f?z-96>>5:-1;P[ud]=z,a[z-64]=A,z<g?(A.isShared=!0,a.sharedLength=z-63,s=!0,U>=0?(Ue[Me++]=(z&31)+96,Ue[Me++]=U):Ue[Me++]=z):(U>=0?(Ue[Me++]=213,Ue[Me++]=114,Ue[Me++]=(z&31)+96,Ue[Me++]=U):(Ue[Me++]=212,Ue[Me++]=114,Ue[Me++]=z),R&&(x+=b*R),y.length>=p&&(y.shift()[ud]=0),y.push(P),_(A))}for(let U=0,L=A.length;U<L;U++)_(E[A[U]])},S=E=>{let A;if(E>16777216){if(E-i>WA)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(WA,Math.round(Math.max((E-i)*(E>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(E-i<<2,Ue.length-1)>>12)+1<<12;let T=new Y0(A);return ur=new DataView(T.buffer,0,A),Ue.copy?Ue.copy(T,0,i,E):T.set(Ue.slice(i,E)),Me-=i,i=0,dn=T.length-10,Ue=T}}useBuffer(e){Ue=e,ur=new DataView(Ue.buffer,Ue.byteOffset,Ue.byteLength),Me=0}};nw=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,zP];wg=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?qA(e,16,t):XA(xv?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==GP&&this.structuredClone?qA(e,jP.indexOf(i.name),t):XA(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function qA(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function XA(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function jX(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function HX(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function Ou(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");nw.unshift(e.Class),wg.unshift(e)}kX(e)}var qP=new WP({useRecords:!1}),Xoe=qP.pack,Yoe=qP.pack,{NEVER:Qoe,ALWAYS:Zoe,DECIMAL_ROUND:Koe,DECIMAL_FIT:Joe}=UX,GX=512,WX=1024,YA=new WP({structuredClone:!0});Ou({Class:Et.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Et.prototype),e}});Ou({Class:yt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,yt.prototype),e}});Ou({Class:ds.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,ds.prototype),e}});Ou({Class:zA.prototype.constructor,type:4,write(e){return e.id},read(e){return new zA(e)}});Ou({Class:FA.prototype.constructor,type:5,write(e){return e.data},read(e){return new FA(e)}});Ou({Class:Er.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Er.prototype),e}});function qX(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function Uy(e){if(Jb(e))return e;if(Array.isArray(e))return e.map(Uy);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Uy(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Ny;(e=>{function t(s){return YA.pack(s)}e.serialize=t;function i(s){return YA.unpack(s)}e.deserialize=i;function r(s){return qX(t(Uy(s))).toString()}e.checksum=r})(Ny||(Ny={}));var QA;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(QA||(QA={}));function ZA(e){return e==="MouseDown"||e==="MouseUp"||e==="KeyDown"||e==="KeyUp"||e==="Collision"||e==="Trigger"}var ys={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],API:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],WEBHOOK:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"],AIAssistantListener:["SetVariable"],AIAssistantTrigger:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional","ClearLocalStorage","UserAPI"]},KA;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,actions:new yt}:{type:r,disabled:!1,key:void 0,actions:new yt}}e.defaultData=i})(KA||(KA={}));var _g;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(_g||(_g={}));var Vy;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:_g.propertyDefaultData(s),rOperand:{..._g.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(Vy||(Vy={}));var JA;(e=>{function t(i){return i.find(r=>r==="ifActions"||r==="elseActions")!==void 0}e.isConditionalSubActions=t})(JA||(JA={}));var $A;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new yt,outActions:new yt,condition:Vy.distanceDefaultData(r)}}e.defaultData=i})($A||($A={}));var eM;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new yt,drop:new yt}})(eM||(eM={}));var jy;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new yt})(jy||(jy={}));var Hy;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Hy||(Hy={}));var tM;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new yt}}e.defaultData=i})(tM||(tM={}));var iM;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new yt}}e.defaultData=i})(iM||(iM={}));var rM;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new yt}}e.defaultData=i})(rM||(rM={}));var sM;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,target:"character",actions:new yt}}e.defaultData=i})(sM||(sM={}));var aM;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,target:"all",triggeringObjects:[],actions:new yt,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(aM||(aM={}));var Gy;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new yt},o={size:"tablet",operator:"<",actions:new yt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new yt},h=new yt;return h.push({id:lt.generateUUID(),fi:0,data:n},{id:lt.generateUUID(),fi:1,data:o},{id:lt.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new yt}}e.defaultBreakpointData=a})(Gy||(Gy={}));var Wy;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new yt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(Wy||(Wy={}));var nM;(e=>{function t(r){return r.type==="API"}e.is=t;function i(){return{disabled:!1,type:"API",successActions:new yt,errorActions:new yt,userAPIId:""}}e.defaultData=i})(nM||(nM={}));var oM;(e=>{function t(r){return r.type==="WEBHOOK"}e.is=t;function i(){return{disabled:!1,type:"WEBHOOK",actions:new yt,userWebhookId:""}}e.defaultData=i})(oM||(oM={}));var lM;(e=>{function t(r){return r.type==="AIAssistantListener"}e.is=t;function i(){return{disabled:!1,type:"AIAssistantListener",actions:new yt,analysis:"average",analysisRange:[0,71],analysisSingle:0}}e.defaultData=i})(lM||(lM={}));var hM;(e=>{function t(r){return r.type==="AIAssistantTrigger"}e.is=t;function i(){return{disabled:!1,description:"",type:"AIAssistantTrigger",actions:new yt}}e.defaultData=i})(hM||(hM={}));var Ru="personal camera",Wd="a218fcc3-276b-49b9-b485-49037fd14f5f",XX=2960946,sa=5526619,Co;(e=>{function t(f,g){return f[0]===g[0]&&f[1]===g[1]}e.isEqual=t;function i(f,g,m){return[f[0]+(g[0]-f[0])*m,f[1]+(g[1]-f[1])*m]}e.lerp=i;function r(f,g){return[f[0]+g[0],f[1]+g[1]]}e.add=r;function s(f,g){return[f[0]-g[0],f[1]-g[1]]}e.sub=s;function a(f,g){return[f[0]*g[0],f[1]*g[1]]}e.multiply=a;function n(f,g){return[f[0]/g[0],f[1]/g[1]]}e.divide=n;function o(f,g){return Math.pow(g[0]-f[0],2)+Math.pow(g[1]-f[1],2)}e.distanceSquared=o;function l(f,g){return Math.sqrt(o(f,g))}e.distance=l;function h(f,g){return f[0]*g[0]+f[1]*g[1]}e.dot=h;function c(f,g){return[f[0]*g,f[1]*g]}e.scalarMultiply=c;function u(f,g,m){let y=e.sub(g,f),x=e.sub(m,f),b=e.dot(y,x)/e.dot(y,y),_=e.scalarMultiply(y,b);return e.add(f,_)}e.projectionOnto=u;function d(f,g,m){return l(f,u(f,g,m))}e.projectionOntoDistance=d;function p(f,g){return[(f[0]+g[0])*.5,(f[1]+g[1])*.5]}e.center=p})(Co||(Co={}));var _h;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,c){return[l[0]+(h[0]-l[0])*c,l[1]+(h[1]-l[1])*c,l[2]+(h[2]-l[2])*c]}e.lerp=o})(_h||(_h={}));var Sg;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(Sg||(Sg={}));var cM;(e=>{let t=180/Math.PI,i=Math.PI/180;function r(o){return typeof o=="number"?o*t:o}function s(o){return typeof o=="number"?o*i:o}function a(o){return[r(o[0]),r(o[1]),r(o[2])]}e.radToDeg=a;function n(o){return[s(o[0]),s(o[1]),s(o[2])]}e.degToRad=n})(cM||(cM={}));var uu;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})(uu||(uu={}));var cs;(e=>{function t(h){return typeof h=="object"&&typeof h.r=="number"&&typeof h.g=="number"&&typeof h.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(h){return{r:Math.round(h.r*255),g:Math.round(h.g*255),b:Math.round(h.b*255),a:1}}e.toRgb255a1=i;function r(h){return{r:h.r,g:h.g,b:h.b}}e.clone=r;function s(h){return h=Math.floor(h),{r:(h>>16&255)/255,g:(h>>8&255)/255,b:(h&255)/255}}e.fromHex=s;function a(h){return Math.round(h.r*255)*65536+Math.round(h.g*255)*256+Math.round(h.b*255)}e.toHex=a;function n(h,c){return h.r===c.r&&h.g===c.g&&h.b===c.b}e.equals=n;function o(h,c){return h.r.toFixed(2)===c.r.toFixed(2)&&h.g.toFixed(2)===c.g.toFixed(2)&&h.b.toFixed(2)===c.b.toFixed(2)}e.equalsFixed=o;function l(h,c,u){return{r:h.r+(c.r-h.r)*u,g:h.g+(c.g-h.g)*u,b:h.b+(c.b-h.b)*u}}e.lerp=l})(cs||(cs={}));var Di;(e=>{e.white={...cs.white,a:1},e.transparent={...cs.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}e.from0to1=t;function i(l,h){return{...cs.fromHex(l),a:h}}e.fromHexAndA=i;function r(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}e.toRgb255a1=r;function s(l,h){return cs.equals(l,h)&&l.a===h.a}e.equals=s;function a(l,h){return cs.equalsFixed(l,h)&&l.a.toFixed(2)===h.a.toFixed(2)}e.equalsFixed=a;function n(l,h,c){return{r:l.r+(h.r-l.r)*c,g:l.g+(h.g-l.g)*c,b:l.b+(h.b-l.b)*c,a:l.a+(h.a-l.a)*c}}e.lerp=n;function o({r:l,g:h,b:c,a:u}=e.white){return`rgba(${l*255}, ${h*255}, ${c*255}, ${u})`}e.toStyle=o})(Di||(Di={}));var qy;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(qy||(qy={}));var YX=(e=>(e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING",e))(YX||{}),Xy;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Xy||(Xy={}));var Yy;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(Yy||(Yy={}));var ll;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(ll||(ll={}));function uM(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var Ph;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Ph||(Ph={}));var du;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}e.getZoom=t})(du||(du={}));var yl;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(a=>a*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let a={...r};if(XP.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;YP.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;QP.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;ZP.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;KP.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;JP.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(yl||(yl={}));var Qy;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(Qy||(Qy={}));var XP=["count"],YP=["radius","start","end","position","scale","rotation"],QP=["position","scale","rotation"],ZP=["count","size"],KP=["count","position","scale","rotation"],JP=["strength","scale","rotation","position","movement","seed","freqScale"],Zy;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Zy||(Zy={}));var Ky;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:Di.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Di.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Di.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Ky||(Ky={}));var Ag;(e=>(e.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},e.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},e.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:e.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...e.defaultCollisionData}))(Ag||(Ag={}));var pu;(e=>e.defaultData={enabled:"visibility",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]})(pu||(pu={}));var Jy;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Jy||(Jy={}));var $y;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})($y||($y={}));var ex;(e=>e.defaultData={...$y.defaultData,...Jy.defaultData})(ex||(ex={}));var dM;(e=>{function t(i,r){let s=[];if("material"in i){let a=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;a&&s.push(a)}else if("materials"in i)for(let a of i.materials){let n=typeof a=="string"?r.materials[a]??r.lib.materials[a]?.asset:a;n&&s.push(n)}return s}e.getMaterialData=t})(dM||(dM={}));var Mg;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Mg||(Mg={}));var pM;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="particle"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(pM||(pM={}));function QX(e){return e.type!=="displace"}var fM;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(fM||(fM={}));var $P=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],ZX=["wrapping","image","video","name","minFilter","magFilter"],Yr;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,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],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Mg.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...n,type:"color",color:cs.fromHex(sa)};case"depth":return{...n,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{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,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{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...cs.fromHex(6710886),a:1},colorB:{...cs.fromHex(6710886),a:1},colorC:{...cs.fromHex(16777215),a:1},colorD:{...cs.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{...n,type:"fresnel",color:Di.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,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:Di.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:Di.fromHexAndA(0,1),contourColor:Di.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...n,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{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...cs.fromHex(0),a:1},colorB:{...cs.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}}}})(Yr||(Yr={}));var Jr;(e=>{function t(c){return!c.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(c){let u="";return c.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{u+=`${p}${f}`,Array.isArray(f)?f.forEach(g=>u+=`${g}`):typeof f=="object"?Object.values(f).forEach(g=>{typeof g=="number"?u+=`${g.toFixed(4)}`:u+=`${g}`}):u+=`${f}`})}),u}e.getHash=i;function r(){return{layers:new yt}}e.defaultEmptyData=r;function s(c="layer1",u="layer2"){return n("phong",c,u)}e.defaultData=s;function a(c,u){return{...c,name:u}}e.withName=a;function n(c,u="layer1",d="layer2"){let p=new yt;return p.push({fi:0,data:Yr.defaultData("light",c),id:u}),p.push({fi:1,data:Yr.defaultData("color"),id:d}),{layers:p}}e.defaultTwoLayerData=n;function o(c){let u=Yr.defaultData("texture");c&&Object.assign(u.texture,{image:c});let d=new yt;return d.push({fi:0,data:u,id:"layer1"}),d.push({fi:1,data:{...Yr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Yr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}e.defaultUIObjectMaterial=o;function l(c,u="phong",d="layer1",p="layer2"){let f=Yr.defaultData("texture");Object.assign(f.texture,{image:c});let g=new yt;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:Yr.defaultData("light",u),id:p}),{layers:g}}e.defaultTwoLayerTextureData=l;function h(c,u="phong",d="layer1",p="layer2"){let f=Yr.defaultData("video");Object.assign(f.texture,{video:c});let g=new yt;return g.push({fi:0,data:f,id:d}),g.push({fi:1,data:Yr.defaultData("light",u),id:p}),{layers:g}}e.defaultTwoLayerVideoTextureData=h})(Jr||(Jr={}));var Eg;(e=>{function t(){return{points:new yt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Eg||(Eg={}));var Cg;(e=>{function t(){return{points:new yt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Cg||(Cg={}));var eD={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},tx;(e=>{function t(i,r){let s={...i};return iD.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(tx||(tx={}));var tD={shape:eD,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},iD=["depth","offset","angle","twist","startScale","endScale"],Tg;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"||r==="InputGeometry"}e.isParametricMesh=i})(Tg||(Tg={}));var ix;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,tx.merge(s.extrusion,r.extrusion))),s}e.merge=t})(ix||(ix={}));var cl;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="UIGeometry")return{type:i,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Cg.defaultData(),extrusion:tD};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Eg.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="ShapeBlendGeometry")return{type:i,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="InputGeometry")return{...e.defaultData("TextGeometry"),type:i,editable:!0};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(cl||(cl={}));var Q0=["width","height","depth"],rx;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:cs.white,near:.1,far:2e3})(rx||(rx={}));var Pg;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focusDistance:100,focalLength:20,bokehScale:5},noise:{...t,blendFunction:16}}})(Pg||(Pg={}));var sx;(e=>e.defaultData={softShadowQuality:"low"})(sx||(sx={}));var ax;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(ax||(ax={}));var nx;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(nx||(nx={}));var fu;(e=>e.defaultData={usePhysics:!1,gravity:-10})(fu||(fu={}));var ox;(e=>e.defaultData={playCamera:Ru,gameControlObject:null})(ox||(ox={}));var lx;(e=>e.defaultData={backgroundColor:Di.fromHexAndA(XX,1),postprocessing:Pg.defaultData,fog:rx.defaultData,globalPhysics:fu.defaultData,ambient:ax.defaultData,ao:nx.defaultData,shadow:sx.defaultData,publish:ox.defaultData})(lx||(lx={}));var hx;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(hx||(hx={}));var mM;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(mM||(mM={}));var mu;(e=>{e.identity={...qy.identity,hiddenMatrix:uu.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:a?.position||s.position,rotation:a?.rotation||s.rotation,scale:a?.scale||s.scale,hiddenMatrix:a?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,a){return vP({position:_h.isEqual(s.position,a.position)?void 0:a.position,rotation:_h.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:_h.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:uu.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(mu||(mu={}));var Ur;(e=>e.defaultData={states:new yt,events:new yt,visible:!0,raycastLock:!1,physics:pu.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...mu.identity,cloner:null})(Ur||(Ur={}));var cx;(e=>e.defaultData={type:"Empty",...Ur.defaultData})(cx||(cx={}));var gM;(e=>e.defaultData={type:"ParticleCollider",...hx.defaultData,...Ur.defaultData})(gM||(gM={}));var vM;(e=>e.defaultData={type:"Component",...Ur.defaultData})(vM||(vM={}));var yM;(e=>e.defaultData={type:"Particle",...Ur.defaultData,...Ag.defaultData})(yM||(yM={}));var ul;(e=>e.defaultData={type:"Mesh",...Ur.defaultData,...ex.defaultData})(ul||(ul={}));var gp;(e=>e.defaultData={...Ur.defaultData,...mu.identity,position:[0,0,du.DefaultTargetOffset],...du.defaultData})(gp||(gp={}));var ux;(e=>{function t(i){return{...Ur.defaultData,...Ky.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(ux||(ux={}));var Dg;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(Dg||(Dg={}));var xl;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Ur.defaultData,...s,component:r,overrides:new Er,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=mu.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(xl||(xl={}));var gu;(e=>{e.defaultData={type:"Page",...Ur.defaultData,physics:{...pu.defaultData,fusedBody:!1},...lx.defaultData,camera:gp.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(gu||(gu={}));var dx;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:uu.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:pu.defaultData,states:new yt,events:new yt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...du.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("RectangleGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("BooleanGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultShapeBlendObject={name:"Shape Blend",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("ShapeBlendGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("TextGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultInputObject={name:"Input",...Ur.defaultData,...ul.defaultData,geometry:cl.defaultData("InputGeometry"),material:Jr.defaultTwoLayerData("phong","layer1","layer2")}))(dx||(dx={}));var uh;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new Er}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new Er})))):Ph.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=mp(o.material,l=>{if(typeof l!="string")for(let[h,c]of Object.entries(n.material.layers)){let u=l.layers.data(h);u&&Yr.patch(u,c)}}).data),o.materials&&n.materials&&(o.materials=mp(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let c=n.materials[h];if(typeof c!="string")for(let[u,d]of Object.entries(c.layers)){let p=l[h]?.layers?.data(u);p&&Yr.patch(p,d)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function c(u,d){for(let[p,f]of Object.entries(d.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let y={path:[...u,"layers",p,"texture"],props:g,type:0};l.push(y)}if(Object.keys(m).length>0){let y={path:[...u,"layers",p],props:m,type:0};l.push(y)}}}for(let[u,d]of Object.entries(n))if(u!=="name")if(u==="cloner")l.push(...Qy.toOps(d,["cloner"]));else if(u==="pathSnapping")l.push({path:[u],props:{slide:d.slide,offset:d.offset},type:0});else if(u==="material")c(["material"],d);else if(u==="materials")for(let[p,f]of Object.entries(d))c(["materials",p],f);else if(h[u]===0){if(u==="geometry"&&d.extrusion!==void 0){let p={path:[u,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[u],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[u]=d;return l}e.toOps=r;function s(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,mu.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Ph.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:ix.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:yl.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:yl.merge(o.cloner,n.cloner)});else if(Zy.is(a.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=cs.clone(l.color))}return o}e.patch=s})(uh||(uh={}));var Ig;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Ig||(Ig={}));var To;(e=>e.defaultData={orbitControls:Ig.defaultData,playPage:Wd,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3},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,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(To||(To={}));var px;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(px||(px={}));var fx;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(fx||(fx={}));var dh;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...px.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:fx.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(dh||(dh={}));var vp;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{if(o.type==="Instance"){let l=Lg.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(vp||(vp={}));var ph;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",e.defaultLight={fi:-1,data:ux.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function t(s=!0,a=[]){let n=[],o=dx.defaultMeshObject;s&&(n.push({...e.defaultLight}),n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:o,children:[]})),n.push(...a);let l=new ds;return l.push({fi:1,id:Wd,data:{...gu.defaultData,name:"Scene 1"},children:n}),l}e.createDefaultObjectTreeWithPage=t,e.defaultData={objects:t(),publish:To.defaultData,styles:dh.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new ds,publish:To.defaultData,styles:dh.defaultData()}},e.emptyDataWithPage=function(s=!0){return{objects:t(s),publish:To.defaultData,styles:dh.defaultData()}},e.emptyData=function(){return{objects:new ds,publish:{...To.defaultData},styles:dh.defaultData()}};function i(s){return{...e.defaultData,objects:Ia(s,ds.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(ph||(ph={}));var qd;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(qd||(qd={}));var mx;(e=>(e.defaultData=t=>({url:t,name:"New Webhook",parametersSchemas:new yt}),e.defaultParameterValueByType=t=>t==="number"?0:t==="boolean"?!1:""))(mx||(mx={}));var xM;(e=>e.defaultData=(t,i="GET")=>({url:t,method:i,name:"New API",headers:new yt,queries:new yt,autoStart:!0}))(xM||(xM={}));var ps;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(ps||(ps={}));var gx;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(gx||(gx={}));var bM;(e=>e.all=[...gx.all,"components"])(bM||(bM={}));var wM;(e=>{function t(){return{images:new Et,videos:new Et,colors:new Et,audios:new Et,particles:new Et,fonts:new Et,materials:new Et,components:new Et,variables:new Et,userAPIs:new Et,userWebhooks:new Et}}e.defaultData=t})(wM||(wM={}));var Bo;(e=>{function t(){return{images:new Et,videos:new Et,colors:new Et,audios:new Et,particles:new Et,fonts:new Et,materials:new Et,components:new Et,variables:new Et,userAPIs:new Et,userWebhooks:new Et}}e.defaultData=t})(Bo||(Bo={}));var Sa;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ia(n,Et.prototype)}e.defaultColors=t;function i(){return Ia({},Et.prototype)}e.defaultImages=i;function r(){return{catelogs:new Et,materials:new Et,images:new Et,videos:new Et,colors:new Et,audios:new Et,particles:new Et,fonts:new Et,variables:new yt,userAPIs:new Et,userWebhooks:new Et,lib:Bo.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),c=Math.round(n-l*3600-h*60);return{textValue:[l,h,c]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(Sa||(Sa={}));var Og;(e=>e.list=["idle","move","jump","run"])(Og||(Og={}));var Rg;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,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"],["run","\u21E7"],["none","Ctrl"]],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 yt,move:new yt,jump:new yt,run:new yt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Di.fromHexAndA(3728051,1)}}))(Rg||(Rg={}));function _M(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...Bn(pr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...pr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function dl(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function pl(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=Jr.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Jr.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Jr.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==Er.prototype&&t(s.material)})})}function KX(e){Object.assign(e.scene.publish,{orbitControls:{...Ig.defaultData,...pr(e.scene.publish.orbitControls)}})}function JX(e){Object.assign(e.scene.publish.settings,{video:{...To.defaultData.settings.video,...pr(e.scene.publish.settings.video)}})}function $X(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if(($P.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(ZX.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function eY(e){e.scene.publish.withBackground=!0}function tY(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function iY(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function rY(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function sY(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=pr(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=pr(i).booleanExclude!==!0)}})}function aY(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function nY(e){function t(r){Object.setPrototypeOf(r,Er.prototype),r.texture&&Object.setPrototypeOf(r.texture,Er.prototype)}function i(r){Object.setPrototypeOf(r,Er.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(a=>{let n=a;if(n.material){let o=pr(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=pr(l).layers;i(h),l.layers=h}})})}function SM(e){e.layers===void 0&&Object.assign(e,Jr.defaultTwoLayerData("lambert"))}function Z0(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...pr(t),colors:i,steps:r};Object.assign(t,s)}})}function oY(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function AM(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Z0(r)}):"material"in i&&typeof i.material!="string"&&Z0(i.material)}),Object.values(e.shared.materials).forEach(t=>Z0(t))}function lY(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function hY(e){e.shared.audios=Ia({},Et.prototype)}function cY(e){e.shared.videos=Ia({},Et.prototype)}function uY(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function dY(e){Object.entries(pr(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(pr(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function pY(e){e.scene.publish.settings.web.preload=!1}function MM(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function EM(e){e.layers&&e.layers.forEach(t=>{QX(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 fY(e){e.shared.fonts=Ia({},Et.prototype)}function mY(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function gY(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=Jr.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=mY(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Ur.defaultData,...ul.defaultData,flatShading:!1,wireframe:!1,geometry:{...cl.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:a,states:pr(s.states),events:pr(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=pr(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function vY(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new yt,move:new yt,jump:new yt}});else{let a=new yt;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:lt.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(c,Bn(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(c,{control1:{...n.control1},control2:{...n.control2}});let u={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},d={state:n.state,...u,...c},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new yt({fi:0,id:lt.generateUUID(),data:h},{fi:1,id:lt.generateUUID(),data:d})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function yY(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new yt,o=[];if(i.events.forEach((l,h,c)=>{if(l.type==="Audio"&&l.trigger===a){let u;o.push(h),l.interaction==="play"?u={...Bn(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")&&(u={...Bn(l,"interaction","delay","object","playAudio"),type:"Audio"}),u&&n.push({fi:c,id:h,data:u})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:lt.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function CM(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Yr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function TM(e){dl(e,CM),pl(e,CM)}function xY(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function bY(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function wY(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=Jr.defaultTwoLayerData("phong"))})}function _Y(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function SY(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function AY(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function MY(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function EY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function CY(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function TY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Rg.defaultDataThirdPerson.navmesh)})})}function PY(e){e.scene.styles||(e.scene.styles=dh.defaultData())}function PM(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function DY(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),pl(e,PM),dl(e,PM)}function IY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new yt})})})}function OY(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function DM(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function RY(e,t){if(t<1&&(pl(e,_M),dl(e,_M),e.schema=1),t<2&&(KX(e),e.schema=2),t<3&&($X(e),e.schema=3),t<4&&(eY(e),e.schema=4),t<5&&(tY(e),e.schema=5),t<6&&(iY(e),e.schema=6),t<7&&(rY(e),e.schema=7),t<8&&(e.schema=8),t<9&&(AM(e),e.schema=9),t<10&&(oY(e),e.schema=10),t<11&&(lY(e),e.schema=11),t<12&&(AM(e),e.schema=12),t<13&&(hY(e),e.schema=13),t<14&&(uY(e),e.schema=14),t<15&&(dY(e),e.schema=15),t<16&&(pY(e),e.schema=16),t<17&&(pl(e,MM),dl(e,MM),e.schema=17),t<18&&(pl(e,SM),dl(e,SM),e.schema=18),t<19&&(JX(e),e.schema=19),t<20&&(fY(e),gY(e),e.schema=20),t<21&&(vY(e),yY(e),e.schema=21),t<22&&(TM(e),e.schema=22),t<23&&(xY(e),e.schema=23),t<24&&(bY(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(cY(e),t<25&&(e.schema=25)),t<26&&(sY(e),e.schema=26),t<27&&(aY(e),e.schema=27),t<28&&(TM(e),e.schema=28),t<29&&(nY(e),e.schema=29),t<30&&(wY(e),e.schema=30),t<31&&(_Y(e),e.schema=31),t<33&&(SY(e),e.schema=33),t<34&&(AY(e),e.schema=34),t<35&&(MY(e),e.schema=35),t<36&&(EY(e),e.schema=36),t<37&&(CY(e),e.schema=37),t<38&&(pl(e,EM),dl(e,EM),e.schema=38),t<39&&(TY(e),e.schema=39),t<40&&(PY(e),e.schema=40),t<41&&(DY(e),e.schema=41),t<42&&(IY(e),e.schema=42),t<43&&(OY(e),e.schema=43),t<99){pl(e,DM),dl(e,DM),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Ru);let i=pr(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Wd,r.insertBefore(null,null,[{id:Wd,data:{...gu.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Bn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Bn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...fu.defaultData,...Bn(e.scene.environment,"usePhysics","gravity")},camera:pr(e.scene.ownerCamera)??gu.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==ph.TRASH_CAN_ID&&r.move(Wd,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,pu.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function IM(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function LY(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function BY(e){Array.isArray(pr(e.events))&&e.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Lc=180/Math.PI;function OM(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Lc)}function rD(e){OM(e),e.type==="Page"&&OM(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Lc))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Lc),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Lc),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Lc,t.extrusion.twist*=Lc),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(pr(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Repeat")})}function zY(e){e.shared.variables=Ia({},Et.prototype)}function FY(e){let t=pr(e.shared.variables);e.shared.variables=Ia(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),yt.prototype)}var vo=117;function sD(e,t){t(e.data);for(let i of e.children)sD(i,t)}function kY(e){let t=e.schema??104;t!==vo&&t<105&&(sD(e.asset,rD),e.schema=105)}function UY(e){e.shared.particles=Ia({},Et.prototype),e.shared.lib&&(e.shared.lib.particles=Bo.defaultData().particles)}function NY(e){e.scene.objects.traverse((t,i)=>{i.type==="Particle"&&typeof i.renderMaterial.size=="number"&&Object.assign(i.renderMaterial,{size:[i.renderMaterial.size,i.renderMaterial.size]})})}function VY(e){e.scene.objects.traverse((t,i)=>{i.type==="Page"&&(i.postprocessing.depthOfField.focusDistance=100,i.postprocessing.depthOfField.focalLength=20,i.postprocessing.depthOfField.bokehScale=5)})}function jY(e){e.scene.objects.traverse((t,i)=>{Array.isArray(pr(i.events))!==!1&&i.events?.forEach(r=>{let s=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(a=>{a.type==="Transition"&&(a.runMode=s??"Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode=s==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),n.type==="Animation"&&(n.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(a=>{a.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Once"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}),r.outActions?.forEach(a=>{a.type==="Transition"&&(a.runMode="Repeat"),(a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Normal")}))})})}function HY(e){e.shared.userAPIs=Ia({},Et.prototype),e.shared.userWebhooks=Ia({},Et.prototype),e.shared.lib&&(e.shared.lib.userAPIs=Bo.defaultData().userAPIs,e.shared.lib.userWebhooks=Bo.defaultData().userWebhooks)}function GY(e){e.scene.publish.settings.videoStatic===void 0&&(e.scene.publish.settings.videoStatic=To.defaultData.settings.videoStatic)}function aD(e){let t=e.schema??0;if(t!==vo){console.warn("updating from ",t,"to ",vo),RY(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=To.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(pl(e,IM),dl(e,IM),e.schema=101),t<102&&(LY(e),e.schema=102),t<104&&(e.shared.catelogs=new Et,e.shared.lib=Bo.defaultData(),e.schema=104),t<105&&(zY(e),e.scene.objects.traverse((i,r)=>{rD(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))kY(i);t<106&&(FY(e),e.schema=106),t<107&&(e.shared.lib.variables=Bo.defaultData().variables,e.schema=107),t<109&&(UY(e),e.schema=109),t<110&&(NY(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{BY(r)}),e.schema=111),t<112&&(VY(e),e.schema=112),t<113&&(jY(e),e.schema=113),t<114&&(e.scene.publish.settings.web.imageQuality===void 0&&(e.scene.publish.settings.web.imageQuality=70),e.schema=114),t<115&&(HY(e),e.schema=115),t<116&&(GY(e),e.schema=116),t<117&&(e.scene.publish.settings.web.pixelRatioMobile===void 0&&(e.scene.publish.settings.web.pixelRatioMobile=0),e.scene.publish.settings.web.pixelRatioDesktop===void 0&&(e.scene.publish.settings.web.pixelRatioDesktop=0),e.schema=117)}}var Lg;(e=>{e.defaultData={schema:vo,scene:ph.defaultData,frames:new Et().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qd.defaultData),shared:{...Sa.emptyData(),colors:Sa.defaultColors()}},e.emptyDataForImports=function(){let a=ph.emptyDataWithPage();return{schema:vo,scene:a,frames:new Et().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qd.defaultData),shared:{...Sa.emptyData(),colors:Sa.defaultColors(),images:Sa.defaultImages()}}},e.emptyData=function(){return{schema:vo,scene:ph.emptyDataWithPage(),frames:new Et().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",qd.defaultData),shared:Sa.emptyData()}},e.clipboard2dData=function(){return{schema:vo,scene:ph.emptyData(),frames:new Et,shared:Sa.emptyData()}},e.collabHelper={...Ry,updateSchema(a){return(a.schema??0)<vo?mp(a,aD):(a.schema??0)-vo}};function t(a){let n=e.collabHelper.updateSchema(a);return typeof n=="number"?n===0?a:null:n.data}e.updateSchemaDirectly=t;function i(a){return{...a,shared:{...a.shared,lib:Bo.defaultData()}}}e.withoutLib=i;function r(a,n){let o=a.scene.objects.get(n);if(o&&o.data.type==="Component")return o;{let l=a.shared.lib.components[n];if(l)return l.asset}}e.getComponentData=r;function s(a){let n=Object.values(a.shared.userAPIs);for(let o of n){let l=o.headers;for(let h of l)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}e.hasSensitiveData=s})(Lg||(Lg={}));var vx;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(vx||(vx={}));var RM;(e=>{function t(i){return!0}e.is=t})(RM||(RM={}));var Bg;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale,shear:s?.shear??r.shear}}e.merge=t;function i(r,s){return vP({position:Co.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:Co.isEqual(r.scale,s.scale)?void 0:s.scale,shear:r.shear&&s.shear&&Co.isEqual(r.shear,s.shear)?void 0:s.shear})}e.diff=i})(Bg||(Bg={}));var yx;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(yx||(yx={}));var LM;(e=>e.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})(LM||(LM={}));var zg;(e=>e.defaultData={opacity:1,fill:{color:Di.fromHexAndA(sa,1),enabled:!0},stroke:{color:Di.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Di.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Di.from0to1([0,0,0,1]),enabled:!1,spread:0}})(zg||(zg={}));var fh;(e=>{function t(n,o){return{name:o}}e.newEmpty=t;function i(n,o){if(o===void 0)return n;let l={...n},h=["width","height","cornerRadius"];for(let c of h)c in l&&c in o&&o[c]!==void 0&&Object.assign(l,{[c]:o[c]});return l}function r(n,o){if(o===void 0)return n;let l={...n};return"fill"in l&&"fill"in o&&o.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...o.fill}}),"stroke"in l&&"stroke"in o&&o.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...o.stroke}}),"layerBlur"in l&&"layerBlur"in o&&o.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...o.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in o&&o.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...o.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in o&&o.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...o.dropShadow}}),"innerShadow"in l&&"innerShadow"in o&&o.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...o.innerShadow}}),l}function s(n,o){if(o===void 0)return n;let l={...n};return Object.assign(l,Bg.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=s;function a(n,o){let l,h=[];for(let[c,u]of Object.entries(o))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[c]=u);return h}e.toOps=a})(fh||(fh={}));var yp;(e=>e.defaultData={...Bg.defaultData,...yx.defaultData,states:new yt,events:new yt,visible:!0,raycastLock:!1})(yp||(yp={}));var vu;(e=>e.defaultData={...yp.defaultData,...zg.defaultData})(vu||(vu={}));var Fg;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Fg||(Fg={}));var xx;(e=>e.defaultData={...vu.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(xx||(xx={}));var xp;(e=>e.defaultData={...vu.defaultData,...Fg.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(xp||(xp={}));var bx;(e=>e.defaultData={...vu.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(bx||(bx={}));var wx;(e=>e.defaultData={...vu.defaultData,type:"path2d",path:"",name:"Path"})(wx||(wx={}));var BM;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"||i.type==="path2d"}e.is=t})(BM||(BM={}));var kg;(e=>e.defaultData={...yp.defaultData,name:"Group",type:"group2d"})(kg||(kg={}));var _x;(e=>e.defaultData=()=>({...yp.defaultData,...Fg.defaultData,...zg.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Di.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Di.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(_x||(_x={}));var Sh;(e=>{function t(n){switch(n){case"rectangle2d":return{...xp.defaultData};case"ellipse2d":return{...xx.defaultData};case"text2d":return{...bx.defaultData};case"vector2d":return{...xp.defaultData};case"path2d":return{...wx.defaultData};case"frame2d":return{..._x.defaultData()};case"group2d":return{...kg.defaultData}}}e.defaultData=t;function i(n){return"width"in n&&"height"in n?[typeof n.width=="number"?n.width*.5:0,typeof n.height=="number"?n.height*.5:0]:[0,0]}e.getPivot=i;function r(n){return n.type==="rectangle2d"||n.type==="ellipse2d"||n.type==="text2d"||n.type==="frame2d"}e.isResizeable=r;function s(n){return n.type==="frame2d"&&n.autoLayout!==void 0}e.isAutoLayoutable=s;function a(n){return n.type==="rectangle2d"||n.type==="frame2d"}e.hasCorners=a})(Sh||(Sh={}));var Sx;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ds},e.emptyData=function(){return{type:"scene2d",objects:new ds}}))(Sx||(Sx={}));function mh(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),a={},n={},o=e[0].morphTargetsRelative,l=new gt,h=0;for(let c=0;c<e.length;++c){let u=e[c],d=0;if(i!==(u.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 p in u.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(u.attributes[p]),d++}if(d!==r.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(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in u.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(u.morphAttributes[p])}if(t){let p;if(i)p=u.index.count;else if(u.attributes.position!==void 0)p=u.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(h,p,c),h+=p}}if(i){let c=0,u=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+c);c+=e[d].attributes.position.count}l.setIndex(u)}for(let c in a){let u=zM(a[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(let c in n){let u=n[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<u;++d){let p=[];for(let g=0;g<n[c].length;++g)p.push(n[c][g][d]);let f=zM(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function zM(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new Tt(a,i,r)}var WY=Math.pow(2,-24),Wf=class{constructor(){}};function In(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function FM(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function kM(e,t){t.set(e)}function UM(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function qf(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function dd(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function qY(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Tt(s,1));for(let a=0;a<i;a++)s[a]=a}}function XY(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function K0(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,y=s!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],M=e[x+1],S=_-M,E=_+M;S<a&&(a=S),E>l&&(l=E),y&&_<u&&(u=_),y&&_>f&&(f=_);let A=e[x+2],T=e[x+3],P=A-T,R=A+T;P<n&&(n=P),R>h&&(h=R),y&&A<d&&(d=A),y&&A>g&&(g=A);let z=e[x+4],U=e[x+5],L=z-U,H=z+U;L<o&&(o=L),H>c&&(c=H),y&&z<p&&(p=z),y&&z>m&&(m=z)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=c,y&&(s[0]=u,s[1]=d,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function YY(e,t,i,r){let s=1/0,a=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=t*6,u=(t+i)*6;c<u;c+=6){let d=e[c+0];d<s&&(s=d),d>o&&(o=d);let p=e[c+2];p<a&&(a=p),p>l&&(l=p);let f=e[c+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function QY(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let c=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=c;let u=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=u;let d=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=d}a++,n--}else return a}}var uo=32,ZY=(e,t)=>e.candidate-t.candidate,Jo=new Array(uo).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Xf=new Float32Array(6);function KY(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=FM(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=FM(e),n!==-1&&(o=JY(i,r,s,n));else if(a===2){let l=dd(e),h=1.25*s,c=r*6,u=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/uo;if(s<uo/4){let g=[...Jo];g.length=s;let m=0;for(let x=c;x<u;x+=6,m++){let b=g[m];b.candidate=i[x+2*d],b.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:S}=b;for(let E=0;E<3;E++)S[E]=1/0,S[E+3]=-1/0,M[E]=1/0,M[E+3]=-1/0,_[E]=1/0,_[E+3]=-1/0;qf(x,i,_)}g.sort(ZY);let y=s;for(let x=0;x<y;x++){let b=g[x];for(;x+1<y&&g[x+1].candidate===b.candidate;)g.splice(x+1,1),y--}for(let x=c;x<u;x+=6){let b=i[x+2*d];for(let _=0;_<y;_++){let M=g[_];b>=M.candidate?qf(x,i,M.rightCacheBounds):(qf(x,i,M.leftCacheBounds),M.count++)}}for(let x=0;x<y;x++){let b=g[x],_=b.count,M=s-b.count,S=b.leftCacheBounds,E=b.rightCacheBounds,A=0;_!==0&&(A=dd(S)/l);let T=0;M!==0&&(T=dd(E)/l);let P=1+1.25*(A*_+T*M);P<h&&(n=d,h=P,o=b.candidate)}}else{for(let y=0;y<uo;y++){let x=Jo[y];x.count=0,x.candidate=p+f+y*f;let b=x.bounds;for(let _=0;_<3;_++)b[_]=1/0,b[_+3]=-1/0}for(let y=c;y<u;y+=6){let x=~~((i[y+2*d]-p)/f);x>=uo&&(x=uo-1);let b=Jo[x];b.count++,qf(y,i,b.bounds)}let g=Jo[uo-1];kM(g.bounds,g.rightCacheBounds);for(let y=uo-2;y>=0;y--){let x=Jo[y],b=Jo[y+1];UM(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let m=0;for(let y=0;y<uo-1;y++){let x=Jo[y],b=x.count,_=x.bounds,M=Jo[y+1].rightCacheBounds;b!==0&&(m===0?kM(_,Xf):UM(_,Xf,Xf)),m+=b;let S=0,E=0;m!==0&&(S=dd(Xf)/l);let A=s-m;A!==0&&(E=dd(M)/l);let T=1+1.25*(S*m+E*A);T<h&&(n=d,h=T,o=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function JY(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function $Y(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let u=0;u<s;u++){let d=u*3,p=u*6,f,g,m;n?(f=r[d+0],g=r[d+1],m=r[d+2]):(f=r[d+0]*h+l,g=r[d+1]*h+l,m=r[d+2]*h+l);for(let y=0;y<3;y++){let x,b,_;n?(x=i[c[y]](f),b=i[c[y]](g),_=i[c[y]](m)):(x=o[f+y],b=o[g+y],_=o[m+y]);let M=x;b<M&&(M=b),_<M&&(M=_);let S=x;b>S&&(S=b),_>S&&(S=_);let E=(S-M)/2,A=y*2;a[p+A+0]=M+E,a[p+A+1]=E+(Math.abs(M)+E)*WY,M<t[y]&&(t[y]=M),S>t[y+3]&&(t[y+3]=S)}}return a}function eQ(e,t){function i(y){d&&d(y/p)}function r(y,x,b,_=null,M=0){if(!f&&M>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=c||M>=l)return i(x+b),y.offset=x,y.count=b,y;let S=KY(y.boundingData,_,n,x,b,u);if(S.axis===-1)return i(x+b),y.offset=x,y.count=b,y;let E=QY(o,n,x,b,S);if(E===x||E===x+b)i(x+b),y.offset=x,y.count=b;else{y.splitAxis=S.axis;let A=new Wf,T=x,P=E-x;y.left=A,A.boundingData=new Float32Array(6),K0(n,T,P,A.boundingData,a),r(A,T,P,a,M+1);let R=new Wf,z=E,U=b-P;y.right=R,R.boundingData=new Float32Array(6),K0(n,z,U,R.boundingData,a),r(R,z,U,a,M+1)}return y}qY(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=$Y(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,g=[],m=XY(e);if(m.length===1){let y=m[0],x=new Wf;x.boundingData=s,YY(n,y.offset,y.count,a),r(x,y.offset,y.count,a),g.push(x)}else for(let y of m){let x=new Wf;x.boundingData=new Float32Array(6),K0(n,y.offset,y.count,x.boundingData,a),r(x,y.offset,y.count,a),g.push(x)}return g}function tQ(e,t){let i=eQ(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<i.length;c++){let u=i[c],d=l(u),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,u),n.push(p)}return n;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function h(c,u){let d=c/4,p=c/2,f=!!u.count,g=u.boundingData;for(let m=0;m<6;m++)r[d+m]=g[m];if(f){let m=u.offset,y=u.count;return s[d+6]=m,a[p+14]=y,a[p+15]=65535,c+32}else{let m=u.left,y=u.right,x=u.splitAxis,b;if(b=h(c+32,m),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=b/4,b=h(b,y),s[d+7]=x,b}}}var Nn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};Nn.prototype.setFromBox=function(){let e=new I;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let c=t.dot(e);a=Math.min(c,a),n=Math.max(c,n)}this.min=a,this.max=n}}();var $oe=function(){let e=new Nn;return function(t,i){let r=t.points,s=t.satAxes,a=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let c=a[h],u=s[h];if(e.setFromPoints(u,n),c.isSeparated(e))return!1}for(let h=0;h<3;h++){let c=l[h],u=o[h];if(e.setFromPoints(u,r),c.isSeparated(e))return!1}}}(),iQ=function(){let e=new I,t=new I,i=new I;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let c=i.dot(h),u=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-u*u,g,m;f!==0?g=(c*u-p*d)/f:g=0,m=(c+g*u)/d,a.x=g,a.y=m}}(),ow=function(){let e=new re,t=new I,i=new I;return function(r,s,a,n){iQ(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let c;l<0?c=s.start:c=s.end;let u=t,d=i;if(r.closestPointToPoint(c,!0,t),s.closestPointToPoint(h,!0,i),u.distanceToSquared(c)<=d.distanceToSquared(h)){a.copy(u),n.copy(c);return}else{a.copy(h),n.copy(d);return}}}}(),rQ=function(){let e=new I,t=new I,i=new Gs,r=new Ta;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=c,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let u=a.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=n){let d=u.projectPoint(o,t);if(a.containsPoint(d))return!0}return!1}}(),sQ=1e-15;function mc(e){return Math.abs(e)<sQ}var zo=class extends us{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new Nn),this.points=[this.a,this.b,this.c],this.sphere=new Ks,this.plane=new Gs,this.needsUpdate=!0}intersectsSphere(e){return rQ(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let c=s[2],u=a[2];c.subVectors(t,i),u.setFromPoints(c,r);let d=s[3],p=a[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};zo.prototype.closestPointToSegment=function(){let e=new I,t=new I,i=new Ta;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,c=1/0;for(let u=0;u<3;u++){let d=(u+1)%3;i.start.copy(l[u]),i.end.copy(l[d]),ow(i,r,e,t),h=e.distanceToSquared(t),h<c&&(c=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<c&&(c=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<c&&(c=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(c)}}();zo.prototype.intersectsTriangle=function(){let e=new zo,t=new Array(3),i=new Array(3),r=new Nn,s=new Nn,a=new I,n=new I,o=new I,l=new I,h=new Ta,c=new Ta,u=new Ta;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let g=this.plane,m=d.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let y=this.satBounds,x=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let M=0;M<4;M++){let S=y[M],E=x[M];if(r.setFromPoints(E,i),S.isSeparated(r))return!1}let b=d.satBounds,_=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let M=0;M<4;M++){let S=b[M],E=_[M];if(r.setFromPoints(E,t),S.isSeparated(r))return!1}for(let M=0;M<4;M++){let S=x[M];for(let E=0;E<4;E++){let A=_[E];if(a.crossVectors(S,A),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let y=this.points,x=!1,b=0;for(let U=0;U<3;U++){let L=y[U],H=y[(U+1)%3];h.start.copy(L),h.end.copy(H),h.delta(n);let q=x?c.start:c.end,Z=mc(m.distanceToPoint(L));if(mc(m.normal.dot(n))&&Z){c.copy(h),b=2;break}if((m.intersectLine(h,q)||Z)&&!mc(q.distanceTo(H))){if(b++,x)break;x=!0}}if(b===1&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(b!==2)return!1;let _=d.points,M=!1,S=0;for(let U=0;U<3;U++){let L=_[U],H=_[(U+1)%3];h.start.copy(L),h.end.copy(H),h.delta(o);let q=M?u.start:u.end,Z=mc(g.distanceToPoint(L));if(mc(g.normal.dot(o))&&Z){u.copy(h),S=2;break}if((g.intersectLine(h,q)||Z)&&!mc(q.distanceTo(H))){if(S++,M)break;M=!0}}if(S===1&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(S!==2)return!1;if(c.delta(n),u.delta(o),n.dot(o)<0){let U=u.start;u.start=u.end,u.end=U}let E=c.start.dot(n),A=c.end.dot(n),T=u.start.dot(n),P=u.end.dot(n),R=A<T,z=E<P;return E!==P&&T!==A&&R===z?!1:(p&&(l.subVectors(c.start,u.start),l.dot(n)>0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(n)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}();zo.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();zo.prototype.distanceToTriangle=function(){let e=new I,t=new I,i=["a","b","c"],r=new Ta,s=new Ta;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let c=0;c<3;c++){let u,d=i[c],p=a[d];this.closestPointToPoint(p,e),u=p.distanceToSquared(e),u<h&&(h=u,n&&n.copy(e),o&&o.copy(p));let f=this[d];a.closestPointToPoint(f,e),u=f.distanceToSquared(e),u<h&&(h=u,n&&n.copy(f),o&&o.copy(e))}for(let c=0;c<3;c++){let u=i[c],d=i[(c+1)%3];r.set(this[u],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(a[f],a[g]),ow(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Vn=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new je,this.invMatrix=new je,this.points=new Array(8).fill().map(()=>new I),this.satAxes=new Array(3).fill().map(()=>new I),this.satBounds=new Array(3).fill().map(()=>new Nn),this.alignedSatBounds=new Array(3).fill().map(()=>new Nn),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Vn.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){let u=1*l|2*h|4*c,d=r[u];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=c?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],c=s[l],u=1<<l,d=r[u];h.subVectors(n,d),c.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Vn.prototype.intersectsBox=function(){let e=new Nn;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Vn.prototype.intersectsTriangle=function(){let e=new zo,t=new Array(3),i=new Nn,r=new Nn,s=new I;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let u=0;u<3;u++){let d=n[u],p=o[u];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,c=this.points;for(let u=0;u<3;u++){let d=l[u],p=h[u];if(i.setFromPoints(p,c),d.isSeparated(i))return!1}for(let u=0;u<3;u++){let d=o[u];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,c),i.isSeparated(r))return!1}}return!0}}();Vn.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Vn.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Vn.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Ta),i=new Array(12).fill().map(()=>new Ta),r=new I,s=new I;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,c=a.min,u=a.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];s.copy(m).clamp(c,u);let y=m.distanceToSquared(s);if(y<p&&(p=y,o&&o.copy(m),l&&l.copy(s),y<h))return Math.sqrt(y)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){let x=(g+1)%3,b=(g+2)%3,_=m<<x|y<<b,M=1<<g|m<<x|y<<b,S=d[_],E=d[M];t[f].set(S,E);let A=e[g],T=e[x],P=e[b],R=i[f],z=R.start,U=R.end;z[A]=c[A],z[T]=m?c[T]:u[T],z[P]=y?c[P]:u[T],U[A]=u[A],U[T]=m?c[T]:u[T],U[P]=y?c[P]:u[T],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let y=0;y<=1;y++){s.x=g?u.x:c.x,s.y=m?u.y:c.y,s.z=y?u.z:c.z,this.closestPointToPoint(s,r);let x=s.distanceToSquared(r);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}for(let g=0;g<12;g++){let m=t[g];for(let y=0;y<12;y++){let x=i[y];ow(m,x,r,s);let b=r.distanceToSquared(s);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(s),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var gc=new I,vc=new I,yc=new I,Yf=new re,Qf=new re,Zf=new re,NM=new I,VM=new I,jM=new I,Kf=new I;function aQ(e,t,i,r,s,a){let n;return a===$r?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==_s,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function nQ(e,t,i,r,s,a,n,o,l){gc.fromBufferAttribute(t,a),vc.fromBufferAttribute(t,n),yc.fromBufferAttribute(t,o);let h=aQ(e,gc,vc,yc,Kf,l);if(h){r&&(Yf.fromBufferAttribute(r,a),Qf.fromBufferAttribute(r,n),Zf.fromBufferAttribute(r,o),h.uv=us.getInterpolation(Kf,gc,vc,yc,Yf,Qf,Zf,new re)),s&&(Yf.fromBufferAttribute(s,a),Qf.fromBufferAttribute(s,n),Zf.fromBufferAttribute(s,o),h.uv1=us.getInterpolation(Kf,gc,vc,yc,Yf,Qf,Zf,new re)),i&&(NM.fromBufferAttribute(i,a),VM.fromBufferAttribute(i,n),jM.fromBufferAttribute(i,o),h.normal=us.getInterpolation(Kf,gc,vc,yc,NM,VM,jM,new I),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let c={a,b:n,c:o,normal:new I,materialIndex:0};us.getNormal(gc,vc,yc,c.normal),h.face=c,h.faceIndex=a}return h}function nD(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:c,uv:u,uv1:d}=e.attributes,p=nQ(i,h,c,u,d,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function oQ(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)nD(e,t,i,n,a)}function lQ(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=nD(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function Tn(e,t,i,r){let s=e.a,a=e.b,n=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function HM(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(Tn(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var oD=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function fl(e,t){return t[e+15]===65535}function Zc(e,t){return t[e+6]}function bp(e,t){return t[e+14]}function wp(e){return e+8}function _p(e,t){return t[e+6]}function hQ(e,t){return t[e+7]}var Gc=new mr,Ug=new I,cQ=["x","y","z"];function Ax(e,t,i,r,s){let a=e*2,n=Lu,o=Cl,l=Tl;if(fl(a,o)){let h=Zc(e,l),c=bp(a,o);oQ(t,i,r,h,c,s)}else{let h=wp(e);Ng(h,n,r,Ug)&&Ax(h,t,i,r,s);let c=_p(e,l);Ng(c,n,r,Ug)&&Ax(c,t,i,r,s)}}function Mx(e,t,i,r){let s=e*2,a=Lu,n=Cl,o=Tl;if(fl(s,n)){let l=Zc(e,o),h=bp(s,n);return lQ(t,i,r,l,h)}else{let l=hQ(e,o),h=cQ[l],c=r.direction[h]>=0,u,d;c?(u=wp(e),d=_p(e,o)):(u=_p(e,o),d=wp(e));let p=Ng(u,a,r,Ug)?Mx(u,t,i,r):null;if(p){let g=p.point[h];if(c?g<=a[d+l]:g>=a[d+l+3])return p}let f=Ng(d,a,r,Ug)?Mx(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var uQ=function(){let e,t,i=[],r=new oD(()=>new mr);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),n};function s(a,n,o,l,h=null,c=0,u=0){function d(x){let b=x*2,_=Cl,M=Tl;for(;!fl(b,_);)x=wp(x),b=x*2;return Zc(x,M)}function p(x){let b=x*2,_=Cl,M=Tl;for(;!fl(b,_);)x=_p(x,M),b=x*2;return Zc(x,M)+bp(b,_)}let f=a*2,g=Lu,m=Cl,y=Tl;if(fl(f,m)){let x=Zc(a,y),b=bp(f,m);return In(a,g,e),l(x,b,!1,u,c+a,e)}else{let x=wp(a),b=_p(a,y),_=x,M=b,S,E,A,T;if(h&&(A=e,T=t,In(_,g,A),In(M,g,T),S=h(A),E=h(T),E<S)){_=b,M=x;let q=S;S=E,E=q,A=T}A||(A=e,In(_,g,A));let P=fl(_*2,m),R=o(A,P,S,u+1,c+_),z;if(R===2){let q=d(_),Z=p(_)-q;z=l(q,Z,!0,u+1,c+_,A)}else z=R&&s(_,n,o,l,h,c,u+1);if(z)return!0;T=t,In(M,g,T);let U=fl(M*2,m),L=o(T,U,E,u+1,c+M),H;if(L===2){let q=d(M),Z=p(M)-q;H=l(q,Z,!0,u+1,c+M,T)}else H=L&&s(M,n,o,l,h,c,u+1);return!!H}}}(),dQ=function(){let e=new zo,t=new zo,i=new je,r=new Vn,s=new Vn;return function a(n,o,l,h,c=null){let u=n*2,d=Lu,p=Cl,f=Tl;if(c===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),c=r),fl(u,p)){let g=o,m=g.index,y=g.attributes.position,x=l.index,b=l.attributes.position,_=Zc(n,f),M=bp(u,p);if(i.copy(h).invert(),l.boundsTree)return In(n,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:S=>s.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(h),S.b.applyMatrix4(h),S.c.applyMatrix4(h),S.needsUpdate=!0;for(let E=_*3,A=(M+_)*3;E<A;E+=3)if(Tn(t,E,m,y),t.needsUpdate=!0,S.intersectsTriangle(t))return!0;return!1}});for(let S=_*3,E=M+_*3;S<E;S+=3){Tn(e,S,m,y),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let A=0,T=x.count;A<T;A+=3)if(Tn(t,A,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=n+8,m=f[n+6];return In(g,d,Gc),!!(c.intersectsBox(Gc)&&a(g,o,l,h,c)||(In(m,d,Gc),c.intersectsBox(Gc)&&a(m,o,l,h,c)))}}}();function Ng(e,t,i,r){return In(e,t,Gc),i.intersectBox(Gc,r)}var Ex=[],Vm,Lu,Cl,Tl;function Rd(e){Vm&&Ex.push(Vm),Vm=e,Lu=new Float32Array(e),Cl=new Uint16Array(e),Tl=new Uint32Array(e)}function Jf(){Vm=null,Lu=null,Cl=null,Tl=null,Ex.length&&Rd(Ex.pop())}var J0=Symbol("skip tree generation"),$0=new mr,e1=new mr,xc=new je,Ql=new Vn,pd=new Vn,fd=new I,$f=new I,pQ=new I,fQ=new I,mQ=new I,GM=new mr,fn=new oD(()=>new zo),Xd=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Xd.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Xd.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new Xd(t,{...i,[J0]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new Tt(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[J0]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[J0]||(this._roots=tQ(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new mr))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s,a,n,o,l=0,h=this._roots;for(let u=0,d=h.length;u<d;u++)s=h[u],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),c(0,l),l+=s.byteLength;function c(u,d,p=!1){let f=u*2;if(n[f+15]===65535){let g=a[u+6],m=n[f+14],y=1/0,x=1/0,b=1/0,_=-1/0,M=-1/0,S=-1/0;for(let E=3*g,A=3*(g+m);E<A;E++){let T=i[E],P=r.getX(T),R=r.getY(T),z=r.getZ(T);P<y&&(y=P),P>_&&(_=P),R<x&&(x=R),R>M&&(M=R),z<b&&(b=z),z>S&&(S=z)}return o[u+0]!==y||o[u+1]!==x||o[u+2]!==b||o[u+3]!==_||o[u+4]!==M||o[u+5]!==S?(o[u+0]=y,o[u+1]=x,o[u+2]=b,o[u+3]=_,o[u+4]=M,o[u+5]=S,!0):!1}else{let g=u+8,m=a[u+6],y=g+d,x=m+d,b=p,_=!1,M=!1;e?b||(_=e.has(y),M=e.has(x),b=!_&&!M):(_=!0,M=!0);let S=b||_,E=b||M,A=!1;S&&(A=c(g,d,b));let T=!1;E&&(T=c(m,d,b));let P=A||T;if(P)for(let R=0;R<3;R++){let z=g+R,U=m+R,L=o[z],H=o[z+3],q=o[U],Z=o[U+3];o[u+R]=L<q?L:q,o[u+R+3]=H>Z?H:Z}return P}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let c=r[n+6],u=s[l+14];e(o,h,new Float32Array(i,n*4,6),c,u)}else{let c=n+8,u=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(a(c,o+1),a(u,o+1))}}}raycast(e,t=en){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=n?t[o[h].materialIndex].side:l,d=s.length;if(Rd(i[h]),Ax(0,r,u,e,s),Jf(),n){let p=o[h].materialIndex;for(let f=d,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=en){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,c=i.length;h<c;h++){let u=a?t[o[h].materialIndex].side:l;Rd(i[h]);let d=Mx(0,r,u,e);Jf(),d!=null&&(n==null||d.distance<n.distance)&&(n=d,a&&(d.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Rd(s),r=dQ(0,i,e,t),Jf(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let u=t;t=(d,p,f,g)=>{let m=p*3;return u(d,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=fn.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let u=o;o=(d,p,f,g,m)=>u(d,p,f,g,m)?!0:HM(d,p,r,l,f,g,s)}else o||(l?o=(u,d,p,f)=>HM(u,d,r,l,p,f,s):o=(u,d,p)=>p);let h=!1,c=0;for(let u of this._roots){if(Rd(u),h=uQ(0,r,n,o,a,c),Jf(),h)break;c+=u.byteLength}return fn.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;xc.copy(t).invert();let h=fn.getPrimitive(),c=fn.getPrimitive();if(s){let d=function(p,f,g,m,y,x,b,_){for(let M=g,S=g+m;M<S;M++){Tn(c,M*3,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let E=p,A=p+f;E<A;E++)if(Tn(h,E*3,a,n),h.needsUpdate=!0,s(h,c,E,M,y,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,g,m,y,x,b,_,M){return p(f,g,m,y,x,b,_,M)?!0:d(f,g,m,y,x,b,_,M)}}else r=d}e.getBoundingBox(e1),e1.applyMatrix4(t);let u=this.shapecast({intersectsBounds:d=>e1.intersectsBox(d),intersectsRange:(d,p,f,g,m,y)=>($0.copy(y),$0.applyMatrix4(xc),e.shapecast({intersectsBounds:x=>$0.intersectsBox(x),intersectsRange:(x,b,_,M,S)=>r(d,p,x,b,g,m,M,S)}))});return fn.releasePrimitive(h),fn.releasePrimitive(c),u}intersectsBox(e,t){return Ql.set(e.min,e.max,t),Ql.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Ql.intersectsBox(i),intersectsTriangle:i=>Ql.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ql.set(e.boundingBox.min,e.boundingBox.max,t),Ql.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,c=e.index,u=fn.getPrimitive(),d=fn.getPrimitive(),p=$f,f=pQ,g=null,m=null;r&&(g=fQ,m=mQ);let y=1/0,x=null,b=null;return xc.copy(t).invert(),pd.matrix.copy(xc),this.shapecast({boundsTraverseOrder:_=>Ql.distanceToBox(_),intersectsBounds:(_,M,S)=>S<y&&S<a?(M&&(pd.min.copy(_.min),pd.max.copy(_.max),pd.needsUpdate=!0),!0):!1,intersectsRange:(_,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:S=>pd.distanceToBox(S),intersectsBounds:(S,E,A)=>A<y&&A<a,intersectsRange:(S,E)=>{for(let A=S*3,T=(S+E)*3;A<T;A+=3){Tn(d,A,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=_*3,R=(_+M)*3;P<R;P+=3){Tn(u,P,l,o),u.needsUpdate=!0;let z=u.distanceToTriangle(d,p,g);if(z<y&&(f.copy(p),m&&m.copy(g),y=z,x=P/3,b=A/3),z<s)return!0}}}});{let S=c?c.count:h.count;for(let E=0,A=S;E<A;E+=3){Tn(d,E,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let T=_*3,P=(_+M)*3;T<P;T+=3){Tn(u,T,l,o),u.needsUpdate=!0;let R=u.distanceToTriangle(d,p,g);if(R<y&&(f.copy(p),m&&m.copy(g),y=R,x=T/3,b=E/3),R<s)return!0}}}}}),fn.releasePrimitive(u),fn.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=y,i.faceIndex=x,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(xc),f.applyMatrix4(xc),r.distance=f.sub(r.point).length(),r.faceIndex=b),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(fd.copy(e).clamp(h.min,h.max),fd.distanceToSquared(e)),intersectsBounds:(h,c,u)=>u<n&&u<a,intersectsTriangle:(h,c)=>{h.closestPointToPoint(e,fd);let u=e.distanceToSquared(fd);return u<n&&($f.copy(fd),n=u,o=c),u<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy($f):t.point=$f.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{In(0,new Float32Array(t),GM),e.union(GM)}),e}},Cx=Ll(TB()),gQ=.5*(Math.sqrt(3)-1),md=(3-Math.sqrt(3))/6,vQ=1/3,mn=1/6,ele=(Math.sqrt(5)-1)/4,tle=(5-Math.sqrt(5))/20,Yd=e=>Math.floor(e)|0,WM=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]),t1=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 yQ(e=Math.random){let t=lD(e),i=new Float64Array(t).map(s=>WM[s%12*2]),r=new Float64Array(t).map(s=>WM[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*gQ,c=Yd(s+h),u=Yd(a+h),d=(c+u)*md,p=c-d,f=u-d,g=s-p,m=a-f,y,x;g>m?(y=1,x=0):(y=0,x=1);let b=g-y+md,_=m-x+md,M=g-1+2*md,S=m-1+2*md,E=c&255,A=u&255,T=.5-g*g-m*m;if(T>=0){let z=E+t[A],U=i[z],L=r[z];T*=T,n=T*T*(U*g+L*m)}let P=.5-b*b-_*_;if(P>=0){let z=E+y+t[A+x],U=i[z],L=r[z];P*=P,o=P*P*(U*b+L*_)}let R=.5-M*M-S*S;if(R>=0){let z=E+1+t[A+1],U=i[z],L=r[z];R*=R,l=R*R*(U*M+L*S)}return 70*(n+o+l)}}function xQ(e=Math.random){let t=lD(e),i=new Float64Array(t).map(a=>t1[a%12*3]),r=new Float64Array(t).map(a=>t1[a%12*3+1]),s=new Float64Array(t).map(a=>t1[a%12*3+2]);return function(a,n,o){let l,h,c,u,d=(a+n+o)*vQ,p=Yd(a+d),f=Yd(n+d),g=Yd(o+d),m=(p+f+g)*mn,y=p-m,x=f-m,b=g-m,_=a-y,M=n-x,S=o-b,E,A,T,P,R,z;_>=M?M>=S?(E=1,A=0,T=0,P=1,R=1,z=0):_>=S?(E=1,A=0,T=0,P=1,R=0,z=1):(E=0,A=0,T=1,P=1,R=0,z=1):M<S?(E=0,A=0,T=1,P=0,R=1,z=1):_<S?(E=0,A=1,T=0,P=0,R=1,z=1):(E=0,A=1,T=0,P=1,R=1,z=0);let U=_-E+mn,L=M-A+mn,H=S-T+mn,q=_-P+2*mn,Z=M-R+2*mn,X=S-z+2*mn,se=_-1+3*mn,le=M-1+3*mn,te=S-1+3*mn,ie=p&255,fe=f&255,ce=g&255,ue=.6-_*_-M*M-S*S;if(ue<0)l=0;else{let Ae=ie+t[fe+t[ce]];ue*=ue,l=ue*ue*(i[Ae]*_+r[Ae]*M+s[Ae]*S)}let ae=.6-U*U-L*L-H*H;if(ae<0)h=0;else{let Ae=ie+E+t[fe+A+t[ce+T]];ae*=ae,h=ae*ae*(i[Ae]*U+r[Ae]*L+s[Ae]*H)}let Pe=.6-q*q-Z*Z-X*X;if(Pe<0)c=0;else{let Ae=ie+P+t[fe+R+t[ce+z]];Pe*=Pe,c=Pe*Pe*(i[Ae]*q+r[Ae]*Z+s[Ae]*X)}let ve=.6-se*se-le*le-te*te;if(ve<0)u=0;else{let Ae=ie+1+t[fe+1+t[ce+1]];ve*=ve,u=ve*ve*(i[Ae]*se+r[Ae]*le+s[Ae]*te)}return 32*(l+h+c+u)}}function lD(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Na=new us,bQ=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Na.a.fromBufferAttribute(e,r),Na.b.fromBufferAttribute(e,r+1),Na.c.fromBufferAttribute(e,r+2),s*=Na.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Na.a.fromBufferAttribute(this.positionAttribute,e*3),Na.b.fromBufferAttribute(this.positionAttribute,e*3+1),Na.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Na.a,r).addScaledVector(Na.b,s).addScaledVector(Na.c,1-(r+s)),Na.getNormal(i),this}},wQ=Ll(I3()),_Q=new je,SQ=new je,AQ=new je,Dh;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Dh||(Dh={}));var lw=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new je,this.copyPreviousMatrix=!0,this.hiddenMatrix=new je,this.matrixWorldRigid=new je,this.shearScale=new je,this.shearScaleInv=new je}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Mi&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)Dh.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Dh.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:a}=(0,wQ.SVD)(i),n=_Q.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=SQ.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=AQ.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new je().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof je?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},MQ=class extends lw(Mi){},EQ=e=>e.type==="Mesh",fs=class extends MQ{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new fs(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return EQ(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}},ah=new I,nh=new I,Kc=new je,hD=[new I(-1,1,1),new I(-1,-1,1),new I(1,-1,1),new I(1,1,1),new I(-1,1,-1),new I(-1,-1,-1),new I(1,-1,-1),new I(1,1,-1)],CQ=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],TQ=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],qM=(e,t,i)=>{e.updateEntityBoxSize(ah,nh),Kc.copy(t).multiply(e.matrixWorld),nh.x===0&&nh.y===0&&nh.z===0?i.push(new I(ah.x,ah.y,ah.z).applyMatrix4(Kc)):hD.forEach(r=>{i.push(r.clone().multiply(nh).add(ah).applyMatrix4(Kc))})},XM=class extends mr{constructor(){super(...arguments),this.matrix=new je,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new je().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new I);return}qM(s,t,r)}}):qM(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Kc.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(nh).multiplyScalar(.5),this.getCenter(ah),Kc.copy(this.matrix).setPosition(ah),this.vertices=hD.map(e=>e.clone().multiply(nh).applyMatrix4(Kc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=CQ.map(([e,t])=>new Ta(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new I))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=TQ.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},bl={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},PQ=class extends oT{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(e*l/s),c=o.getPoints(h);for(let u=0;u<c.length;u++){let d=c[u];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Tx=.001;function Px(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Tx}function i1(e,t){let i=new I(...e.position),r=new I(...e.controlNext.position),s=new I(...t.controlPrevious.position),a=new I(...t.position);return Px(i,r,a)&&Px(i,s,a)}function cD(e){let t=e.points.map(c=>new I(...c.data.position)),i=[e.points[0]],r=new I(...i[0].data.position);for(let c=0;c<e.points.length-1;c++)Px(r,t[c],t[c+1])||(i.push(e.points[c]),r=t[c]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let c=0;c<n;c++){let u=i[c].data,d=new I(...u.position),p=new I(...u.controlPrevious.position),f=new I(...u.controlNext.position),g={position:d,baseRoundness:u.roundness,controlPrevious:p,controlNext:f};if(u.roundness===0||!e.isClosed&&(c===0||c===n-1)){o[c]={...g,removedLength:0};continue}let m=s&&c==0?n-1:c-1,y=s&&c==n-1?0:c+1,x=i[m].data,b=i[y].data,_=new I(...x.position),M=new I(...b.position),S=_.clone().sub(d).normalize(),E=M.clone().sub(d).normalize();Object.assign(g,{prevDir:S,nextDir:E});let A=i1(x,u),T=i1(u,b);if(!A||!T)o[c]={...g,removedLength:0};else{let P=S.clone().add(E).normalize(),R=P.clone().cross(S).length()/S.dot(P);o[c]={...g,tan:R,removedLength:u.roundness/R}}}for(let c=0;c<a;c++){let u=c,d=s&&c===n-1?0:c+1,p=o[u],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let c=0;c<a;c++){let u=c,d=s&&c===n-1?0:c+1,p=o[u],f=o[d],g=null;if(!i1(i[u].data,i[d].data))p.position.distanceTo(f.position)>Tx&&(g=new zm(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),y=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&y.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(y)>Tx&&(g=new zm(m,m.clone().lerp(y,.3),y.clone().lerp(m,.3),y))}l[2*c+1]=g}for(let c=0;c<n;c++){let u=o[c];if(u.removedLength===0){l[2*c]=null;continue}let d=u.position,p=u.prevDir.clone().multiplyScalar(u.removedLength).add(d),f=u.nextDir.clone().multiplyScalar(u.removedLength).add(d),g=u.tan*u.removedLength,m=u.prevDir.clone().add(u.nextDir).normalize(),y=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(x,2))).add(y),_=m.clone().multiplyScalar(-g).add(b),M=d.distanceTo(_)/d.distanceTo(y),S=u.prevDir.clone().multiplyScalar(M*d.distanceTo(p)).add(d),E=S.clone().lerp(_,2),A=p.clone().lerp(S,4/3),T=f.clone().lerp(E,4/3);l[2*c]=new zm(p,A,T,f)}let h=new PQ;return l.forEach(c=>{c&&h.add(c)}),h}var ni;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ni||(ni={}));var yo=e=>ni.is(e),DQ={type:"completeState",isfromEntity:!0},IQ=["x","y","z"],r1=new I,OQ=new I().set(0,1,0),hw=e=>class extends lw(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new XM,this._recursiveBBox=new XM,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(ni.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ni.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ni.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)uh.toOps(this.data,s.data).forEach(a=>{let n=xg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=uh.patch(this.data,s),uh.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{yo(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(ni.is(i[r]))return i[r];if(ni.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ni.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)yo(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{ni.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)yo(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)yo(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)yo(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>yo(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x*lt.RAD2DEG,this.rotation.y*lt.RAD2DEG,this.rotation.z*lt.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Oy(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,IQ[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(r1.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(lt.DEG2RAD),this.rotation.setFromVector3(r1),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??uu.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)ni.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ni.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Oy(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=Li(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(c=>c===void 0)){let c=this.data;if(c!==void 0){let u=kr.zoom(c,t.path.slice(2));if(u)for(let d in t.props)t.props[d]===void 0&&d in u&&(h[d]=u[d])}}n={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:c,...u}=l;l=u}if(t.props.material!==void 0&&"material"in l){let{material:c,...u}=l;l=u}let h=kr.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,uh.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Li(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let c of Object.keys(t.props)){l[l.length-1]=c;let u=r.scene.findInstance([this.uuid,...l]);u&&(u.overrideData=t.props[c],u.updateState(Ml.apply(u.component.data,u.overrideData),r))}}else{let c=r.scene.findInstance([this.uuid,...l]);if(c){let u=kr.zoom(c.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(u)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=u[p]);t={...t,props:d}}c.overrideData=Dg.resolve(i.overrides,l),c.updateByOp(t,Kr.applySimple(c.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let c of xl.rootOverrideProps)c in t.props&&(h===void 0&&(h={}),h[c]=t.props[c]);h&&(l={...t,props:h})}else for(let h of xl.rootOverrideProps)if(Li(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let c=Ml.filterOp(h.overrideData,l);c&&h.updateByOp(c,Kr.applySimple(h.data,c),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let c=Ml.filterOp(h.overrideData,t);if(c){let u;a===h.data&&t===c?u=i:u=Kr.applySimple(h.data,c),h.updateByOp(c,u,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ph.is(t.props.type)&&bl.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){bl.changeEntityProptotype(this,i,r);for(let s of this.children)ni.is(s)&&s.updateVisible(r.scene)}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0?this.updateState(t.props,r):t.type===0&&("resolutionLevel"in t.props||"useChildrenColors"in t.props)&&this.updateState(i,r),t.path[0]==="morphTargetInfluences"&&t.type===0){let s=i.morphTargetInfluences.get(t.path[1])?.data.name;s&&this.updateMorphInfluences(s,r.shared.getVariable(t.props.value,[this.uuid,"morphTargetInfluences",s]))}if(Li(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Li(t.path,["cloner"])!==null){let s=Kr.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible(r.scene)}}updatePathSnapping(t=this.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=cD(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let c=null;try{c=l.curves.length?l.getPointAt(h):null}catch{}if(c===null)return;let u=this.parent?this.parent?.matrixWorld:new je;n.updateMatrixWorld();let d=new je().multiplyMatrices(u.clone().invert(),n.matrixWorld);c.applyMatrix4(d);let p={position:c.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new je().extractRotation(n.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(c),m=new je().lookAt(c,g,OQ),y=r1.setFromEuler(new Fr().setFromRotationMatrix(m)).multiplyScalar(lt.RAD2DEG);p={...p,rotation:y.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(DQ)})}updateVisible(t){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!t)return;let i=!1;this.traverseEntity(r=>{if(r.data.type==="Splat")return i=!0,!0}),i&&t.reloadSplats()}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(i?.scene),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible(i.scene)),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof bl.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new bl.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}requestRender(){this.dispatchEvent({type:"requestRender"})}},uD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.parameters?.radiusTop,r=e.parameters?.radiusBottom,s=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);s.thetaLength=lt.clamp(s.thetaLength,0,360);let a=s.width/2,n=s.radiusTop??a,o=s.radiusBottom??a;if(n===o?(n=a,o=a):n>o?(n=a,o=o*a/n):(n=n*a/o,o=a),s.shapeBlendNode){n=i??a,o=r??a;let l=Math.max(n,o)*2;s.width=l,s.depth=l}return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(s.height??s.width),depth:Math.abs(s.depth??s.width),radiusTop:n,radiusBottom:o})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:c,cornerRadius:u,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new gt,f.setAttribute("position",new at([],3))):u||p?f=new dD(h,c,r,s,a,n,o,l*Math.PI/180,u,u,d,p):f=new Cb(h,c,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function $o(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function YM(e){return new re(e.y,-e.x)}var dD=class extends gt{constructor(e,t,i,r,s,a,n,o,l,h,c,u,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],g=[],m=[],y=0,x=i/2,b=new I,_=new I;d&&e==0&&(e=l),d&&t==0&&(t=h);let M=new re(e,x),S=new re(t,-x),E=null,A=null,T=null,P=null,R=M.clone().sub(S),z=0,U=0,L=0;u>0&&(z=Math.min(e,t)*(1-u),U=e-z,L=t-z);let H=M.clone();H.x-=z;let q=Math.PI-R.angle(),Z=R.angle(),X=Math.tan(Z/2),se=Math.tan(q/2),le=X+se,te=u?le:se,ie=u?le:X;if(l=Math.min(l,(e-U)/te,R.length()/le),h=Math.min(h,(t-L)/ie,R.length()/le),l>0){let ve=l/X;E=M.clone().sub(new re(ve,l)),u&&(T=E.clone(),T.x-=z-le*l),M.sub(R.clone().setLength(ve))}if(h>0){let ve=h/se;A=S.clone().sub(new re(ve,-h)),S.add(R.clone().setLength(ve)),u&&(P=A.clone(),P.x-=z-le*h,H.sub(R.clone().setLength(ve)))}R=M.clone().sub(S);let fe=R.length()<.5,ce=[];for(let ve=0;ve<=r;ve++){let Ae=[],ye=ve/r,Ve=ye*o+n,Ie=new re(Math.sin(Ve),Math.cos(Ve));P&&A?(ue(Ae,ye,Ie,q,h,P,-1,!0),ue(Ae,ye,Ie,Z,h,A,-1,!1)):A?(ae(Ae,Ie,A.x,0,-1),ue(Ae,ye,Ie,Z,h,A,-1,!1)):a||ae(Ae,Ie,t,L,-1);let Ce=YM(R).normalize();if($o(Ce,Ie,b),!fe)for(let it=0;it<=s;it++){let Je=it/s,st=R.clone().multiplyScalar(Je).add(S);$o(st,Ie,_),f.push(_.x,_.y,_.z),g.push(b.x,b.y,b.z),m.push(ye,.5+_.y/i),Ae.push(y++)}if(T&&E?(ue(Ae,ye,Ie,q,l,E,1,!1),ue(Ae,ye,Ie,Z,l,T,1,!0)):E?(ue(Ae,ye,Ie,q,l,E,1,!1),ae(Ae,Ie,E.x,0,1)):a||ae(Ae,Ie,e,U,1),u&&!fe){let it=YM(R).multiplyScalar(-1).normalize();$o(it,Ie,b);for(let Je=0;Je<=s;Je++){let st=Je/s,nt=R.clone().multiplyScalar(-st).add(H);$o(nt,Ie,_),f.push(_.x,_.y,_.z),g.push(b.x,b.y,b.z),m.push(ye,.5+_.y/i),Ae.push(y++)}}u&&!a&&Ae.push(Ae[0]),ce.push(Ae)}for(let ve=0;ve<ce.length-1;ve++)for(let Ae=0;Ae<ce[0].length-1;Ae++){if(a&&u&&Ae==s)continue;let ye=ce[ve][Ae],Ve=ce[ve+1][Ae],Ie=ce[ve+1][Ae+1],Ce=ce[ve][Ae+1],it=f[Ie*3+0],Je=f[Ie*3+2];p.push(ye,Ve,Ce),(it!=0||Je!=0)&&p.push(Ve,Ie,Ce)}o<Math.PI*2&&(Pe(-1,ce[0],n),Pe(1,ce[ce.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new at(f,3)),this.setAttribute("normal",new at(g,3)),this.setAttribute("uv",new at(m,2));function ue(ve,Ae,ye,Ve,Ie,Ce,it,Je){for(let st=0;st<c+1;st++){let nt=st/c,Ze=it<0?nt:1-nt;Je&&(Ze-=1),Ze*=Ve;let Qe=new re(Math.sin(Ze),Math.cos(Ze)*it),pt=Qe.clone().multiplyScalar(Ie).add(Ce);$o(pt,ye,_),f.push(_.x,_.y,_.z),$o(Qe,ye,b),g.push(b.x,b.y,b.z),m.push(Ae,.5+_.y/i),ve.push(y++)}}function ae(ve,Ae,ye,Ve,Ie){let Ce=new I,it=new re,Je=[ye,Ve];Ie<0&&Je.reverse();for(let st of Je)it.set(st,x*Ie),$o(it,Ae,Ce),f.push(Ce.x,Ce.y,Ce.z),g.push(0,Ie,0),m.push(.5,.5),ve.push(y++)}function Pe(ve,Ae,ye){let Ve=new re(Math.sin(ye),Math.cos(ye)),Ie=new re(-Math.cos(ye),Math.sin(ye)),Ce=new I,it=ve<0?(nt,Ze,Qe)=>p.push(nt,Ze,Qe):(nt,Ze,Qe)=>p.push(nt,Qe,Ze),Je=new re((e+t+U+L)/4,0);$o(Je,Ve,Ce),f.push(Ce.x,Ce.y,Ce.z),g.push(Ie.x,0,Ie.y),m.push(.5,.5);let st=y++;for(let nt of Ae){let Ze=f.slice(nt*3,nt*3+3);f.push(...Ze),g.push(Ie.x,0,Ie.y);let Qe=m.slice(nt*2,nt*2+2);m.push(...Qe),y++}for(let nt=st+1;nt<y-1;nt++)it(st,nt,nt+1);it(st,y-1,st+1)}}},RQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=lt.clamp(i.thetaLength,0,360),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:c,cornerSegments:u}=e.parameters,d;return l===0?(d=new gt,d.setAttribute("position",new at([],3))):h>0||c>0||l<360?d=new dD(0,t/2,r,s,a,n,o,l*Math.PI/180,h,c,u,0,!0):d=new Tb(t/2,r,s,a,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},LQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o===0?h=new rn(t,i,r,s,a,n):h=new BQ(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},s1=Math.PI/2,BQ=class extends gt{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry",r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let l=[],h=[],c=[],u=[],d=0;p("z","y","x",-1,-1,i,t,e,a,s),p("z","y","x",1,-1,i,t,-e,a,s),p("x","z","y",1,1,e,i,t,r,a),p("x","z","y",1,-1,e,i,-t,r,a),p("x","y","z",1,-1,e,t,i,r,s),p("x","y","z",-1,-1,e,t,-i,r,s),n>0&&(f("z","y","x",-1,-1,1,i,t,e,a),f("z","y","x",1,-1,-1,i,t,e,a),f("z","y","x",-1,1,-1,i,t,e,a),f("z","y","x",1,1,1,i,t,e,a),f("x","y","z",-1,-1,-1,e,t,i,r),f("x","y","z",1,-1,1,e,t,i,r),f("x","y","z",-1,1,1,e,t,i,r),f("x","y","z",1,1,-1,e,t,i,r),f("y","x","z",-1,-1,1,t,e,i,s),f("y","x","z",1,-1,-1,t,e,i,s),f("y","x","z",1,1,1,t,e,i,s),f("y","x","z",-1,1,-1,t,e,i,s),g(1,1,1),g(-1,1,1),g(1,-1,1),g(-1,-1,1),g(1,1,-1),g(-1,1,-1),g(1,-1,-1),g(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new at(h,3)),this.setAttribute("normal",new at(c,3)),this.setAttribute("uv",new at(u,2));function p(m,y,x,b,_,M,S,E,A,T){let P=(M-2*n)/A,R=(S-2*n)/T,z=M/2-n,U=S/2-n,L=E/2,H=A+1,q=T+1,Z=0,X=new I;for(let se=0;se<q;se++){let le=se*R-U;for(let te=0;te<H;te++){let ie=te*P-z;X[m]=ie*b,X[y]=le*_,X[x]=L,h.push(X.x,X.y,X.z),X[m]=0,X[y]=0,X[x]=E>0?1:-1,c.push(X.x,X.y,X.z),u.push(te/A),u.push(1-se/T),Z+=1}}for(let se=0;se<T;se++)for(let le=0;le<A;le++){let te=d+le+H*se,ie=d+le+H*(se+1),fe=d+(le+1)+H*(se+1),ce=d+(le+1)+H*se;l.push(te,ie,ce),l.push(ie,fe,ce)}d+=Z}function f(m,y,x,b,_,M,S,E,A,T){let P=(S-2*n)/T,R=S/2-n,z=E/2-n,U=A/2,L=T+1,H=0,q=new I,Z=new I;for(let X=0;X<o+1;X++){let se=X/o*s1,le=Math.sin(se)*n,te=(1-Math.cos(se))*n,ie=Math.sin(se),fe=Math.cos(se);q[y]=(z+le)*_,q[x]=(U-te)*M,Z[m]=0,Z[y]=ie*Math.sign(q[y]),Z[x]=fe*Math.sign(q[x]);for(let ce=0;ce<L;ce++){let ue=ce*P-R;q[m]=ue*b,h.push(q.x,q.y,q.z),c.push(Z.x,Z.y,Z.z),u.push(ce/T),u.push(0),H+=1}}for(let X=0;X<o;X++)for(let se=0;se<T;se++){let le=d+se+L*X,te=d+se+L*(X+1),ie=d+(se+1)+L*(X+1),fe=d+(se+1)+L*X;l.push(le,te,fe),l.push(te,ie,fe)}d+=H}function g(m,y,x){let b=new I,_=new I(e/2,t/2,i/2);_.subScalar(n);let M=[],S=m*y*x>0?(A,T,P)=>l.push(A,T,P):(A,T,P)=>l.push(A,P,T);for(let A=0;A<=o;A++){let T=[],P=s1*(1-A/o),R=Math.cos(P),z=Math.sin(P),U=0;for(let L=0;L<=A;L++){let H=Math.cos(U),q=Math.sin(U);b.x=R*H,b.y=z,b.z=R*q;let Z=_.clone().addScaledVector(b,n);h.push(m*Z.x,y*Z.y,x*Z.z),c.push(m*b.x,y*b.y,x*b.z),u.push(0,0),T.push(d++),U+=s1/A}M.push(T)}let E=M.length-1;for(let A=0;A<E;A++){let T=M[A],P=M[A+1],R=T.length-1;S(T[0],P[1],P[0]);for(let z=1;z<=R;z++)S(T[z-1],T[z],P[z]),S(T[z],P[z+1],P[z])}}}},cw=class extends gt{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),c(),this.setAttribute("position",new at(n,3)),this.setAttribute("normal",new at(l,3)),this.setAttribute("uv",new at(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let u={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new I,p=d.clone(),f=new us,g=s*r,m=r-g,y=a+1,x=new I,b=(Z,X)=>x.subVectors(Z,X).normalize(),_=(Z,X)=>Array(Z).fill(void 0).map(X),M=_(e.length/3,(Z,X)=>new I().fromArray(e,X*3).setLength(r)),S=[],E=1e6;for(let Z=0;Z<M.length;Z++){let X=M[Z],se=[],le,te,ie,fe=1e10,ce=-1;for(;(ce=t.indexOf(Z,ce+1))!=-1;){let ve=ce-ce%3;le=t[ve+(ce+1)%3],te=t[ve+(ce+2)%3],ie=X.distanceToSquared(M[le]),fe=Math.min(fe,ie),se.push([le,te,ie])}fe+=1e-6;let ue=[],ae=0,Pe=se.length;for(let ve=0;ve<Pe;ve++){[le,te,ie]=se[ae];let Ae=S[le]?.includes(Z)==!0;ie<=fe&&ue.push(le+ +Ae*E),ae=se.findIndex(ye=>ye[0]==te)}S.push(ue)}let A=[];{let Z=0,X=0,se,le,te=u==3;for(let ie=0;ie<=a;ie++){se=ie*(ie+1)/2,le=(ie+1)*(ie+2)/2;for(let fe=0;fe<a-ie;fe++)[Z,X]=[se+fe+ie+2,le+fe+ie+3],A.push(se,le,...te?[X,se]:[Z,le],X,Z),[se,le]=[Z,X];A.push(se,le,se+a+2)}}let T=d.clone(),P=d.clone(),R=d.clone(),z=d.clone(),U=d.clone(),L=[],H=_(M.length,()=>_(u,()=>d.clone()));for(let Z=0;Z<M.length;Z++){d.copy(M[Z]).normalize(),T.copy(d).multiplyScalar(m);let X=S[Z];for(let ue=0;ue<X.length;ue++){let ae=X[ue],Pe=X[(ue+1)%u];f.setFromPointsAndIndices(M,Z,ae%E,Pe%E),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(T,H[Z][ue])}let se=[],le=[],te=[],ie=new I;a==0&&[...H[Z]].reduce((ue,ae)=>ue.add(ae),ie).multiplyScalar(1/u);for(let ue=0;ue<u;ue++){let ae=[],Pe=(ue-1+u)%u,ve=H[Z][Pe],Ae=H[Z][ue];d.copy(ve).sub(T),p.copy(Ae).sub(T);let ye=T.angleTo(d),Ve=d.angleTo(p),Ie=Math.cos(ye)*g;a==0?P.copy(ie):P.copy(T).setLength(m+Ie),le.push(Ie);let Ce=[P,ve,Ae];for(let it=0;it<2;it++){let Je=Ce[it],st=Ce[it+1];z.subVectors(Je,T),U.subVectors(st,T),R.crossVectors(z,U).normalize();for(let nt=0;nt<y;nt++){let Ze=[ye,Ve][it]*nt/y;d.copy(z).applyAxisAngle(R,Ze).add(T),se.push(d.clone()),it&&(b(d,T),ae.push([nt==0?Je:d.clone(),x.clone()]))}it&&(b(st,T),ae.push([st,x.clone()]))}te.push(ae)}L.push(te);let fe=2*y,ce=2;for(let ue=0;ue<u;ue++){let ae=fe*ue,Pe=fe*((ue+1)%u),ve=[se[ae]];for(let ye=1;ye<y;ye++){z=se[ae+ye],U=se[Pe+ye],ve.push(z);for(let Ve=1,Ie=ye-ce+1;Ve<=Ie;Ve++)d.lerpVectors(z,U,Ve/(Ie+1)),d.sub(T).setLength(le[ue]).add(T),ve.push(d.clone());ve.push(U)}for(let ye=0;ye<y;ye++)ve.push(se[ye+y+ae]);ve.push(se[Pe+y]);let Ae=A.map(ye=>ve[ye]);n.push(...Ae.map(ye=>[ye.x,ye.y,ye.z]).flat()),l.push(...Ae.map(ye=>(b(ye,T),[x.x,x.y,x.z])).flat())}}let q=[];for(let Z=0;Z<S.length;Z++)for(let X=0;X<u;X++){let se=S[Z][X];if(se<E){let le=S[se].findIndex(fe=>fe%E==Z),te=L[Z][X],ie=L[se][le];for(let fe=0;fe<y;fe++){let ce=te[fe],ue=ie[y-fe],ae=te[fe+1],Pe=ie[y-(fe+1)];[ce,ue,ae,ae,ue,Pe].forEach(ve=>{n.push(ve[0].x,ve[0].y,ve[0].z),l.push(ve[1].x,ve[1].y,ve[1].z)})}q.push(te[0][0],ie[y][0],te[y][0],ie[0][0])}}for(;q.length;){let Z,X,se,le;[Z,X]=q.splice(0,2);let te=[Z];for(;Z!=X;)te.push(X),se=q.indexOf(X),le=se%2,X=q.splice(se-le,2)[1-le];x.subVectors(te[0],te[1]).cross(d.subVectors(te[0],te[2])).normalize();let ie=x.dot(te[0])<0;ie&&x.negate();for(let fe=1;fe<=te.length-2;fe++)[te[fe+ +ie],te[fe+1-+ie],te[0]].forEach(ce=>{n.push(ce.x,ce.y,ce.z),l.push(x.x,x.y,x.z)})}}function c(){let u=new I;for(let S=0;S<n.length;S+=3){u.x=n[S+0],u.y=n[S+1],u.z=n[S+2];let E=_(u)/2/Math.PI+.5,A=M(u)/Math.PI+.5;o.push(E,1-A)}let d=new I,p=new I,f=new I,g=new I,m=new re,y=new re,x=new re,b=(S,E,A,T)=>{T<0&&S.x===1&&(o[E]=S.x-1),A.x===0&&A.z===0&&(o[E]=T/2/Math.PI+.5)};for(let S=0,E=0;S<n.length;S+=9,E+=6){d.set(n[S+0],n[S+1],n[S+2]),p.set(n[S+3],n[S+4],n[S+5]),f.set(n[S+6],n[S+7],n[S+8]),m.set(o[E+0],o[E+1]),y.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),g.copy(d).add(p).add(f).divideScalar(3);let A=_(g);b(m,E+0,d,A),b(y,E+2,p,A),b(x,E+4,f,A)}for(let S=0;S<o.length;S+=6){let E=o[S+0],A=o[S+2],T=o[S+4],P=Math.max(E,A,T),R=Math.min(E,A,T);P>.9&&R<.1&&(E<.2&&(o[S+0]+=1),A<.2&&(o[S+2]+=1),T<.2&&(o[S+4]+=1))}function _(S){return Math.atan2(S.z,-S.x)}function M(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}}static fromJSON(e){return new cw(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},zQ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new pD(t*.5,a,n):new hT(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},pD=class extends cw{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new pD(e.radius,e.corner,e.cornerSides)}},gd=1e-12,uw=class{constructor(e){this.position=new re,this.startPosition=new re,this.uuid=lt.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new uw(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Dx=class extends uw{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Dx(this.parent).copy(this)}},Jc=class extends uw{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Dx(this),new Dx(this))}static create(e,t){let i=new Jc(e,new re(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Jc(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new re,t=new re){let[i,r]=this.computeTangents();return i&&r&&(QM(i,e),QM(r,t)),[e,t]}computeTangent(e=new re){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new re){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function QM(e,t=new re){let i=e.length();return t.set(-e.y/i,e.x/i)}var dw=e=>e,Bu=new re,bv=new re,FQ=new re,kQ=new re,UQ=new re,NQ=new re,fD=new I,mD=new I;function VQ(e){let t=new re;t.addVectors(e.v0,Bu.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new re;return i.addVectors(e.v2,bv.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Za(e.v0,t,i,e.v2)}function Ld(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function jQ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function HQ(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function gD(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function GQ(e,t,i){return KM(e,t)&&KM(t,i)&&Ix(e.position,t.position,i.position)}function Ix(e,t,i){return Bu.copy(t).sub(e).cross(bv.copy(i).sub(e))===0}function WQ(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function qQ(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function XQ(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,c=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),u;return gD(t,e,i)>Math.PI&&(c*=-1),Ld(h,o)?u=(o+h)*(r/c-.5)*8/3/(n-l):u=(n+l)*(r/c-.5)*8/3/(h-o),s.set(t.x-u*o,t.y+u*n),a.set(i.x+u*h,i.y-u*l),[s,a]}function ZM(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function KM(e,t){return Ix(e.position,e.controls[1].position,t.position)&&Ix(e.position,t.controls[0].position,t.position)}function YQ(e,t,i,r,s=.5){let a=Bu.subVectors(t,e).multiplyScalar(s).add(e),n=bv.subVectors(i,t).multiplyScalar(s).add(t),o=FQ.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=kQ.subVectors(n,a).multiplyScalar(s).add(a),c=UQ.subVectors(o,n).multiplyScalar(s).add(n),u=o,d=NQ.subVectors(c,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,c.x,c.y,u.x,u.y,r.x,r.y]}function QQ(e,t,i=12,r=!0){let s=mD.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=dw(t[l]),c=Bu,u=Ah(h,i);o.push(u);for(let d=0;d<=u;d++)if(h instanceof Za||h instanceof Dl||h instanceof $a){if(h.getPoint(d/u,c),s.set(c.x,c.y,0),a!==void 0&&HQ(a,s))continue;a===void 0&&(a=fD),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function ZQ(e,t,i,r=12,s=!0){let a=mD.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,c=dw(t[l]),u=Bu,d=Ah(c,r);o.push(d);for(let p=0;p<=d;p++)if(c instanceof Za||c instanceof Dl||c instanceof $a){if(c.getPoint(p/d,u),a.set(u.x,u.y,0),h?.equals(a))continue;h===void 0?h=fD:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function JM(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=Ah(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=Ah(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Ah(e[0].roundedCurveCorner,t)*.5),r}function Ah(e,t=12){return e&&e instanceof av?t*2:e&&(e instanceof $a||e instanceof nT)?1:e&&e instanceof Eb?t*e.points.length:t}function KQ(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=dw(t[n]),l=Ah(o,i),h=Bu;for(let c=0;c<=l;c++)if(o instanceof Za||o instanceof Dl||o instanceof $a){if(o.getPoint(c/l,h),s!==void 0&&jQ(s,h,gd))continue;s===void 0&&(s=bv),s.copy(h),e.push(h.x,h.y),a++}}return Ld(e[0],e[e.length-2],gd)&&Ld(e[1],e[e.length-1],gd)&&(e.pop(),e.pop()),r&&a>1&&!(Ld(e[a-1],e[1],gd)&&Ld(e[a-2],e[0],gd))&&(e.push(e[0],e[1]),a++),e}var a1=new re,JQ=new re,$Q=new re,eZ=new re,tZ=new re,iZ=new re,ar=class extends sg{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Gs(new I(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=lt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new ar;return r.isClosed=e.isClosed,r.points=e.points.map(s=>Jc.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>ar.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],a=e-t;if(a<=s.points.length-1)return s.points[a];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],a=s.points.indexOf(e);if(a>=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=a1.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=lt.generateUUID()){let r;e instanceof re?r=e:r=new re(e,t);let s=new Jc(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return QQ(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=JM(this.points,e,!1),this.roundedCurveDivisions=JM(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return ZQ(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),KQ(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Ah(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,n=a[e];if(ZM(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(a1.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){ZM(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&GQ(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,c=s.curveAfter;if(h===void 0||c===void 0)continue;let u=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=c.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),y=Math.min(g,m),x=1-y/p,b=y/f,_=h.getPointAt(x,a1),M=c.getPointAt(b,JQ);this._subSplitCurve(h,u,x,_,void 0),this._subSplitCurve(c,d,b,void 0,M);let S;if(this.useCubicForRoundedCorners){let E=gD(_,s.position,M)/2,A=Math.tan(E)*_.distanceTo(s.position),[T,P]=WQ(_,M,A,$Q,eZ),R=qQ(T,P,s.position),[z,U]=XQ(R,_,M,A,tZ,iZ);S=new Za(_.clone(),z.clone(),U.clone(),M.clone())}else S=new Dl(_.clone(),s.position.clone(),M.clone());s.roundedCurveCorner=S,this.roundedCurves.splice(i+t,0,S),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof $a)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=YQ(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new ar(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],a=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],c=e.points[r+6],u=new Jc(lt.generateUUID(),new re(s,a));u.controls[0].position.set(n,o),u.controls[1].position.set(l,h),u.roundness=c,this.points.push(u)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new ar;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof Za&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof Dl&&(s[n]=VQ(s[n]));for(n=0,o=s.length;n<o;n++){let c=s[n],u=n>0?s[n-1]:null,d;c instanceof Za?(d=this.createPoint(c.v0),d.controls[1].position.copy(c.v1)):c instanceof $a&&(d=this.createPoint(c.v1)),d!==void 0&&(u!==null&&i(d,u),a.push(d))}let l=s[s.length-1],h=!1;return l instanceof Za?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof $a&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof sg&&(this.shapeHoles=e.holes.map(s=>{let a=new ar;return a.fromShape(s),a})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Ox=Math.PI*2;function n1({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function rZ(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function $M(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function sZ(e,t,i,r,s,a,n,o,l,h){let c=Math.pow(s,2),u=Math.pow(a,2),d=Math.pow(n,2),p=Math.pow(o,2),f=c*u-c*p-u*d;f<0&&(f=0),f/=c*p+u*d,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/a*o,m=f*-a/s*n,y=g+(e+i)/2,x=m+(t+r)/2,b=(n-g)/s,_=(o-m)/a,M=(-n-g)/s,S=(-o-m)/a,E=$M(1,0,b,_),A=$M(b,_,M,S);return!h&&A>0&&(A-=Ox),h&&A<0&&(A+=Ox),{centerx:y,centery:x,ang1:E,ang2:A}}function aZ({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,c=(t-r)/2;if(h===0&&c===0)return[];s=Math.abs(s),a=Math.abs(a);let u=Math.pow(h,2)/Math.pow(s,2)+Math.pow(c,2)/Math.pow(a,2);u>1&&(s*=Math.sqrt(u),a*=Math.sqrt(u));let d=sZ(e,t,i,r,s,a,h,c,n,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,y=Math.abs(f)/(Ox/4);Math.abs(1-y)<1e-7&&(y=1);let x=Math.max(Math.ceil(y),1);f/=x;for(let b=0;b<x;b++)l.push(rZ(p,f)),p+=f;return l.map(b=>{let{x:_,y:M}=n1(b[0],s,a,g,m),{x:S,y:E}=n1(b[1],s,a,g,m),{x:A,y:T}=n1(b[2],s,a,g,m);return{x1:_,y1:M,x2:S,y2:E,x:A,y:T}})}var Pi;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Pi||(Pi={}));var _r;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(_r||(_r={}));function Ot(e,t){if(!e)throw t||"Assertion Failed!"}var At=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Ot(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){Ot(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){Ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){Ot(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,a){var n,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),vd=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),em=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Bc=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),eE=function(){function e(){var t=new Bc,i=new vd,r=new em(0),s=new em(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new em(0),r=new em(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;Ot(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Ot(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new Bc,i=new Bc,r=new vd,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var a=new Bc;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new vd;this.makeFace_(n,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new vd;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new Bc;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new vd;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&At.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&At.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){Ot(s.prev===a),l=s.anEdge;do Ot(l.Sym!==l),Ot(l.Sym.Sym===l),Ot(l.Lnext.Onext.Sym===l),Ot(l.Onext.Sym.Lnext===l),Ot(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Ot(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Ot(n.prev===o),l=n.anEdge;do Ot(l.Sym!==l),Ot(l.Sym.Sym===l),Ot(l.Lnext.Onext.Sym===l),Ot(l.Onext.Sym.Lnext===l),Ot(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Ot(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Ot(l.Sym.next===h.Sym),Ot(l.Sym!==l),Ot(l.Sym.Sym===l),Ot(l.Org!==null),Ot(l.Dst!==null),Ot(l.Lnext.Onext.Sym===l),Ot(l.Onext.Sym.Lnext===l);Ot(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),tE=function(){function e(){this.handle=null}return e}(),iE=function(){function e(){this.key=null,this.node=0}return e}(),nZ=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new tE,this.handles[r]=new iE;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Ot(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new tE;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new iE}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;Ot(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),o1=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),rE=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),oZ=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new rE,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new rE;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),lZ=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?At.vertLeq(a.Org,n.Org)?At.edgeSign(n.Dst,a.Org,n.Org)<=0:At.edgeSign(a.Dst,n.Org,a.Org)>=0:At.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return At.edgeSign(a.Dst,s,a.Org)>=0;var o=At.edgeEval(a.Dst,s,a.Org),l=At.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Ot(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Ot(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new o1;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case Pi.ODD:return(i&1)!==0;case Pi.NONZERO:return i!==0;case Pi.POSITIVE:return i>0;case Pi.NEGATIVE:return i<0;case Pi.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,c,u=!0;h=r;do Ot(At.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,c=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===c.Org;)h.Onext!==c&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(c.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!u&&e.checkForRightSplice(t,l)&&(e.addWinding(h,c),e.deleteRegion(t,l),t.mesh.delete(c)),u=!1,l=o,c=h;l.dirty=!0,Ot(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=At.vertL1dist(i,t),a=At.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(At.vertLeq(s.Org,a.Org)){if(At.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;At.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(At.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(Ot(!At.vertEq(s.Dst,a.Dst)),At.vertLeq(s.Dst,a.Dst)){if(At.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(At.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,c,u,d=new Bc,p,f;if(Ot(!At.vertEq(h,l)),Ot(At.edgeSign(l,t.event,n)<=0),Ot(At.edgeSign(h,t.event,o)>=0),Ot(n!==t.event&&o!==t.event),Ot(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(c=Math.min(n.t,l.t),u=Math.max(o.t,h.t),c>u))return!1;if(At.vertLeq(n,o)){if(At.edgeSign(h,n,o)>0)return!1}else if(At.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),At.intersect(l,n,h,o,d),Ot(Math.min(n.t,l.t)<=d.t),Ot(d.t<=Math.max(o.t,h.t)),Ot(Math.min(h.s,l.s)<=d.s),Ot(d.s<=Math.max(o.s,n.s)),At.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=At.vertLeq(n,o)?n:o,At.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),At.vertEq(d,n)||At.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!At.vertEq(l,t.event)&&At.edgeSign(l,t.event,d)>=0||!At.vertEq(h,t.event)&&At.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(At.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),At.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,s),s.Org.s=d.s,s.Org.t=d.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,n,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,a;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),At.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),At.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}At.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;if(s=i.eUp,At.vertEq(s.Org,r)){Ot(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!At.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Ot(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(Ot(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),At.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new o1;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,At.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=At.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var c=t.mesh.connect(o.Dnext,i.anEdge);l=c.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);Ot(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new o1,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new oZ(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Ot(i.fixUpperEdge),Ot(++r===1)),Ot(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,At.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new nZ(a,At.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,Ot(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!At.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),hZ=function(){function e(){this.mesh=new eE,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=Pi.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,a,n,o,l=[0,0,0],h=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)a=i.coords[m],h[m]=a,f[m]=i,l[m]=a,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var y=0;y<3;++y)a=i.coords[y],a<h[y]&&(h[y]=a,f[y]=i),a>l[y]&&(l[y]=a,p[y]=i);var x=0;if(l[1]-h[1]>l[0]-h[0]&&(x=1),l[2]-h[2]>l[x]-h[x]&&(x=2),h[x]>=l[x]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[x],s=p[x],c[0]=r.coords[0]-s.coords[0],c[1]=r.coords[1]-s.coords[1],c[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)u[0]=i.coords[0]-s.coords[0],u[1]=i.coords[1]-s.coords[1],u[2]=i.coords[2]-s.coords[2],d[0]=c[1]*u[2]-c[2]*u[1],d[1]=c[2]*u[0]-c[0]*u[2],d[2]=c[0]*u[1]-c[1]*u[0],n=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],n>o&&(o=n,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,a=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);a&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;At.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;At.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(At.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(At.edgeGoesLeft(s.Lnext)||At.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(At.edgeGoesRight(r.Lprev)||At.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var a,n=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){a=c.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=n,++n}this.elementCount=n,i===_r.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var u=h.n*s;this.vertices[u+0]=h.coords[0],this.vertices[u+1]=h.coords[1],s>2&&(this.vertices[u+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(c.inside){a=c.anEdge,l=0;do{var h=a.Org;this.elements[d++]=h.n,l++,a=a.Lnext}while(a!==c.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===_r.CONNECTED_POLYGONS){a=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==c.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,c=0;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==s);this.elements[c++]=a,this.elements[c++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new eE),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,a,n){if(t===void 0&&(t=Pi.ODD),i===void 0&&(i=_r.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),lZ.computeInterior(this,n);var o=this.mesh;return i===_r.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===_r.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function wl(e){var t=e.windingRule,i=t===void 0?Pi.ODD:t,r=e.elementType,s=r===void 0?_r.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,c=h===void 0?[0,0,1]:h,u=e.contours,d=u===void 0?[]:u,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var y=new hZ;e.edgeCreateCallback&&(y.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(y.vertexIdCallback=e.vertexIdCallback);for(var x=0;x<d.length;x++)y.addContour(l||2,d[x]);return y.tesselate(i,s,n,l,c,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:m?y.mesh:void 0}}}var ile=Pi.ODD,rle=Pi.NONZERO,sle=Pi.POSITIVE,ale=Pi.NEGATIVE,nle=Pi.ABS_GEQ_TWO,ole=_r.POLYGONS,lle=_r.CONNECTED_POLYGONS,hle=_r.BOUNDARY_CONTOURS,Rx=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*Rx.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*Rx.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},vD=Rx;vD.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var cZ=class{constructor(e=[],t=(i,r)=>i<r?-1:i>r?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:i}=this,r=t[e];for(;e>0;){let s=e-1>>1,a=t[s];if(i(r,a)>=0)break;t[e]=a,e=s}t[e]=r}_down(e){let{data:t,compare:i}=this,r=this.length>>1,s=t[e];for(;e<r;){let a=(e<<1)+1,n=a+1;if(n<this.length&&i(t[n],t[a])<0&&(a=n),i(t[a],s)>=0)break;t[e]=t[a],e=a}t[e]=s}};function uZ(e,t,i=1,r=!1){let s=1/0,a=1/0,n=-1/0,o=-1/0;for(let[x,b]of e[0])x<s&&(s=x),b<a&&(a=b),x>n&&(n=x),b>o&&(o=b);let l=n-s,h=o-a,c=Math.max(i,Math.min(l,h));if(c===i){let x=[s,a];return x.distance=0,x.distance}let u=new cZ([],(x,b)=>b.max-x.max),d=pZ(e),p=new Vg(s+l/2,a+h/2,0,e);p.d>d.d&&(d=p);let f=2;function g(x,b,_){let M=new Vg(x,b,_,e);if(f++,M.max>d.d+i&&u.push(M),M.d>d.d&&(d=M,r&&console.log(`found best ${Math.round(1e4*M.d)/1e4} after ${f} probes`),d.d>t))return t}let m=c/2;for(let x=s;x<n;x+=c)for(let b=a;b<o;b+=c)g(x+m,b+m,m);for(;u.length;){let{max:x,x:b,y:_,h:M}=u.pop();if(x-d.d<=i)break;m=M/2,g(b-m,_-m,m),g(b+m,_-m,m),g(b-m,_+m,m),g(b+m,_+m,m)}r&&console.log(`num probes: ${f}
3176
3176
  best distance: ${d.d}`);let y=[d.x,d.y];return y.distance=d.d,y.distance}function Vg(e,t,i,r){this.x=e,this.y=t,this.h=i,this.d=dZ(e,t,r),this.max=this.d+this.h*Math.SQRT2}function dZ(e,t,i){let r=!1,s=1/0;for(let a of i)for(let n=0,o=a.length,l=o-1;n<o;l=n++){let h=a[n],c=a[l];h[1]>t!=c[1]>t&&e<(c[0]-h[0])*(t-h[1])/(c[1]-h[1])+h[0]&&(r=!r),s=Math.min(s,fZ(e,t,h,c))}return s===0?0:(r?1:-1)*Math.sqrt(s)}function pZ(e){let t=0,i=0,r=0,s=e[0];for(let n=0,o=s.length,l=o-1;n<o;l=n++){let h=s[n],c=s[l],u=h[0]*c[1]-c[0]*h[1];i+=(h[0]+c[0])*u,r+=(h[1]+c[1])*u,t+=u*3}let a=new Vg(i/t,r/t,0,e);return t===0||a.d<0?new Vg(s[0][0],s[0][1],0,e):a}function fZ(e,t,i,r){let s=i[0],a=i[1],n=r[0]-s,o=r[1]-a;if(n!==0||o!==0){let l=((e-s)*n+(t-a)*o)/(n*n+o*o);l>1?(s=r[0],a=r[1]):l>0&&(s+=n*l,a+=o*l)}return n=e-s,o=t-a,n*n+o*o}var pw={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},yD={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},xD={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},l1=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),fw=class extends gt{constructor(e,t,i=0,r=12,s=3,a=Pi.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(T=>{let P=T.extractShapePointsToFlatArray([],r),R=[];for(let z=P.length-1;z>=1;z-=2){let U=P[z-1],L=P[z-0];R.push(U,L)}return R}),h=[],c=[];for(let T=0;T<o.length;T+=2)c.push([o[T],o[T+1]]);h.push(c);for(let T=0;T<l.length;T++){let P=l[T],R=[];for(let z=0;z<P.length;z+=2)R.push([P[z],P[z+1]]);h.push(R)}let u;e.isText?u=new Rb().setFromPoints(e.points.map(T=>T.position)).getSize(new re).length()*.1:h[0].length===0?u=i:i>0?u=uZ(h,i):u=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,u,t/2),this._bevelSegments=Math.floor(s));let d;try{d=wl({windingRule:a,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=pw}let p;try{p=wl({windingRule:Pi.ODD,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=yD}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let T=0;T<p.elements.length;T++){let P=p.elements[T],R=T%2===0?d.vertexCount:0;d.elements.push(P+R)}for(let T=0;T<p.vertexIndices.length;T++){let P=p.vertexIndices[T],R=d.vertexCount;d.vertexIndices.push(P+R)}for(let T=0;T<p.vertices.length;T++){let P=p.vertices[T];d.vertices.push(P)}}let g=1/0,m=-1/0,y=1/0,x=-1/0;for(let T=0,P=d.vertexCount;T<P;T++){let R=T*2,z=d.vertices[R+0],U=d.vertices[R+1];z<g&&(g=z),z>m&&(m=z),U<y&&(y=U),U>x&&(x=U)}this._minX=g,this._minY=y,this._width=m-g,this._height=x-y,this._buffer=new vD(this._computeBufferEstimatedSize(d));let b=[],_=[];for(let T=d.elementCount-1;T>=0;T--){let P=T>=f,R=T*2,z=d.elements[R+0],U=d.elements[R+1],L=z+U,H={start:z,count:U,normals:[],continuous:[],concave:[]},q=z,Z=L-1,X=z+1,se=this._shape.roundedCurves.length;do{let ce=q-z,ue=d.vertices[Z*2+0],ae=d.vertices[Z*2+1],Pe=d.vertices[q*2+0],ve=d.vertices[q*2+1],Ae=d.vertices[X*2+0],ye=d.vertices[X*2+1],Ve=Pe-ue,Ie=ve-ae,Ce=Math.sqrt(Ve*Ve+Ie*Ie);Ve/=Ce,Ie/=Ce;let it=Pe-Ae,Je=ve-ye,st=Math.sqrt(it*it+Je*Je);it/=st,Je/=st,H.normals[ce*2+0]=-Je,H.normals[ce*2+1]=it,H.concave[ce]=Ve*Je-Ie*it>0;let nt=d.vertexIndices[q];if(Array.isArray(nt))H.continuous[ce]=!1;else{let[Ze,Qe]=this._shape.getCurveIndexFromVertexId(nt-1,!0);if(Qe>0&&Qe<1)H.continuous[ce]=!0;else{let pt=Qe===1?Ze+1:Ze-1;pt=(pt+se)%se;let wt=Qe===1?0:1,ee=this._shape.roundedCurves[Ze].getTangent(Qe),W=this._shape.roundedCurves[pt].getTangent(wt);H.continuous[ce]=ee.dot(W)>.95}}P&&(H.normals[ce*2+0]*=-1,H.normals[ce*2+1]*=-1),[Z,q,X]=[q,X,X+1],X>=L&&(X-=U)}while(X!==z+1);let le=[];le.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(z*2,L*2),vertexCount:U,vertexIndices:new Array(U).fill(!0).map((ce,ue)=>[ue,ue]),elements:[0,U],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(z*2,L*2)});let te=0;for(let ce=1;ce<=this._bevelSegments;ce++){let ue=ce/this._bevelSegments*Math.PI/2,ae=(1-Math.cos(ue))*this._bevel,Pe=[],ve=[],Ae=[],ye=[],Ve=0;for(let Ce=0;Ce<U;Ce++){let it=Ce*2,Je=(Ce-1+U)%U*2,st=d.vertices[H.start*2+it+0],nt=d.vertices[H.start*2+it+1],Ze=-H.normals[Je+0]*ae,Qe=-H.normals[Je+1]*ae,pt=-H.normals[it+0]*ae,wt=-H.normals[it+1]*ae;if(H.concave[Ce]||!H.concave[Ce]&&P){let ee=Math.atan2(Qe,Ze),W=Math.atan2(wt,pt);W>ee&&(W-=Math.PI*2);let _e=W-ee;if(H.continuous[Ce]||P){let We=ee+_e/2,V=Math.cos(We)*ae,Oe=Math.sin(We)*ae;Pe[2*Ve+0]=st+V*(P?-1:1),Pe[2*Ve+1]=nt+Oe*(P?-1:1),ye[Ve]=Ce,Ve++}else{let We=Math.max(1,Math.floor(r/4*Math.abs(_e)/Math.PI));for(let V=0;V<=We;V++){let Oe=ee+_e*(V/We),ut=Math.cos(Oe)*ae,He=Math.sin(Oe)*ae;Pe[2*Ve+0]=st+ut,Pe[2*Ve+1]=nt+He,ye[Ve]=Ce,Ve++}}}else Pe[2*Ve+0]=st+Ze,Pe[2*Ve+1]=nt+Qe,ye[Ve]=Ce,ve[Ce]=Ve,Ve++,Pe[2*Ve+0]=st,Pe[2*Ve+1]=nt,ye[Ve]=Ce,Ve++,Pe[2*Ve+0]=st+pt,Pe[2*Ve+1]=nt+wt,ye[Ve]=Ce,Ae[Ce]=Ve,Ve++}let Ie=wl({windingRule:Pi.POSITIVE,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Pe],edgeCreateCallback:Ce=>{let it=Ce.Org.idx,Je=ye[it],st=ye[(it+1)%ye.length];Ce.idx=[Je,st],Ce.Sym.idx=[st,Je]},vertexIdCallback:Ce=>{let it=Ce.Lprev.idx;return[it?it[1]:0,Ce.idx?Ce.idx[0]:0]}});if(!Ie)throw console.log("Error"),new Error(`error generating bevel geometry for ${ce}'th loop`);if(!Ie.vertexCount){let Ce=(ce-1)/this._bevelSegments*Math.PI/2;te=(1-Math.sin(Ce))*this._bevel;break}for(let Ce=0;Ce<Ie.vertexIndices.length;Ce++){let[it,Je]=Ie.vertexIndices[Ce];if(it===Je)continue;let st=Je;Je<it&&(st+=U);for(let nt=it;nt<st;nt++){let Ze=nt%U,Qe=(nt+1)%U;if(!H.continuous[Ze]||!H.continuous[Qe]){Ie.vertexIndices[Ce]=[it,Ze],Ie.vertexIndices.splice(Ce+1,0,[Qe,Je]),Ie.vertices.splice((Ce+1)*2,0,Ie.vertices[Ce*2],Ie.vertices[Ce*2+1]);break}}}le.push({bevelI:ce,angle:ue,size:ae,boundary:Ie,reverseMap:ye,insetPoints:Pe})}let ie=(ce,ue,ae)=>{let Pe=0,ve=ce.boundary.vertexIndices.length;for(;Pe<ve&&ae(ce.boundary.vertexIndices[ue]);)ue=(ue+1)%ve,Pe++;return Pe},fe=b.length;for(let ce=1;ce<le.length;ce++){let ue=le[ce-1],ae=le[ce],Pe=ue.boundary.vertexIndices.length,ve=ae.boundary.vertexIndices.length;if(!Pe||!ve)break;let Ae=H.concave.length,ye=0,Ve=l1(ye,U);for(;!ue.boundary.vertexIndices.filter(Ve).length||!ae.boundary.vertexIndices.filter(Ve).length;)ye++,Ve=l1(ye,U);let Ie=ue.boundary.vertexIndices.findIndex(Ve),Ce=ae.boundary.vertexIndices.findIndex(Ve);do Ie=(Ie+1)%Pe;while(Ve(ue.boundary.vertexIndices[Ie]));do Ce=(Ce+1)%ve;while(Ve(ae.boundary.vertexIndices[Ce]));ye=(ye+1)%U;let it=ye,Je=0,st=this._buildBevelVert(H,ue,(Ie-1+Pe)%Pe,void 0,Je),nt=this._buildBevelVert(H,ae,(Ce-1+ve)%ve,void 0,Je),Ze=st,Qe=nt,pt,wt,ee=!1;do{Je=(ye||Ae)/Ae,Ve=l1(ye,U);let W=ie(ue,Ie,Ve),_e=ie(ae,Ce,Ve),We=ee;if(ee=!1,W&&!_e){for(let V=0;V<W;V++)pt=this._buildBevelVert(H,ue,(Ie+V)%Pe,V/(W-1),Je),b.push(Ze.topN,pt.topP,Qe.topN),n===!1&&b.push(pt.bottomP,Ze.bottomN,Qe.bottomN),Ze=pt;ee=!0}else if(!W&&_e)for(let V=0;V<_e;V++)wt=this._buildBevelVert(H,ae,(Ce+V)%ve,V/(_e-1),Je),b.push(Qe.topN,Ze.topP,wt.topP),n===!1&&b.push(Ze.bottomP,Qe.bottomN,wt.bottomP),Qe=wt;else if(W&&_e)if(pt=this._buildBevelVert(H,ue,Ie,0,Je),wt=this._buildBevelVert(H,ae,Ce,0,Je),We?(b.push(Ze.topN,wt.topP,Qe.topN),b.push(Ze.topN,pt.topP,wt.topP),n===!1&&(b.push(wt.bottomP,Ze.bottomN,Qe.bottomN),b.push(wt.bottomP,pt.bottomP,Ze.bottomN))):(b.push(Qe.topN,Ze.topN,pt.topP),b.push(Qe.topN,pt.topP,wt.topP),n===!1&&(b.push(pt.bottomP,Ze.bottomN,Qe.bottomN),b.push(pt.bottomP,Qe.bottomN,wt.bottomP))),Ze=pt,Qe=wt,W===_e)for(let V=1;V<W;V++)pt=this._buildBevelVert(H,ue,(Ie+V)%Pe,V/(W-1),Je),wt=this._buildBevelVert(H,ae,(Ce+V)%ve,V/(_e-1),Je),b.push(Ze.topN,pt.topP,Qe.topN),b.push(Qe.topN,pt.topP,wt.topP),n===!1&&(b.push(pt.bottomP,Ze.bottomN,Qe.bottomN),b.push(pt.bottomP,Qe.bottomN,wt.bottomP)),Ze=pt,Qe=wt;else if(W>_e){let V=W/_e,Oe=0;for(let ut=1;ut<W;ut++)pt=this._buildBevelVert(H,ue,(Ie+ut)%Pe,ut/(W-1),Je),b.push(Ze.topN,pt.topP,Qe.topN),n===!1&&b.push(pt.bottomP,Ze.bottomN,Qe.bottomN),Ze=pt,ut>(Oe+1)*V&&(Oe++,wt=this._buildBevelVert(H,ae,(Ce+Oe)%ve,Oe/(_e-1),Je),b.push(Qe.topN,pt.topP,wt.topP),n===!1&&b.push(pt.bottomP,Qe.bottomN,wt.bottomP),Qe=wt)}else{let V=_e/W,Oe=0;for(let ut=1;ut<_e;ut++)wt=this._buildBevelVert(H,ae,(Ce+ut)%ve,ut/(_e-1),Je),b.push(Qe.topN,pt.topP,wt.topP),n===!1&&b.push(pt.bottomP,Qe.bottomN,wt.bottomP),Qe=wt,ut>(Oe+1)*V&&(Oe++,pt=this._buildBevelVert(H,ue,(Ie+Oe)%Pe,Oe/(W-1),Je),b.push(Ze.topN,pt.topP,Qe.topN),n===!1&&b.push(pt.bottomP,Ze.bottomN,Qe.bottomN),Ze=pt)}Ie=(Ie+W)%Pe,Ce=(Ce+_e)%ve,ye=(ye+1)%Ae}while(ye!==it)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(le,H,b),P){let ce=[];for(let ue=b.length-1;ue>=fe+2;ue-=3){let ae=b[ue-2],Pe=b[ue-1],ve=b[ue-0];ce.push(ve,Pe,ae)}b.splice(fe,b.length-fe,...ce)}if(P){let ce=[];for(let ue=le[le.length-1].boundary.vertices.length-1;ue>=1;ue-=2){let ae=le[le.length-1].boundary.vertices[ue-1],Pe=le[le.length-1].boundary.vertices[ue-0];ce.push(ae,Pe)}_.push(ce)}if(!P){let ce=le[le.length-1],ue;try{ue=wl({windingRule:le.length>1?Pi.POSITIVE:Pi.ODD,elementType:_r.POLYGONS,vertexSize:2,strict:!0,contours:[ce.insetPoints,..._]})}catch{ue=xD}if(!ue)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<u&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ae=0;ae<ue.elementCount*3;ae+=3){let Pe=this._buildSurfaceVert(ue,ue.elements[ae+0],te),ve=this._buildSurfaceVert(ue,ue.elements[ae+1],te),Ae=this._buildSurfaceVert(ue,ue.elements[ae+2],te);b.push(Pe.top,ve.top,Ae.top),n===!1&&b.push(Ae.bottom,ve.bottom,Pe.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new Tt(Uint32Array.from(b),1),S=new Tt(this._buffer.positions,3),E=new Tt(this._buffer.normals,3),A=new Tt(this._buffer.uvs,2);S.needsUpdate=!0,E.needsUpdate=!0,A.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",E),this.setAttribute("uv",A),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,c=l*2,u={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[c+0]=n,this._buffer.uvs[c+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[c+2]=n,this._buffer.uvs[c+3]=o),this.vertexCache[r]=u,u}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[n,o]=t.boundary.vertexIndices[i],l,h,c,u;n!==o?(h=n,l=o,u=!1,c=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,u=e.concave[l]&&t.bevelI>0,c=e.continuous[l]||u);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,y=t.boundary.vertices[f+0],x=t.boundary.vertices[f+1],b=(1-p)*this._bevel,_=(y-this._minX)/this._width,M=(x-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(_=s),M=1);let S=e.normals[g+0],E=e.normals[g+1],A=e.normals[m+0],T=e.normals[m+1];if(u){let L=A-S,H=T-E;S=S+L*(1-r),E=E+H*(1-r);let q=Math.sqrt(S*S+E*E);S/=q,E/=q}let P=this.forPathBevel?this._buffer.get(c?1:2):this._buffer.get(c?2:4),R=P*3,z=P*2,U={i,fi:l,topP:P+0,topN:P+0,bottomP:P+1,bottomN:P+1,pathBevelUCoord:s};return this._buffer.positions[R+0]=y,this._buffer.positions[R+1]=x,this._buffer.positions[R+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[R+0]=S*d,this._buffer.normals[R+1]=E*d,this._buffer.normals[R+2]=p,this._buffer.uvs[z+0]=_,this._buffer.uvs[z+1]=M,this.forPathBevel===!1&&(this._buffer.positions[R+3]=y,this._buffer.positions[R+4]=x,this._buffer.positions[R+5]=b,this._buffer.normals[R+3]=S*d,this._buffer.normals[R+4]=E*d,this._buffer.normals[R+5]=-p,this._buffer.uvs[z+2]=M,this._buffer.uvs[z+3]=_),c||(this.forPathBevel?(P+=1,R+=3,z+=2):(P+=2,R+=6,z+=4),U.topP=P+0,U.bottomP=P+1,this._buffer.positions[R+0]=y,this._buffer.positions[R+1]=x,this._buffer.positions[R+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[R+0]=A*d,this._buffer.normals[R+1]=T*d,this._buffer.normals[R+2]=p,this._buffer.uvs[z+0]=_,this._buffer.uvs[z+1]=M,this.forPathBevel===!1&&(this._buffer.positions[R+3]=y,this._buffer.positions[R+4]=x,this._buffer.positions[R+5]=b,this._buffer.normals[R+3]=A*d,this._buffer.normals[R+4]=T*d,this._buffer.normals[R+5]=-p,this._buffer.uvs[z+2]=M,this._buffer.uvs[z+3]=_)),this.vertexCache[a]=U,U}clone(){let e=new fw(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=pv(this.userData),e}},bD=class extends gt{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Pi.ODD,this.elementType=_r.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Pi.ODD,elementType:_r.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),a,n=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(n=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!n&&!o)break}if(!n&&!o)try{a=wl({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=pw}let c=a?.vertexCount??1,u=a?.elementCount??1;if(this._positionAttribute=new Tt(new Float32Array(c*3),3),this._normalAttribute=new Tt(new Float32Array(c*3),3),this._uvAttribute=new Tt(new Float32Array(c*2),2),this._indexAttribute=new Tt(new Uint32Array(u*3),1),a){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let x=0,b=c;x<b;x++){let _=x*2,M=a.vertices[_+0],S=a.vertices[_+1];M<d&&(d=M),M>p&&(p=M),S<f&&(f=S),S>g&&(g=S)}let m=p-d,y=g-f;for(let x=0,b=c;x<b;x++){let _=x*2,M=a.vertices[_+0],S=a.vertices[_+1],E=(M-d)/m,A=(S-f)/y;this._positionAttribute.setXYZ(x,M,S,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,E,A)}for(let x=0,b=u;x<b;x++){let _=x*3,M=a.elements[_+0],S=a.elements[_+1],E=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,S),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 bD(this._shape,this._curveSegments);return e.userData=pv(this.userData),e}},wD=class extends fw{constructor(e,t,i=0,r=12,s=3,a=Pi.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new wD(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=pv(this.userData),e}},kh=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Pi.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof ar?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new ar(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new ar(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new bD(e.shape,s,{windingRule:n}):o=new wD(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},_D=Math.PI*2,mw=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return i.angle=lt.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof ar?e.shape:new ar,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,c=t*.5,u=i*.5,d=mZ(h,c,u,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new gt,p.setAttribute("position",new at([],3))):p=kh.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function mZ(e,t,i,r,s,a){if(r>=_D)return s>30||s%4===0?(vZ(e,t,i,a),Math.round(s/4)):sE(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=aZ({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?gZ(e,n.x,n.y,h,s,t,i,a):sE(e,r,s,t,i,a)}function gZ(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint($c(t,i));for(let h=0,c=r.length;h<c;h++){let u=r[h],d=e.points[h],p=$c(u.x,u.y);d.controls[1].position.set(u.x1,u.y1),p.controls[0].position.set(u.x2,u.y2),e.addPoint(p)}return o>0?SD(e,a,n,o):e.addPoint($c(0,0)),l}function sE(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,c=Math.cos(l)*s;e.addPoint($c(h,c))}return t<_D?a>0?SD(e,r,s,a):e.addPoint($c(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&AD(e,r,s,a)),1}function vZ(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(tm(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(tm(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(tm(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(tm(s,a-i,s+o,a-i,s-o,a-i)),r>0&&AD(e,t,i,r)}function $c(e,t){return new Jc(lt.generateUUID(),new re(e,t))}function tm(e,t,i,r,s,a){let n=$c(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function SD(e,t,i,r){MD(e,t,i,r).forEach(s=>e.addPoint(s))}function AD(e,t,i,r){let s=MD(e,t,i,r),a=new ar;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function MD(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new re(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=lt.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),c=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(c),l.controls[1].position.copy(h)}),o}var yZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:c,cornerSegments:u}=e.parameters,d=new ED(!1,t,i,r,s,a,n,o,l,h,c,u);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},h1=new Xc([0,0,0],1),ED=class extends gt{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,c=1,u=1){if(super(),a===0)return;let d=e&&a===1;d&&(u=0),c>100&&(c=100),c===0&&(u=0);let p=()=>new I,f=new I,g=p(),m=p(),y=p(),x,b,_,M,S,E,A,T,P=p(),R=p(),z=p(),U=p(),L=p(),H=p(),q=p(),Z=p(),X=i-2*o+.001,se=X/a,le=Math.ceil(n*a),te=le+1,ie=X/le,fe=-X/2,ce=h+1,ue=2*Math.PI/h,ae=Math.PI/2/u,Pe=.01,ve=Math.min((1-c/100)*o,o-Pe),Ae=o-ve,ye=0,Ve=2,Ie=u*Ve+Ve,Ce=ce*Ie/Ve,it=Ce+ce*te,Je=Math.max(0,ce*(te+Ie)),[st,nt,Ze]=[3,3,2].map(ke=>Array(Je*ke).fill(0)),Qe=[],pt=s-o;function wt(ke,dt){let ot=Math.PI/2;E=dt*ie,T=2*Math.PI*(E%se)/se+ot,E+=fe,A=Math.sin(T)*pt,S=Math.cos(T)*pt,e?ke.set(S,A,E):ke.set(S,E,A)}wt(f,-1e-10),wt(g,0),P.copy(f),wt(f,1);let ee=f.distanceTo(g),W=d?0:Ae+ve,_e=ee*le+2*W,We=ve,V=_e-W;for(let ke=0;ke<=le;ke++){wt(m,ke),Z.subVectors(m,P).normalize(),P.copy(m),H.copy(m).setComponent(+e+1,0).normalize(),q.crossVectors(Z,H).normalize();let dt=ke===0,ot=ke===le,_t=dt?3*Math.PI/2:ae,bt=dt?We:V,ri=dt?ce:it,vi=dt?0:Je-ce,ii=Z.clone().multiplyScalar(dt?-Ae:Ae).add(m),me=Z.clone().multiplyScalar(dt?-1:1).normalize();for(let Ee=0;Ee<ce;Ee++){let Xe=Ee*ue;if(R.addVectors(f.copy(H).multiplyScalar(o*Math.cos(Xe)),g.copy(q).multiplyScalar(o*Math.sin(Xe))),z.copy(R).normalize(),dt||ot){d||(ye=vi+Ee,[0,1,2].forEach(Ke=>{st[ye*3+Ke]=ii.getComponent(Ke),nt[ye*3+Ke]=me.getComponent(Ke)}),Ze[ye*2]=+ot,Ze[ye*2+1]=Ee/h),g.copy(z).multiplyScalar(ve),y.addVectors(m,g);for(let Ke=0;Ke<u;Ke++){let vt=Ke*ae+_t;U.addVectors(f.copy(Z).multiplyScalar(Ae*Math.sin(vt)),g.copy(z).multiplyScalar(Ae*Math.cos(vt))),L.copy(U).normalize(),g.addVectors(y,U),U.normalize(),ye=ri+Ke*ce+Ee,[0,1,2].forEach(wi=>{st[ye*3+wi]=g.getComponent(wi),nt[ye*3+wi]=L.getComponent(wi)});let Mt=+dt+Math.sin(vt);Ze[ye*2]=(bt+Ae*Mt)/_e,Ze[ye*2+1]=Ee/h}}g.addVectors(m,R),ye=Ce+ke*ce+Ee,[0,1,2].forEach(Ke=>{st[ye*3+Ke]=g.getComponent(Ke),nt[ye*3+Ke]=z.getComponent(Ke)}),Ze[ye*2]=(W+ke*ee)/_e,Ze[ye*2+1]=Ee/h}}let Oe=te+2*u+Ve,ut=1,[He,ze]=[+d,Oe-1];for(let ke=He;ke<=ze-1;ke++){let dt=d&&ke===ze-1;for(let ot=0;ot<ce-1;ot++)x=ke*ce+ot,b=x+1,_=(dt?ot:x)+ce,M=(dt?ot+1:b)+ce,ke===0?Qe.push(b,M,_):ke===Oe-2?Qe.push(x,b,_):Qe.push(x,b,_,b,M,_)}this.setIndex(Qe),this.setAttribute("position",new at(st,3)),this.setAttribute("normal",new at(nt,3)),this.setAttribute("uv",new at(Ze,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,a,n,o,l=6*(t-1)*e.radialSegments,h=t,c=h===t;for(let u=0;u<e.radialSegments;u++)s=h*i+u,a=s+1,n=(c?u:s)+i,o=(c?u+1:a)+i,r[l++]=s,r[l++]=a,r[l++]=n,r[l++]=a,r[l++]=o,r[l++]=n;return r.length=l,h1.array=r,h1.count=r.length,h1}},xZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new CD(t*.5,a,n):new fT(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},CD=class extends cw{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],a=[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],n="IcosahedronGeometry";super(s,a,n,e,t,i),this.type=n}static fromJSON(e){return new CD(e.radius,e.corner,e.cornerSides)}},bZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new sg;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let a=new lT(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},gn=new je,c1=new Mi,im=new I,jg=class extends gs{constructor(){super(),this.uuid=lt.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new Sr().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let a=0,n=s.vertexNormals.length;a<n;a++)s.vertexNormals[a].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return gn.makeRotationX(e),this.applyMatrix4(gn),this}rotateY(e){return gn.makeRotationY(e),this.applyMatrix4(gn),this}rotateZ(e){return gn.makeRotationZ(e),this.applyMatrix4(gn),this}translate(e,t,i){return gn.makeTranslation(e,t,i),this.applyMatrix4(gn),this}scale(e,t,i){return gn.makeScale(e,t,i),this.applyMatrix4(gn),this}lookAt(e){return c1.lookAt(e),c1.updateMatrix(),this.applyMatrix4(c1.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,a=r.normal,n=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let u=0;u<s.count;u++)t.vertices.push(new I().fromBufferAttribute(s,u)),n!==void 0&&t.colors.push(new Ct().fromBufferAttribute(n,u));function h(u,d,p,f){let g=n===void 0?[]:[t.colors[u].clone(),t.colors[d].clone(),t.colors[p].clone()],m=a===void 0?[]:[new I().fromBufferAttribute(a,u),new I().fromBufferAttribute(a,d),new I().fromBufferAttribute(a,p)],y=new Lx(u,d,p,m,g,f);t.faces.push(y),o!==void 0&&t.faceVertexUvs[0].push([new re().fromBufferAttribute(o,u),new re().fromBufferAttribute(o,d),new re().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new re().fromBufferAttribute(l,u),new re().fromBufferAttribute(l,d),new re().fromBufferAttribute(l,p)])}let c=e.groups;if(c.length>0)for(let u=0;u<c.length;u++){let d=c[u],p=d.start,f=d.count;for(let g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(i!==void 0)for(let u=0;u<i.count;u+=3)h(i.getX(u),i.getX(u+1),i.getX(u+2));else for(let u=0;u<s.count;u+=3)h(u,u+1,u+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(im).negate(),this.translate(im.x,im.y,im.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new je;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new I,t=new I;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],a=this.vertices[s.a],n=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,n),t.subVectors(a,n),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new I;if(e){let i=new I,r=new I;for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],a=s.vertexNormals;a.length===3?(a[0].copy(t[s.a]),a[1].copy(t[s.b]),a[2].copy(t[s.c])):(a[0]=t[s.a].clone(),a[1]=t[s.b].clone(),a[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,a=r.vertexNormals.length;s<a;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new jg;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,a=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new I,h={a:new I,b:new I,c:new I};s.push(l),a.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new mr),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ks),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,a=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,c=e.colors;t!==void 0&&(r=new Sr().getNormalMatrix(t));for(let u=0,d=n.length;u<d;u++){let p=n[u].clone();t!==void 0&&p.applyMatrix4(t),a.push(p)}for(let u=0,d=c.length;u<d;u++)h.push(c[u].clone());for(let u=0,d=l.length;u<d;u++){let p=l[u],f,g,m=p.vertexNormals,y=p.vertexColors,x=new Lx(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),r!==void 0&&x.normal.applyMatrix3(r).normalize();for(let b=0,_=m.length;b<_;b++)f=m[b].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),x.vertexNormals.push(f);x.color.copy(p.color);for(let b=0,_=y.length;b<_;b++)g=y[b],x.vertexColors.push(g.clone());x.materialIndex=p.materialIndex+i,o.push(x)}for(let u=0,d=e.faceVertexUvs.length;u<d;u++){let p=e.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],y=[];for(let x=0,b=m.length;x<b;x++)y.push(m[x].clone());this.faceVertexUvs[u].push(y)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],c=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[c]===void 0?(t[c]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[c]]}let a=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let c=[h.a,h.b,h.c];for(let u=0;u<3;u++)if(c[u]===c[(u+1)%3]){a.push(o);break}}for(let o=a.length-1;o>=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,c=this.faceVertexUvs.length;h<c;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new I(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],a,n;r&&r.length===t&&(a=[]),s&&s.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;a&&a.push(r[l]),n&&n.push(s[l])}a&&(this.faceVertexUvs[0]=a),n&&(this.faceVertexUvs[1]=n)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},a=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],g=!0,m=!1,y=this.faceVertexUvs[0][p]!==void 0,x=f.normal.length()>0,b=f.vertexNormals.length>0,_=f.color.r!==1||f.color.g!==1||f.color.b!==1,M=f.vertexColors.length>0,S=0;if(S=h(S,0,0),S=h(S,1,g),S=h(S,2,m),S=h(S,3,y),S=h(S,4,x),S=h(S,5,b),S=h(S,6,_),S=h(S,7,M),i.push(S),i.push(f.a,f.b,f.c),i.push(f.materialIndex),y){let E=this.faceVertexUvs[0][p];i.push(d(E[0]),d(E[1]),d(E[2]))}if(x&&i.push(c(f.normal)),b){let E=f.vertexNormals;i.push(c(E[0]),c(E[1]),c(E[2]))}if(_&&i.push(u(f.color)),M){let E=f.vertexColors;i.push(u(E[0]),u(E[1]),u(E[2]))}}function h(p,f,g){return g?p|1<<f:p&~(1<<f)}function c(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function u(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return n[f]!==void 0||(n[f]=a.length,a.push(p.getHex())),n[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,a.length>0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new jg().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let u=0,d=t.length;u<d;u++)this.vertices.push(t[u].clone());let i=e.colors;for(let u=0,d=i.length;u<d;u++)this.colors.push(i[u].clone());let r=e.faces;for(let u=0,d=r.length;u<d;u++)this.faces.push(r[u].clone());for(let u=0,d=e.faceVertexUvs.length;u<d;u++){let p=e.faceVertexUvs[u];this.faceVertexUvs[u]===void 0&&(this.faceVertexUvs[u]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],y=[];for(let x=0,b=m.length;x<b;x++){let _=m[x];y.push(_.clone())}this.faceVertexUvs[u].push(y)}}let s=e.morphTargets;for(let u=0,d=s.length;u<d;u++){let p={};if(p.name=s[u].name,s[u].vertices!==void 0){p.vertices=[];for(let f=0,g=s[u].vertices.length;f<g;f++)p.vertices.push(s[u].vertices[f].clone())}if(s[u].normals!==void 0){p.normals=[];for(let f=0,g=s[u].normals.length;f<g;f++)p.normals.push(s[u].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let u=0,d=a.length;u<d;u++){let p={};if(a[u].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,g=a[u].vertexNormals.length;f<g;f++){let m=a[u].vertexNormals[f],y={};y.a=m.a.clone(),y.b=m.b.clone(),y.c=m.c.clone(),p.vertexNormals.push(y)}}if(a[u].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=a[u].faceNormals.length;f<g;f++)p.faceNormals.push(a[u].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let u=0,d=n.length;u<d;u++)this.skinWeights.push(n[u].clone());let o=e.skinIndices;for(let u=0,d=o.length;u<d;u++)this.skinIndices.push(o[u].clone());let l=e.lineDistances;for(let u=0,d=l.length;u<d;u++)this.lineDistances.push(l[u]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new wZ().fromGeometry(this),t=new gt,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",rm.call(new Tt(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",rm.call(new Tt(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",aE.call(new Tt(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",nE.call(new Tt(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",nE.call(new Tt(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n<o;n++){let l=a[n],h=new at(l.data.length*3,3);h.name=l.name,s.push(rm.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new at(e.skinIndices.length*4,4);t.setAttribute("skinIndex",oE.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new at(e.skinWeights.length*4,4);t.setAttribute("skinWeight",oE.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new gt,i=e.geometry;if(e.isPoints||e.isLine){let r=new at(i.vertices.length*3,3),s=new at(i.colors.length*3,3);if(t.setAttribute("position",rm.call(r,i.vertices)),t.setAttribute("color",aE.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new at(i.lineDistances.length,1);t.setAttribute("lineDistance",_Z.call(a,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};jg.prototype.isGeometry=!0;var wZ=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,a=e.faces;for(r=0;r<a.length;r++){let n=a[r];n.materialIndex!==s&&(s=n.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:n[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,c=h.length,u;if(c>0){u=[];for(let m=0;m<c;m++)u[m]={name:h[m].name,data:[]};this.morphTargets.normal=u}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let y=t[m];this.vertices.push(i[y.a],i[y.b],i[y.c]);let x=y.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let _=y.normal;this.normals.push(_,_,_)}let b=y.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let _=y.color;this.colors.push(_,_,_)}if(s===!0){let _=r[0][m];_!==void 0?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new re,new re,new re))}if(a===!0){let _=r[1][m];_!==void 0?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new re,new re,new re))}for(let _=0;_<o;_++){let M=n[_].vertices;l[_].data.push(M[y.a],M[y.b],M[y.c])}for(let _=0;_<c;_++){let M=h[_].vertexNormals[m];u[_].data.push(M.a,M.b,M.c)}f&&this.skinIndices.push(d[y.a],d[y.b],d[y.c]),g&&this.skinWeights.push(p[y.a],p[y.b],p[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Lx=class{constructor(e,t,i,r,s,a=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new I,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new Ct,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function _Z(e){return this.array.set(e),this}function aE(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new Ct),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function nE(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new re),t[i++]=a.x,t[i++]=a.y}return this}function rm(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new I),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this}function oE(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new zt),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var SZ=["a","b","c"];function AZ(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function u1(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function d1(e,t,i,r,s,a){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let c=i[n],u=i[o];h={a:c,b:u,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function MZ(e,t,i,r){let s,a,n;for(s=0,a=e.length;s<a;s++)i[s]={edges:[]};for(s=0,a=t.length;s<a;s++)n=t[s],d1(n.a,n.b,e,r,n,i),d1(n.b,n.c,e,r,n,i),d1(n.c,n.a,e,r,n,i)}function sm(e,t,i,r,s){e.push(new Lx(t,i,r,void 0,void 0,s))}function bc(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function am(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var EZ=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof gt?e=new jg().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new I,i,r,s,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],c=h!==void 0&&h.length>0,u=[],d=new Map;MZ(o,l,u,d);let p=[],f,g,m,y,x,b,_;for(let Pe of Array.from(d.keys())){for(g=d.get(Pe),m=new I,x=3/8,b=1/8,_=g.faces.length,_!=2&&(x=.5,b=0,_!=1),m.addVectors(g.a,g.b).multiplyScalar(x),t.set(0,0,0),a=0;a<_;a++){for(y=g.faces[a],n=0;n<3&&(f=o[AZ(y,SZ[n])],!(f!==g.a&&f!==g.b));n++);f&&t.add(f)}t.multiplyScalar(b),m.add(t),g.newEdge=p.length,p.push(m)}let M,S,E,A,T,P,R,z=[];for(r=0,s=o.length;r<s;r++){for(P=o[r],T=u[r].edges,i=T.length,i==3?M=3/16:i>3&&(M=3/(8*i)),S=1-i*Number(M),E=M,i<=2&&(i==2?(S=3/4,E=1/8):i==1||i==0),R=P.clone().multiplyScalar(S),t.set(0,0,0),a=0;a<i;a++)A=T[a],f=A.a!==P?A.a:A.b,t.add(f);t.multiplyScalar(Number(E)),R.add(t),z.push(R)}let U=z.concat(p),L=z.length,H,q,Z,X=[],se=[],le,te,ie,fe,ce=new re,ue=new re,ae=new re;for(r=0,s=l.length;r<s;r++)y=l[r],H=Number(u1(y.a,y.b,d).newEdge)+L,q=Number(u1(y.b,y.c,d).newEdge)+L,Z=Number(u1(y.c,y.a,d).newEdge)+L,sm(X,H,q,Z,y.materialIndex),sm(X,y.a,H,Z,y.materialIndex),sm(X,y.b,q,H,y.materialIndex),sm(X,y.c,Z,q,y.materialIndex),c&&(le=h[r],te=le[0],ie=le[1],fe=le[2],ce.set(bc(te.x,ie.x),bc(te.y,ie.y)),ue.set(bc(ie.x,fe.x),bc(ie.y,fe.y)),ae.set(bc(te.x,fe.x),bc(te.y,fe.y)),am(se,ce,ue,ae),am(se,te,ce,ae),am(se,ie,ue,ce),am(se,fe,ae,ue));e.vertices=U,e.faces=X,c&&(e.faceVertexUvs[0]=se)}},Rr=new I,CZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new gt().copy(new rn(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Rr),r={width:Rr.x,height:Rr.y,depth:Rr.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,a=e.geometry??new gt().copy(new rn(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(Rr)):Rr.set(n.width,n.height,n.depth),(t!==Rr.x||i!==Rr.y||r!==Rr.z)&&a.scale(Rr.x===0?1:t/Rr.x,Rr.y===0?1:i/Rr.y,Rr.z===0?1:r/Rr.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new EZ(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new ST(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(Rr);let a=100/Rr.x;Object.assign(s.parameters,{width:100,height:Rr.y*a,depth:Rr.z*a}),t(this.build(s))})}},TD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof ar?e.shape:new ar,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5,u=0,d=0,p=2*Math.PI/r;for(let g=0;g<r;g++){let m=p*g,y=u+Math.sin(m)*h,x=d+Math.cos(m)*c;l.addPoint(l.createPoint(y,x))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=kh.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},TZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new DZ(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function yd(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function p1(e,t,i,r,s,a){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let h=n.add(o).normalize();a.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(h)),a.addScaledVector(o,r/Math.sin(h))}}function PZ(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var DZ=class extends gt{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],c=[],u=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),g=2*Math.PI/i,m=(i-2)*Math.PI/i,y=Math.PI-m,x=new I(0,-d,0),b=new I(0,d,0),_=new re(e,-d),M=new re(f,-d),S=new re(0,b.y).sub(M),E=new re(0,b.y).sub(_),A=new re(S.y,-S.x).normalize(),T=new re(E.y,-E.x).normalize(),P=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;a=Math.min(a,P);let R;{let X=new I(A.x,A.y,0),se=new I(Math.cos(g)*X.x,X.y,Math.sin(g)*X.x);R=X.angleTo(se)}let z=a/Math.tan((Math.PI-S.angle())/2),U=a/Math.tan((Math.PI-R)/2),L=new I;if(!s){l.push(x.x,x.y,x.z),h.push(0,-1,0),c.push(0,0);let X=u++,se=[],le=_.clone(),te=z/Math.cos(Math.PI/i);le.x-=te;for(let ie=0;ie<i;ie++){let fe=ie/i*Math.PI*2+p,ce=new re(Math.sin(fe),Math.cos(fe));yd(le,ce,L),l.push(L.x,L.y,L.z),h.push(0,-1,0),c.push(0,0),se.push(u++)}for(let ie=0;ie<se.length;ie++)o.push(se[ie],X,se[(ie+1)%se.length])}let H=[];{let X=new I,se=new I,le=new I,te=new I,ie=new I,fe=new I;for(let ce=0;ce<i;ce++){let ue=ce/i*Math.PI*2+p,ae=(ce+.5)/i*Math.PI*2+p,Pe=(ce+1)/i*Math.PI*2+p,ve=new re(Math.sin(ue),Math.cos(ue)),Ae=new re(Math.sin(ae),Math.cos(ae)),ye=new re(Math.sin(Pe),Math.cos(Pe));yd(_,ve,se),yd(_,ye,le),yd(A,Ae,X),p1(b,se,le,U,U,te),l.push(te.x,te.y,te.z),p1(se,b,le,U,z,ie),l.push(ie.x,ie.y,ie.z),p1(le,se,b,z,U,fe),l.push(fe.x,fe.y,fe.z),h.push(X.x,X.y,X.z),h.push(X.x,X.y,X.z),h.push(X.x,X.y,X.z),c.push(0,0),c.push(0,0),c.push(0,0);let Ve=u++,Ie=u++,Ce=u++;if(o.push(Ve,Ie,Ce),a>0){{let st=se.clone().add(le).multiplyScalar(.5),nt=b.clone().sub(st).normalize(),Ze=x.clone().sub(st).normalize().add(nt).normalize().multiplyScalar(-1),Qe=fe.clone().sub(ie);q(st,Qe,Ze,S.angle())}let it,Je;{let st=new I;yd(T,ye,st);let nt=fe.clone().add(te).multiplyScalar(.5);nt=PZ(nt,le,b);let Ze=fe.clone().sub(te);[it,Je]=q(nt,Ze,st,R,te.y)}{let st=it,nt=st.clone().setY(0).normalize(),Ze=new I(0,-1,0),Qe=nt.clone().cross(Ze);Z(st,nt,Ze,Qe)}H.concat(Je);{let st=S.angle(),nt=Math.PI-st,Ze=b.clone();Ze.y-=a/Math.sin(st-Math.PI/2);let Qe=new I,pt=[];for(let ee=0;ee<n;ee++){let W=[],_e=Math.PI/2-nt*ee/n,We=Math.cos(_e),V=Math.sin(_e),Oe=ae;for(let ut=0;ut<=ee;ut++){let He=Math.cos(Oe),ze=Math.sin(Oe);X.x=We*ze,X.y=V,X.z=We*He,Qe.copy(Ze).addScaledVector(X,a),l.push(Qe.x,Qe.y,Qe.z),h.push(X.x,X.y,X.z),c.push(0,0),W.push(u++),Oe+=Math.PI*2/ee/i}pt.push(W)}Je.reverse(),pt.push(Je);let wt=pt.length-1;for(let ee=0;ee<wt;ee++){let W=pt[ee],_e=pt[ee+1],We=W.length-1;o.push(_e[1],W[0],_e[0]);for(let V=1;V<=We;V++)o.push(W[V],W[V-1],_e[V]),o.push(_e[V+1],W[V],_e[V])}}}}}this.setIndex(o),this.setAttribute("position",new at(l,3)),this.setAttribute("normal",new at(h,3)),this.setAttribute("uv",new at(c,2));function q(X,se,le,te,ie){let fe=-te/2,ce=(Math.PI-te)/2,ue=se.clone().normalize().cross(le);X.addScaledVector(le,-a/Math.sin(ce));let ae=new I,Pe=new I,ve=1,Ae=u,ye=[];for(let Ve=0;Ve<=n;Ve++){let Ie=fe+Ve/n*te;Pe.set(0,0,0),Pe.addScaledVector(ue,Math.sin(Ie)),Pe.addScaledVector(le,Math.cos(Ie));for(let Ce=0;Ce<=ve;Ce++){let it=Ce/ve-.5;if(ae.copy(X),ae.addScaledVector(se,it),ae.addScaledVector(Pe,a),ie!=null){let Je=Math.max(0,ae.y-ie);ae.addScaledVector(se,-Je/se.y)}l.push(ae.x,ae.y,ae.z),h.push(Pe.x,Pe.y,Pe.z),c.push(0,0),Ce===0&&ye.push(u),u++}}for(let Ve=0;Ve<n;Ve++)for(let Ie=0;Ie<ve;Ie++){let Ce=Ae+Ie+(ve+1)*Ve,it=Ce+(ve+1),Je=it+1,st=Ce+1;o.push(Ce,it,st),o.push(it,Je,st)}return[X.clone().addScaledVector(se,.5),ye]}function Z(X,se,le,te){let ie=Math.PI/2,fe=E.angle()-ie,ce=[],ue=new I,ae=new I;for(let ve=0;ve<=n;ve++){let Ae=[],ye=ve/n;for(let Ve=0;Ve<=ve;Ve++){let Ie=((ve?Ve/ve:0)-.5)*y,Ce=Math.cos(Ie),it=Math.sin(Ie),Je=Math.atan(Math.tan(fe)*Ce),st=(ie+Je)*ye,nt=Math.cos(st),Ze=Math.sin(st);ue.set(0,0,0),ue.addScaledVector(se,Ze*Ce),ue.addScaledVector(le,nt),ue.addScaledVector(te,Ze*it),ae.copy(X).addScaledVector(ue,a),l.push(ae.x,ae.y,ae.z),h.push(ue.x,ue.y,ue.z),c.push(0,0),Ae.push(u++)}ce.push(Ae)}let Pe=ce.length-1;for(let ve=0;ve<Pe;ve++){let Ae=ce[ve],ye=ce[ve+1],Ve=Ae.length-1;o.push(Ae[0],ye[1],ye[0]);for(let Ie=1;Ie<=Ve;Ie++)o.push(Ae[Ie-1],Ae[Ie],ye[Ie]),o.push(Ae[Ie],ye[Ie+1],ye[Ie])}}}},gw=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof ar?e.shape:new ar,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},c={x:-h.x,y:-h.y},u={x:h.x,y:h.y};function d(_,M,S){return M>i&&S>r?Math.min(_*i/M,_*r/S):M>i?_*i/M:S>r?_*r/S:_}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=c.x,g=u.x,m=u.y,y=c.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let x=!0;for(let _=0,M=t.points.length;_<M;_++)t.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(x=!1);x&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let b=kh.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},IZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},e.parameters);return i.thetaLength=lt.clamp(i.thetaLength,0,180),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,c;return h===0?(c=new gt,c.setAttribute("position",new at([],3))):c=new Yc(.5*t,s,a,n,o,l,h*lt.DEG2RAD),c.scale(1,i/t,r/t),Object.assign(c,{userData:{...e,type:"SphereGeometry"}})}},OZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,a=new kn(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},RZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:a,cornerSegments:n}=e.parameters,o=new LZ(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},LZ=class extends gt{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let c=[],u=Math.PI/2,d=(Pe=0,ve=0,Ae=0)=>new I(Pe,ve,Ae),p=d(),f=d(),[g,m,y]=[t/2,e/2,i/2],x=-m,b=+m,[_,M,S]=[d(x,-g,+y),d(x,-g,-y),d(x,+g,-y)],E=(Pe,ve=!1)=>Math.sin(Pe-Math.PI/(1+ +ve)),A=(Pe,ve=!1)=>Math.cos(Pe-Math.PI/(1+ +ve));S.y=Math.sin(r)*t-g;let T=Math.cos(r)*t-y,P=_.z-h;r<=u?(S.z=Math.min(T,P),S.z==P&&(S.y-=(T-P)/Math.tan(u-r))):M.z=Math.min(M.z-T-y,_.z-h),p.subVectors(_,M),f.subVectors(S,M);let R=Math.min(p.length(),f.length())*s/100,z=R*Math.tan(r/2),U=R/Math.cos(r/2),L=p.clone().normalize().add(f.normalize()).setLength(U).add(M);p.set(0,E(r,!0),A(r,!0)),c.push([S,p.clone()]);let H=(Math.PI-r)/a;for(let Pe=0;Pe<=a;Pe++){let ve=u+r+Pe*H;p.set(0,Math.sin(ve)*z,Math.cos(ve)*z),p.add(L),f.set(0,E(ve),A(ve)),c.push([p.clone(),f.clone()])}c.push([_,d(0,1,0)]);let q=Math.sin(H/2)*z*2,Z=c.length-1,X=c[0][0].distanceTo(c[1][0]),se=c[Z-1][0].distanceTo(c[Z][0]),le=X+q*a+se;c[0].push(1);for(let Pe=0;Pe<=a;Pe++)c[Pe+1].push(1-(X+Pe*q)/le);c[Z].push(0);let[te,ie,fe]=c[0],ce,ue,ae;for(let Pe=1;Pe<c.length;Pe++)[ce,ue,ae]=c[Pe],n.push(x,te.y,te.z,x,ce.y,ce.z,b,te.y,te.z,b,te.y,te.z,x,ce.y,ce.z,b,ce.y,ce.z),o.push(0,ie.y,ie.z,0,ue.y,ue.z,0,ie.y,ie.z,0,ie.y,ie.z,0,ue.y,ue.z,0,ue.y,ue.z),l.push(0,fe,0,ae,1,fe,1,fe,0,ae,1,ae),[te,ie,fe]=[ce,ue,ae];this.setAttribute("position",new at(n,3)),this.setAttribute("normal",new at(o,3)),this.setAttribute("uv",new at(l,2))}},PD=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof ar?e.shape:new ar,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,c=e.shape,u=t*.5,d=i*.5,p=0,f=0,g=n*Math.PI/360/s,m=Math.PI/2*3*-1,y=u*r/100,x=d*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let _=0;_<s;_++){let M=g*_,S=p+Math.sin(M)*u,E=f+Math.cos(M)*d;c.addPoint(c.createPoint(S,E))}}else for(let _=0;_<s;_++){let M=p+Math.cos(m)*u,S=f+Math.sin(m)*d;c.addPoint(c.createPoint(M,S)),m+=g,M=p+Math.cos(m)*y,S=f+Math.sin(m)*x,_<=s,c.addPoint(c.createPoint(M,S)),m+=g}c.isClosed=!0;for(let _=0,M=c.points.length;_<M;_++)c.points[_].roundness=a;c.roundness=a,c.update();let b=kh.create({shape:c,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},BZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new kn(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},zZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width);i.shapeBlendNode&&(s=r);let a=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=FZ(t,i,r,t*.5,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function FZ(e,t,i,r,s,a,n,o,l,h,c){[t,i]=[i,t],n=t/2;let u=lt.clamp(s/360,0,1);if(u===0){let d=new gt;return d.setAttribute("position",new at([],3)),d}return u===1&&(h=0),new ED(!0,e,t,i,r,u,a,n,o,l,h,c)}var kZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:a,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new gT(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},UZ=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof ar?e.shape:new ar,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,c=i*.5;o?(l.addPoint(l.createPoint(-h,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(h,-c)),l.addPoint(l.createPoint(-h,-c))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let u=kh.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(u,{userData:{...e,type:"TriangleGeometry"}})}};function NZ(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}function VZ(e){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(e.toLowerCase())}function jZ(e,t,i){let r,s,a,n=Math.floor(e*6),o=e*6-n,l=i*(1-t),h=i*(1-o*t),c=i*(1-(1-o)*t);switch(n%6){case 0:r=i,s=c,a=l;break;case 1:r=h,s=i,a=l;break;case 2:r=l,s=i,a=c;break;case 3:r=l,s=h,a=i;break;case 4:r=c,s=l,a=i;break;case 5:default:r=i,s=l,a=h;break}return{r:r*255,g:s*255,b:a*255}}function HZ(e,t,i){e/=255,t/=255,i/=255;let r=Math.max(e,t,i),s=Math.min(e,t,i),a=r,n=r-s,o=r==0?0:n/r,l;if(r==s)l=0;else{switch(r){case e:l=(t-i)/n+(t<i?6:0);break;case t:l=(i-e)/n+2;break;case i:default:l=(e-t)/n+4;break}l/=6}return{h:l,s:o,v:a}}function GZ(e){return e=Math.floor(e),{r:e>>16&255,g:e>>8&255,b:e&255}}function WZ(e,t,i){return(e<<16)+(t<<8)+i}function qZ(e,t,i){return e=Math.round(e),t=Math.round(t),i=Math.round(i),"#"+[e,t,i].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function XZ(e){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,(r,s,a,n)=>String(s+s+a+a+n+n));let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null}var YZ={parseRgba:VZ,hsvToRgb:jZ,rgbToHsv:HZ,hexToRgb:GZ,rgbToHex:WZ,rgbToHexString:qZ,hexStringToRgb:XZ},QZ=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},ZZ=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},Le=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Le.version}static addUnaryOp(e){return Le.max_unop_len=Math.max(e.length,Le.max_unop_len),Le.unary_ops[e]=1,Le}static addBinaryOp(e,t,i){return Le.max_binop_len=Math.max(e.length,Le.max_binop_len),Le.binary_ops[e]=t,i?Le.right_associative.add(e):Le.right_associative.delete(e),Le}static addIdentifierChar(e){return Le.additional_identifier_chars.add(e),Le}static addLiteral(e,t){return Le.literals[e]=t,Le}static removeUnaryOp(e){return delete Le.unary_ops[e],e.length===Le.max_unop_len&&(Le.max_unop_len=Le.getMaxKeyLen(Le.unary_ops)),Le}static removeAllUnaryOps(){return Le.unary_ops={},Le.max_unop_len=0,Le}static removeIdentifierChar(e){return Le.additional_identifier_chars.delete(e),Le}static removeBinaryOp(e){return delete Le.binary_ops[e],e.length===Le.max_binop_len&&(Le.max_binop_len=Le.getMaxKeyLen(Le.binary_ops)),Le.right_associative.delete(e),Le}static removeAllBinaryOps(){return Le.binary_ops={},Le.max_binop_len=0,Le}static removeLiteral(e){return delete Le.literals[e],Le}static removeAllLiterals(){return Le.literals={},Le}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new Le(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return Le.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Le.binary_ops[String.fromCharCode(e)]||Le.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Le.isIdentifierStart(e)||Le.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(Le.hooks[e]){let i={context:this,node:t};return Le.hooks.run(e,i),i.node}return t}searchHook(e){if(Le.hooks[e]){let t={context:this};return Le.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===Le.SPACE_CODE||e===Le.TAB_CODE||e===Le.LF_CODE||e===Le.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:Le.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===Le.SEMCOL_CODE||i===Le.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,Le.max_binop_len),t=e.length;for(;t>0;){if(Le.binary_ops.hasOwnProperty(e)&&(!Le.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Le.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,s,a,n,o,l;if(a=this.gobbleToken(),!a||(t=this.gobbleBinaryOp(),!t))return a;for(s={value:t,prec:Le.binaryPrecedence(t),right_a:Le.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=Le.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:Le.right_associative.has(t)},l=t;let h=c=>s.right_a&&c.right_a?i>c.prec:i<=c.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:Le.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:Le.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,Le.isDecimalDigit(e)||e===Le.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===Le.SQUOTE_CODE||e===Le.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===Le.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,Le.max_unop_len),i=t.length;i>0;){if(Le.unary_ops.hasOwnProperty(t)&&(!Le.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Le.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Le.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}Le.isIdentifierStart(e)?(r=this.gobbleIdentifier(),Le.literals.hasOwnProperty(r.name)?r={type:Le.LITERAL,value:Le.literals[r.name],raw:r.name}:r.name===Le.this_str&&(r={type:Le.THIS_EXP})):e===Le.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===Le.PERIOD_CODE||t===Le.OBRACK_CODE||t===Le.OPAREN_CODE||t===Le.QUMARK_CODE;){let i;if(t===Le.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Le.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===Le.OBRACK_CODE?(e={type:Le.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==Le.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===Le.OPAREN_CODE?e={type:Le.CALL_EXP,arguments:this.gobbleArguments(Le.CPAREN_CODE),callee:e}:(t===Le.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:Le.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;Le.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===Le.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);Le.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));Le.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);Le.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,Le.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===Le.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Le.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Le.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":e+=`
3177
3177
  `;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=s}else e+=s}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:Le.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(Le.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,Le.isIdentifierPart(e));)this.index++;return{type:Le.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){i=!0,this.index++,e===Le.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(s===Le.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===Le.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===Le.CBRACK_CODE)for(let a=t.length;a<r;a++)t.push(null)}}else if(t.length!==r&&r!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===Le.COMPOUND)&&this.throwError("Expected comma"),t.push(a)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(Le.CPAREN_CODE);if(this.code===Le.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:Le.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Le.ARRAY_EXP,elements:this.gobbleArguments(Le.CBRACK_CODE)}}},KZ=new QZ;Object.assign(Le,{hooks:KZ,plugins:new ZZ(Le),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});Le.max_unop_len=Le.getMaxKeyLen(Le.unary_ops);Le.max_binop_len=Le.getMaxKeyLen(Le.binary_ops);var yu=e=>new Le(e).parse(),JZ=Object.getOwnPropertyNames(Le);JZ.forEach(e=>{yu[e]===void 0&&e!=="prototype"&&(yu[e]=Le[e])});yu.Jsep=Le;var $Z="ConditionalExpression",eK={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:$Z,test:i,consequent:r,alternate:s},i.operator&&e.binary_ops[i.operator]<=.9){let a=i;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};yu.plugins.register(eK);function wv(e){return{all:e=e||new Map,on:function(t,i){var r=e.get(t);r?r.push(i):e.set(t,[i])},off:function(t,i){var r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var r=e.get(t);r&&r.slice().map(function(s){s(i)}),(r=e.get("*"))&&r.slice().map(function(s){s(t,i)})}}}var DD=class{constructor(e,t,i){this.id=e,this.userAPI=t,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(r=>r()),this.emitter=wv(),this._innerCallUserAPI=async r=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await aK(this.userAPI,r),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(s){let a=s.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=a,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0},t?.integration?.type==="OpenAI"?this.result={content:""}:t.method==="GET"&&t.url!==""&&(this.prefetchPromise=this.prefetch(i)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=dp(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?dp(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(e){await this.callUserAPI(e)}async callUserAPI(e){await this._debouncedCallUserAPI(e)}update(e,t,i=!0){this.userAPI=e,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&i&&this._debouncedPrefetch(t)}retrieveValue(e){if(this.result)try{return kr.zoom(this.result,e)}catch(t){console.error(t)}}retrieveZoomedKeyValues(e){if(this.result){let t=e&&e.length?kr.zoom(this.result,e):this.result;if(sK(t))return Object.entries(t);if(rK(t))return t.map((i,r)=>[r.toString(),i]);throw iK(t)?new Error("This path points to a value, use retrieveValue() instead. "+e?.join(".")):new Error("Path error"+e?.join("."))}}dispose(){}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}get autostart(){return this.userAPI.autoStart}};function tK(e){let t=new Headers;return e.headers.forEach(i=>{i.data.key!==""&&t.append(i.data.key,i.data.value)}),t}function iK(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function rK(e){return Array.isArray(e)}function sK(e){return typeof e=="object"&&e!==null}async function aK(e,t,i=new AbortController){let r,s=e.url,a=e.proxy?.enabled??!1,n;if(e.integration?.type==="OpenAI"){let l=Bd(e.integration.prompt===""?[]:JSON.parse(e.integration.prompt),t),h=e.integration.behavior===""?[]:Bd(JSON.parse(e.integration.behavior),t);n=`{
3178
3178
  "model": "${e.integration.model}",
@@ -3189,7 +3189,7 @@ best distance: ${d.d}`);let y=[d.x,d.y];return y.distance=d.d,y.distance}functio
3189
3189
  }`}if(a){s=`https://apis.spline.design/file/${e.proxy.fileId}/external-api/request?uuidexternalapi=${e.proxy.proxyId}`;let l;n!==void 0?l=n:e.method==="POST"&&e.body&&(l=Bd(JSON.parse(e.body),t)),l!==void 0&&(s+=`&data=${encodeURIComponent(l.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else e.integration?.type==="OpenAI"?r=n:e.method==="POST"&&e.body&&(r=Bd(JSON.parse(e.body),t));let o=await fetch(s,{method:a?"GET":e.method,headers:a?void 0:tK(e),signal:i.signal,body:r});if(!o.ok)throw new Error("status:"+o.status+"_:_"+o.statusText);if(e.integration?.type==="OpenAI"){let l=await o.json();return a&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await o.json();return a&&(l=l.response),l}}var ID=(e,t)=>{if(typeof e=="string"){let i=t.getVariable(e);if(i)return ID(i,t)}return ps.isBoolean(e)?ps.getDisplayedValue(e).toLowerCase():ps.getDisplayedValue(e)},Bd=(e,t)=>e.map((i,r)=>{if("text"in i)return i.text;if("type"in i){if(i.type==="paragraph")return(r>0?`
3190
3190
  `:"")+Bd(i.children,t);if(i.type==="variable"){let s=t.getVariable(i.variableId);if(s!==void 0)return ID(s,t)}}return""}).join(""),nK=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],oK=["0","1","2","3","4","5","6","7","8","9","."],lK=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function hK(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}yu.addBinaryOp("^",11,!0);function OD(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];if("objType"in o&&o.objType==="api"){let l=JSON.parse(o.id),h=l[0],c=t.getUserAPI(h);if(c!==void 0&&c instanceof DD){let u=c.retrieveValue(l.slice(1));u!==void 0&&(r+=u)}continue}if("objType"in o&&o.objType==="webhook"){let l=JSON.parse(o.id),[h,c]=l,u=t.getUserWebhook(h);if(u!==void 0){let d=u.getParameterValue(c);d!==void 0&&(r+=d)}continue}if("objType"in o&&o.objType==="aiAssistant"){let l=t.openAIRealtime;if("objId"in o&&o.objId!==void 0){let h;if(t.scene.data.objects.traverse((c,u)=>{let d=u.events?.find(p=>p.id===o.objId);d&&(h=d)}),h!==void 0&&h.data.type==="AIAssistantListener"){let c=l?.computeAnalysisForListenerEvent(h.data);if(c!==void 0){r+=c;continue}}}r+=l?.voice??0;continue}if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),c=ps.getDisplayedValue(h);i==="number"&&ps.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?c=parseFloat(c).toString():i==="boolean"&&ps.isBoolean(h)?c=h?"true":"false":i==="boolean"&&ps.isTextValue(h)&&!Array.isArray(h.textValue)&&(c='"'+c+'"'),r+=c;continue}else if(i==="string"){o.name!=='"'&&(o.name!=="+"||o.escaped)&&(r+=o.name),o.name==="+"&&!o.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!hK(o.name)&&!oK.includes(o.name)&&!nK.includes(o.name)&&!lK.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let s;try{s=yu(r)}catch(n){console.error(r,n);return}let a;try{a=fi(s)}catch(n){console.error(r,s,n)}return a}function fi(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return Number(fi(e.left)===fi(e.right));case"!=":return Number(fi(e.left)!==fi(e.right));case">":return Number(fi(e.left)>fi(e.right));case">=":return Number(fi(e.left)>=fi(e.right));case"<":return Number(fi(e.left)<fi(e.right));case"<=":return Number(fi(e.left)<=fi(e.right));case"+":return fi(e.left)+fi(e.right);case"-":return fi(e.left)-fi(e.right);case"*":return fi(e.left)*fi(e.right);case"/":return fi(e.left)/fi(e.right);case"%":return fi(e.left)%fi(e.right);case"&&":return fi(e.left)&&fi(e.right);case"||":return fi(e.left)||fi(e.right);case"^":return Math.pow(fi(e.left),fi(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-fi(e.argument);case"!":return Number(!fi(e.argument));default:throw new Error("Unknown operator: "+e.operator)}case"Identifier":throw new Error("Unknown identifier: "+e.name);case"Literal":return e.value;case"CallExpression":if(e.callee.type==="Identifier"){if(e.callee.name==="random"){let t=0,i=1;if(e.arguments.length>=1)try{t=fi(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=fi(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(fi))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var cK=new je,uK=new je;function dK(e,t,i){let r=[new I,new I,new I],s=[new I,new I,new I];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((a,n)=>{let o=s[n],l=lt.lerp(a.length(),o.length(),i);a.lerp(o,i).setLength(l)}),new je().makeBasis(r[0],r[1],r[2])}var pK=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=t?.shapeData??mw.create({parameters:eD}).userData.shape;return{path:e.path??Cg.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:a,extrusion:{...tD,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new fK(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new gt,{userData:{...e,type:"PathGeometry"}})}},fK=class extends gt{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)||!NZ(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(r*s),n=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,n-a+1),s+2),l=[],h=[];for(let Z=0;Z<o;Z++){let X=this.inputs.path.isClosed?(Z+a)%e.length:Math.min(Z+a,e.length-1);l.push(e[X].clone()),h.push(t[X].clone())}let c=(Z,X,se)=>{l[Z]=l[Z].clone().lerp(l[X],se),h[Z]=dK(h[Z],h[X],se)},u=0,d=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(u=d,c(0,1,u));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,c(l.length-1,l.length-2,1-p)),i===0){let Z=l.length-1;l[Z].copy(l[0]),h[Z].copy(h[0])}this._applyPathModifiers(h,u,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,y=g>0?this.inputs.parameters.extrusion.capType:"flat",x=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(x=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:_,vertices:M}=this._computeShapePoints(x),S=0,E;y==="round"&&(E=new fw(this.inputs.shapeData,2*g,g,x,m,void 0,!0),S=E.getAttribute("position").count);let A=0,T=0;_.sort((Z,X)=>Z.start-X.start),_.forEach(Z=>{Z.verticesStart=A,Z.verticesCount=Z.continuous.reduce((X,se,le)=>X+(le===0||!se?2:1),0),T+=Z.verticesCount,A=T});let P=T*o,R,z=0;if(this._isOpenEnded()&&y==="flat"){try{R=wl({windingRule:Pi.ODD,elementType:_r.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{R=xD}z=R.vertexCount}let U=P+2*z+S*2,L=P+2*z,H={positions:new Float32Array(U*3),normals:new Float32Array(U*3),uvs:new Float32Array(U*2)},q=[];if(_.forEach(Z=>{this._extrudeRegion(Z,M,h,l,H,q,this._isGeometryClosed()&&!this._isOpenEnded())}),R&&(this._closeEnd(R,P,q,H,h[0],l[0],!1),this._closeEnd(R,P+z,q,H,h[h.length-1],l[l.length-1],!0)),E){H.positions.set(E.getAttribute("position").array,L*3),H.normals.set(E.getAttribute("normal").array,L*3),H.uvs.set(E.getAttribute("uv").array,L*2);for(let le=L;le<L+S;le++)H.uvs[le*2+1]=1e-4;let Z=q.length;q.push(...E.getIndex().array.map(le=>le+L)),L+=S,H.positions.set(E.getAttribute("position").array,L*3),H.normals.set(E.getAttribute("normal").array,L*3),H.uvs.set(E.getAttribute("uv").array,L*2);let X=q.length;q.push(...E.getIndex().array.map(le=>le+L)),this.setAttribute("position",new Tt(H.positions,3)),this.setAttribute("normal",new Tt(H.normals,3)),this.setAttribute("uv",new Tt(H.uvs,2)),this.setIndex(q);let se=cK;se.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(se,L,U),se.copy(h[0]).setPosition(l[0]).multiply(uK.makeScale(1,1,-1)),this.applyMatrix4OnRange(se,L-S,L),this.reverseIndicesOnRange(Z,X)}else this.setAttribute("position",new Tt(H.positions,3)),this.setAttribute("normal",new Tt(H.normals,3)),this.setAttribute("uv",new Tt(H.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=cD(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new I,a=new I,n=new I,o=new I,l=new I(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let y;f===i-1?y=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):y=e[f+1];let x=g.clone().sub(m).normalize(),b=y.clone().sub(g).normalize(),_=x.clone().add(b).normalize();n.copy(_),f===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let M=l.clone().cross(_).normalize(),S=_.clone().cross(M).normalize();l.copy(S),o.copy(M),f===0&&(s.copy(S),a.copy(_));let E=new je().makeBasis(M,S,_);t.push(E)}let h=r?a:n,c=r?s:new I(0,1,0),u=h.clone().cross(o).normalize(),d=Math.acos(c.dot(u));if(isNaN(d))return t;let p=c.clone().cross(u);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let g=new je().makeRotationZ(d*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:a,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new je,h=new je;return e.forEach((c,u)=>{let d=u===0?0:u===r-1?1:(u-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(lt.lerp(s,s+a,d)*lt.DEG2RAD);let p=lt.lerp(n,o,d);h.makeScale(p,p,p),c.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Pi.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let y=f[m-1],x=f[m-0];g.push(y,x)}return g}),a;try{a=wl({windingRule:t,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{a=pw}let n;try{n=wl({windingRule:Pi.ODD,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{n=yD}if(!a)throw new Error("error generating geometry");let o=a.elementCount;if(n){a.elementCount+=n.elementCount;for(let p=0;p<n.elements.length;p++){let f=n.elements[p],g=p%2===0?a.vertexCount:0;a.elements.push(f+g)}for(let p=0;p<n.vertexIndices.length;p++){let f=n.vertexIndices[p],g=a.vertexCount;a.vertexIndices.push(f+g)}for(let p=0;p<n.vertices.length;p++){let f=n.vertices[p];a.vertices.push(f)}}let l=1/0,h=-1/0,c=1/0,u=-1/0;for(let p=0,f=a.vertexCount;p<f;p++){let g=p*2,m=a.vertices[g+0],y=a.vertices[g+1];m<l&&(l=m),m>h&&(h=m),y<c&&(c=y),y>u&&(u=y)}let d=[];for(let p=a.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=a.elements[g+0],y=a.elements[g+1],x=m+y,b={start:m,count:y,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(b);let _=m,M=x-1,S=m+1,E=i.roundedCurves.length;do{let A=_-m,T=a.vertices[M*2+0],P=a.vertices[M*2+1],R=a.vertices[_*2+0],z=a.vertices[_*2+1],U=a.vertices[S*2+0],L=a.vertices[S*2+1],H=R-T,q=z-P,Z=Math.sqrt(H*H+q*q);H/=Z,q/=Z;let X=R-U,se=z-L,le=Math.sqrt(X*X+se*se);X/=le,se/=le,b.normals[A*2+0]=-se,b.normals[A*2+1]=X;let te=a.vertexIndices[_];if(Array.isArray(te))b.continuous[A]=!1;else{let[ie,fe]=i.getCurveIndexFromVertexId(te-1,!0);if(fe>0&&fe<1)b.continuous[A]=!0;else{let ce=fe===1?ie+1:ie-1;ce=(ce+E)%E;let ue=fe===1?0:1,ae=i.roundedCurves[ie].getTangent(fe),Pe=i.roundedCurves[ce].getTangent(ue);b.continuous[A]=ae.dot(Pe)>.95}}f&&(b.normals[A*2+0]*=-1,b.normals[A*2+1]*=-1),[M,_,S]=[_,S,S+1],S>=x&&(S-=y)}while(S!==m+1)}return{regions:[r,...s],infos:d,vertices:a.vertices}}_insertVertex(e,t,i,r,s){let a=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,i,r,s,a,n){let o=new I,l=new I,h=new I,c=new I,u=new re;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let y=0;y<e.count;y++){let x=(e.start+y)*2;if(o.set(t[x+0],t[x+1],0),h.copy(o).applyMatrix4(p).add(g),e.continuous[y])c.set(e.normals[y*2+0],e.normals[y*2+1],0);else{let b=y===0?(e.start+e.count-1)*2:x-2;l.set(t[b+0],t[b+1],0),c.copy(o).sub(l),c.set(-c.y,c.x,0),e.isHole||c.negate()}if(c.applyMatrix4(p).normalize(),u.set(y===0?1:y/e.count,f/(i.length-1)),this._insertVertex(s,m,h,c,u),m++,!e.continuous[y]||y===0){if(y===0)c.set(e.normals[y*2+0],e.normals[y*2+1],0),u.set(0,f/(i.length-1));else{let b=y===e.count-1?e.start*2:x+2;l.set(t[b+0],t[b+1],0),c.copy(l).sub(o),c.set(-c.y,c.x,0),e.isHole||c.negate()}c.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,c,u),m++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let y=0;y<e.count;y++){(!e.continuous[y]||y===0)&&m++;let x=y===e.count-1?0:m+1,b=f+m,_=f+x,M=g+x,S=g+m;e.isHole?a.push(b,M,_,b,S,M):a.push(b,_,M,b,M,S),m++}}}_closeEnd(e,t,i,r,s,a,n){let o=e.vertexCount,l=new I(0,0,n?-1:1).applyMatrix4(s),h=new I,c=new re;for(let d=0;d<o;d++){let p=2*d;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(a),this._insertVertex(r,t+d,h,l,c)}let u=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=u[p+0]+t,g=u[p+(n?1:2)]+t,m=u[p+(n?2:1)]+t;i.push(f,g,m)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new Sr().getNormalMatrix(e).elements,a,n,o,l,h=this.attributes.position,c=this.attributes.normal;if(!h||!c)return;let u=h.array,d=c.array,p=h.itemSize;for(let f=t*p,g=i*p;f<g;f+=p){if(f===t)debugger;a=u[f+0],n=u[f+1],o=u[f+2],l=1/(r[3]*a+r[7]*n+r[11]*o+r[15]),u[f+0]=(r[0]*a+r[4]*n+r[8]*o+r[12])*l,u[f+1]=(r[1]*a+r[5]*n+r[9]*o+r[13])*l,u[f+2]=(r[2]*a+r[6]*n+r[10]*o+r[14])*l,a=d[f+0],n=d[f+1],o=d[f+2],d[f+0]=s[0]*a+s[3]*n+s[6]*o,d[f+1]=s[1]*a+s[4]*n+s[7]*o,d[f+2]=s[2]*a+s[5]*n+s[8]*o}h.needsUpdate=!0,c.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),a=i.getX(r+1),n=i.getX(r+2);i.setXYZ(r,n,a,s)}i.needsUpdate=!0}}};function RD(){let e=new gt;return e.setAttribute("position",new Tt(new Float32Array([]),3)),e.setIndex(new Tt(new Uint16Array([]),1)),e}var mK=RD().attributes,gK=12,vK=1,Bx=class extends gt{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,mK),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,t)):this.updateFont(e.font,t).then(()=>{this.update(e,t),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,t){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:r,height:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o,text:l,textTransform:h}=e,c=ps.getDisplayedValue(l),u=h===2?c.toUpperCase():h===3?c.toLowerCase():c,d=yK(e,i,u,t),{shapes:p,charWidths:f,charCoords:g}=i.generateShapes(d,e,t),m=(typeof r=="number"?r:Number(t.getVariable(r)))*.5,y=(typeof s=="number"?s:Number(t.getVariable(s)))*.5,x=p.map(M=>new ar().fromShape(M,!0));this.vectorShapes=x;let b=x.map(M=>kh.create({shape:M,parameters:{depth:a,extrudeBevelSegments:o,extrudeBevelSize:n,windingRule:a<=0?Pi.NONZERO:Pi.ODD,subdivisions:this.isLowResolution&&a>0?vK:gK}})),_=b.length?mh(b):RD();_.translate(-m,y,0),this.dispose(),this.wrappedText=d,this.charCoords=g,this.charWidths=f,this.deleteAttribute("extrudeNormal"),Object.entries(_.attributes).forEach(([M,S])=>{this.setAttribute(M,S)}),this.setIndex(_.index),this.computeBoundingSphere()}clone(){let e=Ia(new gt,Bx.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},t)}get text(){return this.userData.parameters.text??""}};function yK(e,t,i,r){let s=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,a=[""],n="";for(let o of i)n+=o,o===" "||o===`
3191
3191
  `?(a[a.length-1]+=n,n="",o===`
3192
- `&&a.push("")):t.getTextWidth(a[a.length-1]+n,e)>s&&(a[a.length-1].length&&a.push(""),t.getTextWidth(a[a.length-1]+n,e)>s&&(n.length===1?(a[a.length-1]+=n,n=""):(a[a.length-1]+=n.slice(0,-1),n=n[n.length-1],a.push(""))));return a[a.length-1]+=n,a}var LD,BD=new Promise(e=>{LD=e}),lE=!1,nm;function xK(e){if(lE)return;if(nm)return nm;async function t(){let i=e??"https://unpkg.com/@splinetool/modelling-wasm@1.10.54/build",r=import("./process.js"),[s,a]=await Promise.all([r,fetch(`${i}/process.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});LD(o),lE=!0}return nm=t(),nm}var bK=["font"];function Sp(e,t,i,r){let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let h of n){let c=a;for(let u of h)c=c[u];for(s in c){let u=c[s];uM(u)&&!bK.includes(s)&&(c[s]=t.getVariable(u,[r.uuid,"geometry",...h,s]),uM(c[s])&&(c[s]=1))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=ar.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry"){if(a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new ST().parse(a),o.geometry.groups.length===0){let h=o.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else if(a.type==="SubdivGeometry"){let h=new Ls(a,i);return h.data=e,h}else{if(a.type==="TextGeometry")return new Bx(a,t);if(a.type==="InputGeometry")return new Bx(a,t);if(a.type==="UIGeometry")return gw.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}let l;try{l=pE(o)}catch(h){console.error(h)}if(!l){let h=ar.createFromState(Eg.defaultData(),100,100);o.shape=h,l=pE(o)}return l}var wK=new je;function zx(e,t,i,r){let s=e.position.array,a=e.normal.array,n=wK.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,u=s.length;c<u;c+=3)s[c]*=t,s[c+1]*=i,s[c+2]*=r,o=a[c],l=a[c+1],h=a[c+2],a[c]=n[0]*o+n[4]*l+n[8]*h,a[c+1]=n[1]*o+n[5]*l+n[9]*h,a[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var om=new mr,wc=new I,Pt;BD.then(e=>{Pt=e});var hE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cE=new Uint32Array([0,1,2,3]),uE=new Uint8Array([4]),Ls=class extends gt{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=_h.div(t,i);this.subdividedGeometry&&zx(this.subdividedGeometry.attributes,...r),this.originalGeometry&&zx(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(wc.fromArray(r));let a=wc.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Ls.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new rn(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ls.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ks,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;om.setFromBufferAttribute(t),om.getCenter(i),e.boundingSphere.radius=i.distanceTo(om.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),om.getSize(wc);let r={width:wc.x,height:wc.y,depth:wc.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Pt.free_bvh(t),Pt.free_subdivision_surface(t));try{s=Ls.allocate(e,r)}catch(l){console.error(l,e),s=Ls.allocate({positionWASM:hE,indexWASM:cE,verticesPerFaceWASM:uE},r)}if(Pt.set_destination_refinement_level(s,0),a=Ls.buildLevel(s,!0,o),e.subdivisions>0)try{Pt.set_destination_refinement_level(s,e.subdivisions),n=Ls.buildLevel(s,!1,o)}catch{try{Pt.set_destination_refinement_level(s,e.subdivisions-1),n=Ls.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:Sp(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=_v(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,u=c+e.radialSegments*3;h=[c,u]}return{indices:n,verticesPerFace:o}=zD(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=hE,r=cE,s=uE);let o=i.length,l=r.length,h=s.length,c=i.length+a.length+n.length,u=r.length+s.length,d=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=u*Uint32Array.BYTES_PER_ELEMENT,g=Pt._malloc(d),m=new Float32Array(Pt.HEAPF32.buffer,g,c),y=new Uint32Array(Pt.HEAPU32.buffer,g+p,u);m.set(i,0),m.set(a,i.length),m.set(n,i.length+a.length),y.set(r,0),y.set(s,r.length);let x;e?.scaleBaked?.some(_=>_!==1)&&(x=new je().makeScale(...e.scaleBaked)),t&&(x?x.premultiply(t):x=t);let b=x?Pt.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,x.elements):Pt.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Pt._free(g),b}static buildLevel(e,t,i,r,s){let a=s?Pt.get_mesh_data2(e,t?Pt.Level.CONTROL:Pt.Level.REFINED,i,s.elements):Pt.get_mesh_data(e,t?Pt.Level.CONTROL:Pt.Level.REFINED,i),n=8,o=Pt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,c=Pt.HEAPU32[o[h]>>2],u=Pt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=Pt.HEAPU32[o[h]>>2],p=Pt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Pt.HEAPU32[o[h]>>2],g=Pt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Pt.HEAPU32[o[h]>>2],y=Pt.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let x=new gt;if(x.setIndex(new Xc(y,1)),x.setAttribute("position",new at(u,3)),x.setAttribute("normal",new at(p,3)),t){x.setAttribute("faceMap",new Xc(g,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new Tt(b,4))}return Pt.free_mesh_data(a),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Pt.free_mesh_data(a)}static freeSubdivPointer(e){Pt.free_bvh(e),Pt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Pt.get_wireframe_data_for_base_level(e),s=4,a=Pt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=Pt.HEAPU32[a[o]>>2],h=Pt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=Pt.HEAPU32[a[o]>>2],u=Pt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let d=new gt;d.setAttribute("position",new at(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Tt(p,3)),d.setIndex(new Xc(u,1)),Pt.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Pt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Pt.set_destination_refinement_level(e,t);let s=i?Pt.get_topological_data2(e,r?Pt.Level.CONTROL:Pt.Level.REFINED,i.elements):Pt.get_topological_data(e,r?Pt.Level.CONTROL:Pt.Level.REFINED),a=6,n=Pt.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=Pt.HEAPU32[n[l]>>2],c=new Float32Array(Pt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let u=Pt.HEAPU32[n[l]>>2],d=new Uint32Array(Pt.HEAPU32.subarray(u>>2,(u>>2)+o[l]));l++;let p=Pt.HEAPU32[n[l]>>2],f=new Uint8Array(Pt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Pt.free_topological_data(s),{positions:c,indices:d,verticesPerFace:f}}},dE=["getX","getY","getZ"];function _v(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,u="";for(let d=0;d<3;d++)u+=`${~~(e[dE[d]](c)*o)},`;if(u in i)a.push(i[u]);else{for(let d=0;d<3;d++)n.push(e[dE[d]](c));i[u]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var lm=new I,f1=new I,m1=new I,g1=new I;function zD(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let u=0;if(c<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(u++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(u++);return a.push(u),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}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]){lm.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),f1.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),m1.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),g1.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),f1.sub(lm).normalize(),m1.sub(lm).normalize(),g1.sub(lm).normalize();let l=f1.cross(m1).dot(g1);Math.abs(l)>.005||r&&r.some((h,c)=>c%2===1?!1:o>=r[c]&&o<r[c+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let u=0,d=0;u<e.length;u+=3,d++)e[u+2]===0&&(l.push(d),c++),e[u+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let u=h[0];h[0]=h[1],h[1]=u}l.reverse(),s.push(...l,...h),a.push(c,c)}return{indices:s,verticesPerFace:a}}var mo={};EB(mo,{calcBoolean:()=>EK,calcBooleanTopological:()=>MK,freeMeshSet:()=>DK,getMeshSet:()=>CK,hasOpenEdges:()=>TK,transformMeshSet:()=>PK});var FD,_K=new Promise(e=>{FD=e}),hm;function SK(e){if(hm)return hm;async function t(){let i=e??"https://unpkg.com/@splinetool/boolean-wasm@1.10.54/build",r=import("./boolean.js"),[s,a]=await Promise.all([r,fetch(`${i}/boolean.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});FD(o)}return hm=t(),hm}var ai,eu;_K.then(e=>ai=e);function AK(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=_v(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=zD(a,n,e);o=h.length,r=[];for(let c=0,u=0;c<o;c++){r.push(h[c]);for(let d=0;d<h[c];d++)r.push(l[u++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function kD(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=ai._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(ai.HEAPU32.buffer,a,t):new Float32Array(ai.HEAPF32.buffer,a,t)).set(e,0),a}function UD(e){switch(e){case 0:return ai.OP.UNION;case 1:return ai.OP.INTERSECTION;case 2:return ai.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+e)}}function MK(e,t){eu===void 0&&(eu=ai.init_csg());let i=kD(e),r=ai.csg_calc_topological(eu,i,e.length,UD(t));ai._free(i);let s=6,a=ai.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=ai.HEAPU32[a[o]>>2],h=new Float32Array(ai.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=ai.HEAPU32[a[o]>>2],u=new Uint32Array(ai.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let d=ai.HEAPU32[a[o]>>2],p=new Uint8Array(ai.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return ai.free_mesh_data(r),{positions:h,indices:u,verticesPerFace:p}}function EK(e,t,i,r){eu===void 0&&(eu=ai.init_csg());let s=kD(e),a=ai.csg_calc(eu,s,e.length,r,UD(t));ai._free(s);let n=5,o=ai.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,c=ai.HEAPU32[o[h]>>2],u=ai.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=ai.HEAPU32[o[h]>>2],p=ai.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new at(u,3)),i.setAttribute("normal",new at(p,3));let g=ai.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Ks),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},ai.free_mesh_data(a),f}function CK(e,t,i){if(ai===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let y=e.userData;a=y.verticesPerFace.length,r=y.positions,s=Array(y.verticesPerFace.reduce((x,b)=>x+b,0)+a);for(let x=0,b=0,_=0;x<y.verticesPerFace.length;x++){s[_++]=y.verticesPerFace[x];for(let M=0;M<y.verticesPerFace[x];M++)s[_++]=y.indices[b++]}}else({positions:r,faceIndices:s,nFaces:a}=AK(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,u=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=ai._malloc(c),f=new Float32Array(ai.HEAPF32.buffer,p,l),g=new Uint32Array(ai.HEAPU32.buffer,p+u,h);f.set(r,0),g.set(s,0);let m=ai.get_csg_mesh(p,n,p+u,o,a);return ai._free(p),m}function TK(e){return ai.has_open_edges(e)}function PK(e,t){ai.transform_csg_mesh(e,t.elements)}function DK(e){ai.free_csg_mesh(e)}var IK={ConeGeometry:RQ,CubeGeometry:LQ,CylinderGeometry:uD,DodecahedronGeometry:zQ,EllipseGeometry:mw,HelixGeometry:yZ,IcosahedronGeometry:xZ,LatheGeometry:bZ,NonParametricGeometry:CZ,PolygonGeometry:TD,PyramidGeometry:TZ,RectangleGeometry:gw,SphereGeometry:IZ,PlaneGeometry:OZ,BackdropGeometry:RZ,StarGeometry:PD,TextFrameGeometry:BZ,TorusGeometry:zZ,TorusKnotGeometry:kZ,TriangleGeometry:UZ,PathGeometry:pK,VectorGeometry:kh},pE=e=>IK[e.type].create(e);function _c(e){return e!==null&&"booleanOp"in e}var ND=class extends hw(zi){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new je}updateVisible(e){super.updateVisible(e),this.visible=!_c(this.parent)&&this.visible,_c(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(mo.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),_c(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ND&&(e.freeBooleanPointer(),_c(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&_c(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),_c(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},cm=new mr;function vw(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let u=t;u<i;u++){let d=e.getX(u),p=e.getY(u),f=e.getZ(u);d<a&&(a=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>c&&(c=f)}cm.min.set(a,n,o),cm.max.set(l,h,c),cm.getCenter(r),cm.getSize(s).multiplyScalar(.5)}var OK=new gt,RK=new Ro,Ns=class extends ND{constructor(e,t){super(OK,RK),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?vw(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},hl=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},hl.uuidContext===null)throw new Error("plz startContext");hl.uuidContext===hl.globalContext?this.uuid="_gid"+hl.uuidContext.nodeContextUuid++:this.uuid="_uid"+hl.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===hl.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,a){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},zr=hl;zr.globalContext={nodeContextUuid:0},zr.uuidContext=hl.globalContext;var fE=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},LK=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Xs=new LK,Ii=class extends zr{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=lt.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},Js=class extends Ii{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},ls=class extends Js{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof re?e:new re(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},ba=class extends Js{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof I?e:new I(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},ms=class extends Ct{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},go=class extends Js{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof ms?e:new ms(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},BK=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,mE=/[a-z_0-9]+/gi,tt=class extends Ii{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let a,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;a=mE.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let c=l[h],u=c[0],d=this.isMethod?!this.getInputByName(u):!0,p=u;if(this.keywords[u]||this.useKeywords&&d&&Xs.containsKeyword(u)){let f=this.keywords[u];if(!f){let g=Xs.getKeywordData(u);g.cache&&(f=e.keywords[u]),f=f||Xs.getKeyword(u,e),g.cache&&(e.keywords[u]=f)}p=f.build(e)}u!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+u.length+n),n+=p.length-u.length),this.getIncludeByName(p)===void 0&&Xs.contains(p)&&e.include(Xs.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=BK.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(mE);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},zK=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,VD=class extends Ii{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||VD.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let a,n,o="",l=zK.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},bi=VD;bi.PI="PI",bi.PI2="PI2",bi.RECIPROCAL_PI="RECIPROCAL_PI",bi.RECIPROCAL_PI2="RECIPROCAL_PI2",bi.LOG2="LOG2",bi.EPSILON="EPSILON";var FK=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3192
+ `&&a.push("")):t.getTextWidth(a[a.length-1]+n,e)>s&&(a[a.length-1].length&&a.push(""),t.getTextWidth(a[a.length-1]+n,e)>s&&(n.length===1?(a[a.length-1]+=n,n=""):(a[a.length-1]+=n.slice(0,-1),n=n[n.length-1],a.push(""))));return a[a.length-1]+=n,a}var LD,BD=new Promise(e=>{LD=e}),lE=!1,nm;function xK(e){if(lE)return;if(nm)return nm;async function t(){let i=e??"https://unpkg.com/@splinetool/modelling-wasm@1.10.56/build",r=import("./process.js"),[s,a]=await Promise.all([r,fetch(`${i}/process.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});LD(o),lE=!0}return nm=t(),nm}var bK=["font"];function Sp(e,t,i,r){let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let h of n){let c=a;for(let u of h)c=c[u];for(s in c){let u=c[s];uM(u)&&!bK.includes(s)&&(c[s]=t.getVariable(u,[r.uuid,"geometry",...h,s]),uM(c[s])&&(c[s]=1))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=ar.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry"){if(a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new ST().parse(a),o.geometry.groups.length===0){let h=o.geometry;h.addGroup(0,Math.max(h.getIndex()?.count??0,h.getAttribute("position").count),0)}}else if(a.type==="SubdivGeometry"){let h=new Ls(a,i);return h.data=e,h}else{if(a.type==="TextGeometry")return new Bx(a,t);if(a.type==="InputGeometry")return new Bx(a,t);if(a.type==="UIGeometry")return gw.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}let l;try{l=pE(o)}catch(h){console.error(h)}if(!l){let h=ar.createFromState(Eg.defaultData(),100,100);o.shape=h,l=pE(o)}return l}var wK=new je;function zx(e,t,i,r){let s=e.position.array,a=e.normal.array,n=wK.makeScale(t,i,r).invert().elements,o,l,h;for(var c=0,u=s.length;c<u;c+=3)s[c]*=t,s[c+1]*=i,s[c+2]*=r,o=a[c],l=a[c+1],h=a[c+2],a[c]=n[0]*o+n[4]*l+n[8]*h,a[c+1]=n[1]*o+n[5]*l+n[9]*h,a[c+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var om=new mr,wc=new I,Pt;BD.then(e=>{Pt=e});var hE=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cE=new Uint32Array([0,1,2,3]),uE=new Uint8Array([4]),Ls=class extends gt{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=_h.div(t,i);this.subdividedGeometry&&zx(this.subdividedGeometry.attributes,...r),this.originalGeometry&&zx(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(wc.fromArray(r));let a=wc.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Ls.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new rn(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Ls.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ks,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;om.setFromBufferAttribute(t),om.getCenter(i),e.boundingSphere.radius=i.distanceTo(om.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),om.getSize(wc);let r={width:wc.x,height:wc.y,depth:wc.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(Pt.free_bvh(t),Pt.free_subdivision_surface(t));try{s=Ls.allocate(e,r)}catch(l){console.error(l,e),s=Ls.allocate({positionWASM:hE,indexWASM:cE,verticesPerFaceWASM:uE},r)}if(Pt.set_destination_refinement_level(s,0),a=Ls.buildLevel(s,!0,o),e.subdivisions>0)try{Pt.set_destination_refinement_level(s,e.subdivisions),n=Ls.buildLevel(s,!1,o)}catch{try{Pt.set_destination_refinement_level(s,e.subdivisions-1),n=Ls.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:Sp(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=_v(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let c=e.radialSegments*e.heightSegments*3*2,u=c+e.radialSegments*3;h=[c,u]}return{indices:n,verticesPerFace:o}=zD(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=hE,r=cE,s=uE);let o=i.length,l=r.length,h=s.length,c=i.length+a.length+n.length,u=r.length+s.length,d=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,p=c*Float32Array.BYTES_PER_ELEMENT,f=u*Uint32Array.BYTES_PER_ELEMENT,g=Pt._malloc(d),m=new Float32Array(Pt.HEAPF32.buffer,g,c),y=new Uint32Array(Pt.HEAPU32.buffer,g+p,u);m.set(i,0),m.set(a,i.length),m.set(n,i.length+a.length),y.set(r,0),y.set(s,r.length);let x;e?.scaleBaked?.some(_=>_!==1)&&(x=new je().makeScale(...e.scaleBaked)),t&&(x?x.premultiply(t):x=t);let b=x?Pt.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,x.elements):Pt.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Pt._free(g),b}static buildLevel(e,t,i,r,s){let a=s?Pt.get_mesh_data2(e,t?Pt.Level.CONTROL:Pt.Level.REFINED,i,s.elements):Pt.get_mesh_data(e,t?Pt.Level.CONTROL:Pt.Level.REFINED,i),n=8,o=Pt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,c=Pt.HEAPU32[o[h]>>2],u=Pt.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=Pt.HEAPU32[o[h]>>2],p=Pt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Pt.HEAPU32[o[h]>>2],g=Pt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Pt.HEAPU32[o[h]>>2],y=Pt.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let x=new gt;if(x.setIndex(new Xc(y,1)),x.setAttribute("position",new at(u,3)),x.setAttribute("normal",new at(p,3)),t){x.setAttribute("faceMap",new Xc(g,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new Tt(b,4))}return Pt.free_mesh_data(a),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(u),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,Pt.free_mesh_data(a)}static freeSubdivPointer(e){Pt.free_bvh(e),Pt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Pt.get_wireframe_data_for_base_level(e),s=4,a=Pt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=Pt.HEAPU32[a[o]>>2],h=Pt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let c=Pt.HEAPU32[a[o]>>2],u=Pt.HEAPU32.subarray(c>>2,(c>>2)+n[o]);if(t===void 0){let d=new gt;d.setAttribute("position",new at(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Tt(p,3)),d.setIndex(new Xc(u,1)),Pt.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Pt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Pt.set_destination_refinement_level(e,t);let s=i?Pt.get_topological_data2(e,r?Pt.Level.CONTROL:Pt.Level.REFINED,i.elements):Pt.get_topological_data(e,r?Pt.Level.CONTROL:Pt.Level.REFINED),a=6,n=Pt.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=Pt.HEAPU32[n[l]>>2],c=new Float32Array(Pt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let u=Pt.HEAPU32[n[l]>>2],d=new Uint32Array(Pt.HEAPU32.subarray(u>>2,(u>>2)+o[l]));l++;let p=Pt.HEAPU32[n[l]>>2],f=new Uint8Array(Pt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Pt.free_topological_data(s),{positions:c,indices:d,verticesPerFace:f}}},dE=["getX","getY","getZ"];function _v(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let c=t?t.getX(h):h,u="";for(let d=0;d<3;d++)u+=`${~~(e[dE[d]](c)*o)},`;if(u in i)a.push(i[u]);else{for(let d=0;d<3;d++)n.push(e[dE[d]](c));i[u]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var lm=new I,f1=new I,m1=new I,g1=new I;function zD(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let c=0;for(let d=0;d<l.length;d+=2)c+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let u=0;if(c<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(u++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(u++);return a.push(u),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}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]){lm.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),f1.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),m1.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),g1.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),f1.sub(lm).normalize(),m1.sub(lm).normalize(),g1.sub(lm).normalize();let l=f1.cross(m1).dot(g1);Math.abs(l)>.005||r&&r.some((h,c)=>c%2===1?!1:o>=r[c]&&o<r[c+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],c=0;for(let u=0,d=0;u<e.length;u+=3,d++)e[u+2]===0&&(l.push(d),c++),e[u+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let u=h[0];h[0]=h[1],h[1]=u}l.reverse(),s.push(...l,...h),a.push(c,c)}return{indices:s,verticesPerFace:a}}var mo={};EB(mo,{calcBoolean:()=>EK,calcBooleanTopological:()=>MK,freeMeshSet:()=>DK,getMeshSet:()=>CK,hasOpenEdges:()=>TK,transformMeshSet:()=>PK});var FD,_K=new Promise(e=>{FD=e}),hm;function SK(e){if(hm)return hm;async function t(){let i=e??"https://unpkg.com/@splinetool/boolean-wasm@1.10.56/build",r=import("./boolean.js"),[s,a]=await Promise.all([r,fetch(`${i}/boolean.wasm`).then(l=>l.arrayBuffer())]),n=s.default,o=await n({wasmBinary:a});FD(o)}return hm=t(),hm}var ai,eu;_K.then(e=>ai=e);function AK(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=_v(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=zD(a,n,e);o=h.length,r=[];for(let c=0,u=0;c<o;c++){r.push(h[c]);for(let d=0;d<h[c];d++)r.push(l[u++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,c=0;c<r.length;)r[c++]=3,o++,r[c++]=n[h++],r[c++]=n[h++],r[c++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function kD(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=ai._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(ai.HEAPU32.buffer,a,t):new Float32Array(ai.HEAPF32.buffer,a,t)).set(e,0),a}function UD(e){switch(e){case 0:return ai.OP.UNION;case 1:return ai.OP.INTERSECTION;case 2:return ai.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+e)}}function MK(e,t){eu===void 0&&(eu=ai.init_csg());let i=kD(e),r=ai.csg_calc_topological(eu,i,e.length,UD(t));ai._free(i);let s=6,a=ai.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=ai.HEAPU32[a[o]>>2],h=new Float32Array(ai.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let c=ai.HEAPU32[a[o]>>2],u=new Uint32Array(ai.HEAPU32.subarray(c>>2,(c>>2)+n[o]));o++;let d=ai.HEAPU32[a[o]>>2],p=new Uint8Array(ai.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return ai.free_mesh_data(r),{positions:h,indices:u,verticesPerFace:p}}function EK(e,t,i,r){eu===void 0&&(eu=ai.init_csg());let s=kD(e),a=ai.csg_calc(eu,s,e.length,r,UD(t));ai._free(s);let n=5,o=ai.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,c=ai.HEAPU32[o[h]>>2],u=ai.HEAPF32.subarray(c>>2,(c>>2)+l[h]);h++;let d=ai.HEAPU32[o[h]>>2],p=ai.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new at(u,3)),i.setAttribute("normal",new at(p,3));let g=ai.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Ks),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},ai.free_mesh_data(a),f}function CK(e,t,i){if(ai===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let y=e.userData;a=y.verticesPerFace.length,r=y.positions,s=Array(y.verticesPerFace.reduce((x,b)=>x+b,0)+a);for(let x=0,b=0,_=0;x<y.verticesPerFace.length;x++){s[_++]=y.verticesPerFace[x];for(let M=0;M<y.verticesPerFace[x];M++)s[_++]=y.indices[b++]}}else({positions:r,faceIndices:s,nFaces:a}=AK(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,c=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,u=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=ai._malloc(c),f=new Float32Array(ai.HEAPF32.buffer,p,l),g=new Uint32Array(ai.HEAPU32.buffer,p+u,h);f.set(r,0),g.set(s,0);let m=ai.get_csg_mesh(p,n,p+u,o,a);return ai._free(p),m}function TK(e){return ai.has_open_edges(e)}function PK(e,t){ai.transform_csg_mesh(e,t.elements)}function DK(e){ai.free_csg_mesh(e)}var IK={ConeGeometry:RQ,CubeGeometry:LQ,CylinderGeometry:uD,DodecahedronGeometry:zQ,EllipseGeometry:mw,HelixGeometry:yZ,IcosahedronGeometry:xZ,LatheGeometry:bZ,NonParametricGeometry:CZ,PolygonGeometry:TD,PyramidGeometry:TZ,RectangleGeometry:gw,SphereGeometry:IZ,PlaneGeometry:OZ,BackdropGeometry:RZ,StarGeometry:PD,TextFrameGeometry:BZ,TorusGeometry:zZ,TorusKnotGeometry:kZ,TriangleGeometry:UZ,PathGeometry:pK,VectorGeometry:kh},pE=e=>IK[e.type].create(e);function _c(e){return e!==null&&"booleanOp"in e}var ND=class extends hw(zi){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new je}updateVisible(e){super.updateVisible(e),this.visible=!_c(this.parent)&&this.visible,_c(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(mo.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),_c(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof ND&&(e.freeBooleanPointer(),_c(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&_c(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),_c(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},cm=new mr;function vw(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0;for(let u=t;u<i;u++){let d=e.getX(u),p=e.getY(u),f=e.getZ(u);d<a&&(a=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>c&&(c=f)}cm.min.set(a,n,o),cm.max.set(l,h,c),cm.getCenter(r),cm.getSize(s).multiplyScalar(.5)}var OK=new gt,RK=new Ro,Ns=class extends ND{constructor(e,t){super(OK,RK),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?vw(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},hl=class{constructor(e){if(this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},hl.uuidContext===null)throw new Error("plz startContext");hl.uuidContext===hl.globalContext?this.uuid="_gid"+hl.uuidContext.nodeContextUuid++:this.uuid="_uid"+hl.uuidContext.nodeContextUuid++,this.type=e,this.name=""}static startContext(e){this.uuidContext===null||this.uuidContext===hl.globalContext?this.uuidContext=e:console.error("Can't start context twice")}static endContext(e){this.uuidContext!==e&&console.error("Can't end context twice"),this.uuidContext=null}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,a){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}},zr=hl;zr.globalContext={nodeContextUuid:0},zr.uuidContext=hl.globalContext;var fE=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},LK=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},Xs=new LK,Ii=class extends zr{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=lt.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},Js=class extends Ii{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},ls=class extends Js{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof re?e:new re(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},ba=class extends Js{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof I?e:new I(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},ms=class extends Ct{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},go=class extends Js{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof ms?e:new ms(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},BK=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,mE=/[a-z_0-9]+/gi,tt=class extends Ii{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let a,n=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;a=mE.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let c=l[h],u=c[0],d=this.isMethod?!this.getInputByName(u):!0,p=u;if(this.keywords[u]||this.useKeywords&&d&&Xs.containsKeyword(u)){let f=this.keywords[u];if(!f){let g=Xs.getKeywordData(u);g.cache&&(f=e.keywords[u]),f=f||Xs.getKeyword(u,e),g.cache&&(e.keywords[u]=f)}p=f.build(e)}u!==p&&o[c.index+n-1]!=="."&&(o=o.substring(0,c.index+n)+p+o.substring(c.index+u.length+n),n+=p.length-u.length),this.getIncludeByName(p)===void 0&&Xs.contains(p)&&e.include(Xs.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=BK.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(mE);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},zK=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,VD=class extends Ii{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||VD.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let a,n,o="",l=zK.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},bi=VD;bi.PI="PI",bi.PI2="PI2",bi.RECIPROCAL_PI="RECIPROCAL_PI",bi.RECIPROCAL_PI2="RECIPROCAL_PI2",bi.LOG2="LOG2",bi.EPSILON="EPSILON";var FK=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3193
3193
  )*?)}`,"gim"),kK=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),jD=class extends Ii{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=FK.exec(e);if(t){let i=t[2],r;for(;r=kK.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},yw=class extends Ii{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};Xs.addKeyword("uv",function(){return new yw});Xs.addKeyword("uv2",function(){return new yw(1)});var zc=class extends Ii{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??zc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case tn:return["Linear"];case Gt:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=zc.Nodes[this.method],a=e.include(s);if(a===zc.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let n=this.factor.build(e,"f");return e.format(a+"( "+i+", "+n+" )",r,t)}else return e.format(a+"( "+i+" )",r,t)}fromEncoding(e){let t=zc.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=zc.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},On=zc;On.Nodes={LinearToLinear:new tt(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3194
3194
  `)),sRGBToLinear:new tt(["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(`
3195
3195
  `)),LinearTosRGB:new tt(["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(`
@@ -5047,7 +5047,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5047
5047
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
5048
5048
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
5049
5049
  return displaced_position;
5050
- }`,[e,t])}}();var Dt={normalRenderTarget:new _o,normalRenderTargetDepth:new _o,transmissionRenderTarget:new _o,aspectRatio:new ls,transmissionSize:new ls(2048,2048),transmissionRenderTargetDepth:new _o,aoRenderTarget:new _o,aoEnabled:new Bs,pixelRatioNode:new ht(1),resolution:new ls,penumbraSize:new ih(5,.5),frameIndex:new Ri(0),transmissionLod:new Ri(2)};for(let e of Object.values(Dt))e.isRenderGlobal=!0;var dI={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.54/build/ui.wasm"},ww=class extends zr{constructor(){super("basic"),this.nodeType="Basic",this.color=new nr(sa),this.shadingAlpha=new ht(1),this.shadingBlend=new Ri(0),this.previousModelViewMatrix=new jn,this.previouseProjectionMatrix=new jn}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Dt.frameIndex}),e.mergeUniform({resolution:Dt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(_u.merge([et.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
5050
+ }`,[e,t])}}();var Dt={normalRenderTarget:new _o,normalRenderTargetDepth:new _o,transmissionRenderTarget:new _o,aspectRatio:new ls,transmissionSize:new ls(2048,2048),transmissionRenderTargetDepth:new _o,aoRenderTarget:new _o,aoEnabled:new Bs,pixelRatioNode:new ht(1),resolution:new ls,penumbraSize:new ih(5,.5),frameIndex:new Ri(0),transmissionLod:new Ri(2)};for(let e of Object.values(Dt))e.isRenderGlobal=!0;var dI={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.56/build/ui.wasm"},ww=class extends zr{constructor(){super("basic"),this.nodeType="Basic",this.color=new nr(sa),this.shadingAlpha=new ht(1),this.shadingBlend=new Ri(0),this.previousModelViewMatrix=new jn,this.previouseProjectionMatrix=new jn}get category(){return"phong"}generate(e){let t;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:Dt.frameIndex}),e.mergeUniform({resolution:Dt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(_u.merge([et.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
5051
5051
  `));let r=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
5052
5052
  #include <skinbase_vertex>
5053
5053
  #include <skinnormal_vertex>
@@ -8139,7 +8139,7 @@ void main() {
8139
8139
  gVelocity = vec4(0.0); // so it is ignored by TAA
8140
8140
  }`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new re},viewport:{type:"v2",value:new re},basisViewport:{type:"v2",value:new re},debugColor:{type:"v3",value:new Ct},covariancesTextureSize:{type:"v2",value:new re(1024,1024)},centersColorsTextureSize:{type:"v2",value:new re(1024,1024)},orthoZoom:{type:"f",value:-1}};return new ci({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:yh,depthTest:!0,depthWrite:!1,side:_s})}static buildGeomtery(e){let t=new gt;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new Tt(i,3);t.setAttribute("position",r),r.setXYZ(0,-1,-1,0),r.setXYZ(1,-1,1,0),r.setXYZ(2,1,1,0),r.setXYZ(3,1,-1,0),r.needsUpdate=!0;let s=new _T().copy(t),a=new Uint32Array(e),n=new ap(a,1,!1);return n.setUsage(Mz),s.setAttribute("splatIndex",n),s.instanceCount=e,s}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(r=>r.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,t=0,i=0;for(let r of this.splatBuffers){let s=r.nsplats;this.colors.subarray(e,e+s*4).set(r.colorsA),e+=s*4,this.centers.subarray(t,t+s*3).set(r.decoded.xyz.denormDequant().data),t+=s*3,this.covariances.subarray(i,i+s*6).set(new Float32Array(r.precomputedCovarianceBufferData)),i+=s*6}}allocateAndStoreLocalSplatDataInTextures(){let e=this.splatCount,t=new re(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new re(4096,1024);for(;i.x*i.y*4<e*4;)i.y*=2;let r,s;if(this.halfPrecisionCovariancesOnGPU){s=new Uint16Array(t.x*t.y*2);for(let c=0;c<this.covariances.length;c++)s[c]=i8.toHalfFloat(this.covariances[c]);r=new Fs(s,t.x,t.y,Zm,Oo)}else s=new Float32Array(t.x*t.y*2),s.set(this.covariances),r=new Fs(s,t.x,t.y,Zm,Ti);r.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=r,this.material.uniforms.covariancesTextureSize.value.copy(t);let a=new Uint32Array(i.x*i.y*4);for(let c=0;c<e;c++){let u=c*4,d=c*3,p=c*4;a[p]=zre(this.colors[u],this.colors[u+1],this.colors[u+2],this.colors[u+3]),a[p+1]=V1(this.centers[d]),a[p+2]=V1(this.centers[d+1]),a[p+3]=V1(this.centers[d+2])}let n=new Fs(a,i.x,i.y,k3,Ao);n.internalFormat="RGBA32UI",n.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=n,this.material.uniforms.centersColorsTextureSize.value.copy(i);let o=256*4,l=new Float32Array(256*16);for(let c=0;c<this.meshMatrixWorlds.length;c++)l.set(this.meshMatrixWorlds[c].elements,c*16);let h=new Fs(l,o,1,qi,Ti);h.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=h,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:s,texture:r,size:t},centerColors:{data:a,texture:n,size:i},meshMatrixWorlds:{data:l,texture:h}}}updateIndexes(e){let t=this.geometry;t.attributes.splatIndex.set(e),t.attributes.splatIndex.needsUpdate=!0,t.instanceCount=e.length}updateUniforms(e,t,i,r){this.splatCount>0&&(Em.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Em),this.material.uniforms.basisViewport.value.set(2/Em.x,2/Em.y),this.material.uniforms.focal.value.set(t,i),this.material.uniforms.orthoZoom.value=r,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}},KI,Fre=new Promise(e=>{KI=e}),PC=!1,Cm;function kre(){if(PC)return;if(Cm)return Cm;async function e(){let t=await Promise.resolve().then(()=>(y2(),v2));KI(t),PC=!0}return Cm=e(),Cm}var JI;Fre.then(e=>JI=e);var Ure=class{constructor(e={}){Pd(this,"updateView",function(){let t=new je,i=[],r=new I(0,0,-1),s=new I(0,0,-1),a=new I,n=new I;return function(o=!1,l){let h=this.updateMatrixWorldsInWorkerIfNeeded(),c=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,p=!1;if(s.dot(r)<=.95&&(d=!0),n.copy(l.position).sub(a).length()>=1&&(p=!0),!d&&!p&&!h&&!c&&!this.needsInitialRender)return}this.needsInitialRender=!1,a.copy(l.position),r.copy(s),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),i[0]=l.position.x,i[1]=l.position.y,i[2]=l.position.z;let u={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...h?{newMatrixWorlds:this.meshMatrixWorlds}:{},...c?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=u:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(u))}}()),this.scene=e.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new je().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(e,t){let i=new re;this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(e.getSize(i),this.cameraFocalLengthX=t.projectionMatrix.elements[0]*this.devicePixelRatio*i.x*.45,this.cameraFocalLengthY=t.projectionMatrix.elements[5]*this.devicePixelRatio*i.y*.45,this.splatMesh.updateUniforms(i,this.cameraFocalLengthX,this.cameraFocalLengthY,t.isPerspectiveCamera?-1:t.zoom*this.devicePixelRatio))}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new I().fromArray(e.position)),e.orientation&&(e.orientation=new Rt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&t.push(a)}),this.splatMesh&&this.splatMesh.dispose(),t.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=t.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=t.map(a=>a.matrixWorld.clone()),this.cropsArray=t.map(a=>a.data.crops.map(n=>n.data));let i=t.map(a=>new JI.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),r=0,s=[0];for(let a of i)r+=a.getSplatCount(),s.push(r);return this.setupSplatMesh(i,r,e.position,e.orientation,e.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(r),!0}updateMatrixWorldsInWorkerIfNeeded(){let e=this.splatDataTextures.meshMatrixWorlds.data;for(let t=0;t<this.meshMatrixWorlds.length;t++)e.set(this.meshMatrixWorlds[t].elements,t*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((t,i)=>t.equals(this.meshMatrixWorldsOld[i]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(t=>t.clone()),!0)}cropsChanged(){let e=!1;return this.splatEntries.forEach((t,i)=>{t.data.crops.forEach((r,s)=>{this.cropsArray[i][s]===void 0?(e=!0,this.cropsArray[i][s]=r.data):Object.entries(r.data).forEach(([a,n])=>{Array.isArray(n)&&n.some((o,l)=>o!==this.cropsArray[i][s][a][l])?(e=!0,this.cropsArray[i][s][a]=n):n!==this.cropsArray[i][s]?.[a]&&(e=!0,this.cropsArray[i][s][a]=n)})}),t.data.crops.length!==this.cropsArray[i]?.length&&(this.cropsArray[i].length=t.data.crops.length,e=!0)}),e}setupSplatMesh(e,t,i=new I,r=new Rt,s=!1,a=1,n,o){this.splatMesh=qm.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=t,this.splatMesh.onBeforeRender=(l,h,c)=>this.update(l,c)}setupSortWorker(e){this.sortWorker=Bre(e),this.sortWorker.onmessage=t=>{t.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(t.data.indexesBuffer)),this.lastSortTime=t.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):t.data.sortCanceled?this.sortRunning=!1:t.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):t.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(e,t){this.splatMesh!==null&&(this.updateSplatMeshUniforms(e,t),this.updateView(!1,t))}getSplatMesh(){return this.splatMesh}},rb=new Ro;rb.wireframe=!0;var DC=new I,kw=class extends Zs{constructor(e,t){super(),this.data=e,this.sharedAssets=t,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.splatViewer=null,this.shapeBlendIntances=[],this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new Ore,this.invisibleObjects=new ru("jflkdsafjasdifjaslk",{...cx.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new Qr("fdasfa",{...gu.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Tre(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Cre(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Qr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>bP(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===Ru)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}find2D(e){for(let t of this.children)if(t instanceof Qr&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof Qr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&i instanceof ws&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof Qr&&t.uiScene&&t.uiScene.traverse(e)}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(this),r.resetBBoxNeedsUpdate(),Ya(r)&&Po(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");i.traverseEntity(s=>{s instanceof Rh&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(a=>a!==s))}),this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Po(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ya(i)&&(i.freeBooleanPointer(),r instanceof Oh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof Lw&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(this),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),Ya(i)&&(i.invalidateUpstreamBooleanData(),Po(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Oh&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof Qr&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{xre(s,t,i,{scene:this,shared:r}),s instanceof Ar&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}updateEntity2DByOp(e,t,i,r,s,a=[]){e.updateEntityByOp(t,i,r,s),this.traverseEntity(n=>{(n instanceof ws||n instanceof Qr)&&(a.includes(n.frameId??"")||n.frameId===t)&&n.updateEntity2DByOp(t,i,r,s)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{r instanceof Ss&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ni.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{ni.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=mp(l.data,h=>{let c=h.events.data(n.id),u=l.goUp(a);if(u){let d=[...xP(u.identity),e].join("-"),p=this.entityIdentityToEntity[d];if(p){let f=p.uuid,g=kr.zoom(c,t);g[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Animation"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Conditional"&&(this.rewriteActions(n.data.ifActions,[...t,n.id,"ifActions"],i,r,s,a),this.rewriteActions(n.data.elseActions,[...t,n.id,"elseActions"],i,r,s,a))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof su&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=mp(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of Og.list)this.rewriteActions(r.data.gameActions[a],["gameActions",a],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof su&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(a=>{i.addClip(a)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),zw(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof su&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)ni.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let n=a.cloner;if(ni.is(a)&&!a.raycastLock&&(a.visible||n?.object.data.visible))if(t===!0&&a.isInstanceRoot){let o=[];if(e.intersectObject(a,!0,o),o.length){let l=o[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let h=a.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Ya(a)||Wx(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),ib(a,e,i)),r(a)}};return r(this.activePage),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;ni.is(s)&&(s.visible||a?.object.data.visible)&&((Ya(s)||Wx(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),ib(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)ni.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)ni.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)ni.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof Ar&&i.data.type==="Mesh"&&(i.data.geometry.type==="TextGeometry"||i.data.geometry.type==="InputGeometry")&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s,t);let a=i.invalidateDownstreamBooleanData();Po(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Dh.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)ni.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){let n={scene:this,shared:a},o=Fw(e,t,n);return o instanceof Rh&&this.shapeBlendIntances.push(o),o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,a)),o.updateState(t,n),o instanceof Ar&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(this),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{let h=l.dataPatched;if(l instanceof Ar&&h.bones&&h.boneInverses){let c=h.bones.map(p=>this.find(p)),u=h.boneInverses.map(p=>new je().fromArray(p)),d=new Ab(c,u);l.bind(d,l.bindMatrix)}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:a,recursive:n}=e[r],o=this.find(a),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new mr;return i.setFromPoints(t),i.getCenter(DC),DC}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof Ns)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof Ol&&e(t.material[i]);else t.material instanceof Ol&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Ss&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(){this.splatViewer=new Ure({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}},Xm=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},Nre=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return jre(Math.atan2(r,i))},Vre=(e,t,i)=>{let r={x:0,y:0};return i=sb(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},sb=e=>e*(Math.PI/180),jre=e=>e*(180/Math.PI),Hre=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,j1=new Map,IC=e=>{j1.has(e)&&clearTimeout(j1.get(e)),j1.set(e,setTimeout(e,100))},Zg=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},OC=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},$I=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),RC=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},ab=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},Uw=(e,t,i)=>{let r=eO(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let a="";for(let n=0,o=t.length;n<o;n+=1)a+=t[n]+" "+i+", ";r[s]=a.slice(0,-2)}return r},Gre=(e,t)=>{let i=eO(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},eO=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},H1=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},Wre=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},nb=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},qre=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(tO="ontouchstart"in window,iO=!!window.PointerEvent,rO=!!window.MSPointerEvent);var tO,iO,rO,Sd={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"}},qc,Mp={};iO?qc=Sd.pointer:rO?qc=Sd.MSPointer:tO?(qc=Sd.touch,Mp=Sd.mouse):qc=Sd.mouse;function Nh(){}Nh.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};Nh.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};Nh.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(n){n.call(i,{type:s,target:i},t)})};Nh.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=Wre(t.options,e))};Nh.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Zg(e,qc[t],i._domHandlers_[t]),Mp[t]&&Zg(e,Mp[t],i._domHandlers_[t]),i};Nh.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},OC(e,qc[t],i._domHandlers_[t]),Mp[t]&&OC(e,Mp[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var Nw=Nh;function jr(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=jr.id,jr.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}jr.prototype=new Nw;jr.constructor=jr;jr.id=0;jr.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};jr.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=Gre("borderRadius","50%"),i=Uw("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},H1(r.el,i),this.options.shape==="circle"&&H1(r.back,t),H1(r.front,t),this.applyStyles(r),this};jr.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};jr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};jr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};jr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};jr.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};jr.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};jr.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=Uw("transition",["top","left"],r);var a={front:{}};a.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(a),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};jr.prototype.restCallback=function(){var e=this,t={};t.front=Uw("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};jr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};jr.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,a,n;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?a="left":a="right"),e.lockX||(t>0?n="up":n="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:a,y:n,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+a,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var Xre=jr;function gr(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=gr.id,gr.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}gr.prototype=new Nw;gr.constructor=gr;gr.id=0;gr.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};gr.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};gr.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};gr.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},a=i.options,n={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-n.x,y:e.y-n.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",a.zone.appendChild(o);var l=o.getBoundingClientRect();a.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new Xre(i,{color:a.color,size:a.size,threshold:a.threshold,fadeTime:a.fadeTime,dataOnly:a.dataOnly,restJoystick:a.restJoystick,restOpacity:a.restOpacity,mode:a.mode,identifier:t,position:e,zone:a.zone,frontPosition:{x:0,y:0},shape:a.shape});return a.dataOnly||(ab(h.ui.el,s),ab(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};gr.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};gr.prototype.bindNipple=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};gr.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var a=e.force||e.pressure||e.webkitForce||0;a!==s&&(t.trigger("pressure",a),r.trigger("pressure "+t.identifier+":pressure",a),s=a)}.bind(r),100)};gr.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=$I(e),t.updateBox();var s=function(a){t.actives.length<i.maxNumberOfNipples?t.processOnStart(a):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(a))};return nb(e,s),t.manager.bindDocument(),!1};gr.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),a=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,n);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(c){c.trigger("start",c),t.trigger("start "+c.id+":start",c),c.show(),a>0&&t.pressureFn(e,c,c.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=Xm(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};gr.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};gr.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.scroll;if(!Hre(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=s.el.getBoundingClientRect();s.position={x:a.x+n.left,y:a.y+n.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=Xm(l,s.position),c=Nre(l,s.position),u=sb(c),d=h/o,p={distance:h,position:l},f,g;if(s.options.shape==="circle"?(f=Math.min(h,o),g=Vre(s.position,f,c)):(g=qre(l,s.position,o),f=Xm(g,s.position)),i.follow){if(h>o){let b=l.x-g.x,_=l.y-g.y;s.position.x+=b,s.position.y+=_,s.el.style.top=s.position.y-(t.box.top+a.y)+"px",s.el.style.left=s.position.x-(t.box.left+a.x)+"px",h=Xm(l,s.position)}}else l=g,h=f;var m=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:m,y},i.dataOnly||ab(s.ui.front,s.frontPosition);var x={identifier:s.identifier,position:l,force:d,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:u,degree:c},vector:{x:m/o,y:-y/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};x=s.computeDirection(x),x.angle={radian:sb(180-c),degree:180-c},s.trigger("move",x),t.trigger("move "+s.id+":move",x)};gr.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[a.id]=a.identifier))};gr.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};gr.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var Yre=gr;function is(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=RC(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(a){a.forEach(function(n){s=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;Zg(window,"resize",function(){IC(i)});var r=function(){t.scroll=RC()};return Zg(window,"scroll",function(){IC(r)}),t.collections}is.prototype=new Nw;is.constructor=is;is.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};is.prototype.create=function(e){return this.createCollection(e)};is.prototype.createCollection=function(e){var t=this,i=new Yre(t,e);return t.bindCollection(i),t.collections.push(i),i};is.prototype.bindCollection=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};is.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};is.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};is.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};is.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};is.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};is.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};is.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};is.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=$I(t);var a=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),nb(i.collections,a.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return nb(t,n),!1};is.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};is.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var Qre=is,LC=new Qre,Zre={create:function(e){return LC.create(e)},factory:LC},sO=new Map,Jd=new Map,gh=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:a,delay:n,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Ud({src:l,volume:a,delay:n,loop:o}),Jd.has(i.uuid)?Jd.get(i.uuid).push(this):Jd.set(i.uuid,[this]),sO.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},ob=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=sO.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Jd.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Jd.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},aO=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new gh(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new ob(t);else throw new Error("Missing property")}dispatchBasic(){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof gh?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof gh?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof gh&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},nO=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.delay=0,this.emission=e.emission,e.delay!==void 0&&(this.delay=e.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},e);return}this.particleSystem.start()}stop(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},e);return}this.particleSystem.stop()}freeze(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},e);return}this.particleSystem.froze()}unFreeze(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},e);return}this.particleSystem.unFroze()}reset(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},e);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(Vi(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchConditional(){if(Vi(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchGameControl(e){if(Vi(this.shared,this.condition)===!1||!this.particleSystem)return!1;e==="start"?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}},Kre="text/plain",Jre="us-ascii",BC=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),$re=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:a}=i.groups,n=r.split(";");a=t?"":a;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(c=>{let[u,d=""]=c.split("=").map(p=>p.trim());return u==="charset"&&(d=d.toLowerCase(),d===Jre)?"":`${u}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==Kre)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${a?`#${a}`:""}`};function ese(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return $re(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=a.exec(r.pathname);if(!h)break;let c=h[0],u=h.index,d=r.pathname.slice(n,u);o+=d.replace(/\/{2,}/g,"/"),o+=c,n=u+c.length}let l=r.pathname.slice(n,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=r.pathname.split("/"),n=a[a.length-1];BC(n,t.removeDirectoryIndex)&&(a=a.slice(0,-1),r.pathname=a.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...r.searchParams.keys()])BC(a,t.removeQueryParameters)&&r.searchParams.delete(a);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var tse=class{constructor({url:e,context:t},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:ese(e,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=t??"tab"}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;Iu?window.location.assign(this.url):(this.context==="tab"||yP&&this.context==="none"?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.controlsManager.orbitControls?.onPointerUp(It[0]),mX())}},oO=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=a=>{this.timeoutIdQueue.shift();let n=this.page.scene.find(a);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?n.dataPatched.physics?.fusedBody:!0;if(n.cloner){for(let h of n.cloner.children)l?(h.playModeVisible=!1,h.rigidBody&&n.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,h.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0)):h.playModeVisible===void 0&&(h.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(Vi(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(Vi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},lO=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=s,this.shared=i}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Kw(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},hO={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},Vw={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},ise=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Kg={CSS:{},springs:{}};function Ja(e,t,i){return Math.min(Math.max(e,t),i)}function $d(e,t){return e.indexOf(t)>-1}function G1(e,t){return e.apply(null,t)}var Lt={arr:function(e){return Array.isArray(e)},obj:function(e){return $d(Object.prototype.toString.call(e),"Object")},pth:function(e){return Lt.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||Lt.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return Lt.hex(e)||Lt.rgb(e)||Lt.hsl(e)},key:function(e){return!hO.hasOwnProperty(e)&&!Vw.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function cO(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function uO(e,t){var i=cO(e),r=Ja(Lt.und(i[0])?1:i[0],.1,100),s=Ja(Lt.und(i[1])?100:i[1],.1,100),a=Ja(Lt.und(i[2])?10:i[2],.1,100),n=Ja(Lt.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=a/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,c=1,u=l<1?(l*o+-n)/h:-n+o;function d(f){var g=t?t*f/1e3:f;return l<1?g=Math.exp(-g*l*o)*(c*Math.cos(h*g)+u*Math.sin(h*g)):g=(c+u*g)*Math.exp(-g*o),f===0||f===1?f:1-g}function p(){var f=Kg.springs[e];if(f)return f;for(var g=1/6,m=0,y=0;;)if(m+=g,d(m)===1){if(y++,y>=16)break}else y=0;var x=m*g*1e3;return Kg.springs[e]=x,x}return t?d:p}function rse(e){return e===void 0&&(e=10),function(t){return Math.ceil(Ja(t,1e-6,1)*e)*(1/e)}}var sse=function(){var e=11,t=1/(e-1);function i(c,u){return 1-3*u+3*c}function r(c,u){return 3*u-6*c}function s(c){return 3*c}function a(c,u,d){return((i(u,d)*c+r(u,d))*c+s(u))*c}function n(c,u,d){return 3*i(u,d)*c*c+2*r(u,d)*c+s(u)}function o(c,u,d,p,f){var g,m,y=0;do m=u+(d-u)/2,g=a(m,p,f)-c,g>0?d=m:u=m;while(Math.abs(g)>1e-7&&++y<10);return m}function l(c,u,d,p){for(var f=0;f<4;++f){var g=n(u,d,p);if(g===0)return u;var m=a(u,d,p)-c;u-=m/g}return u}function h(c,u,d,p){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var f=new Float32Array(e);if(c!==u||d!==p)for(var g=0;g<e;++g)f[g]=a(g*t,c,d);function m(y){for(var x=0,b=1,_=e-1;b!==_&&f[b]<=y;++b)x+=t;--b;var M=(y-f[b])/(f[b+1]-f[b]),S=x+M*t,E=n(S,c,d);return E>=.001?l(y,S,c,d):E===0?S:o(y,x,x+t,c,d)}return function(y){return c===u&&d===p||y===0||y===1?y:a(m(y),u,p)}}return h}(),dO=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,a=4;r<((s=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var a=Ja(r,1,10),n=Ja(s,.1,2);return function(o){return o===0||o===1?o:-a*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/a))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(a){return Math.pow(a,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(a,n){return function(o){return 1-s(a,n)(1-o)}},e["easeInOut"+r]=function(a,n){return function(o){return o<.5?s(a,n)(o*2)/2:1-s(a,n)(o*-2+2)/2}}}),e}();function jw(e,t){if(Lt.fnc(e))return e;var i=e.split("(")[0],r=dO[i],s=cO(e);switch(i){case"spring":return uO(e,t);case"cubicBezier":return G1(sse,s);case"steps":return G1(rse,s);default:return G1(r,s)}}function pO(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Ev(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],a=0;a<i;a++)if(a in e){var n=e[a];t.call(r,n,a,e)&&s.push(n)}return s}function Cv(e){return e.reduce(function(t,i){return t.concat(Lt.arr(i)?Cv(i):i)},[])}function zC(e){return Lt.arr(e)?e:(Lt.str(e)&&(e=pO(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Hw(e,t){return e.some(function(i){return i===t})}function Gw(e){var t={};for(var i in e)t[i]=e[i];return t}function lb(e,t){var i=Gw(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Tv(e,t){var i=Gw(e);for(var r in t)i[r]=Lt.und(e[r])?t[r]:e[r];return i}function ase(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function nse(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,c){return l+l+h+h+c+c}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),a=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+s+","+a+","+n+",1)"}function ose(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,a=t[4]||1;function n(d,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?d+(p-d)*6*f:f<1/2?p:f<2/3?d+(p-d)*(2/3-f)*6:d}var o,l,h;if(r==0)o=l=h=s;else{var c=s<.5?s*(1+r):s+r-s*r,u=2*s-c;o=n(u,c,i+1/3),l=n(u,c,i),h=n(u,c,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+a+")"}function lse(e){if(Lt.rgb(e))return ase(e);if(Lt.hex(e))return nse(e);if(Lt.hsl(e))return ose(e)}function Io(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function hse(e){if($d(e,"translate")||e==="perspective")return"px";if($d(e,"rotate")||$d(e,"skew"))return"deg"}function hb(e,t){return Lt.fnc(e)?e(t.target,t.id,t.total):e}function Rn(e,t){return e.getAttribute(t)}function Ww(e,t,i){var r=Io(t);if(Hw([i,"deg","rad","turn"],r))return t;var s=Kg.CSS[t+i];if(!Lt.und(s))return s;var a=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=a+i;var l=a/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return Kg.CSS[t+i]=h,h}function fO(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?Ww(e,s,i):s}}function qw(e,t){if(Lt.dom(e)&&!Lt.inp(e)&&(Rn(e,t)||Lt.svg(e)&&e[t]))return"attribute";if(Lt.dom(e)&&Hw(ise,t))return"transform";if(Lt.dom(e)&&t!=="transform"&&fO(e,t))return"css";if(e[t]!=null)return"object"}function mO(e){if(Lt.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function cse(e,t,i,r){var s=$d(t,"scale")?1:0+hse(t),a=mO(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?Ww(e,a,r):a}function Xw(e,t,i,r){switch(qw(e,t)){case"transform":return cse(e,t,r,i);case"css":return fO(e,t,i);case"attribute":return Rn(e,t);default:return e[t]||0}}function Yw(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Io(e)||0,s=parseFloat(t),a=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+a+r;case"-":return s-a+r;case"*":return s*a+r}}function gO(e,t){if(Lt.col(e))return lse(e);if(/\s/g.test(e))return e;var i=Io(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Qw(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function use(e){return Math.PI*2*Rn(e,"r")}function dse(e){return Rn(e,"width")*2+Rn(e,"height")*2}function pse(e){return Qw({x:Rn(e,"x1"),y:Rn(e,"y1")},{x:Rn(e,"x2"),y:Rn(e,"y2")})}function vO(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var a=t.getItem(s);s>0&&(i+=Qw(r,a)),r=a}return i}function fse(e){var t=e.points;return vO(e)+Qw(t.getItem(t.numberOfItems-1),t.getItem(0))}function yO(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return use(e);case"rect":return dse(e);case"line":return pse(e);case"polyline":return vO(e);case"polygon":return fse(e)}}function mse(e){var t=yO(e);return e.setAttribute("stroke-dasharray",t),t}function gse(e){for(var t=e.parentNode;Lt.svg(t)&&Lt.svg(t.parentNode);)t=t.parentNode;return t}function xO(e,t){var i=t||{},r=i.el||gse(e),s=r.getBoundingClientRect(),a=Rn(r,"viewBox"),n=s.width,o=s.height,l=i.viewBox||(a?a.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function vse(e,t){var i=Lt.str(e)?pO(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:xO(i),totalLength:yO(i)*(r/100)}}}function yse(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=xO(e.el,e.svg),s=i(),a=i(-1),n=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(n.y-a.y,n.x-a.x)*180/Math.PI}}function FC(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=gO(Lt.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Lt.str(e)||t?r.split(i):[]}}function bO(e){var t=e?Cv(Lt.arr(e)?e.map(zC):zC(e)):[];return Ev(t,function(i,r,s){return s.indexOf(i)===r})}function wO(e){var t=bO(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:mO(i)}}})}function xse(e,t){var i=Gw(t);if(/^spring/.test(i.easing)&&(i.duration=uO(i.easing)),Lt.arr(e)){var r=e.length,s=r===2&&!Lt.obj(e[0]);s?e={value:e}:Lt.fnc(t.duration)||(i.duration=t.duration/r)}var a=Lt.arr(e)?e:[e];return a.map(function(n,o){var l=Lt.obj(n)&&!Lt.pth(n)?n:{value:n};return Lt.und(l.delay)&&(l.delay=o?0:t.delay),Lt.und(l.endDelay)&&(l.endDelay=o===a.length-1?t.endDelay:0),l}).map(function(n){return Tv(n,i)})}function bse(e){for(var t=Ev(Cv(e.map(function(a){return Object.keys(a)})),function(a){return Lt.key(a)}).reduce(function(a,n){return a.indexOf(n)<0&&a.push(n),a},[]),i={},r=function(a){var n=t[a];i[n]=e.map(function(o){var l={};for(var h in o)Lt.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function wse(e,t){var i=[],r=t.keyframes;r&&(t=Tv(bse(r),t));for(var s in t)Lt.key(s)&&i.push({name:s,tweens:xse(t[s],e)});return i}function _se(e,t){var i={};for(var r in e){var s=hb(e[r],t);Lt.arr(s)&&(s=s.map(function(a){return hb(a,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function Sse(e,t){var i;return e.tweens.map(function(r){var s=_se(r,t),a=s.value,n=Lt.arr(a)?a[1]:a,o=Io(n),l=Xw(t.target,e.name,o,t),h=i?i.to.original:l,c=Lt.arr(a)?a[0]:h,u=Io(c)||Io(l),d=o||u;return Lt.und(n)&&(n=h),s.from=FC(c,d),s.to=FC(Yw(n,c),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=jw(s.easing,s.duration),s.isPath=Lt.pth(a),s.isColor=Lt.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var _O={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var a="";r.list.forEach(function(n,o){a+=o+"("+n+") "}),e.style.transform=a}}};function SO(e,t){var i=wO(e);i.forEach(function(r){for(var s in t){var a=hb(t[s],r),n=r.target,o=Io(a),l=Xw(n,s,o,r),h=o||Io(l),c=Yw(gO(a,h),l),u=qw(n,s);_O[u](n,s,c,r.transforms,!0)}})}function Ase(e,t){var i=qw(e.target,t.name);if(i){var r=Sse(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function Mse(e,t){return Ev(Cv(e.map(function(i){return t.map(function(r){return Ase(i,r)})})),function(i){return!Lt.und(i)})}function AO(e,t){var i=e.length,r=function(a){return a.timelineOffset?a.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+l+a.duration*(a.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0;return r(a)+n+o+a.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+a.duration*(a.loop??1)-a.endDelay-l})):t.endDelay,s}var kC=0;function Ese(e){var t=lb(hO,e),i=lb(Vw,e),r=wse(i,e),s=wO(e.targets),a=Mse(s,r),n=AO(a,i),o=kC;return kC++,Tv(t,{id:o,children:[],animatables:s,animations:a,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var Pa=[],UC=[],Uc,NC=function(){let e=0,t=!0;function i(a){let n=Pa.length;if(n){let o=0;for(;o<n;){let l=Pa[o];l.paused?(Pa.splice(o,1),n--):(l.tick(a),o++)}t&&(Uc=requestAnimationFrame(i))}else Uc&&(cancelAnimationFrame(Uc),Uc=null)}function r(){e=performance.now(),Uc=requestAnimationFrame(i)}function s(a){e+=a,i(e)}return{isUsingInternalRaf:t,play:r,update:s}}();function Cse(e){document.hidden?(Pa.forEach(function(t){return t.pause(e.timeStamp)}),UC=Pa.slice(0),fr.running=Pa=[]):UC.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Cse);function fr(e){e===void 0&&(e={});var t=0,i=0,r=0,s,a,n=0,o=null;function l(E){var A=window.Promise&&new Promise(function(T){return o=T});return E.finished=A,A}var h=Ese(e),c=l(h);function u(){var E=h.direction;E!=="alternate"&&(h.direction=E!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,a.forEach(function(A){(A.loop===1||A.loop%2===0)&&(A.reversed=h.reversed)})}function d(){h.direction="normal",h.reversed=!1,a.forEach(function(E){return E.reversed=!1})}function p(E){return h.reversed?h.duration-E:E}function f(){t=0,i=p(h.currentTime)*(1/fr.speed)}function g(E,A,T=!1){A&&(h.reversed?A.seek(A.duration*A.loop-(E-A.timelineOffset-A.pingPongDelayCorrection),T):A.seek(E-A.timelineOffset-A.startOnceDelay-A.pingPongDelayCorrection,T))}function m(E,A=!1){if(h.reversed)for(var T=n;T--;)g(E,a[T],A);else for(var P=0;P<n;P++)g(E,a[P],A)}function y(E){var A=0,T=h.animations,P=T.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?E=h.duration-h.delay+h.endDelay-E:E=h.duration+h.delay-h.endDelay-E):M(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?E=h.duration-h.delay+h.endDelay-E:E=h.duration+h.delay-h.endDelay-E);A<P;){var R=T[A],z=R.animatable,U=R.tweens,L=U.length-1,H=U[L];L&&(H=Ev(U,function(ye){return E<ye.end})[0]||H);let Ae;h.parent?.reversed&&h.direction==="alternate"?Ae=Ja(E-H.start-H.endDelay,0,H.duration)/H.duration:Ae=Ja(E-H.start-H.delay,0,H.duration)/H.duration;for(var q=isNaN(Ae)?1:H.easing(Ae),Z=H.to.strings,X=H.round,se=[],le=H.to.numbers.length,te=void 0,ie=0;ie<le;ie++){var fe=void 0;let ye,Ve;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(ye=H.to.numbers[ie],Ve=H.from.numbers[ie]||0):(Ve=H.to.numbers[ie],ye=H.from.numbers[ie]||0):M(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(ye=H.to.numbers[ie],Ve=H.from.numbers[ie]||0):(Ve=H.to.numbers[ie],ye=H.from.numbers[ie]||0),H.isPath?fe=yse(H.value,q*Ve):fe=ye+q*(Ve-ye),X&&(H.isColor&&ie>2||(fe=Math.round(fe*X)/X)),se.push(fe)}var ce=Z.length;if(!ce)te=se[0];else{te=Z[0];for(var ue=0;ue<ce;ue++){var ae=Z[ue],Pe=Z[ue+1],ve=se[ue];isNaN(ve)||(Pe?te+=ve+Pe:te+=ve+" ")}}_O[R.type](z.target,R.property,te,z.transforms),R.currentValue=te,A++}}function x(E){h[E]&&!h.passThrough&&h[E](h)}function b(){h.remaining&&h.remaining!==!0&&h.remaining--}let _={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 M(E,A,T,P,R){return _[E<<4|A<<3|T<<2|P<<1|R]}function S(E,A=!1){var T=h.duration;let P=h.delay,R=T-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(P=h.endDelay,R=T-h.delay);var z=p(E);if(h.progress=Ja(z/T*100,0,100),A||(h.reversePlayback=z<h.currentTime),n&&m(z,A),!h.began&&h.currentTime>=0&&(h.began=!0,x("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,x("loopBegin")),(h.reversed||z>=0)&&z<=P&&h.currentTime!==0&&(y(0),x("change")),(z>=R&&h.currentTime!==T+h.pingPongDelayCorrection||!T)&&(y(T),x("change")),z>P&&z<R?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,x("changeBegin")),y(z),x("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,x("change"),n&&x("timelineChangeComplete")):h.began&&z>R&&x("changeComplete"),h.currentTime=Ja(z,0,T+h.pingPongDelayCorrection),h.began&&x("update"),E>=T)if(b(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,x("loopComplete"),x("complete"),!h.passThrough&&"Promise"in window&&(o(),c=l(h)));else{n?t+=h.duration/fr.speed:t+=h.duration;for(let U of a)U.setStartTime(0),U.remaining=U.loop;x("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?u():n&&d()}}return h.reset=function(){var E=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=E==="reverse",h.remaining=h.loop,a=h.children,n=a.length;for(var A=n;A--;)h.children[A].reset();y(h.reversed?h.duration:0)},h.setStartTime=function(E){t=E},h.set=function(E,A){return SO(E,A),h},h.tick=function(E){r=E,t||(t=r),S((r+(i-t))*fr.speed)},h.seek=function(E,A=!1){S(E-t,A)},h.pause=function(E){h.paused=!0,n&&(s=E??performance.now())},h.play=function(E){!h.paused||(h.completed&&h.reset(),h.paused=!1,Pa.push(h),n&&s!==void 0&&(t+=(E??performance.now())-s),!Uc&&NC.isUsingInternalRaf&&NC.play())},h.reverse=function(){u(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function VC(e,t){for(var i=t.length;i--;)Hw(e,t[i].animatable.target)&&t.splice(i,1)}function Tse(e){for(var t=bO(e),i=Pa.length;i--;){var r=Pa[i],s=r.animations,a=r.children;VC(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;VC(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}}function Pse(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?jw(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",c=Lt.arr(e),u=parseFloat(c?e[0]:e),d=c?parseFloat(e[1]):0,p=Io(c?e[1]:e)||0,f=t.start||0+(c?u:0),g=[],m=0;return function(y,x,b){if(o&&(n=0),l&&(n=(b-1)/2),h&&(n=b-1),!g.length){for(var _=0;_<b;_++){if(!s)g.push(Math.abs(n-_));else{var M=l?(s[0]-1)/2:n%s[0],S=l?(s[1]-1)/2:Math.floor(n/s[0]),E=_%s[0],A=Math.floor(_/s[0]),T=M-E,P=S-A,R=Math.sqrt(T*T+P*P);a==="x"&&(R=-T),a==="y"&&(R=-P),g.push(R)}m=Math.max.apply(Math,g)}r&&(g=g.map(function(U){return r(U/m)*m})),i==="reverse"&&(g=g.map(function(U){return a?U<0?U*-1:-U:Math.abs(m-U)}))}var z=c?(d-u)/m:u;return f+z*(Math.round(g[x]*100)/100)+p}}function Dse(e){e===void 0&&(e={});var t=fr(e);return t.duration=0,t.add=function(i,r){var s=Pa.indexOf(t),a=t.children;s>-1&&Pa.splice(s,1);function n(d){d.passThrough=!0}for(var o=0;o<a.length;o++)n(a[o]);var l=Tv(i,lb(Vw,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Lt.und(r)?h:Yw(r,h),n(t);var c=fr(l);n(c),a.push(c),c.parent=t;var u=AO(a,e);return t.delay=u.delay,t.endDelay=u.endDelay,t.duration=u.duration,c.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}fr.version="3.2.0";fr.speed=1;fr.running=Pa;fr.remove=Tse;fr.get=Xw;fr.set=SO;fr.convertPx=Ww;fr.path=vse;fr.setDashoffset=mse;fr.stagger=Pse;fr.timeline=Dse;fr.easing=jw;fr.penner=dO;fr.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var ep=fr,jC=new I,HC=new I,GC=new Rt;function Ise(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let a=1-s*s;if(a<=Number.EPSILON){let c=1-r;return i.w=c*e.w+r*t.w,i.x=c*e.x+r*t.x,i.y=c*e.y+r*t.y,i.z=c*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(a),o=Math.atan2(n,s),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function hs(e,t,i,r,s,a){let n=i[e]!==void 0?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(s.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(s.getVariable(o)??0):o;if(l!==h)return{update:c=>{let u=lt.lerp(l,h,c);a?t[e]=Math.trunc(u):t[e]=u},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function Zw(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(u=>typeof u=="string"?Number(s.getVariable(u)??0):u),c=[...o].map(u=>typeof u=="string"?Number(s.getVariable(u)??0):u);if(!(h.length!==c.length||Zb(h,c)))return{update:u=>{h.forEach((d,p)=>{let f=lt.lerp(d,c[p],u);t[e][p]=a?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],c)}}}function Jg(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function WC(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?Jg(new I,a,s):o.clone(),h=Jg(new I,n,s);if(!l.equals(h))return{update:c=>{o.lerpVectors(l,h,c)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function qC(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function $g(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=!(o instanceof re),h=o instanceof re?o:new re().fromArray(o),c=a?qC(new re,a,s):h.clone(),u=qC(new re,n,s);if(!c.equals(u))return{update:d=>{h.lerpVectors(c,u,d),l&&(t[e]=h.toArray())},start:()=>{h.copy(c),l&&(t[e]=h.toArray())},end:()=>{h.copy(u),l&&(t[e]=h.toArray())}}}function Ose(e,t,i,r){let s=i[e]?i[e]:void 0,a=r[e];if(!a)return;let n=t[e],o=s?new je().fromArray(s):n.clone(),l=new I,h=new Rt,c=new I;o.decompose(l,h,c);let u=new je().fromArray(a),d=new I,p=new Rt,f=new I;if(u.decompose(d,p,f),!o.equals(u))return{update:g=>{GC.slerpQuaternions(h,p,g),jC.lerpVectors(l,d,g),HC.lerpVectors(c,f,g),n.compose(jC,GC,HC)},start:()=>{n.compose(l,h,c)},end:()=>{n.compose(d,p,f)}}}function Rse(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?typeof a=="string"?s.getColor(a).clone():new Ct().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Ct().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:u=>{c.lerpColors(l,h,u),t[e]?.copy?.(c)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function Tm(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=new ms(o.r,o.g,o.b,o.a),h=a?typeof a=="string"?s.getColor(a).clone():new ms(a.r,a.g,a.b,a.a):l.clone(),c=typeof n=="string"?s.getColor(n).clone():new ms(n.r,n.g,n.b,n.a);if(!h.equals(c))return{update:u=>{l.lerpColors(h,c,u);let d=lt.lerp(h.a,c.a,u);l.a=d,t[e]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(c)}}}function Fl(e,t,i,r,s){if(typeof t[e]=="number")return hs(e,t,i??{},r,s);if(Array.isArray(t[e]))return Zw(e,t,i??{},r,s)}function Lse(e,t,i,r){let s=[],a=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let o=a??e.zoom,l=n;o!==l&&s.push({update:h=>{e.zoom=lt.lerp(o,l,h),e.updateProjectionMatrix()},start:()=>{e.zoom=o,e.updateProjectionMatrix()},end:()=>{e.zoom=l,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let o=hs("targetOffset",e,t,i,r);o&&s.push(o)}return s}function Bse(e,t,i,r){if(i.scaleBaked===void 0)return;let s=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o),a=i.scaleBaked.map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o);if(_h.isEqual(s,a))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[lt.lerp(s[0],a[0],o),lt.lerp(s[1],a[1],o),lt.lerp(s[2],a[2],o)]},r),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions()},end:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData(),e.refreshAttachedClonersInteractions()}}),n}function zse(e,t,i,r){if(!i.extrusion)return;let s=e.extrusion,a=t.extrusion??{},n=i.extrusion,o=[];return iD.forEach(l=>{let h=Fl(l,s,a,n,r);h&&o.push(h)}),o}function Fse(e,t,i,r){let s=[];if(!("geometry"in i))return s;let a=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Ap){let l=Bse(e,n,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,Bn(a,Q0),Bn(n,Q0)),Q0.forEach(h=>{let c=Fl(h,l,n,o,r);c&&s.push(c)}),e instanceof Lw){Object.assign(l,{extrusion:{...a.extrusion}});let h=zse(l,n,o,r);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded(),e.refreshAttachedClonersInteractions()}})}return s}function kse(e,t,i,r){let s=[];if(i.intensity!==void 0){let a=hs("intensity",e,t,i,r);a&&s.push(a)}if(i.color!==void 0){let a=Rse("color",e,t,i,r);a&&s.push(a)}return s}function Use(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let a="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=a[l]??{},c=n[l];typeof h=="string"||typeof c=="string"||s.push(...XC(o,h,c,r))})}else{if(!("material"in i&&i.material))return s;let a="material"in t&&t.material?t.material:{},n=i.material;if(typeof a=="string"||typeof n=="string")return s;s.push(...XC(e.material,a,n,r))}return s}function XC(e,t,i,r){let s=[],a=Wc(i,r)||!!t.layers&&Wc(t,r);s.push(Yse(e,a));for(let n of e.layers){let o=t.layers?.data(n.uuid),l=i.layers.data(n.uuid);if(!l||n.type!=="light"&&(!(n.visible??!0)||!(l.visible??!0)))continue;let h=n.getNames().filter(c=>!$P.some(u=>c.includes(u)));for(let c of h)try{let u=n.getValue(c),d;if(c==="colors")d=qse(n,o,l,c);else if(Array.isArray(u))c==="steps"&&(d=Wse(n,o,l,c));else if(typeof u=="number")d=Nse(n,o,l,c,r);else{if(typeof u=="boolean")continue;u instanceof re?d=Vse(n,o,l,c):u instanceof I?d=jse(n,o,l,c,r):u instanceof ms?d=Gse(n,o,l,c,r):u instanceof Ct?d=Hse(n,o,l,c,r):"isTexture"in u&&(d=Xse(n,o,l,c))}d&&(Array.isArray(d)?s.push(...d):s.push(d))}catch(u){console.error(`lerpMaterial: unexpected material layer for ${c}`,u)}}return s}function Nse(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:e.getValue(r),n=i[r],o=typeof a=="string"?Number(s.getVariable(a)??0):a,l=typeof n=="string"?Number(s.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,lt.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function Vse(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),a=t?new re().fromArray(t[r]):s.clone(),n=new re().fromArray(i[r]);if(!a.equals(n))return{update:o=>{s.lerpVectors(a,n,o)},start:()=>{s.copy(a)},end:()=>{s.copy(n)}}}function jse(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?Jg(new I,n,s):a.clone(),h=Jg(new I,o,s);if(!l.equals(h))return{update:c=>{a.lerpVectors(l,h,c)},start:()=>{a.copy(l)},end:()=>{a.copy(h)}}}function Hse(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new Ct().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Ct().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let c=o.clone();return{update:u=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,u)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function Gse(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new Ct().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new ms(n.r,n.g,n.b,n.a);if(l.equals(h))return;let c=o.clone();return{update:u=>{e.getValue(r)!==c&&e.setValue(r,c),c.lerpColors(l,h,u)},start:()=>{c.copy(l)},end:()=>{c.copy(h)}}}function Wse(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a,o=i[r];return Zb(n,o)||s.push({update:l=>{let h=[...a];for(let c=0;c<a.length;++c){let u=n[c],d=o[c];h[c]=lt.lerp(u,d,l)}e.setValue(r,h)},start:()=>{e.setValue(r,n)},end:()=>{e.setValue(r,o)}}),s.length?s:void 0}function qse(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a.map(l=>l.toArray()),o=i[r];for(let l=0;l<a.length;++l){let h=[...n[l]],c=[...o[l]];Sg.isEqual(h,c)||s.push({update:u=>{a[l].fromArray(Sg.lerp(h,c,u))},start:()=>{a[l].fromArray(h)},end:()=>{a[l].fromArray(c)}})}return s.length?s:void 0}function Xse(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("rotation"),a=t?.[r]?.rotation??0,n=i[r]?.rotation??0;if(s&&a!==n)return{update:m=>{s.value=lt.lerp(a,n,m)*lt.DEG2RAD},start:()=>{s.value=a*lt.DEG2RAD},end:()=>{s.value=n*lt.DEG2RAD}};let o=e.getNode("mat");if(!o)return;let l=t?t[r]:o,h=i[r],c=[...l.repeat],u=[...l.offset],d=[...h.repeat],p=[...h.offset],f=l.rotation??0,g=h.rotation??0;if(!Co.isEqual(c,d)||!Co.isEqual(u,p)||f!==g)return{update:m=>{o.repeat=Co.lerp(c,d,m),o.offset=Co.lerp(u,p,m),o.rotation=lt.lerp(f,g,m),o.updateMatrix()},start:()=>{o.repeat=[...c],o.offset=[...u],o.rotation=f,o.updateMatrix()},end:()=>{o.repeat=[...d],o.offset=[...p],o.rotation=g,o.updateMatrix()}}}function Yse(e,t){return{update:()=>{e.transparent=t}}}var W1=new I,YC=new Fr;function Qse(e,t,i,r,s){let a=[],n,o,l,h,c,u,d,p;if(e instanceof ts?(n=$g("position",e,t,i,s),n&&a.push(n),l=hs("rotation",e,t,i,s),l&&a.push(l),h=$g("shear",e,t,i,s),h&&a.push(h)):(p={slide:t.pathSnapping?.slide??e.updatedPathSnapping?.slide??e.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??e.updatedPathSnapping?.offset??e.dataPatched.pathSnapping?.offset??0},u=hs("slide",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),u&&a.push(u),d=hs("offset",p,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),d&&a.push(d),!u&&!d&&(n=WC("position",e,t,i,s),n&&a.push(n),o=WC("scale",e,t,i,s),o&&a.push(o),l=Zse(e,t,i,r,s),l&&a.push(l),c=Ose("hiddenMatrix",e,t,i),c&&a.push(c))),n||o||l||c||u||d){let f=e instanceof ts?()=>{e.updateWorldMatrix(!0,!1,!0),e.resetBBoxNeedsUpdate()}:()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Ya(e)&&Po(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,p))};a.push({update:f,start:f,end:f})}return a}function Zse(e,t,i,r,s){let a=t?.rotation?t.rotation.map(c=>(typeof c=="string"?Number(s.getVariable(c)??0):c)*lt.DEG2RAD):void 0,n=i.rotation?.map(c=>(typeof c=="string"?Number(s.getVariable(c)??0):c)*lt.DEG2RAD);if(!n)return;let o=a?new I().fromArray(a):new I().setFromEuler(e.rotation),l=new I().fromArray(n);if(o.equals(l))return;let h=W1.subVectors(l,o);if(r&&h.toArray().every(c=>Math.abs(c)<2*Math.PI)){let c=new Rt().setFromEuler(YC.setFromVector3(o)),u=new Rt().setFromEuler(YC.setFromVector3(l));return{update:d=>{Ise(c,u,e.quaternion,d)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:c=>{W1.lerpVectors(o,l,c),e.rotation.setFromVector3(W1)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function Kse(e,t,i,r){let s=[];if(!("cloner"in i)||!e.cloner)return s;let a=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;XP.forEach(p=>{let f;p==="count"?f=hs("count",a.parameters,n,o,r,!0):f=Fl(p,a.parameters,n??{},o,r),f&&s.push(f)});let l=Jse(a,n,o,r);l?.length&&s.push(...l);let h=$se(a,n,o,r);h?.length&&s.push(...h);let c=eae(a,n,o,r);c?.length&&s.push(...c);let u=tae(a,n,o,r);u?.length&&s.push(...u);let d=iae(a,n,o,r);return d?.length&&s.push(...d),s.length&&s.push({update:()=>{a.update()}}),s}function Jse(e,t,i,r){if(e.parameters.type!=="radial")return;let s=t.radial,a=i.radial;if(!a)return;let n=e.parameters.radial,o=[];return YP.forEach(l=>{let h=Fl(l,n,s??{},a,r);h&&o.push(h)}),o}function $se(e,t,i,r){if(e.parameters.type!=="linear")return;let s=t.linear,a=i.linear;if(!a)return;let n=[],o=e.parameters.linear;return QP.forEach(l=>{let h=Fl(l,o,s??{},a,r);h&&n.push(h)}),n}function eae(e,t,i,r){if(e.parameters.type!=="grid")return;let s=t.grid,a=i.grid;if(!a)return;let n=[],o=e.parameters.grid;return ZP.forEach(l=>{let h;l==="count"?h=Zw(l,o,s??{},a,r,!0):h=Fl(l,o,s??{},a,r),h&&n.push(h)}),n}function tae(e,t,i,r){if(e.parameters.type!=="toObject")return;let s=t.toObject,a=i.toObject;if(!a)return;let n=[],o=e.parameters.toObject;return KP.forEach(l=>{let h;l==="count"?h=hs(l,o,s??{},a,r,!0):h=Fl(l,o,s??{},a,r),h&&n.push(h)}),n}function iae(e,t,i,r){if(!e.parameters.randomness)return;let s=t.randomnessObject,a=i.randomnessObject;if(!a)return;let n=[],o=e.parameters.randomnessObject;return JP.forEach(l=>{let h=Fl(l,o,s??{},a,r);h&&n.push(h)}),n}function rae(e,t){return{update:()=>{e instanceof Zr&&(e.fill.enabled=t)}}}function sae(e,t){return{update:()=>{e instanceof Zr&&(e.stroke.enabled=t)}}}function aae(e,t){return{update:()=>{e instanceof Zr&&(e.dropShadow.enabled=t)}}}function nae(e,t){return{update:()=>{e instanceof Zr&&(e.innerShadow.enabled=t)}}}function oae(e,t){return{update:()=>{e instanceof Zr&&(e.backgroundBlur.enabled=t)}}}function lae(e,t){return{update:()=>{e instanceof Zr&&(e.layerBlur.enabled=t)}}}function hae(e,t,i,r,s){let a=[],n,o,l,h,c,u,d,p,f,g,m,y,x,b,_;if("width"in e&&(n=hs("width",e,t,i,s),n&&a.push(n)),"height"in e&&(o=hs("height",e,t,i,s),o&&a.push(o)),e instanceof Zr||e instanceof Fn){let M={...t.fill},S={...i.fill};M.enabled!==void 0&&M.enabled!==S.enabled&&(a.push(rae(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}})),l=Tm("color",e.fill,M,S,s),l&&a.push(l)}if(e instanceof Zr){let M={...t.stroke},S={...i.stroke};(M.enabled||S.enabled)&&(a.push(sae(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}})),h=Tm("color",e.stroke,M,S,s),h&&a.push(h),c=hs("thickness",e.stroke,M,S,s),c&&a.push(c)}if(e instanceof Zr){let M={...t.dropShadow},S={...i.dropShadow};(M.enabled||S.enabled)&&(a.push(aae(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}})),u=Tm("color",e.dropShadow,M,S,s),u&&a.push(u),d=hs("blurRadius",e.dropShadow,M,S,s),d&&a.push(d),f=hs("spread",e.dropShadow,M,S,s),f&&a.push(f),p=$g("offset",e.dropShadow,M,S,s),p&&a.push(p)}if(e instanceof Zr){let M={...t.innerShadow},S={...i.innerShadow};(M.enabled||S.enabled)&&(a.push(nae(e,!0)),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}}),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}})),g=Tm("color",e.innerShadow,M,S,s),g&&a.push(g),m=hs("blurRadius",e.innerShadow,M,S,s),m&&a.push(m),x=hs("spread",e.innerShadow,M,S,s),x&&a.push(x),y=$g("offset",e.innerShadow,M,S,s),y&&a.push(y)}if(e instanceof Zr||e instanceof Fn){let M={...t.backgroundBlur},S={...i.backgroundBlur};(M.enabled||S.enabled)&&(a.push(oae(e,!0)),M.enabled||Object.assign(M,{enabled:!0,radius:0}),S.enabled||Object.assign(S,{enabled:!0,radius:0})),b=hs("radius",e.backgroundBlur,M,S,s),b&&a.push(b)}if(e instanceof Zr){let M={...t.layerBlur},S={...i.layerBlur};(M.enabled||S.enabled)&&(a.push(lae(e,!0)),M.enabled||Object.assign(M,{enabled:!0,radius:0}),S.enabled||Object.assign(S,{enabled:!0,radius:0})),_=hs("radius",e.layerBlur,M,S,s),_&&a.push(_)}if(e instanceof Fn||e instanceof Np){let M=Zw("cornerRadius",e,t,i,s);M&&a.push(M)}return a}function QC(e,t,i,r,s){let a=[];return e.data.visible&&a.push(...Qse(e,t,i,s,r)),e instanceof ts?a.push(...hae(e,t,i,s,r)):(e.data.visible&&a.push(...Kse(e,t,i,r)),Ya(e)?(e instanceof Ar&&e.data.visible&&a.push(...Fse(e,t,i,r)),e.data.visible&&a.push(...Use(e,t,i,r))):Q$(e)?e.data.visible&&a.push(...kse(e,t,i,r)):Y$(e)&&a.push(...Lse(e,t,i,r))),a.length?{update:n=>{a.forEach(o=>o.update(n))},start:n=>{a.forEach(o=>o.start?.(n))},end:n=>{a.forEach(o=>o.end?.(n))}}:void 0}var ZC=new I;function Kw(e,t,i=!1){let r=[],s=a=>{let n=a.data;delete a.states,a.currentState=null,a.reversibleToState=null,a.currentTransitionEvent=null;for(let o of n.states){let l={...o.data};a.states||(a.states={}),a.states[o.id]=fh.patch(n,l)}JC(e.scene,a,null,t,n.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),KC(e)};e.scene.traverse2D(s),e.traverseChildren(a=>{if(i&&(a.rigidBody?.setTranslation(a.position0,!0),a.rigidBody?.setRotation(a.rotation0,!0),a.rigidBody?.setLinvel(ZC,!0),a.rigidBody?.setAngvel(ZC,!0)),!ni.is(a))return;let n=a.uuid,o=a.data;if(delete a.states,a.uuid===Ru)return;let l=!1;r.some(h=>e.scene.find(n)?.isDescendantOf(h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&r.push(n),a.data=o,a.currentState=null,a.reversibleToState=null,a.currentTransitionEvent=null;for(let h of o.states){let c={...h.data};e.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete c.position,h.data.rotation!==void 0&&delete c.rotation,h.data.hiddenMatrix!==void 0&&delete c.hiddenMatrix),a.states||(a.states={}),a.states[h.id]=uh.patch(o,c)}JC(e.scene,a,null,t,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),a instanceof ws&&a.frame&&(a.frame.traverse(h=>s(h)),a.uiCanvas?.applySize())}),KC(e),e.frame&&(e.frame.traverse(a=>s(a)),e.uiCanvas?.applySize())}function KC(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let a=e.scene.find(s.data.object);a&&(a.visible=!1)}}})}function JC(e,t,i,r,s=!1){if(t instanceof Ar&&!(t instanceof Rh)&&t.removeInteractionGeometry(r),t instanceof ts?t.changeSelectedState(i,{shared:r},s):t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Ar&&t.updateGeometryGroupsIfNeeded(),t instanceof Ss&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),!(t instanceof ts)){if(t.cloner)for(let a of t.cloner.children)a.playModeVisible=void 0;t.updateVisible()}}function MO(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
8141
8141
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
8142
- )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=ll.linear;break;case 1:i=ll.ease;break;case 2:i=ll.easeIn;break;case 3:i=ll.easeOut;break;case 4:i=ll.easeInOut;break;default:i=ll.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function cb(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var cae={type:"beginState"},uae={type:"completeState",isfromEntity:!1},ub=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,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.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 n=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=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object instanceof ts||this.object.traverseEntity(o=>{o!==this.object&&o instanceof Ss&&o.dispatchEvent(cae)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=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=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object instanceof ts||this.object.traverseEntity(o=>{o!==this.object&&o instanceof Ss&&o.dispatchEvent(uae)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=QC(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=Ym(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=Ym(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=Ym(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...cb(r),...MO(r),change:this.onChange},this.callback=QC(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},EO=class extends gs{constructor(e,t,i,r,s){if(super(),this.eventType=e,this.data=t,this.page=i,this.shared=r,this.condition=s,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.hasPlayedOnce=!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,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!t.object)throw new Error("Missing property");let a=this.page.scene.find(t.object)??this.page.uiCanvas?.find(t.object)??this.page.scene.find2DInUIObjects(t.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=t.tweens[0].data.delayDirection==="start-once"?t.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Ym(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&ZA(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=cb(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=ep.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(a=>a?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let a=s===-1?0:s;for(let n=a;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Ss&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n]=c,this.timeline.add(c.params,this.timeline.duration+(n===a?r.delay:0))}this.timeline.duration+=r.endDelay}else{let a=s===-1?this.data.tweens.length-1:s+1;for(let n=a;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Ss&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n-1]=c,this.timeline.add(c.params,this.timeline.duration+(n===a?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Vi(this.shared,this.condition)===!1||ZA(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;clearTimeout(this.timeoutId);let e=cb(this.data.tweens[0].data).pingPongDelayCorrection;ep({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}}})}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 instanceof ts?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(Vi(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(Vi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):ep({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Ym(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var dae={type:"beginState"},$C={type:"completeState",isfromEntity:!1},e3={type:"requestRender"},CO=class extends gs{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new I,this.posEnd=new I,this.qStart=new Rt,this.qEnd=new Rt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=ep({targets:i,t:1,...MO(this.data),update:()=>{i.t===0&&(this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(dae));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(e3),i.t===1&&r.dispatchEvent($C)}})}switchCamera(e){let t=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Vi(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(Vi(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.animation?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent($C),this.page.activeCamera.dispatchEvent(e3))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function TO(e){let t=e?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(t?.length){let i=Bq(t);return i&&i>2?i:2}return 2}var PO=class extends gs{constructor(e,t,i,r,s){super(),this.data=e,this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];if(this.duration=o?.getClip()?.duration??1,this.data.crop2){let l=TO(o?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=o?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Vi(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=lt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(Vi(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},DO=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target||t.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),Kw(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},IO=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Vi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=OD(this.data.expression,this.shared,ps.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},OO=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(Vi(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}},pae=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let t=this.shared.data.variables.data(e)?.value;t!==void 0&&this.shared.updateVariable(e,t),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(Hx(e))})}dispose(){}},fae=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;this.data.userAPIId&&this.shared.getUserAPI(this.data.userAPIId)?.callUserAPI(this.shared)}dispose(){}};function Vi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=OD(t.expression,e,"boolean");return t.negate?!i:!!i}function Cr(e,t,i,r,s,a){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?ys[e.type].includes("Audio")&&n.Audio.push(new aO(h,c,a,r,l)):c.type==="Video"&&!(a instanceof ts)?ys[e.type].includes("Video")&&n.Video.push(new LO(h,c,a,r,l)):c.type==="Particles"?ys[e.type].includes("Particles")&&n.Particles.push(new nO(c,i,r,l)):c.type==="Link"?ys[e.type].includes("Link")&&n.Link.push(new tse(c,s.controlsManager,r,l)):c.type==="Create"?ys[e.type].includes("Create")&&n.Create.push(new BO(c,i,s.controlsManager,r,l)):c.type==="Destroy"?ys[e.type].includes("Destroy")&&n.Destroy.push(new oO(c,i,s.controlsManager,r,l)):c.type==="Reset"?ys[e.type].includes("Reset")&&n.Reset.push(new lO(c,i,r,s,l)):c.type==="Transition"?ys[e.type].includes("Transition")&&n.Transition.push(new EO(e.type,c,i,r,l)):c.type==="SwitchCamera"?ys[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new CO(c,i,r,l)):c.type==="SceneTransition"?ys[e.type].includes("SceneTransition")&&n.SceneTransition.push(new DO(c,i,s,r,l)):c.type==="Animation"?ys[e.type].includes("Animation")&&n.Animation.push(new PO(c,i,s.animationControls,r,l)):c.type==="SetVariable"?ys[e.type].includes("SetVariable")&&n.SetVariable.push(new IO(c,i,r,l)):c.type==="DynamicVariablePlay"?ys[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new OO(c,i,r,l)):c.type==="Conditional"?ys[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0}))):c.type==="ClearLocalStorage"?ys[e.type].includes("ClearLocalStorage")&&n.ClearLocalStorage.push(new pae(c,i,r,l)):c.type==="UserAPI"&&ys[e.type].includes("UserAPI")&&n.UserAPI.push(new fae(c,i,r,l))}catch{}};return t.forEach(o()),n}function es(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof aO||i instanceof LO||i instanceof nO||i instanceof PO||i instanceof EO||i instanceof BO||i instanceof oO||i instanceof CO||i instanceof DO||i instanceof lO||i instanceof IO||i instanceof OO)&&i.dispose()})})}function mae(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var RO=new Map,tp=new Map,Sl=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=mae(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,Iu&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),tp.has(i.uuid)?tp.get(i.uuid).push(this):tp.set(i.uuid,[this]),RO.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(e){return new Promise((t,i)=>{if(!this.videoElement)return i();let r=this.videoElement.duration;if(r>0){let s=e%r;this.videoElement.currentTime=s}this.videoElement.addEventListener("seeked",()=>t(),{once:!0})})}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)}},db=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=RO.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=tp.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...tp.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},LO=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new Sl(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new db(t);else throw new Error("Missing property")}dispatchBasic(){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Sl?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Sl?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},t3=(()=>{let e,t,i,r;function s(o){!e&&!i3()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,u=h.length,d=0;for(;d<u;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&c[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(c[p.userData.actionId]>p.userData.quantity&&c[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),u--,r())}e=d>0?requestAnimationFrame(a):void 0,i=d>0?o:void 0}function n(){i3()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function i3(){return!!document&&document.hidden}var r3=new Rt,gae=new I,vae=new I,BO=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=lt.generateUUID(),this.dispatch=()=>{if(Vi(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(Vi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=$q(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=()=>{this.timeoutIdQueue.shift();let n=new fs(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.scale.copy(this.object.scale),n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),t3(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Ea)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof fs)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Ea)return;n instanceof fs?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new I().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(gae,r3,vae),l.applyQuaternion(r3),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");t3(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},zO=200,q1=.02,X1=.3,yae=65,Ile=new I,s3=new I,a3=new I,xae=new I,Os=new I,js=new I,sl=new I,Y1=new je,n3=new je,bae=new je,Ole=new je,Ga=new Rt,oo=new Rt,bn=new Fr(0,0,0,"YXZ"),wae=new I(1,0,0),Wa=new I(0,1,0),_ae=new I(0,0,1),o3=new I(1,1,1),Rle=new Ks,Sae=1,Aae=.025,Mae=16e-6,l3=12,Eae=20,qr=new Ta,ya=new mr,Cae={type:"requestRender"},Tae={type:"updateMatrix"},h3=Math.PI/6,pb=class extends gs{constructor(e,t,i,r,s,a,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new je,this.target0=new I,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=zO,this.euler0=new Fr(0,0,0,"YXZ"),this.position0Cam=new I,this.quat0Cam=new Rt,this.scale0Cam=new I,this.hiddenMatrix0Cam=new je,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Ta(new I(0,-40,0),new I(0,40,0)),matrix:new je,position:new I,rotation:new Rt},this.euler=new Fr(0,0,0,"YXZ"),this.eulerDelta=new I,this.lastPosition=new I,this.lastCameraQuaternion=new Rt,this.lastCameraPosition=new I,this.PI_2=Math.PI/2,this.prevMouse=new re,this.velocityTarget=new I,this.velocity=new I,this.directionXZ=new I,this.rotVelocityStick=new I,this.rotVelocityTarget=new I,this.rotVelocity=new I,this.rotDirection=new I,this.nonColliderRotOffset=new je,this.nonColliderPosOffset=new je,this.firstPointerId=-1,this.rot=new I,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new je,this.objectToTarget=new I,this.objectToTarget0=new I,this.objectToCamXZ=new I,this.objectToCamXZ0=new I,this.targetToCamera=new I,this.targetToCamera0=new I,this.cameraPolarAxis0=new I,this.targetPos=new I,this.targetQuat=new Rt,this.lerpFactorPos=new I().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Rt,this.objXZQuatInv=new Rt,this.objXZRotMat=new je,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new I,this.pushedVelocity=new I,this.groundYRotation=0,this.objectRealQuat=new Rt,this.colliderWorldQuat=new Rt,this.groundNormal=new I,this.groundTilt=new Rt,this.groundTiltInv=new Rt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new I,this.quaternion=new Rt,this.scale=new I,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!ra&&!BA&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(BA&&pX<15.5&&!ra?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?pb.isLocked=!0:pb.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let y=f.axes[m];g===0?m===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(y)>=.3&&(this.vrEulerYOffset+=y<0?1:-1),this.movementState.rotPosY=y):this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new I(0,0,-1).applyQuaternion(this.camera.quaternion),g=new I().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let m,y;Math.abs(f.y)<1e-6?(g.y=0,f.y=0,y=g.projectOnVector(f)):g.y/f.y>0?y=f.multiplyScalar(g.y/f.y):y=f.multiplyScalar(g.length()),this.targetToCamera0.copy(y).negate(),m=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(m,this.position);let x=new Fr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof Ss&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*Sae,this.speedOrbit=(i.speedRotate??100)*Aae,this.mouseOrbitSensitivity=(i.speedRotate??100)*Mae,this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??fu.defaultData.gravity)*l3,this.usePhysics=this.gloabalPhysics.usePhysics??fu.defaultData.usePhysics,this.jumpPower=i.jumpPower*Eae,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Rg.defaultDataThirdPerson.orientWith,this.slopeThresh=yae*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*q1/this.pixelsPerMeter,this.stepThresh=i.collider.height*X1/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*q1/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*X1/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*q1/this.pixelsPerMeter,this.stepThresh=i.collider.height*X1/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let u=new I().fromArray(i.collider.position),d=new Rt().setFromEuler(new Fr().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(u).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(u,d,o3),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new yt;f.push({fi:0,data:{...Yr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Yr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=new _w({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new zi(uD.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new Fr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Ss?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Og.list.forEach(i=>{this.actions[i]=Cr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),es(this.actions.idle),es(this.actions.move),es(this.actions.run),es(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Os.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let o=js.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*l3),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(c.rigidBody===h&&c.userData.isFollowingObj!==this.object.uuid){(c.hasNonUniformScale?c.matrixWorldRigid:c.matrixWorld).decompose(Os,oo,js),this.groundVelocity.subVectors(Os,c.prevT),this.object.getWorldPosition(js).add(this.collider.position).sub(Os),this.groundYRotation=bn.setFromQuaternion(oo).y-c.prevR.y,sl.copy(js).applyAxisAngle(Wa,this.groundYRotation),this.groundVelocity.add(sl.sub(js)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Os.subVectors(this.path[1],this.position),h=js.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=xae.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=js.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let o=Os;this.camera.getWorldDirection(o);let l=sl.copy(Wa).multiplyScalar(o.dot(Wa));o.sub(l);let h=js.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(bn.setFromVector3(this.rot),this.moveMode==="walk"&&(bn.x=0),n.applyEuler(bn),a&&(oo.setFromUnitVectors(Wa,this.groundNormal),n.applyQuaternion(oo)),i){let o=bn.set(0,this.vrEulerYOffset*h3,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=js;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=sl.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),c=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Os.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let u=ni.is(l)?l:l.object;if(c!==null&&this.lastHitObj!==u){let d;l instanceof fs&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),u.dispatchEvent(mb));this.lastHitObj=u}if(c!==null){this.pushedVelocity.copy(h),o.copy(c.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Wa,this.euler.y-this.euler0.y);let o=js.copy(this.objectToCamXZ).normalize(),l=sl.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(Os.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=lt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=lt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=lt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(bn.copy(t),bn.y=0):(bn.copy(this.euler),bn.y=0),this.nonColliderRotOffset.makeRotationFromEuler(bn)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*h3),Ga.setFromAxisAngle(wae,this.rot.x),oo.setFromAxisAngle(Wa,this.rot.y),oo.multiply(Ga),Ga.setFromAxisAngle(_ae,this.rot.z),oo.multiply(Ga),this.quaternion.copy(oo),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=js.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new I;for(let c=0;c<5;c++){let u=o.length(),d=sl.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,u,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&c===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let x of y)if(x.data.target==="character"){let b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,_;if(p.cloner){for(let M of p.cloner.children)if(M.rigidBody===b){_=M;break}}x.dispatch(_),p.dispatchEvent(mb)}}}let f=s3.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=a3.copy(d).multiplyScalar(l.toi).dot(f),m=l.toi;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=l.toi*(g-this.offset)/g,h.addScaledVector(d,m)),o.copy(d).multiplyScalar(u-m),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=sl.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);x.y=0;let b=y.add(x);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{c===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Os.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Ga.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);Y1.lookAt(l,o,Wa).setPosition(l),Y1.decompose(this.targetPos,this.targetQuat,Os),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=lt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=lt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(Tae),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Cae),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ga.setFromAxisAngle(Wa,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?lt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=lt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=lt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Os.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=oo.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Wa.angleTo(e)*180/Math.PI<15||Wa.angleTo(e)*180/Math.PI>85?Ga.identity():Ga.setFromUnitVectors(Wa,e),this.groundTilt.slerp(Ga,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=a3.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Y1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Os,Ga,js).compose(Os,Ga,o3);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;ya.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=n3.copy(a).invert(),o=bae.copy(n3).multiply(i);qr.copy(this.collider.segment),qr.start.applyMatrix4(o),qr.end.applyMatrix4(o);let l=s3.copy(this.position).applyMatrix4(n);ya.expandByPoint(qr.start),ya.expandByPoint(qr.end),ya.min.addScalar(-this.collider.radius),ya.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(qr.end)},intersectsBounds:h=>h.intersectsBox(ya),intersectsTriangle:h=>{let c=Os,u=js,d=h.closestPointToSegment(qr,c,u);if(d<this.collider.radius){let p=this.collider.radius-d,f=u.sub(c).normalize(),g=sl.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(a).sub(this.position);t.add(m),qr.start.addScaledVector(f,p),qr.end.addScaledVector(f,p)}}})}),ya.makeEmpty(),qr.copy(this.collider.segment),qr.start.applyMatrix4(i),qr.end.applyMatrix4(i),ya.expandByPoint(qr.start),ya.expandByPoint(qr.end),ya.min.addScalar(-this.collider.radius),ya.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(qr.end)},intersectsBounds:s=>s.intersectsBox(ya),intersectsTriangle:s=>{let a=Os,n=js,o=s.closestPointToSegment(qr,a,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),qr.start.addScaledVector(h,l),qr.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},FO=pb;FO.isLocked=!1;var Pae=Ll(I3());function kO(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,s=t[8]**2+t[9]**2+t[10]**2,a=t[0]**2+t[4]**2+t[8]**2,n=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||s<l||a<l||n<l||o<l}function xo(e,t){let i=new gt;if(t&&kO(t))return i.setAttribute("position",new at([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new at([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=_v(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new at(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var Dae=new je,Iae=new je,wn=[[0,0,0],[0,0,0],[0,0,0]];function UO(e){let t=e.elements;wn[0][0]=t[0],wn[0][1]=t[4],wn[0][2]=t[8],wn[1][0]=t[1],wn[1][1]=t[5],wn[1][2]=t[9],wn[2][0]=t[2],wn[2][1]=t[6],wn[2][2]=t[10];let{u:i,v:r}=(0,Pae.SVD)(wn),s=Dae.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),a=Iae.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(a.transpose())}var Oae=class extends AT{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new zl({color:65280,linewidth:10}),t=new I(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new I(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new I().addVectors(t,i.multiplyScalar(r)),a=new gt;return a.setFromPoints([t,s]),new ig(a,e)}},NO=e=>e instanceof ru||e instanceof su;function Rae(e,t){return e.distance-t.distance}function VO(e,t,i){if(!(!yo(t)||!t.visible)){Ya(t)&&t.raycast(e,i);for(let r of t.children)VO(e,r,i)}}function Qm(e,t,i,r=!1){if(!r&&!i.some(a=>ev(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>VO(e,a,s)),s.sort(Rae),s}function fb(e){let t=[];if(e.length){let i=e[0].object;yo(i)&&t.push(i);let r=i.parent;for(;r;)NO(r)&&t.push(r),r=r.parent}return t}function bo(e,t,i,r){let s=e.frame;if(s){let a=t[0]*s.width,n=(1-t[1])*s.height;for(let o of i){let l=o===s.uuid?s:s.find(o);if(l?.intersects(a,n))return r(l),!0}}return!1}function ev(e,t){if(Ya(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(NO(t))return jO(e,t)}function jO(e,t){if(!(!yo(t)||!t.visible)){if(Ya(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=jO(e,i);if(r)return r}}}function Lae(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Bae(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var zae=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new Oae,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=Lae(t,i,this._domRect),this.pointerScreen=Bae(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},Ms=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},Jw=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],HO=e=>Jw.find(([t,i])=>i===e)?.[0],Vp=e=>Jw.find(([t])=>t===e)?.[1],Fae=(e,t)=>{let i=HO(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},kae=class extends Ms{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let t=this.splineEvents[HO(e.eventName)]?.[e.target.uuid];if(!t)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(t,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(t)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(t=>{if(t.data?.events.length){for(let[i,r]of Jw)if(t.data.events.some(s=>s.data.type===r&&!s.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(t):this.objectsPerEvents.set(i,[t]);let s={id:t.uuid,name:t.name},a=Fae(r,s),n=this.splineEvents[i];n?n[t.uuid]=a:this.splineEvents[i]={[t.uuid]:a}}}}),this.objectsPerEvents.forEach(t=>{t.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Uae=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Cr(t,t.actions,r,s,a,i)}disconnect(){es(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.SwitchCamera.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},Nae=class extends Ms{constructor(e,t,i){super(e),this.eventManager=t,this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=Qm(s,a,[],!0);this.sceneInterects=n,n.length&&(this.eventContext.sharedAssets.raycastProperty={x:n[0].point.x,y:n[0].point.y,z:n[0].point.z,objX:n[0].object.matrixWorld.elements[12],objY:n[0].object.matrixWorld.elements[13],objZ:n[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{(s.data.type==="MouseDown"||s.data.type==="MousePress")&&(this.onCanvasRaycast(r),s.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{s.data.type==="MouseUp"?(this.onCanvasRaycast(r),s.dispatch()):s.data.type==="MousePress"&&s.dispatchRelease()})},this.onMouseDown=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:s,reverse:a})=>{if(!r||!s)return;let n=Vp(r);n&&(n==="MouseDown"||n==="MouseUp"||n==="MousePress"?(s.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent(a)})):(n==="KeyDown"||n==="KeyUp"||n==="KeyPress")&&(s.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext,r=(s,a)=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];if(s.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:c})=>{try{let u=new Uae(h,c,s,e,t,this.eventManager);u.actions.Video.length&&(this.hasVideoAction=!0),(c.type==="MouseDown"||c.type==="MouseUp"||c.type==="MousePress")&&(c.mode==="Canvas"||c.mode==="Window")?this.canvasMouseEvents.push(u):(l[s.uuid]?l[s.uuid].some(d=>d.id===u.id)||l[s.uuid].push(u):l[s.uuid]=[u],s instanceof Rh&&s.traverseChildren(d=>{if(!d.visible)return!0;d instanceof Ar&&d.data.geometry.shapeBlendNode?.operation!==2&&(l[d.uuid]?l[d.uuid].push(u):l[d.uuid]=[u])}))}catch{}}),l[s.uuid]?.length&&(this.objectsPerTypes[o].push(s instanceof ts&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress")?a:s),s instanceof Rh)){let h=this.objectsPerTypes[o];s.traverseChildren(c=>{if(!c.visible)return!0;c instanceof Ar&&h.indexOf(c)===-1&&h.push(c)})}}};e.traverseEntity(s=>{(s instanceof ws||s instanceof Qr)&&s.frame?.traverse(a=>{r(a,s)}),r(s)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.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(([s,a])=>{a.forEach(n=>{n.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:s}=this.eventContext,a=this.objectsPerTypes[e],n=a.filter(o=>!(o instanceof ts));if(!(!a.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&bo(r,[s.x,s.y],Object.keys(this.eventsPerObjects[e]),o=>{this.handleObjectMouseEventDispatch(o,e)}))){if(t||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=Qm(i,r,n,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),t){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];fb(o).forEach(h=>{h instanceof ws&&bo(h,l,Object.keys(this.eventsPerObjects[e]),c=>{this.handleObjectMouseEventDispatch(c,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=ev(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof ws&&bo(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(a=>!(a instanceof ts)),s=[];if(i.length){if(!e){let{stopRaycast:a,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=bo(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{s.push(c)})),a&&!h){let c=Qm(n,o,r);s=fb(c),c.forEach(u=>{u.object instanceof ws&&bo(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{s.push(d)})})}else r.forEach(c=>{let u=ev(n,c);u&&(s.push(c),c instanceof ws&&bo(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{s.push(d)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{s.includes(a)||this.handleObjectMouseEventDispatchRelease(a,t)}),s.length&&s.forEach(a=>{this.handleObjectMouseEventDispatch(a,t)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},Vae=new I,jae=new I,GO=class{constructor(e,t,i,r,s){this.actionsIn=Cr(e,e.inActions,i,r,s,t),this.actionsOut=Cr(e,e.outActions,i,r,s,t)}disconnect(){es(this.actionsIn),es(this.actionsOut)}},Hae=class extends GO{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let h=Vae.setFromMatrixPosition(this.objects[0].matrixWorld),c=jae.setFromMatrixPosition(this.objects[1].matrixWorld),u=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==u){this.stage=u;let d=u==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Particles.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch()),d.ClearLocalStorage.forEach(p=>p.dispatch()),d.UserAPI.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},Gae=class extends GO{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(c=>c.dispatchConditional()),this.actionsOut.Particles.forEach(c=>c.dispatchConditional()),this.actionsOut.Video.forEach(c=>c.dispatchConditional()),this.actionsOut.Link.forEach(c=>c.dispatch()),this.actionsOut.Create.forEach(c=>c.dispatch()),this.actionsOut.Destroy.forEach(c=>c.dispatch()),this.actionsOut.Reset.forEach(c=>c.dispatch()),this.actionsIn.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(c=>c.play()),this.actionsOut.Animation.forEach(c=>c.play()),this.actionsIn.SwitchCamera.forEach(c=>c.pause()),this.actionsOut.SwitchCamera.forEach(c=>c.play()),this.actionsOut.SceneTransition.forEach(c=>c.dispatch()),this.actionsOut.SetVariable.forEach(c=>c.checkConditions()),this.actionsOut.SetVariable.forEach(c=>c.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(c=>c.dispatchConditional()),this.actionsIn.Particles.forEach(c=>c.dispatchConditional()),this.actionsIn.Video.forEach(c=>c.dispatchConditional()),this.actionsIn.Link.forEach(c=>c.dispatch()),this.actionsIn.Create.forEach(c=>c.dispatch()),this.actionsIn.Destroy.forEach(c=>c.dispatch()),this.actionsIn.Reset.forEach(c=>c.dispatch()),this.actionsOut.Transition.forEach(c=>c.pause()),this.actionsOut.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(c=>c.play()),this.actionsIn.Animation.forEach(c=>c.play()),this.actionsOut.SwitchCamera.forEach(c=>c.pause()),this.actionsIn.SwitchCamera.forEach(c=>c.play()),this.actionsIn.SceneTransition.forEach(c=>c.dispatch()),this.actionsIn.SetVariable.forEach(c=>c.checkConditions()),this.actionsIn.SetVariable.forEach(c=>c.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){ch(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),ch(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),ch(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),ch(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Wae=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:t}=this.eventContext;e.traverseEntity(i=>{if(i.data?.events.length){for(let{id:r,data:s}of i.data.events)if(!s.disabled&&s.type==="Conditional")try{let a;s.condition.type==="Comparison"||(s.condition.type==="Distance"?a=new Hae(r,s,i,e,t,this.eventManager):s.condition.type==="State"&&(a=new Gae(r,s,i,e,t,this.eventManager))),a&&(this.eventsPerConditions[s.condition.type].push(a),(a.actionsIn.Video.length||a.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ad=new I,al=new I,Zl=new I,c3=new Gs,qae=.01,xi=new I,Br=new I,u3=new I,vh=new Rt,Q1=new Fr,Xae=new je,Z1=new Sr,Cc=new I,_n=new I,Tc=.2;function K1(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Yae=function(){let e=new je;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&K1(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?K1(s.position,t.limits):t.reference==="local"&&(vh.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(vh),K1(s.position,t.limits),vh.invert(),s.position.applyQuaternion(vh),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(xi,s.quaternion,Br),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Ns&&Po(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),Qae=class{constructor(e,t,i,r,s,a,n){this.object=e,this.id=t,this.data=i,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=Cr(i,i.dragDropActions.drag,r,s,a,this.object),this.actionsDrop=Cr(i,i.dragDropActions.drop,r,s,a,this.object);let o=[];this.data.objects.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(o.push(h),n[h.uuid]&&n[h.uuid].forEach(c=>{let u=r.find(c);!u||u.data.visible!==!1&&o.push(u)}))}),this.data.dropDestinations.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(this.dropDestIds.push(h.uuid),n[h.uuid]&&n[h.uuid].forEach(c=>{let u=r.find(c);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new I().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new I().setFromMatrixPosition(l.matrixWorld),pointStart:new I,pointEnd:new I,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new I().copy(l.position),quat0:new Rt().copy(l.quaternion),snapped:!1,orientationMatrix:new je,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){es(this.actionsDrag),es(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Zae=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=i=>{if(It.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:s}=this.eventContext,a=s.raycastWithClones(r);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let n of this.events){let o=0;for(let{obj:l,pointEnd:h,pointStart:c}of n.dragItems){if(l===a[0].object||l===a[0].object.object||ni.is(l)&&l.isAncestorOf(a[0].object.uuid)){if(n.activeIdx=o,n.activeDragItem.reset=!1,n.activeDragItem.currentDampingFactor=n.data.dampingFactor,n.activeDragItem.snapped=!1,n.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){n.activeDragItem.obj.rigidBody&&n.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=n.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(xi,vh,Br),Q1.setFromQuaternion(vh),u.prevR===void 0?(u.prevR=Q1.clone(),u.prevT=xi.clone()):(u.prevR.copy(Q1),u.prevT.copy(xi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(n.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,n.data.plane,n.data.referenceFrame),h.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||n.data.drop===!1||n.data.resetOnSnapFail===!1)&&n.activeDragItem.fromPosition.setFromMatrixPosition(n.activeDragItem.obj.matrixWorld),this.activeEvent=n,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}o++}}this.activeEvent=null},this.onPointerMove=i=>{if(It.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:s}=this.eventContext,a=s.raycastWithClones(r);if(It.length===0){let n=!1;for(let o of this.events){for(let{obj:l}of o.dragItems)if(l===a[0]?.object||l===a[0]?.object?.object||ni.is(l)&&l.isAncestorOf(a[0]?.object.uuid)){switch(n=!0,o.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(n)break}n||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let n=this.activeEvent.activeDragItem;n.snapped=!1;let o;if(this.activeEvent.data.drop&&(o=a.filter(l=>n.obj!==l.object&&!n.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ru)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(h=>h===l.object.uuid||s.scene.find(h).isAncestorOf(l.object.uuid))))[0]),o){let l=u3.copy(o.face.normal).applyMatrix3(Z1.getNormalMatrix(o.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")n.fromPosition.setFromMatrixPosition(o.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(n.fromPosition.copy(o.point),this.activeEvent.data.snapSurfaceMode==="bbox"){xi.copy(l).applyMatrix3(Z1.setFromMatrix4(n.obj.matrixWorld).transpose());let h=n.obj;xi.x>Tc?Br.x=-h.recursiveBBox.min.x:xi.x<-Tc&&(Br.x=-h.recursiveBBox.max.x),xi.y>Tc?Br.y=-h.recursiveBBox.min.y:xi.y<-Tc&&(Br.y=-h.recursiveBBox.max.y),xi.z>Tc?Br.z=-h.recursiveBBox.min.z:xi.z<-Tc&&(Br.z=-h.recursiveBBox.max.z),Br.applyMatrix3(Z1.invert())}else Br.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);n.fromPosition.add(Br)}this.activeEvent.data.autoOrient&&(xi.set(0,1,0).cross(l),xi.length()<1e-4&&xi.set(-1,0,0).cross(l),Br.crossVectors(u3,xi),n.orientationMatrix.makeBasis(xi,Br,l)),n.pointStart.copy(n.fromPosition),n.pointEnd.copy(n.pointStart),n.currentDampingFactor=this.activeEvent.snapDampingFactor,n.snapped=!0,this.lastDropDestination!==o.object&&(this.lastDropDestination=o.object,this.activeEvent.actionsDrop.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(h=>{h.dispatchThrottled()}))}else n.orientationMatrix.makeRotationFromQuaternion(n.quat0),this.lastDropDestination=null,n.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(n.obj,n.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.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.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.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(n),n.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.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(s=>{s.stop(),s.object.currentState!==null&&s.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(s=>{s.stop()}),this.activeEvent.actionsDrag.Audio.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(s=>s.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let e={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(e[i.component.uuid]?e[i.component.uuid].push(i.uuid):e[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(r=>r.data.type==="DragDrop"&&!r.data.disabled).forEach(r=>{this.events.push(new Qae(i,r.id,r.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let t=this.eventContext.domElement;t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(al),al.negate();let n=vh.identity();switch(r==="parent"?Xae.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(xi,n,Br):r==="local"&&e.matrixWorld.decompose(xi,n,Br),i){case"x":xi.set(1,0,0).applyQuaternion(n),Cc.copy(al).cross(xi),_n.copy(xi).cross(Cc);break;case"y":xi.set(0,1,0).applyQuaternion(n),Cc.copy(al).cross(xi),_n.copy(xi).cross(Cc);break;case"z":xi.set(0,0,1).applyQuaternion(n),Cc.copy(al).cross(xi),_n.copy(xi).cross(Cc);break;case"xy":_n.set(0,0,1).applyQuaternion(n);break;case"yz":_n.set(1,0,0).applyQuaternion(n);break;case"xz":_n.set(0,1,0).applyQuaternion(n);break;case"adaptive":al.angleTo(Br.set(0,1,0))>Math.PI/6?(xi.crossVectors(Br.set(0,1,0),al),_n.crossVectors(xi,Br)):_n.set(0,1,0);break;default:_n.copy(al);break}Zl.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Zl;if(c3.setFromNormalAndCoplanarPoint(_n,o),!!a.ray.intersectPlane(c3,t)&&(i==="x"||i==="y"||i==="z")){let l=Br.subVectors(t,o).dot(xi);t.copy(o).addScaledVector(xi,l)}}updateDragItem(e,t=!1){Zl.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ad.subVectors(e.fromPosition,Zl).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ad.subVectors(e.obj.userData.worldPosition0,Zl).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ad.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Zl).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ad.length()<qae:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Yae(e,Ad.add(Zl),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Pc=new I,J1=new I,lo=new I,ho=new I,d3=new Gs,Kae=.01,Jae={type:"requestRender"},$ae=function(){let e=new I,t=new I;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),p3=function(){let e=new je;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Ns&&Po(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),ene=class{constructor(e,t,i,r,s,a){this.data=e,this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new I,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...jy.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Cr(e,e.actions,r,s,a,i)}},tne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(It.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new ene(s.data,s.id,r,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ra&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,a=this.onTargetChange(r);this.pairOfEventListeners.push([s,a]),s.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ra&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,es(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(lo),e.isReset)ho.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ho);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(J1),J1.negate(),Pc.copy(J1)):i==="xy"?Pc.set(0,0,1):i==="xz"?Pc.set(0,1,0):i==="yz"&&Pc.set(1,0,0),d3.setFromNormalAndCoplanarPoint(Pc,lo),!o.ray.intersectPlane(d3,ho))return}if(!e.isReset){if(ho.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ho.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&&(ho.x=lo.x),e.data.enabledTranslation[1]===!1&&(ho.y=lo.y),e.data.enabledTranslation[2]===!1&&(ho.z=lo.z);let a=$ae(lo,ho,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=Pc.subVectors(a,lo).divideScalar(e.currentDampingFactor);lo.add(n),t&&p3(e.object,lo),e.paused=n.length()<Kae}else p3(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(Jae)}},Md=new I,Pm=new I,Ed=new je,Dc=new Rt,nl=new Rt,Cd=new I,Td=new I,Kl=new I,co=new I,$1=new Gs,ine=1e-6,rne={type:"requestRender"},sne={type:"changeRotation"},f3=function(){let e=new je;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(UO(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Ns&&Po(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),ane=class{constructor(e,t,i,r){this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new Rt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Hy.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},nne=class extends Ms{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=e=>{if(!(It.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let t of this.events)t.target===void 0&&this.updateSingleEvent(t)}},this.onMouseEnter=e=>{for(let t of this.events)t.target===void 0&&(t.isReset=!1,t.currentDampingFactor=t.data.dampingFactor)},this.onMouseLeave=e=>{for(let t of this.events)t.target===void 0&&(t.data.resetOnPointerLeave&&(t.isReset=!0,t.currentDampingFactor=t.resetDampingFactor),this.updateSingleEvent(t))},this.onScroll=e=>{if(this._lastMouseEvent){let t=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(t)}},this.onTargetChange=e=>()=>{this.updateSingleEvent(e)},this.createUserEventListener=e=>({eventName:t,target:i})=>{if(!t||!i)return;let r=Vp(t);r&&r==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);s&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new ane(s.data,s.id,r,e))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ra&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let n=this.onTargetChange(r),o=r.target;this.pairOfEventListeners.push([o,n]),o.addEventListener("requestRender",n)}let s=this.createUserEventListener(r),a=r.object;this.pairOfUserEventListeners.push([a,s]),a.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ra&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:u}=e;if(c.getWorldPosition(Cd),!e.isReset)if(e.target)e.target.getWorldPosition(Td);else{if(s==="custom"?(l().getWorldDirection(Pm),Pm.negate(),$1.setFromNormalAndCoplanarPoint(Pm,Cd)):(s==="xy"?Md.set(0,0,1):s==="xz"?Md.set(0,1,0):s==="yz"&&Md.set(1,0,0),$1.setFromNormalAndCoplanarPoint(Md,Cd)),!h.ray.intersectPlane($1,Td))return;r>0&&(s==="custom"||s===void 0)&&Td.addScaledVector(Pm,r)}if(e.isReset||(u?t==="target"?Kl.copy(u.up).applyMatrix4(Ed.extractRotation(u.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(co.set(0,0,1),n[2]===!1&&co.set(0,1,0)):i==="y"?(co.set(1,0,0),n[0]===!1&&co.set(0,0,1)):(co.set(0,1,0),n[1]===!1&&co.set(1,0,0)),Kl.copy(co).applyQuaternion(e.worldQuaternion0).normalize()):Kl.set(0,1,0):s==="custom"?Kl.set(0,1,0):Kl.copy(Md)),e.isReset)nl.copy(e.worldQuaternion0);else if(Cd.distanceTo(Td)>a&&o&&u)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)nl.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;one(Ed,Td,Cd,Kl,i,co),nl.setFromRotationMatrix(Ed),Dc.setFromUnitVectors(co.applyQuaternion(nl),Kl),n.some(d=>d===!1)&&t!=="target"&&nl.premultiply(Dc).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Dc.setFromRotationMatrix(UO(c.matrixWorld)),Dc.slerp(nl,1/e.currentDampingFactor),f3(c,Ed.makeRotationFromQuaternion(Dc)),e.paused=8*(1-Dc.dot(nl))<ine):(f3(c,Ed.makeRotationFromQuaternion(nl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(rne),c.dispatchEvent(sne)}},xa=new I,Lr=new I,dr=new I;function one(e,t,i,r,s,a){let n=e.elements;dr.subVectors(t,i),dr.lengthSq()===0&&(dr.z=1),dr.normalize(),Lr.crossVectors(r,dr),Lr.lengthSq()===0&&(Math.abs(r.z)===1?dr.x+=1e-4:dr.z+=1e-4,dr.normalize(),Lr.crossVectors(r,dr)),Lr.normalize(),xa.crossVectors(dr,Lr),s==="x"?a.z===1?[Lr,xa,dr]=[dr,Lr,xa]:(Lr.negate(),[Lr,dr]=[dr,Lr]):s==="y"?a.x===1?[Lr,xa,dr]=[xa,dr,Lr]:(Lr.negate(),[xa,dr]=[dr,xa]):a.x===1&&(Lr.negate(),[Lr,xa]=[xa,Lr]),n[0]=Lr.x,n[4]=xa.x,n[8]=dr.x,n[1]=Lr.y,n[5]=xa.y,n[9]=dr.y,n[2]=Lr.z,n[6]=xa.z,n[10]=dr.z}var lne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Cr(t,t.actions,r,s,a,i)}disconnect(){es(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatchStart()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Create.forEach(e=>e.dispatchStop()),this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},hne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{It.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{It.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{It.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Vp(i);a&&a==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(n=>n.dispatchUserEvent(s)))}}connect(){let{page:e,sharedAssets:t}=this.eventContext,i=(s,a)=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:o}of s.data.events)if(!o.disabled&&o.type==="MouseHover")try{let l=new lne(n,o,s,e,t,this.eventManager);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(l):this.eventsPerObjects[s.uuid]=[l]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s instanceof ts?a:s)}};if(e.traverseEntity(s=>{(s instanceof ws||s instanceof Qr)&&s.frame?.traverse(a=>{i(a,s)}),i(s)}),!this.objects.length)return;let{domElement:r}=this.eventContext;this.domEventsNeeded.clear(),ra&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),r.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(s=>{s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),ra&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s,pointerScreen:a}=this.eventContext,n=!1;if(s.uiCanvas&&(n=bo(s,[a.x,a.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=Qm(r,s,this.objects);t=fb(o),o.forEach(l=>{l.object instanceof ws&&bo(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)})})}else this.objects.forEach(o=>{let l=ev(r,o);l&&(t.push(o),o instanceof ws&&bo(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},cne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Cr(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){es(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch()),this.actions.ClearLocalStorage.forEach(r=>r.dispatch()),this.actions.UserAPI.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},une=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Cr(t,t.actions,r,s,n,i)}getStickyParentElement(){let e=this.domElement;for(;e;){if(window.getComputedStyle(e).position==="sticky")return e;e=e.parentElement}return null}computeScrollBounds(){let e=this.getStickyParentElement(),t=e?.parentElement,i=this.domElement.getBoundingClientRect(),r={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(t){let h=t.getBoundingClientRect(),c=window.getComputedStyle(e),u=parseFloat(c.marginTop)+parseFloat(c.marginBottom),d=parseFloat(c.top),p=parseFloat(c.bottom),f=h.height-u;if(!isNaN(d))i.top===d?(r.top+=h.top-d,r.bottom+=h.top-d):i.top<0&&(r.top-=f-i.height,r.bottom-=f-i.height);else if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,m=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===g-p?(r.top+=h.top-i.height+p+m,r.bottom+=h.top-i.height+p+m):i.bottom<g-p&&(r.top-=f-i.height,r.bottom-=f-i.height)}}let s=document.body,a=document.documentElement,n=window.pageYOffset||a.scrollTop||s.scrollTop,o=a.clientTop||s.clientTop||0,l=Math.round(r.top+n-o);if(this.data.startFrom==="enter"){let h=window.innerHeight,c=r.height,u=this.data.enterAnchor,d=u==="top"?h:u==="bottom"?h-c:h-c*.5;this.scrollStart=l-d}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=r,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){es(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},dne=class extends Ms{constructor(e,t){super(e),this.managers=t,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>s.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),a.forEach(n=>n.dispatch(r))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),s.forEach(a=>a.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Vp(i);a&&a==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r}=this.eventContext,s=a=>{if(a.data?.events.length){for(let{id:n,data:o}of a.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger==="load"||!r){let l=new cne(n,o,a,e,t,this.managers);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(l):this.wheelEventsPerObject.set(a,[l])}else{let l=new une(n,o,a,e,t,i,this.managers);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(l):this.scrollEventsPerObject.set(a,[l])}}};e.traverseEntity(a=>{(a instanceof ws||a instanceof Qr)&&a.frame?.traverse(n=>{s(n)}),s(a)}),this.intersectionObserver=new IntersectionObserver(a=>{let n=a[0];n&&(this.isInview=n.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([a,n])=>{n.forEach(o=>o.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([a,n])=>{n.forEach(o=>o.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},pne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}disconnect(){es(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof gh?t.interaction.audioPlayer.play():t.interaction instanceof ob&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Sl?t.interaction.play(i==="autoplay"):t.interaction instanceof db&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}async seekVideos(e){let t=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&i.interaction instanceof Sl&&t.push(i.interaction.seek(e))}),await Promise.all(t)}pauseVideos(){this.actions.Video.forEach(e=>{e.interaction instanceof Sl&&e.interaction.pause()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof gh?t.interaction.audioPlayer.play():t.interaction instanceof ob&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Sl?t.interaction.play():t.interaction instanceof db&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},fne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.removeEventListener("pointerdown",this.onAny),s.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof gh&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof Sl&&a.interaction.play(n==="autoplay")}),s.actions.Particles.forEach(a=>{a.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{a.forEach(n=>{r.push(n.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>{s.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Vp(i);a&&a==="Start"&&(r instanceof ts||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:s,data:a}of r.data.events){if(a.disabled||a.type!=="Start")continue;let n=new pne(s,a,r,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length||n.actions.Reset.length||n.actions.SetVariable.length||n.actions.DynamicVariablePlay.length||n.actions.ClearLocalStorage.length||n.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}};if(t.traverseEntity(r=>{(r instanceof ws||r instanceof Qr)&&r.frame?.traverse(s=>{i(s)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,a=s?document:r;a.addEventListener("pointerdown",this.onMouseDown,{once:!0}),a.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),a.addEventListener("pointerdown",this.onAny),a.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(a=>a.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},mne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=Cr(t,t.actions,r,s,a,i),this.target=t.target}disconnect(){es(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},gne=class extends Ms{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=a=>{let n=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],h=[];for(let d=0;d<this.propertiesToWatch.length;d++){let{objectId:p,property:f,prevValue:g}=this.propertiesToWatch[d],m=this.eventContext.scene.find(p),y=Wy.propertyPaths[f];if(y[0]==="width"||y[0]==="height"||y[0]==="depth")m=m.geometry.userData.parameters[y[0]];else for(let x=0;x<y.length;x++)m=m[y[x]];g===null?this.propertiesToWatch[d].prevValue=m instanceof I?m.clone():m:(m instanceof I?!m.equals(g):g!==m)&&(h.push({objId:p,property:f}),m instanceof I?this.propertiesToWatch[d].prevValue.copy(m):this.propertiesToWatch[d].prevValue=m)}for(let d=0;d<this.variablesToWatch.length;d++){let{id:p,prevValue:f}=this.variablesToWatch[d],g=n.getVariable(p);g!==f&&(l.push(p),this.variablesToWatch[d].prevValue=g)}for(let d=0;d<this.dynamicVars.length;d++){let{id:p,expectedTime:f,last:g,data:m,timerSeconds:y,startValue:x}=this.dynamicVars[d],b=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?b=1:m.dynamicVariableType==="counter"?b=m.updateInterval:m.dynamicVariableType==="random"&&(b=m.isStatic?1/0:m.updateInterval),f===-1){this.dynamicVars[d].last=a,this.dynamicVars[d].expectedTime=a+b;continue}if(!((n.getDynamicVariablePlayState(p)==="Stopped"||n.getDynamicVariablePlayState(p)==="Restarted")&&(this.dynamicVars[d].last=a,this.dynamicVars[d].expectedTime=a+b,m.dynamicVariableType==="counter"&&n.getVariable(p)!==x&&(n.updateVariable(p,x),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[d].timerSeconds!==x&&(this.dynamicVars[d].timerSeconds=x,n.updateVariable(p,Sa.getFormattedTimerTime(x,m)),this.eventManager.requestRender()),n.getDynamicVariablePlayState(p)==="Restarted"&&n.setDynamicVariablePlayState(p,"Playing"),n.getDynamicVariablePlayState(p)==="Stopped"))){if(n.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[d].deltaToExpectedTime===void 0&&(this.dynamicVars[d].deltaToExpectedTime=Math.max(this.dynamicVars[d].expectedTime-a,0)),this.dynamicVars[d].last=a-(b-this.dynamicVars[d].deltaToExpectedTime),this.dynamicVars[d].expectedTime=a+this.dynamicVars[d].deltaToExpectedTime;continue}else this.dynamicVars[d].deltaToExpectedTime=void 0;if(a>=f)if(this.dynamicVars[d].last=a,this.dynamicVars[d].expectedTime+=b,m.dynamicVariableType==="random"){let _=m.min+Math.random()*(m.max-m.min),M=m.decimals;_=Math.round(_*Math.pow(10,M))/Math.pow(10,M),n.updateVariable(p,_),l.push(p),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){let _=n.getVariable(p),M=n.getDynamicVariableToggleIsForward(p)??!0,S=n.getVariable(p)+m.increment*(M?1:-1);m.hasEnd&&(S=m.increment>0?lt.clamp(S,x,m.endValue):lt.clamp(S,m.endValue,x),S===x&&n.setDynamicVariableToggleIsForward(p,void 0),m.repeat?S===m.endValue&&(S=x):(S===x||S===m.endValue)&&n.setDynamicVariablePlayState(p,"Paused")),S!==_&&(l.push(p),n.updateVariable(p,S),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time"){let _=n.getVariable(p),M=TE(o,m);if(typeof _=="object"&&"textValue"in _&&typeof M=="object"&&"textValue"in M){if(Array.isArray(_.textValue)&&Array.isArray(M.textValue)){if(_.textValue.every((S,E)=>S===M.textValue[E]))continue}else if(_.textValue===M.textValue)continue}else if(_===M)continue;n.updateVariable(p,M),l.push(p),this.eventManager.requestRender()}else{let _=ps.isTextValue(m.endValue)?m3(m.endValue.textValue):m.endValue,M=n.getDynamicVariableToggleIsForward(p)??!0,S=y+(a-g)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(M?1:-1);S=Math.max(S,0),m.hasEnd&&(S=m.dynamicVariableType==="stopwatch"?lt.clamp(S,x,_):lt.clamp(S,_,x),S===x&&n.setDynamicVariableToggleIsForward(p,void 0),m.repeat?Math.abs(S-_)<(m.format==="number3decimal"?1e-4:.1)&&(S=x):(Math.abs(S-x)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(S-_)<(m.format==="number3decimal"?1e-4:.1))&&n.setDynamicVariablePlayState(p,"Paused")),S!==y&&(l.push(p),this.dynamicVars[d].timerSeconds=S,n.updateVariable(p,Sa.getFormattedTimerTime(S,m)),this.eventManager.requestRender())}}}let c=!1;n.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=n.mouseProperty,c=!0);let u=!1;n.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=n.raycastProperty,u=!0),this.events.forEach(d=>{(l.includes(d.data.variableId)||h.find(p=>p.objId===d.data.objectId&&p.property===d.data.property)||d.data.variableId==="mouseProperty"&&c||d.data.variableId==="raycastProperty"&&u)&&(d.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new vne(i.id,i.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(t=>t.data.variableId==="objectProperty"&&t.data.objectId!==null).map(t=>({objectId:t.data.objectId,property:t.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:t,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(s=>s.data.variableId===t)&&this.variablesToWatch.push({id:t,prevValue:e.getVariable(t)});return}let r;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let s;if(ps.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let a=i.value.textValue;a.length===3?s=a[2]+a[1]*60+a[0]*3600:s=a[1]+a[0]*60}else s=i.value;r=s,this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,timerSeconds:s,startValue:r})}else i.dynamicVariableType==="time"&&e.updateVariable(t,TE(new Date,i)),i.dynamicVariableType==="counter"&&(r=ps.isTextValue(i.value)?m3(i.value.textValue):i.value),this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,startValue:r})}),this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},vne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispose(){es(this.actions)}};function m3(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var yne="https://unpkg.com/@splinetool/runtime@1.10.54/build/",xne="https://unpkg.com/@splinetool/navmesh-wasm@1.10.54/build/",bne=`
8142
+ )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=ll.linear;break;case 1:i=ll.ease;break;case 2:i=ll.easeIn;break;case 3:i=ll.easeOut;break;case 4:i=ll.easeInOut;break;default:i=ll.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function cb(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var cae={type:"beginState"},uae={type:"completeState",isfromEntity:!1},ub=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,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.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 n=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=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object instanceof ts||this.object.traverseEntity(o=>{o!==this.object&&o instanceof Ss&&o.dispatchEvent(cae)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=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=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object instanceof ts||this.object.traverseEntity(o=>{o!==this.object&&o instanceof Ss&&o.dispatchEvent(uae)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=QC(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=Ym(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=Ym(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=Ym(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...cb(r),...MO(r),change:this.onChange},this.callback=QC(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},EO=class extends gs{constructor(e,t,i,r,s){if(super(),this.eventType=e,this.data=t,this.page=i,this.shared=r,this.condition=s,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.hasPlayedOnce=!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,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!t.object)throw new Error("Missing property");let a=this.page.scene.find(t.object)??this.page.uiCanvas?.find(t.object)??this.page.scene.find2DInUIObjects(t.object);if(!a)throw new Error("Missing property");if(!a.states)throw new Error("Missing property");if(this.object=a,t.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=t.tweens[0].data.delayDirection==="start-once"?t.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=Ym(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.data.runMode==="Toggle"&&ZA(this.eventType)?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=cb(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=ep.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(a=>a?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let a=s===-1?0:s;for(let n=a;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Ss&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n]=c,this.timeline.add(c.params,this.timeline.duration+(n===a?r.delay:0))}this.timeline.duration+=r.endDelay}else{let a=s===-1?this.data.tweens.length-1:s+1;for(let n=a;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Ss&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let c=new ub(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(c.params,{startOnceDelay:0}),this.tweens[n-1]=c,this.timeline.add(c.params,this.timeline.duration+(n===a?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Vi(this.shared,this.condition)===!1||ZA(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce||(this.hasPlayedOnce=!0,this.playing))return!1;clearTimeout(this.timeoutId);let e=cb(this.data.tweens[0].data).pingPongDelayCorrection;ep({targets:{},duration:this.startOnceDelay+e,easing:"linear",complete:()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}}})}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 instanceof ts?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(Vi(this.shared,this.condition)===!1)return!1;this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(Vi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):ep({targets:{},duration:this.startOnceDelay,easing:"linear",complete:()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()}})}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function Ym(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var dae={type:"beginState"},$C={type:"completeState",isfromEntity:!1},e3={type:"requestRender"},CO=class extends gs{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.posStart=new I,this.posEnd=new I,this.qStart=new Rt,this.qEnd=new Rt,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=ep({targets:i,t:1,...MO(this.data),update:()=>{i.t===0&&(this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(dae));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(e3),i.t===1&&r.dispatchEvent($C)}})}switchCamera(e){let t=this.page.activeCamera,i=this.page.scene.find(e);if(!i||!i.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(i),t.dispatchEvent({type:"cameraChange",camera:i})}play(){if(Vi(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(Vi(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.animation?.pause(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent($C),this.page.activeCamera.dispatchEvent(e3))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};function TO(e){let t=e?.tracks.filter(i=>i.ValueTypeName==="vector"||i.ValueTypeName==="quaternion").map(i=>i.times.length);if(t?.length){let i=Bq(t);return i&&i>2?i:2}return 2}var PO=class extends gs{constructor(e,t,i,r,s){super(),this.data=e,this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];if(this.duration=o?.getClip()?.duration??1,this.data.crop2){let l=TO(o?.getClip());this.leftFrameTime=this.data.crop2[0]/(l-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(l-1)*this.duration}else{let l=o?.getClip()?.tracks[0]?.times.length;l&&l>1?(this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Vi(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=lt.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(Vi(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},DO=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target||t.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{t.type==="ParticleSystem"&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),Kw(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},IO=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Vi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=OD(this.data.expression,this.shared,ps.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},OO=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(Vi(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}},pae=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let t=this.shared.data.variables.data(e)?.value;t!==void 0&&this.shared.updateVariable(e,t),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(Hx(e))})}dispose(){}},fae=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r}dispatch(){if(Vi(this.shared,this.condition)===!1)return!1;this.data.userAPIId&&this.shared.getUserAPI(this.data.userAPIId)?.callUserAPI(this.shared)}dispose(){}};function Vi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=OD(t.expression,e,"boolean");return t.negate?!i:!!i}function Cr(e,t,i,r,s,a){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},o=l=>({id:h,data:c})=>{try{c.type==="Audio"?ys[e.type].includes("Audio")&&n.Audio.push(new aO(h,c,a,r,l)):c.type==="Video"&&!(a instanceof ts)?ys[e.type].includes("Video")&&n.Video.push(new LO(h,c,a,r,l)):c.type==="Particles"?ys[e.type].includes("Particles")&&n.Particles.push(new nO(c,i,r,l)):c.type==="Link"?ys[e.type].includes("Link")&&n.Link.push(new tse(c,s.controlsManager,r,l)):c.type==="Create"?ys[e.type].includes("Create")&&n.Create.push(new BO(c,i,s.controlsManager,r,l)):c.type==="Destroy"?ys[e.type].includes("Destroy")&&n.Destroy.push(new oO(c,i,s.controlsManager,r,l)):c.type==="Reset"?ys[e.type].includes("Reset")&&n.Reset.push(new lO(c,i,r,s,l)):c.type==="Transition"?ys[e.type].includes("Transition")&&n.Transition.push(new EO(e.type,c,i,r,l)):c.type==="SwitchCamera"?ys[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new CO(c,i,r,l)):c.type==="SceneTransition"?ys[e.type].includes("SceneTransition")&&n.SceneTransition.push(new DO(c,i,s,r,l)):c.type==="Animation"?ys[e.type].includes("Animation")&&n.Animation.push(new PO(c,i,s.animationControls,r,l)):c.type==="SetVariable"?ys[e.type].includes("SetVariable")&&n.SetVariable.push(new IO(c,i,r,l)):c.type==="DynamicVariablePlay"?ys[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new OO(c,i,r,l)):c.type==="Conditional"?ys[e.type].includes("Conditional")&&(c.ifActions.forEach(o({expression:c.condition,negate:!1})),c.elseActions.forEach(o({expression:c.condition,negate:!0}))):c.type==="ClearLocalStorage"?ys[e.type].includes("ClearLocalStorage")&&n.ClearLocalStorage.push(new pae(c,i,r,l)):c.type==="UserAPI"&&ys[e.type].includes("UserAPI")&&n.UserAPI.push(new fae(c,i,r,l))}catch{}};return t.forEach(o()),n}function es(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof aO||i instanceof LO||i instanceof nO||i instanceof PO||i instanceof EO||i instanceof BO||i instanceof oO||i instanceof CO||i instanceof DO||i instanceof lO||i instanceof IO||i instanceof OO)&&i.dispose()})})}function mae(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var RO=new Map,tp=new Map,Sl=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=mae(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,Iu&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),tp.has(i.uuid)?tp.get(i.uuid).push(this):tp.set(i.uuid,[this]),RO.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}seek(e){return new Promise((t,i)=>{if(!this.videoElement)return i();let r=this.videoElement.duration;if(r>0){let s=e%r;this.videoElement.currentTime=s}this.videoElement.addEventListener("seeked",()=>t(),{once:!0})})}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)}},db=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=RO.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=tp.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...tp.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},LO=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new Sl(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new db(t);else throw new Error("Missing property")}dispatchBasic(){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Sl?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Vi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Sl?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},t3=(()=>{let e,t,i,r;function s(o){!e&&!i3()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,c=t.sharedGameControlGlobals.nCreatedPerAction,u=h.length,d=0;for(;d<u;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&c[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(c[p.userData.actionId]>p.userData.quantity&&c[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),u--,r())}e=d>0?requestAnimationFrame(a):void 0,i=d>0?o:void 0}function n(){i3()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function i3(){return!!document&&document.hidden}var r3=new Rt,gae=new I,vae=new I,BO=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=lt.generateUUID(),this.dispatch=()=>{if(Vi(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(Vi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=$q(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=()=>{this.timeoutIdQueue.shift();let n=new fs(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.scale.copy(this.object.scale),n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),t3(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Ea)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof fs)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Ea)return;n instanceof fs?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new I().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(gae,r3,vae),l.applyQuaternion(r3),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(c=>c!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");t3(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},zO=200,q1=.02,X1=.3,yae=65,Ile=new I,s3=new I,a3=new I,xae=new I,Os=new I,js=new I,sl=new I,Y1=new je,n3=new je,bae=new je,Ole=new je,Ga=new Rt,oo=new Rt,bn=new Fr(0,0,0,"YXZ"),wae=new I(1,0,0),Wa=new I(0,1,0),_ae=new I(0,0,1),o3=new I(1,1,1),Rle=new Ks,Sae=1,Aae=.025,Mae=16e-6,l3=12,Eae=20,qr=new Ta,ya=new mr,Cae={type:"requestRender"},Tae={type:"updateMatrix"},h3=Math.PI/6,pb=class extends gs{constructor(e,t,i,r,s,a,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new je,this.target0=new I,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=zO,this.euler0=new Fr(0,0,0,"YXZ"),this.position0Cam=new I,this.quat0Cam=new Rt,this.scale0Cam=new I,this.hiddenMatrix0Cam=new je,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Ta(new I(0,-40,0),new I(0,40,0)),matrix:new je,position:new I,rotation:new Rt},this.euler=new Fr(0,0,0,"YXZ"),this.eulerDelta=new I,this.lastPosition=new I,this.lastCameraQuaternion=new Rt,this.lastCameraPosition=new I,this.PI_2=Math.PI/2,this.prevMouse=new re,this.velocityTarget=new I,this.velocity=new I,this.directionXZ=new I,this.rotVelocityStick=new I,this.rotVelocityTarget=new I,this.rotVelocity=new I,this.rotDirection=new I,this.nonColliderRotOffset=new je,this.nonColliderPosOffset=new je,this.firstPointerId=-1,this.rot=new I,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new je,this.objectToTarget=new I,this.objectToTarget0=new I,this.objectToCamXZ=new I,this.objectToCamXZ0=new I,this.targetToCamera=new I,this.targetToCamera0=new I,this.cameraPolarAxis0=new I,this.targetPos=new I,this.targetQuat=new Rt,this.lerpFactorPos=new I().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new Rt,this.objXZQuatInv=new Rt,this.objXZRotMat=new je,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new I,this.pushedVelocity=new I,this.groundYRotation=0,this.objectRealQuat=new Rt,this.colliderWorldQuat=new Rt,this.groundNormal=new I,this.groundTilt=new Rt,this.groundTiltInv=new Rt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new I,this.quaternion=new Rt,this.scale=new I,this.initialAction=!0,this.onPointerDown=f=>{!(f.target===this.domElement||f.target instanceof HTMLElement&&f.target.tagName==="SPLINE-VIEWER"&&f.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!ra&&!BA&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(BA&&pX<15.5&&!ra?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?pb.isLocked=!0:pb.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let y=f.axes[m];g===0?m===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(y)>=.3&&(this.vrEulerYOffset+=y<0?1:-1),this.movementState.rotPosY=y):this.moveMode==="fly"&&(this.movementState.moveNegY=y))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),c=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,c,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new I(0,0,-1).applyQuaternion(this.camera.quaternion),g=new I().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let m,y;Math.abs(f.y)<1e-6?(g.y=0,f.y=0,y=g.projectOnVector(f)):g.y/f.y>0?y=f.multiplyScalar(g.y/f.y):y=f.multiplyScalar(g.length()),this.targetToCamera0.copy(y).negate(),m=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(m,this.position);let x=new Fr().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-x.x,x.x=0,x.z=0,x.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(x)}if(this.object instanceof Ss&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*Sae,this.speedOrbit=(i.speedRotate??100)*Aae,this.mouseOrbitSensitivity=(i.speedRotate??100)*Mae,this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??fu.defaultData.gravity)*l3,this.usePhysics=this.gloabalPhysics.usePhysics??fu.defaultData.usePhysics,this.jumpPower=i.jumpPower*Eae,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Rg.defaultDataThirdPerson.orientWith,this.slopeThresh=yae*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*q1/this.pixelsPerMeter,this.stepThresh=i.collider.height*X1/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*q1/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*X1/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*q1/this.pixelsPerMeter,this.stepThresh=i.collider.height*X1/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let u=new I().fromArray(i.collider.position),d=new Rt().setFromEuler(new Fr().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(u).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(u,d,o3),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new yt;f.push({fi:0,data:{...Yr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Yr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=new _w({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new zi(uD.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new Fr().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Ss?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Og.list.forEach(i=>{this.actions[i]=Cr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),es(this.actions.idle),es(this.actions.move),es(this.actions.run),es(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Os.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let o=js.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*l3),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let c of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(c.rigidBody===h&&c.userData.isFollowingObj!==this.object.uuid){(c.hasNonUniformScale?c.matrixWorldRigid:c.matrixWorld).decompose(Os,oo,js),this.groundVelocity.subVectors(Os,c.prevT),this.object.getWorldPosition(js).add(this.collider.position).sub(Os),this.groundYRotation=bn.setFromQuaternion(oo).y-c.prevR.y,sl.copy(js).applyAxisAngle(Wa,this.groundYRotation),this.groundVelocity.add(sl.sub(js)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Os.subVectors(this.path[1],this.position),h=js.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=xae.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=js.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let o=Os;this.camera.getWorldDirection(o);let l=sl.copy(Wa).multiplyScalar(o.dot(Wa));o.sub(l);let h=js.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(bn.setFromVector3(this.rot),this.moveMode==="walk"&&(bn.x=0),n.applyEuler(bn),a&&(oo.setFromUnitVectors(Wa,this.groundNormal),n.applyQuaternion(oo)),i){let o=bn.set(0,this.vrEulerYOffset*h3,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=js;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=sl.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),c=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Os.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let u=ni.is(l)?l:l.object;if(c!==null&&this.lastHitObj!==u){let d;l instanceof fs&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[u.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),u.dispatchEvent(mb));this.lastHitObj=u}if(c!==null){this.pushedVelocity.copy(h),o.copy(c.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Wa,this.euler.y-this.euler0.y);let o=js.copy(this.objectToCamXZ).normalize(),l=sl.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(Os.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=lt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=lt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=lt.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(bn.copy(t),bn.y=0):(bn.copy(this.euler),bn.y=0),this.nonColliderRotOffset.makeRotationFromEuler(bn)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*h3),Ga.setFromAxisAngle(wae,this.rot.x),oo.setFromAxisAngle(Wa,this.rot.y),oo.multiply(Ga),Ga.setFromAxisAngle(_ae,this.rot.z),oo.multiply(Ga),this.quaternion.copy(oo),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=js.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new I;for(let c=0;c<5;c++){let u=o.length(),d=sl.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,u,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&c===0){this.lastHitObj=p;let y=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(y){for(let x of y)if(x.data.target==="character"){let b=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,_;if(p.cloner){for(let M of p.cloner.children)if(M.rigidBody===b){_=M;break}}x.dispatch(_),p.dispatchEvent(mb)}}}let f=s3.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=a3.copy(d).multiplyScalar(l.toi).dot(f),m=l.toi;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=l.toi*(g-this.offset)/g,h.addScaledVector(d,m)),o.copy(d).multiplyScalar(u-m),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=sl.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);x.y=0;let b=y.add(x);b.y+=this.stepThresh;let _=this.sharedGameControlGlobals.rapierWorld.castShape(b,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);_!==null&&_.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{c===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Os.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Ga.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);Y1.lookAt(l,o,Wa).setPosition(l),Y1.decompose(this.targetPos,this.targetQuat,Os),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=lt.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=lt.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(Tae),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Cae),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ga.setFromAxisAngle(Wa,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?lt.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=lt.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=lt.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Os.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=oo.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Wa.angleTo(e)*180/Math.PI<15||Wa.angleTo(e)*180/Math.PI>85?Ga.identity():Ga.setFromUnitVectors(Wa,e),this.groundTilt.slerp(Ga,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=a3.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Y1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Os,Ga,js).compose(Os,Ga,o3);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;ya.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=n3.copy(a).invert(),o=bae.copy(n3).multiply(i);qr.copy(this.collider.segment),qr.start.applyMatrix4(o),qr.end.applyMatrix4(o);let l=s3.copy(this.position).applyMatrix4(n);ya.expandByPoint(qr.start),ya.expandByPoint(qr.end),ya.min.addScalar(-this.collider.radius),ya.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(qr.end)},intersectsBounds:h=>h.intersectsBox(ya),intersectsTriangle:h=>{let c=Os,u=js,d=h.closestPointToSegment(qr,c,u);if(d<this.collider.radius){let p=this.collider.radius-d,f=u.sub(c).normalize(),g=sl.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(a).sub(this.position);t.add(m),qr.start.addScaledVector(f,p),qr.end.addScaledVector(f,p)}}})}),ya.makeEmpty(),qr.copy(this.collider.segment),qr.start.applyMatrix4(i),qr.end.applyMatrix4(i),ya.expandByPoint(qr.start),ya.expandByPoint(qr.end),ya.min.addScalar(-this.collider.radius),ya.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(qr.end)},intersectsBounds:s=>s.intersectsBox(ya),intersectsTriangle:s=>{let a=Os,n=js,o=s.closestPointToSegment(qr,a,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),qr.start.addScaledVector(h,l),qr.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},FO=pb;FO.isLocked=!1;var Pae=Ll(I3());function kO(e){let t=e.elements,i=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,s=t[8]**2+t[9]**2+t[10]**2,a=t[0]**2+t[4]**2+t[8]**2,n=t[1]**2+t[5]**2+t[9]**2,o=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return i<l||r<l||s<l||a<l||n<l||o<l}function xo(e,t){let i=new gt;if(t&&kO(t))return i.setAttribute("position",new at([],3)),i.setIndex([]),i;if(!e.getAttribute("position"))return i.setAttribute("position",new at([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=_v(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new at(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var Dae=new je,Iae=new je,wn=[[0,0,0],[0,0,0],[0,0,0]];function UO(e){let t=e.elements;wn[0][0]=t[0],wn[0][1]=t[4],wn[0][2]=t[8],wn[1][0]=t[1],wn[1][1]=t[5],wn[1][2]=t[9],wn[2][0]=t[2],wn[2][1]=t[6],wn[2][2]=t[10];let{u:i,v:r}=(0,Pae.SVD)(wn),s=Dae.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),a=Iae.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(a.transpose())}var Oae=class extends AT{constructor(){super(),this.layers.enable(3),this.layers.enable(8),this.layers.enable(9)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new zl({color:65280,linewidth:10}),t=new I(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new I(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new I().addVectors(t,i.multiplyScalar(r)),a=new gt;return a.setFromPoints([t,s]),new ig(a,e)}},NO=e=>e instanceof ru||e instanceof su;function Rae(e,t){return e.distance-t.distance}function VO(e,t,i){if(!(!yo(t)||!t.visible)){Ya(t)&&t.raycast(e,i);for(let r of t.children)VO(e,r,i)}}function Qm(e,t,i,r=!1){if(!r&&!i.some(a=>ev(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>VO(e,a,s)),s.sort(Rae),s}function fb(e){let t=[];if(e.length){let i=e[0].object;yo(i)&&t.push(i);let r=i.parent;for(;r;)NO(r)&&t.push(r),r=r.parent}return t}function bo(e,t,i,r){let s=e.frame;if(s){let a=t[0]*s.width,n=(1-t[1])*s.height;for(let o of i){let l=o===s.uuid?s:s.find(o);if(l?.intersects(a,n))return r(l),!0}}return!1}function ev(e,t){if(Ya(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(NO(t))return jO(e,t)}function jO(e,t){if(!(!yo(t)||!t.visible)){if(Ya(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=jO(e,i);if(r)return r}}}function Lae(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}function Bae(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var zae=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new Oae,this._useWindowEvents=!1,this.pointerWorld={x:0,y:0},this.pointerScreen={x:0,y:0},this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(e){this._domRect=e}get domRect(){return this._domRect}updateRaycaster(e){let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.pointerWorld=Lae(t,i,this._domRect),this.pointerScreen=Bae(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},Ms=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},Jw=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],HO=e=>Jw.find(([t,i])=>i===e)?.[0],Vp=e=>Jw.find(([t])=>t===e)?.[1],Fae=(e,t)=>{let i=HO(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},kae=class extends Ms{constructor(){super(...arguments),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let t=this.splineEvents[HO(e.eventName)]?.[e.target.uuid];if(!t)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(t,{deltaY:e.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(t)}}connect(){let{page:e}=this.eventContext;e.traverseEntity(t=>{if(t.data?.events.length){for(let[i,r]of Jw)if(t.data.events.some(s=>s.data.type===r&&!s.data.disabled)){this.objectsPerEvents.has(i)?this.objectsPerEvents.get(i)?.push(t):this.objectsPerEvents.set(i,[t]);let s={id:t.uuid,name:t.name},a=Fae(r,s),n=this.splineEvents[i];n?n[t.uuid]=a:this.splineEvents[i]={[t.uuid]:a}}}}),this.objectsPerEvents.forEach(t=>{t.forEach(i=>{i.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},Uae=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Cr(t,t.actions,r,s,a,i)}disconnect(){es(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.SwitchCamera.some(t=>t.playing&&t.data.runMode!=="Toggle")||this.actions.SwitchCamera.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},Nae=class extends Ms{constructor(e,t,i){super(e),this.eventManager=t,this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=r=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=Qm(s,a,[],!0);this.sceneInterects=n,n.length&&(this.eventContext.sharedAssets.raycastProperty={x:n[0].point.x,y:n[0].point.y,z:n[0].point.z,objX:n[0].object.matrixWorld.elements[12],objY:n[0].object.matrixWorld.elements[13],objZ:n[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{(s.data.type==="MouseDown"||s.data.type==="MousePress")&&(this.onCanvasRaycast(r),s.dispatch())})},this.onCanvasMouseUp=r=>{(r.target===this.eventContext.domElement||r.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(s=>{s.data.type==="MouseUp"?(this.onCanvasRaycast(r),s.dispatch()):s.data.type==="MousePress"&&s.dispatchRelease()})},this.onMouseDown=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseDown"))},this.onMouseUp=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent())},this.onMousePressRelease=r=>{It.length>1||(this.eventContext.updateRaycaster(r),this.handleMousePressEvent(!0))},this.onKeyDown=r=>{this.heldKeys[r.key]||(this.handleKeyEvent(r,"KeyDown"),this.handleKeyEventHeld(r,"KeyDown",!0)),this.heldKeys[r.key]=!0},this.onKeyUp=r=>{this.handleKeyEvent(r,"KeyUp"),this.handleKeyEventHeld(r,"KeyUp",!0)},this.onKeyPressDown=r=>{this.heldKeysPress[r.key]?this.handleKeyEventHeld(r,"KeyPress"):(this.handleKeyEvent(r,"KeyPress"),this.handleKeyEventHeld(r,"KeyPress",!0)),this.heldKeysPress[r.key]=!0},this.onKeyPressUp=r=>{this.handleKeyEvent(r,"KeyPress",!0)},this.releaseHeldKey=r=>{delete this.heldKeys[r.key]},this.releaseHeldKeyPress=r=>{delete this.heldKeysPress[r.key]},this._onUserEvent=({eventName:r,target:s,reverse:a})=>{if(!r||!s)return;let n=Vp(r);n&&(n==="MouseDown"||n==="MouseUp"||n==="MousePress"?(s.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent(a)})):(n==="KeyDown"||n==="KeyUp"||n==="KeyPress")&&(s.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[s.uuid]?.forEach(o=>{o.dispatchUserEvent()})))}}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext,r=(s,a)=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];if(s.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:c})=>{try{let u=new Uae(h,c,s,e,t,this.eventManager);u.actions.Video.length&&(this.hasVideoAction=!0),(c.type==="MouseDown"||c.type==="MouseUp"||c.type==="MousePress")&&(c.mode==="Canvas"||c.mode==="Window")?this.canvasMouseEvents.push(u):(l[s.uuid]?l[s.uuid].some(d=>d.id===u.id)||l[s.uuid].push(u):l[s.uuid]=[u],s instanceof Rh&&s.traverseChildren(d=>{if(!d.visible)return!0;d instanceof Ar&&d.data.geometry.shapeBlendNode?.operation!==2&&(l[d.uuid]?l[d.uuid].push(u):l[d.uuid]=[u])}))}catch{}}),l[s.uuid]?.length&&(this.objectsPerTypes[o].push(s instanceof ts&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress")?a:s),s instanceof Rh)){let h=this.objectsPerTypes[o];s.traverseChildren(c=>{if(!c.visible)return!0;c instanceof Ar&&h.indexOf(c)===-1&&h.push(c)})}}};e.traverseEntity(s=>{(s instanceof ws||s instanceof Qr)&&s.frame?.traverse(a=>{r(a,s)}),r(s)}),this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),i.addEventListener("pointerdown",this.onCanvasMouseDown),i.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),i.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),i.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),i.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(([s,a])=>{a.forEach(n=>{n.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},e.removeEventListener("pointerdown",this.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r,pointerScreen:s}=this.eventContext,a=this.objectsPerTypes[e],n=a.filter(o=>!(o instanceof ts));if(!(!a.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&bo(r,[s.x,s.y],Object.keys(this.eventsPerObjects[e]),o=>{this.handleObjectMouseEventDispatch(o,e)}))){if(t||this.useForRaycastProperty){let o;if(this.sceneInterects===null?o=Qm(i,r,n,this.useForRaycastProperty):(o=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&o.length&&(this.eventContext.sharedAssets.raycastProperty={x:o[0].point.x,y:o[0].point.y,z:o[0].point.z,objX:o[0].object.matrixWorld.elements[12],objY:o[0].object.matrixWorld.elements[13],objZ:o[0].object.matrixWorld.elements[14]}),t){let l=[o[0]?.uv?.x??0,o[0]?.uv?.y??0];fb(o).forEach(h=>{h instanceof ws&&bo(h,l,Object.keys(this.eventsPerObjects[e]),c=>{this.handleObjectMouseEventDispatch(c,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=ev(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof ws&&bo(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=i.filter(a=>!(a instanceof ts)),s=[];if(i.length){if(!e){let{stopRaycast:a,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=bo(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),c=>{s.push(c)})),a&&!h){let c=Qm(n,o,r);s=fb(c),c.forEach(u=>{u.object instanceof ws&&bo(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{s.push(d)})})}else r.forEach(c=>{let u=ev(n,c);u&&(s.push(c),c instanceof ws&&bo(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{s.push(d)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{s.includes(a)||this.handleObjectMouseEventDispatchRelease(a,t)}),s.length&&s.forEach(a=>{this.handleObjectMouseEventDispatch(a,t)}),this._prevObjects=s}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},Vae=new I,jae=new I,GO=class{constructor(e,t,i,r,s){this.actionsIn=Cr(e,e.inActions,i,r,s,t),this.actionsOut=Cr(e,e.outActions,i,r,s,t)}disconnect(){es(this.actionsIn),es(this.actionsOut)}},Hae=class extends GO{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let d of this.objects)if(!d.visible)return;let h=Vae.setFromMatrixPosition(this.objects[0].matrixWorld),c=jae.setFromMatrixPosition(this.objects[1].matrixWorld),u=h.distanceTo(c)<=this.distance?"in":"out";if(this.stage!==u){this.stage=u;let d=u==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Particles.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch()),d.SetVariable.forEach(p=>p.checkConditions()),d.SetVariable.forEach(p=>p.dispatch()),d.DynamicVariablePlay.forEach(p=>p.dispatch()),d.ClearLocalStorage.forEach(p=>p.dispatch()),d.UserAPI.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let c=r.find(h);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},Gae=class extends GO{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(c=>c.dispatchConditional()),this.actionsOut.Particles.forEach(c=>c.dispatchConditional()),this.actionsOut.Video.forEach(c=>c.dispatchConditional()),this.actionsOut.Link.forEach(c=>c.dispatch()),this.actionsOut.Create.forEach(c=>c.dispatch()),this.actionsOut.Destroy.forEach(c=>c.dispatch()),this.actionsOut.Reset.forEach(c=>c.dispatch()),this.actionsIn.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(c=>c.play()),this.actionsOut.Animation.forEach(c=>c.play()),this.actionsIn.SwitchCamera.forEach(c=>c.pause()),this.actionsOut.SwitchCamera.forEach(c=>c.play()),this.actionsOut.SceneTransition.forEach(c=>c.dispatch()),this.actionsOut.SetVariable.forEach(c=>c.checkConditions()),this.actionsOut.SetVariable.forEach(c=>c.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(c=>c.dispatchConditional()),this.actionsIn.Particles.forEach(c=>c.dispatchConditional()),this.actionsIn.Video.forEach(c=>c.dispatchConditional()),this.actionsIn.Link.forEach(c=>c.dispatch()),this.actionsIn.Create.forEach(c=>c.dispatch()),this.actionsIn.Destroy.forEach(c=>c.dispatch()),this.actionsIn.Reset.forEach(c=>c.dispatch()),this.actionsOut.Transition.forEach(c=>c.pause()),this.actionsOut.Transition.forEach(c=>c.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(c=>c.play()),this.actionsIn.Animation.forEach(c=>c.play()),this.actionsOut.SwitchCamera.forEach(c=>c.pause()),this.actionsIn.SwitchCamera.forEach(c=>c.play()),this.actionsIn.SceneTransition.forEach(c=>c.dispatch()),this.actionsIn.SetVariable.forEach(c=>c.checkConditions()),this.actionsIn.SetVariable.forEach(c=>c.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(c=>c.dispatch()),this.actionsOut.ClearLocalStorage.forEach(c=>c.dispatch()),this.actionsOut.UserAPI.forEach(c=>c.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object)??r.scene.find2D(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){ch(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),ch(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),ch(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),ch(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Wae=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1}connect(){super.connect();let{page:e,sharedAssets:t}=this.eventContext;e.traverseEntity(i=>{if(i.data?.events.length){for(let{id:r,data:s}of i.data.events)if(!s.disabled&&s.type==="Conditional")try{let a;s.condition.type==="Comparison"||(s.condition.type==="Distance"?a=new Hae(r,s,i,e,t,this.eventManager):s.condition.type==="State"&&(a=new Gae(r,s,i,e,t,this.eventManager))),a&&(this.eventsPerConditions[s.condition.type].push(a),(a.actionsIn.Video.length||a.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}}),Object.values(this.eventsPerConditions).forEach(i=>i.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ad=new I,al=new I,Zl=new I,c3=new Gs,qae=.01,xi=new I,Br=new I,u3=new I,vh=new Rt,Q1=new Fr,Xae=new je,Z1=new Sr,Cc=new I,_n=new I,Tc=.2;function K1(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Yae=function(){let e=new je;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&K1(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?K1(s.position,t.limits):t.reference==="local"&&(vh.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(vh),K1(s.position,t.limits),vh.invert(),s.position.applyQuaternion(vh),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(xi,s.quaternion,Br),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Ns&&Po(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),Qae=class{constructor(e,t,i,r,s,a,n){this.object=e,this.id=t,this.data=i,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=Cr(i,i.dragDropActions.drag,r,s,a,this.object),this.actionsDrop=Cr(i,i.dragDropActions.drop,r,s,a,this.object);let o=[];this.data.objects.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(o.push(h),n[h.uuid]&&n[h.uuid].forEach(c=>{let u=r.find(c);!u||u.data.visible!==!1&&o.push(u)}))}),this.data.dropDestinations.forEach(l=>{let h=r.find(l);!h||h.data.visible!==!1&&(this.dropDestIds.push(h.uuid),n[h.uuid]&&n[h.uuid].forEach(c=>{let u=r.find(c);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=o.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new I().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new I().setFromMatrixPosition(l.matrixWorld),pointStart:new I,pointEnd:new I,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new I().copy(l.position),quat0:new Rt().copy(l.quaternion),snapped:!1,orientationMatrix:new je,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){es(this.actionsDrag),es(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Zae=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=i=>{if(It.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:s}=this.eventContext,a=s.raycastWithClones(r);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let n of this.events){let o=0;for(let{obj:l,pointEnd:h,pointStart:c}of n.dragItems){if(l===a[0].object||l===a[0].object.object||ni.is(l)&&l.isAncestorOf(a[0].object.uuid)){if(n.activeIdx=o,n.activeDragItem.reset=!1,n.activeDragItem.currentDampingFactor=n.data.dampingFactor,n.activeDragItem.snapped=!1,n.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){n.activeDragItem.obj.rigidBody&&n.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=n.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(xi,vh,Br),Q1.setFromQuaternion(vh),u.prevR===void 0?(u.prevR=Q1.clone(),u.prevT=xi.clone()):(u.prevR.copy(Q1),u.prevT.copy(xi)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(n.activeDragItem.obj)}this.calcPlaneIntersectPos(l,c,n.data.plane,n.data.referenceFrame),h.copy(c),(this.eventManager.controlsManager.usePhysics&&l.data.physics?.rigidBody==="dynamic"||n.data.drop===!1||n.data.resetOnSnapFail===!1)&&n.activeDragItem.fromPosition.setFromMatrixPosition(n.activeDragItem.obj.matrixWorld),this.activeEvent=n,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}o++}}this.activeEvent=null},this.onPointerMove=i=>{if(It.length>1)return;this.eventContext.updateRaycaster(i);let{raycaster:r,page:s}=this.eventContext,a=s.raycastWithClones(r);if(It.length===0){let n=!1;for(let o of this.events){for(let{obj:l}of o.dragItems)if(l===a[0]?.object||l===a[0]?.object?.object||ni.is(l)&&l.isAncestorOf(a[0]?.object.uuid)){switch(n=!0,o.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(n)break}n||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let n=this.activeEvent.activeDragItem;n.snapped=!1;let o;if(this.activeEvent.data.drop&&(o=a.filter(l=>n.obj!==l.object&&!n.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof ru)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(h=>h===l.object.uuid||s.scene.find(h).isAncestorOf(l.object.uuid))))[0]),o){let l=u3.copy(o.face.normal).applyMatrix3(Z1.getNormalMatrix(o.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")n.fromPosition.setFromMatrixPosition(o.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(n.fromPosition.copy(o.point),this.activeEvent.data.snapSurfaceMode==="bbox"){xi.copy(l).applyMatrix3(Z1.setFromMatrix4(n.obj.matrixWorld).transpose());let h=n.obj;xi.x>Tc?Br.x=-h.recursiveBBox.min.x:xi.x<-Tc&&(Br.x=-h.recursiveBBox.max.x),xi.y>Tc?Br.y=-h.recursiveBBox.min.y:xi.y<-Tc&&(Br.y=-h.recursiveBBox.max.y),xi.z>Tc?Br.z=-h.recursiveBBox.min.z:xi.z<-Tc&&(Br.z=-h.recursiveBBox.max.z),Br.applyMatrix3(Z1.invert())}else Br.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);n.fromPosition.add(Br)}this.activeEvent.data.autoOrient&&(xi.set(0,1,0).cross(l),xi.length()<1e-4&&xi.set(-1,0,0).cross(l),Br.crossVectors(u3,xi),n.orientationMatrix.makeBasis(xi,Br,l)),n.pointStart.copy(n.fromPosition),n.pointEnd.copy(n.pointStart),n.currentDampingFactor=this.activeEvent.snapDampingFactor,n.snapped=!0,this.lastDropDestination!==o.object&&(this.lastDropDestination=o.object,this.activeEvent.actionsDrop.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(h=>{h.dispatchThrottled()}))}else n.orientationMatrix.makeRotationFromQuaternion(n.quat0),this.lastDropDestination=null,n.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(n.obj,n.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.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.ClearLocalStorage.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.UserAPI.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.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.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(n),n.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=i=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.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(s=>{s.stop(),s.object.currentState!==null&&s.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(s=>{s.stop()}),this.activeEvent.actionsDrag.Audio.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(s=>{s.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.ClearLocalStorage.forEach(s=>s.dispatch()),this.activeEvent.actionsDrop.UserAPI.forEach(s=>s.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}}}connect(){let e={};if(this.eventContext.page.traverseEntity(i=>{i.component&&(e[i.component.uuid]?e[i.component.uuid].push(i.uuid):e[i.component.uuid]=[i.uuid])}),this.eventContext.page.traverseEntity(i=>{i.data?.events.filter(r=>r.data.type==="DragDrop"&&!r.data.disabled).forEach(r=>{this.events.push(new Qae(i,r.id,r.data,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager,e))})}),!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let t=this.eventContext.domElement;t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(al),al.negate();let n=vh.identity();switch(r==="parent"?Xae.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(xi,n,Br):r==="local"&&e.matrixWorld.decompose(xi,n,Br),i){case"x":xi.set(1,0,0).applyQuaternion(n),Cc.copy(al).cross(xi),_n.copy(xi).cross(Cc);break;case"y":xi.set(0,1,0).applyQuaternion(n),Cc.copy(al).cross(xi),_n.copy(xi).cross(Cc);break;case"z":xi.set(0,0,1).applyQuaternion(n),Cc.copy(al).cross(xi),_n.copy(xi).cross(Cc);break;case"xy":_n.set(0,0,1).applyQuaternion(n);break;case"yz":_n.set(1,0,0).applyQuaternion(n);break;case"xz":_n.set(0,1,0).applyQuaternion(n);break;case"adaptive":al.angleTo(Br.set(0,1,0))>Math.PI/6?(xi.crossVectors(Br.set(0,1,0),al),_n.crossVectors(xi,Br)):_n.set(0,1,0);break;default:_n.copy(al);break}Zl.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Zl;if(c3.setFromNormalAndCoplanarPoint(_n,o),!!a.ray.intersectPlane(c3,t)&&(i==="x"||i==="y"||i==="z")){let l=Br.subVectors(t,o).dot(xi);t.copy(o).addScaledVector(xi,l)}}updateDragItem(e,t=!1){Zl.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ad.subVectors(e.fromPosition,Zl).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ad.subVectors(e.obj.userData.worldPosition0,Zl).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ad.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Zl).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ad.length()<qae:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Yae(e,Ad.add(Zl),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Pc=new I,J1=new I,lo=new I,ho=new I,d3=new Gs,Kae=.01,Jae={type:"requestRender"},$ae=function(){let e=new I,t=new I;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),p3=function(){let e=new je;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof Ns&&Po(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),ene=class{constructor(e,t,i,r,s,a){this.data=e,this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new I,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...jy.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Cr(e,e.actions,r,s,a,i)}},tne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(It.length>1)){this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new ene(s.data,s.id,r,e,this.eventContext.sharedAssets,this.eventManager))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ra&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events)if(r.target!==void 0){let s=r.target,a=this.onTargetChange(r);this.pairOfEventListeners.push([s,a]),s.addEventListener("requestRender",a)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ra&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,es(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(lo),e.isReset)ho.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ho);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(J1),J1.negate(),Pc.copy(J1)):i==="xy"?Pc.set(0,0,1):i==="xz"?Pc.set(0,1,0):i==="yz"&&Pc.set(1,0,0),d3.setFromNormalAndCoplanarPoint(Pc,lo),!o.ray.intersectPlane(d3,ho))return}if(!e.isReset){if(ho.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ho.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&&(ho.x=lo.x),e.data.enabledTranslation[1]===!1&&(ho.y=lo.y),e.data.enabledTranslation[2]===!1&&(ho.z=lo.z);let a=$ae(lo,ho,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=Pc.subVectors(a,lo).divideScalar(e.currentDampingFactor);lo.add(n),t&&p3(e.object,lo),e.paused=n.length()<Kae}else p3(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(Jae)}},Md=new I,Pm=new I,Ed=new je,Dc=new Rt,nl=new Rt,Cd=new I,Td=new I,Kl=new I,co=new I,$1=new Gs,ine=1e-6,rne={type:"requestRender"},sne={type:"changeRotation"},f3=function(){let e=new je;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(UO(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Ns&&Po(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),ane=class{constructor(e,t,i,r){this.id=t,this.object=i,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new Rt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Hy.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=r.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},nne=class extends Ms{constructor(){super(...arguments),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=e=>{if(!(It.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let t of this.events)t.target===void 0&&this.updateSingleEvent(t)}},this.onMouseEnter=e=>{for(let t of this.events)t.target===void 0&&(t.isReset=!1,t.currentDampingFactor=t.data.dampingFactor)},this.onMouseLeave=e=>{for(let t of this.events)t.target===void 0&&(t.data.resetOnPointerLeave&&(t.isReset=!0,t.currentDampingFactor=t.resetDampingFactor),this.updateSingleEvent(t))},this.onScroll=e=>{if(this._lastMouseEvent){let t=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(t)}},this.onTargetChange=e=>()=>{this.updateSingleEvent(e)},this.createUserEventListener=e=>({eventName:t,target:i})=>{if(!t||!i)return;let r=Vp(t);r&&r==="LookAt"&&this.updateSingleEvent(e)}}connect(){let{page:e}=this.eventContext;if(e.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="LookAt"&&!a.data.disabled);s&&(!e.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new ane(s.data,s.id,r,e))}),!this.events.length)return;let{domElement:t,eventElement:i}=this.eventContext;this.domEventsNeeded.clear(),ra&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),i.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?i.addEventListener("scroll",this.onScroll):(t.addEventListener("pointerenter",this.onMouseEnter),t.addEventListener("pointerleave",this.onMouseLeave));for(let r of this.events){if(r.target!==void 0){let n=this.onTargetChange(r),o=r.target;this.pairOfEventListeners.push([o,n]),o.addEventListener("requestRender",n)}let s=this.createUserEventListener(r),a=r.object;this.pairOfUserEventListeners.push([a,s]),a.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ra&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:c,target:u}=e;if(c.getWorldPosition(Cd),!e.isReset)if(e.target)e.target.getWorldPosition(Td);else{if(s==="custom"?(l().getWorldDirection(Pm),Pm.negate(),$1.setFromNormalAndCoplanarPoint(Pm,Cd)):(s==="xy"?Md.set(0,0,1):s==="xz"?Md.set(0,1,0):s==="yz"&&Md.set(1,0,0),$1.setFromNormalAndCoplanarPoint(Md,Cd)),!h.ray.intersectPlane($1,Td))return;r>0&&(s==="custom"||s===void 0)&&Td.addScaledVector(Pm,r)}if(e.isReset||(u?t==="target"?Kl.copy(u.up).applyMatrix4(Ed.extractRotation(u.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(co.set(0,0,1),n[2]===!1&&co.set(0,1,0)):i==="y"?(co.set(1,0,0),n[0]===!1&&co.set(0,0,1)):(co.set(0,1,0),n[1]===!1&&co.set(1,0,0)),Kl.copy(co).applyQuaternion(e.worldQuaternion0).normalize()):Kl.set(0,1,0):s==="custom"?Kl.set(0,1,0):Kl.copy(Md)),e.isReset)nl.copy(e.worldQuaternion0);else if(Cd.distanceTo(Td)>a&&o&&u)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)nl.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;one(Ed,Td,Cd,Kl,i,co),nl.setFromRotationMatrix(Ed),Dc.setFromUnitVectors(co.applyQuaternion(nl),Kl),n.some(d=>d===!1)&&t!=="target"&&nl.premultiply(Dc).normalize()}e.currentDampingFactor>1?(c.updateWorldMatrix(!0,!1),Dc.setFromRotationMatrix(UO(c.matrixWorld)),Dc.slerp(nl,1/e.currentDampingFactor),f3(c,Ed.makeRotationFromQuaternion(Dc)),e.paused=8*(1-Dc.dot(nl))<ine):(f3(c,Ed.makeRotationFromQuaternion(nl)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),c.dispatchEvent(rne),c.dispatchEvent(sne)}},xa=new I,Lr=new I,dr=new I;function one(e,t,i,r,s,a){let n=e.elements;dr.subVectors(t,i),dr.lengthSq()===0&&(dr.z=1),dr.normalize(),Lr.crossVectors(r,dr),Lr.lengthSq()===0&&(Math.abs(r.z)===1?dr.x+=1e-4:dr.z+=1e-4,dr.normalize(),Lr.crossVectors(r,dr)),Lr.normalize(),xa.crossVectors(dr,Lr),s==="x"?a.z===1?[Lr,xa,dr]=[dr,Lr,xa]:(Lr.negate(),[Lr,dr]=[dr,Lr]):s==="y"?a.x===1?[Lr,xa,dr]=[xa,dr,Lr]:(Lr.negate(),[xa,dr]=[dr,xa]):a.x===1&&(Lr.negate(),[Lr,xa]=[xa,Lr]),n[0]=Lr.x,n[4]=xa.x,n[8]=dr.x,n[1]=Lr.y,n[5]=xa.y,n[9]=dr.y,n[2]=Lr.z,n[6]=xa.z,n[10]=dr.z}var lne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Cr(t,t.actions,r,s,a,i)}disconnect(){es(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatchStart()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Create.forEach(e=>e.dispatchStop()),this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},hne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=i=>{It.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onMouseUp=i=>{It.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=i=>{It.length>1||(this.eventContext.updateRaycaster(i),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Vp(i);a&&a==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(n=>n.dispatchUserEvent(s)))}}connect(){let{page:e,sharedAssets:t}=this.eventContext,i=(s,a)=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:o}of s.data.events)if(!o.disabled&&o.type==="MouseHover")try{let l=new lne(n,o,s,e,t,this.eventManager);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(l):this.eventsPerObjects[s.uuid]=[l]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s instanceof ts?a:s)}};if(e.traverseEntity(s=>{(s instanceof ws||s instanceof Qr)&&s.frame?.traverse(a=>{i(a,s)}),i(s)}),!this.objects.length)return;let{domElement:r}=this.eventContext;this.domEventsNeeded.clear(),ra&&(this.domEventsNeeded.add("pointerdown"),r.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),r.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(s=>{s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),ra&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s,pointerScreen:a}=this.eventContext,n=!1;if(s.uiCanvas&&(n=bo(s,[a.x,a.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=Qm(r,s,this.objects);t=fb(o),o.forEach(l=>{l.object instanceof ws&&bo(l.object,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)})})}else this.objects.forEach(o=>{let l=ev(r,o);l&&(t.push(o),o instanceof ws&&bo(o,[l?.uv?.x??0,l?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{t.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},cne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Cr(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){es(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch()),this.actions.ClearLocalStorage.forEach(r=>r.dispatch()),this.actions.UserAPI.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},une=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Cr(t,t.actions,r,s,n,i)}getStickyParentElement(){let e=this.domElement;for(;e;){if(window.getComputedStyle(e).position==="sticky")return e;e=e.parentElement}return null}computeScrollBounds(){let e=this.getStickyParentElement(),t=e?.parentElement,i=this.domElement.getBoundingClientRect(),r={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(t){let h=t.getBoundingClientRect(),c=window.getComputedStyle(e),u=parseFloat(c.marginTop)+parseFloat(c.marginBottom),d=parseFloat(c.top),p=parseFloat(c.bottom),f=h.height-u;if(!isNaN(d))i.top===d?(r.top+=h.top-d,r.bottom+=h.top-d):i.top<0&&(r.top-=f-i.height,r.bottom-=f-i.height);else if(!isNaN(p)){let g=document.body.clientHeight??window.innerHeight,m=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===g-p?(r.top+=h.top-i.height+p+m,r.bottom+=h.top-i.height+p+m):i.bottom<g-p&&(r.top-=f-i.height,r.bottom-=f-i.height)}}let s=document.body,a=document.documentElement,n=window.pageYOffset||a.scrollTop||s.scrollTop,o=a.clientTop||s.clientTop||0,l=Math.round(r.top+n-o);if(this.data.startFrom==="enter"){let h=window.innerHeight,c=r.height,u=this.data.enterAnchor,d=u==="top"?h:u==="bottom"?h-c:h-c*.5;this.scrollStart=l-d}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=r,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){es(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch()),this.actions.ClearLocalStorage.forEach(s=>s.dispatch()),this.actions.UserAPI.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},dne=class extends Ms{constructor(e,t){super(e),this.managers=t,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>s.handleResize())})},this.onScroll=i=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),a.forEach(n=>n.dispatch(r))})},this.onWheel=i=>{!this.isInview||i.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:i.deltaY}),s.forEach(a=>a.dispatch(i.deltaY))})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Vp(i);a&&a==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r}=this.eventContext,s=a=>{if(a.data?.events.length){for(let{id:n,data:o}of a.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger==="load"||!r){let l=new cne(n,o,a,e,t,this.managers);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(l):this.wheelEventsPerObject.set(a,[l])}else{let l=new une(n,o,a,e,t,i,this.managers);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(l):this.scrollEventsPerObject.set(a,[l])}}};e.traverseEntity(a=>{(a instanceof ws||a instanceof Qr)&&a.frame?.traverse(n=>{s(n)}),s(a)}),this.intersectionObserver=new IntersectionObserver(a=>{let n=a[0];n&&(this.isInview=n.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([a,n])=>{n.forEach(o=>o.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([a,n])=>{n.forEach(o=>o.connect()),a.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(a=>a.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},pne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}disconnect(){es(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof gh?t.interaction.audioPlayer.play():t.interaction instanceof ob&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof Sl?t.interaction.play(i==="autoplay"):t.interaction instanceof db&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}async seekVideos(e){let t=[];this.actions.Video.forEach(i=>{(i.interaction.data.triggerAfter??"autoplay")==="autoplay"&&i.interaction instanceof Sl&&t.push(i.interaction.seek(e))}),await Promise.all(t)}pauseVideos(){this.actions.Video.forEach(e=>{e.interaction instanceof Sl&&e.interaction.pause()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof gh?t.interaction.audioPlayer.play():t.interaction instanceof ob&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof Sl?t.interaction.play():t.interaction instanceof db&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},fne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.removeEventListener("pointerdown",this.onAny),s.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(o=>{o.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof gh&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof Sl&&a.interaction.play(n==="autoplay")}),s.actions.Particles.forEach(a=>{a.dispatchBasic()})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.seekVideos=async i=>{let r=[];[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{a.forEach(n=>{r.push(n.seekVideos(i))})}),await Promise.all(r)},this.pauseVideos=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{r.forEach(s=>{s.pauseVideos()})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Vp(i);a&&a==="Start"&&(r instanceof ts||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext,i=r=>{if(r.data?.events.length)for(let{id:s,data:a}of r.data.events){if(a.disabled||a.type!=="Start")continue;let n=new pne(s,a,r,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length||n.actions.Reset.length||n.actions.SetVariable.length||n.actions.DynamicVariablePlay.length||n.actions.ClearLocalStorage.length||n.actions.UserAPI.length)&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(n):this.eventsPerObject.set(r,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n])),n.actions.Particles.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(n):this.eventsAfterPerObject.set(r,[n]))}};if(t.traverseEntity(r=>{(r instanceof ws||r instanceof Qr)&&r.frame?.traverse(s=>{i(s)}),i(r)}),[...this.eventsAfterPerObject.values()].some(r=>r.length)){if(this.eventManager.activateCount===0){let{domElement:r,isExport:s}=this.eventContext,a=s?document:r;a.addEventListener("pointerdown",this.onMouseDown,{once:!0}),a.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),a.addEventListener("pointerdown",this.onAny),a.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,o])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(a=>a.dispatch()),r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},mne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.initialDisabled=!1,this.actions=Cr(t,t.actions,r,s,a,i),this.target=t.target}disconnect(){es(this.actions)}dispatch(e){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{t.data.runMode==="Toggle"?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},gne=class extends Ms{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.isOutOfFocus=!1,this.events=[],this.onFrame=a=>{let n=this.eventContext.sharedAssets;if(this.rafId=window.requestAnimationFrame(this.onFrame),this.isOutOfFocus)return;let o=new Date,l=[],h=[];for(let d=0;d<this.propertiesToWatch.length;d++){let{objectId:p,property:f,prevValue:g}=this.propertiesToWatch[d],m=this.eventContext.scene.find(p),y=Wy.propertyPaths[f];if(y[0]==="width"||y[0]==="height"||y[0]==="depth")m=m.geometry.userData.parameters[y[0]];else for(let x=0;x<y.length;x++)m=m[y[x]];g===null?this.propertiesToWatch[d].prevValue=m instanceof I?m.clone():m:(m instanceof I?!m.equals(g):g!==m)&&(h.push({objId:p,property:f}),m instanceof I?this.propertiesToWatch[d].prevValue.copy(m):this.propertiesToWatch[d].prevValue=m)}for(let d=0;d<this.variablesToWatch.length;d++){let{id:p,prevValue:f}=this.variablesToWatch[d],g=n.getVariable(p);g!==f&&(l.push(p),this.variablesToWatch[d].prevValue=g)}for(let d=0;d<this.dynamicVars.length;d++){let{id:p,expectedTime:f,last:g,data:m,timerSeconds:y,startValue:x}=this.dynamicVars[d],b=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?b=1:m.dynamicVariableType==="counter"?b=m.updateInterval:m.dynamicVariableType==="random"&&(b=m.isStatic?1/0:m.updateInterval),f===-1){this.dynamicVars[d].last=a,this.dynamicVars[d].expectedTime=a+b;continue}if(!((n.getDynamicVariablePlayState(p)==="Stopped"||n.getDynamicVariablePlayState(p)==="Restarted")&&(this.dynamicVars[d].last=a,this.dynamicVars[d].expectedTime=a+b,m.dynamicVariableType==="counter"&&n.getVariable(p)!==x&&(n.updateVariable(p,x),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[d].timerSeconds!==x&&(this.dynamicVars[d].timerSeconds=x,n.updateVariable(p,Sa.getFormattedTimerTime(x,m)),this.eventManager.requestRender()),n.getDynamicVariablePlayState(p)==="Restarted"&&n.setDynamicVariablePlayState(p,"Playing"),n.getDynamicVariablePlayState(p)==="Stopped"))){if(n.getDynamicVariablePlayState(p)==="Paused"){this.dynamicVars[d].deltaToExpectedTime===void 0&&(this.dynamicVars[d].deltaToExpectedTime=Math.max(this.dynamicVars[d].expectedTime-a,0)),this.dynamicVars[d].last=a-(b-this.dynamicVars[d].deltaToExpectedTime),this.dynamicVars[d].expectedTime=a+this.dynamicVars[d].deltaToExpectedTime;continue}else this.dynamicVars[d].deltaToExpectedTime=void 0;if(a>=f)if(this.dynamicVars[d].last=a,this.dynamicVars[d].expectedTime+=b,m.dynamicVariableType==="random"){let _=m.min+Math.random()*(m.max-m.min),M=m.decimals;_=Math.round(_*Math.pow(10,M))/Math.pow(10,M),n.updateVariable(p,_),l.push(p),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){let _=n.getVariable(p),M=n.getDynamicVariableToggleIsForward(p)??!0,S=n.getVariable(p)+m.increment*(M?1:-1);m.hasEnd&&(S=m.increment>0?lt.clamp(S,x,m.endValue):lt.clamp(S,m.endValue,x),S===x&&n.setDynamicVariableToggleIsForward(p,void 0),m.repeat?S===m.endValue&&(S=x):(S===x||S===m.endValue)&&n.setDynamicVariablePlayState(p,"Paused")),S!==_&&(l.push(p),n.updateVariable(p,S),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time"){let _=n.getVariable(p),M=TE(o,m);if(typeof _=="object"&&"textValue"in _&&typeof M=="object"&&"textValue"in M){if(Array.isArray(_.textValue)&&Array.isArray(M.textValue)){if(_.textValue.every((S,E)=>S===M.textValue[E]))continue}else if(_.textValue===M.textValue)continue}else if(_===M)continue;n.updateVariable(p,M),l.push(p),this.eventManager.requestRender()}else{let _=ps.isTextValue(m.endValue)?m3(m.endValue.textValue):m.endValue,M=n.getDynamicVariableToggleIsForward(p)??!0,S=y+(a-g)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(M?1:-1);S=Math.max(S,0),m.hasEnd&&(S=m.dynamicVariableType==="stopwatch"?lt.clamp(S,x,_):lt.clamp(S,_,x),S===x&&n.setDynamicVariableToggleIsForward(p,void 0),m.repeat?Math.abs(S-_)<(m.format==="number3decimal"?1e-4:.1)&&(S=x):(Math.abs(S-x)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(S-_)<(m.format==="number3decimal"?1e-4:.1))&&n.setDynamicVariablePlayState(p,"Paused")),S!==y&&(l.push(p),this.dynamicVars[d].timerSeconds=S,n.updateVariable(p,Sa.getFormattedTimerTime(S,m)),this.eventManager.requestRender())}}}let c=!1;n.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=n.mouseProperty,c=!0);let u=!1;n.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=n.raycastProperty,u=!0),this.events.forEach(d=>{(l.includes(d.data.variableId)||h.find(p=>p.objId===d.data.objectId&&p.property===d.data.property)||d.data.variableId==="mouseProperty"&&c||d.data.variableId==="raycastProperty"&&u)&&(d.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()}}pause(){this.isOutOfFocus||(this.isOutOfFocus=!0,this.pauseTime=Date.now())}resume(){if(!this.isOutOfFocus)return;this.isOutOfFocus=!1;let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.eventContext.page.traverseEntity(t=>{t.data?.events.filter(i=>i.data.type==="VariableChange"&&!i.data.disabled).forEach(i=>{this.events.push(new vne(i.id,i.data,t,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.propertiesToWatch=this.events.filter(t=>t.data.variableId==="objectProperty"&&t.data.objectId!==null).map(t=>({objectId:t.data.objectId,property:t.data.property,prevValue:null}));let e=this.eventContext.sharedAssets;this.sharedVariables.forEach(({id:t,data:i})=>{if(!("dynamicVariableType"in i)){this.events.find(s=>s.data.variableId===t)&&this.variablesToWatch.push({id:t,prevValue:e.getVariable(t)});return}let r;if(i.dynamicVariableType==="timer"||i.dynamicVariableType==="stopwatch"){let s;if(ps.isTextValue(i.value)&&Array.isArray(i.value.textValue)){let a=i.value.textValue;a.length===3?s=a[2]+a[1]*60+a[0]*3600:s=a[1]+a[0]*60}else s=i.value;r=s,this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,timerSeconds:s,startValue:r})}else i.dynamicVariableType==="time"&&e.updateVariable(t,TE(new Date,i)),i.dynamicVariableType==="counter"&&(r=ps.isTextValue(i.value)?m3(i.value.textValue):i.value),this.dynamicVars.push({id:t,last:-1,expectedTime:-1,data:i,startValue:r})}),this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},vne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispose(){es(this.actions)}};function m3(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var yne="https://unpkg.com/@splinetool/runtime@1.10.56/build/",xne="https://unpkg.com/@splinetool/navmesh-wasm@1.10.56/build/",bne=`
8143
8143
  (async function() {
8144
8144
  const [wasmImport, wasmBinary] = await Promise.all([
8145
8145
  import('${yne}' + 'navmesh.js'),
@@ -8207,7 +8207,7 @@ onmessage = function(messageEvent) {
8207
8207
  `),A.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),A.addEventListener("touchend",P=>P.preventDefault()),this.joysticks[p]=[void 0,f];return}let S={zone:f,mode:"static",position:b,size:g};y==="hide"&&(S.restOpacity=0);let E=Zre.create(S);E.on("move",(A,T)=>{let P=this.gameControl;d==="pos"?T.force<.2?P.moveForce=0:(P.movementState.movePosZ=Math.sin(-T.angle.radian),P.movementState.movePosX=Math.cos(-T.angle.radian),T.force>1.2?P.movementState.run=1:P.movementState.run=0,T.force<.3?P.moveForce=(T.force-.2)/.1:P.moveForce=1):d==="rot"&&(T.force<.2?P.rotForce=0:(P.movementState.rotPosX=T.vector.y,P.movementState.rotPosY=-T.vector.x,T.force<.3?P.rotForce=(T.force-.2)/.1:P.rotForce=1)),this.requestRender()}),E.on("end",(A,T)=>{let P=this.gameControl;d==="pos"?(P.movementState.movePosZ=0,P.movementState.movePosX=0,P.moveForce=1):d==="rot"&&(P.movementState.rotPosX=0,P.movementState.rotPosY=0,P.rotForce=1)}),this.joysticks[p]=[E,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(d=>d.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new di.World(new di.Vector3(0,this.gravity,0)),this.events=new di.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(n=>{let o;if(n instanceof Ea)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof fs)o=n.object;else{if(n instanceof Zd||n instanceof Qd)return;if(o=n,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0}let l=o.dataPatched,h;for(let m of l.events)m.data.disabled!==!0&&m.data.type==="GameControl"&&(h=m.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;n.updateMatrixWorldSVD();let c=tv(l),u=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let m of l.events)if(m.data.disabled!==!0){if(m.data.type==="Collision"){u=!0;let y=new mne(m.id,m.data,o,this.page,this.sharedAssets,this.eventManager);y.initialDisabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(x=>x.id!==m.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(m.data.type==="Follow"){f=!0;let y=m.data.target;n.traverseVisible(x=>{x.userData.isFollowingObj=y})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(n.matrixWorldFusedFalse=n.matrixWorld.clone());let g=n.geometry;if(h!==void 0){let m=di.RigidBodyDesc.kinematicPositionBased();(n.hasNonUniformScale?n.matrixWorldRigid:n.matrixWorld).decompose(br,qa,ol),n.position0=br.clone().divideScalar(this.pixelsPerMeter),n.rotation0=qa.clone(),br.divideScalar(this.pixelsPerMeter),m.setTranslation(br.x,br.y,br.z).setRotation(qa);let y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(m);n.rigidBody=y;let x;h.collider.type==="sphere"?x=di.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?x=di.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):x=di.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(di.CoefficientCombineRule.Average).setRestitutionCombineRule(di.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(x,y);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,o),br.fromArray(h.collider.position).multiply(ol.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(br);let _=new Rt().setFromEuler(new Fr().setFromVector3(new I().fromArray(h.collider.rotation)));b.setRotationWrtParent(_),b.setActiveEvents(di.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||c||f||d||p||u?(this.addRigidBody(n,o,{hasFollow:f,hasTransformAnim:c,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(g&&e.push(xo(g,n.matrixWorld)),l.physics.fusedBody&&n.traverseObject((m,y)=>{if(y===0)return;let x;if(m instanceof Ea)if(m.objectForSample){if(m.objectForSample.dataPatched.physics.fusedBody)return;x=m.object}else return m.object.dataPatched.physics.fusedBody===!0&&m.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(m instanceof Zd||m instanceof Qd)return;if(m instanceof fs)x=m.object;else if(x=m,x.dataPatched.cloner?.hideBase)return!0}let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=m.geometry;_?.getAttribute("position")!==void 0&&e.push(xo(_,m.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=mh(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=di.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),a=di.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(di.CoefficientCombineRule.Multiply).setRestitutionCombineRule(di.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);for(let[n,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(n,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new w3(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new je().compose(Xa.fromArray(t.data.position),Ic.setFromEuler(_3.fromArray(t.data.rotation)),ay);if(t.data.triggerZone==="box"){let s=new mr;s.min.fromArray(t.data.size).multiplyScalar(-.5),s.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),r=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let a=e/1e3;a<s&&a>s*.55&&(a=s),this.accumulator+=a;let n=performance.now(),o=0,l=6;for(;this.accumulator>=s&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=s,o++,!(performance.now()-n>s*1e3)););this.accumulator=this.accumulator%s}}this.skipRender=r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(br,qa,ol),ry.setFromQuaternion(qa);let t=e;t.prevR===void 0?(t.prevR=ry.clone(),t.prevT=br.clone()):(t.prevR.copy(ry),t.prevT.copy(br)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(br.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(qa))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,s;if(t.cloner){for(let a of t.cloner.children)if(a.rigidBody===r){s=a;break}}e.dispatch(s),t.dispatchEvent(mb)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=S3.copy(e.matrixWorld).invert();e.traverseEntity((s,a)=>{if(t===!1&&a===1)return!0;for(let n of s.dataPatched.events)if(n.data.type==="Trigger"&&n.data.disabled!==!0){let o=new w3(n.id,n.data,s,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=di.ColliderDesc.cuboid(...n.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=di.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(di.ActiveEvents.COLLISION_EVENTS),Xa.fromArray(n.data.position),Ic.setFromEuler(_3.fromArray(n.data.rotation)),Om.compose(Xa,Ic,ay).premultiply(s.matrixWorld),i?(Om.decompose(Xa,Ic,sy),l.setActiveCollisionTypes(di.ActiveCollisionTypes.KINEMATIC_FIXED|di.ActiveCollisionTypes.DYNAMIC_FIXED)):(Om.premultiply(r).decompose(Xa,Ic,sy),e.rigidBody.bodyType()===di.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===di.RigidBodyType.Fixed?l.setActiveCollisionTypes(di.ActiveCollisionTypes.KINEMATIC_FIXED|di.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(di.ActiveCollisionTypes.KINEMATIC_KINEMATIC|di.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Xa.divideScalar(this.pixelsPerMeter),l.setTranslation(Xa.x,Xa.y,Xa.z),l.setRotation(Ic),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,a]=this.sharedGameControlGlobals.triggers[t];for(let n=0;n<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;n++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[n];if(s===o||a.isValidTriggeringObject(ni.is(o)?o:o.object)===!1)continue;let l=S3.copy(s.matrixWorld).decompose(Xa,A3,sy).compose(Xa,A3,ay).multiply(r),h=Om.copy(o.matrixWorld).invert().multiply(l);i instanceof mr?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(ny.radius=i,ny.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(ny)),e?a.currentIntersectedObjects.indexOf(o)===-1&&(a.currentIntersectedObjects.push(o),a.dispatch(),s.dispatchEvent(zne)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(c=>c!==o)}}}};function Une(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,a=this._loopCount,n=r===vb;if(e===0)return a===-1?s:n&&(a&1)===1?t-(s-i):s;if(r===U3){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),s>=t||s<i){let o=Math.floor((s-i)/(t-i));s-=(t-i)*o,a+=Math.abs(o);let l=this.repetitions-a;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(s=e>0?t:i,this.repetitions===1&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,n)}else this._setEndings(!1,!1,n);this._loopCount=a,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(n&&(a&1)===1)return t-(s-i)}return s}var M3=!1,Nne=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&s.data.animations&&s.data.animations.forEach((a,n)=>{let o=a[0]+"/";if(Array.isArray(s.identity)?o+=s.identity[0]:o+=s.uuid,this.clipIdToAction[o])return;let l=by.parse(JSON.parse(a[2]));s.animations[n]=l;let h=this.mixer.clipAction(l,s);M3===!1&&(Object.getPrototypeOf(h)._updateTime=Une,M3=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new YN(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(a=>a.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(a=>a.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=N3}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=vb)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*(this.maxFrames-1)%(this.maxFrames-1))),this.requestRender()}get maxFrames(){return TO(this.activeClip??void 0)}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(e/(this.maxFrames-1),.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},oy=new WeakMap,Vne=class extends Dp{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new wy(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.decodeDracoFile(a,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(oy.has(e)){let o=oy.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,a=e.byteLength,n=this._getWorker(s,a).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return n.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),oy.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new gt;e.index&&t.setIndex(new Tt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,a=r.array,n=r.itemSize;t.setAttribute(s,new Tt(a,n))}return t}_loadLibrary(e,t){let i=new wy(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=jne.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
8208
8208
  `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function jne(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(c){e.onModuleLoaded=function(u){c({draco:u})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(c=>{let u=c.draco,d=new u.Decoder,p=new u.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(u,d,p,h),g=f.attributes.map(m=>m.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{u.destroy(p),u.destroy(d)}});break}};function i(n,o,l,h){let c=h.attributeIDs,u=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,p=o.DecodeBufferToMesh(l,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let m in c){let y=self[u[m]],x,b;if(h.useUniqueIDs)b=c[m],x=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,n[c[m]]),b===-1)continue;x=o.GetAttribute(d,b)}g.attributes.push(s(n,o,d,m,y,x))}return f===n.TRIANGULAR_MESH&&(g.index=r(n,o,d)),n.destroy(d),g}function r(n,o,l){let h=l.num_faces()*3,c=h*4,u=n._malloc(c);o.GetTrianglesUInt32Array(l,c,u);let d=new Uint32Array(n.HEAPF32.buffer,u,h).slice();return n._free(u),{array:d,itemSize:1}}function s(n,o,l,h,c,u){let d=u.num_components(),p=l.num_points()*d,f=p*c.BYTES_PER_ELEMENT,g=a(n,c),m=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,u,g,f,m);let y=new c(n.HEAPF32.buffer,m,p).slice();return n._free(m),{name:h,array:y,itemSize:d}}function a(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var Al;function Hne(e){return Al||(Al=new Vne,Al.setDecoderPath(e?`${e}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Al.decoderPending}async function Gne(e){if(Al){let t={attributeIDs:Al.defaultAttributeIDs,attributeTypes:Al.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Al.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function Wne(e,t){let[i,r]=RP(Ny.deserialize(new Uint8Array(e)));return aD(i),t&&t(i),r.result().data}function qne(e){let t=[];return e.scene.objects.traverse((i,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function Xne(e){for(let t of e){let i=await Gne(t.geometry.data.draco);if(i){let r=t.geometry.data;i.index&&(r.index={array:i.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};i.attributes.forEach(({name:a,array:n,itemSize:o})=>{s[a]={array:n,itemSize:o,type:"Float32Array",normalized:!1}}),r.attributes=s,r.draco=void 0}}}var Yne=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=e=>{let t=[e.clientX,e.clientY],i=new Date().getTime();if(this._clickCount>0){let r=t[0]-this._lastPosition[0],s=t[1]-this._lastPosition[1];Math.sqrt(r*r+s*s)>this._distance&&(this._clickCount=0)}this._lastPosition=t,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=e=>{}}start(e,t=500,i=2){this._target&&this.stop(),this.reset(),this._delay=t,this._distance=i,this._target=e,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}},Qne=class{constructor(e,t,i,r,s,a,n,o){this.eventId=e,this.id=t,this.data=i,this.dataEvent=r,this.object=s,this.stage=!1,this.actions=Cr(r,i.actions,a,n,o,s)}disconnect(){es(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Particles.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.ClearLocalStorage.forEach(e=>e.dispatch()),this.actions.UserAPI.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},Zne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=Gy.deviceToSize(s.data.size),n=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=n<a[0];break;case">":o=n>a[0];break;case"<>":o=n>a[0]&&n<a[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())})},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:a}=r.contentRect;this.resize(s,a)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i);let r=s=>{if(!(!s.visible||!s.data?.events.length))for(let{data:a,id:n}of s.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:o,id:l})=>{try{let h=new Qne(n,l,o,a,s,e,t,this.eventManager);this.breakpoints.push(h)}catch{}})};e.traverseEntity(s=>{(s instanceof ws||s instanceof Qr)&&s.frame?.traverse(a=>{r(a)}),r(s)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},Kne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:i})=>{this.events.forEach(r=>{r.data.userAPIId===i&&r.dispatchSuccess()})},this.onError=({userAPIId:i})=>{this.events.forEach(r=>{r.data.userAPIId===i&&r.dispatchError()})},this.userAPIs=e.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="API"&&!t.data.disabled).forEach(t=>{this.events.push(new Jne(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([e,t])=>{t.on("success",this.onSuccess),t.on("error",this.onError),t.autostart&&t.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([e,t])=>{t.off("success",this.onSuccess),t.off("error",this.onError)})}},Jne=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.successActions=Cr(t,t.successActions,r,s,a,i),this.errorActions=Cr(t,t.errorActions,r,s,a,i)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},$ne=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:i})=>{this.events.forEach(r=>{r.data.userWebhookId===i&&r.dispatch()})},this.userWebhooks=e.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="WEBHOOK"&&!t.data.disabled).forEach(t=>{this.events.push(new eoe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([e,t])=>{t.connect(),t.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([e,t])=>{t.off("message",this.onMessage),t.disconnect()})}},eoe=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}};function toe(){let e=document.createElement("textarea");return e.style.position="fixed",e.style.top="200px",e.style.left="400px",e.style.zIndex="-1",e.style.border="1px solid rgba(255,0,0,0.5)",e.style.width="10px",e.style.height="500px",e.style.color="white",e.style.opacity="0.5",e.style.background="transparent",e.style.display="none",e.style.margin="0px",e.style.padding="0px",e.style.boxSizing="content-box",e.style.pointerEvents="none",e}var ioe=new I(0,0,1),E3=new I,C3=new I,T3=new Sr,roe=class{constructor(e,t,i,r,s){this.containerScene=e,this.raycaster=t,this.sharedAssets=i,this.requestRender=r,this.onExit=s,this.htmlInput=null,this.virtualInput=null,this.helper=new LI,this.doubleClickHandler=new Yne,this.isDragging=!1,this.plane=new Gs,this.caretInterval=0,this.planeIntersection=new I,this.projected=new re,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{let a=this.virtualInput?.data;if(this.virtualInput!==void 0&&a){let n=a.material,o=typeof n=="string"?this.sharedAssets.data.materials[n]:n,l=die(o,this.sharedAssets);this.helper.setCaretColor(l)}},this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)},this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))},this.handleCaretUpdate=a=>{if(!this.htmlInput||!this.virtualInput)return;let n=this.helper,o=a?.key==="ArrowLeft"||a?.key==="ArrowRight",l=a?.key==="ArrowUp"||a?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(n.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:o,verticalKeyMove:l}),this.startAnimateTextCursor()):n.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=toe(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let e=this.doubleClickHandler.clickCount,{index:t,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,e>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0};this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[i][Math.max(0,r-1)]===`
8209
8209
  `&&(t--,r--),this._lastIndex=t,this._isFirstDragMove=!0;let s=this.checkClickedObject();if(e===1){if(s===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=t,this.isDragging=!0,this.setInputSelection(t)}else s===this.virtualInput&&(e===2?this.selectClosestWord(i,r):e>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(e){if(this.virtualInput=e,this.updateTextInputStyles(),this.htmlInput)if(e){let t=this.data?.geometry.text;this.htmlInput.value=typeof t=="string"?"":t?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:e}=this;if(e)return e.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let e=this.selectionOnDragStart,{index:t,lineIndex:i,characterIndex:r}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0};i!==void 0&&r!==void 0&&this.virtualInput?.wrappedText[i][r-1]===`
8210
- `&&t--,this.htmlInput.setSelectionRange(Math.min(e,t),Math.max(e,t))}checkClickedObject(){if(this.virtualInput){let e=this.raycaster.intersectObject(this.virtualInput,!1);if(e.length>0){let t=e[0];if(t.object instanceof Bw)return t.object}}return null}selectClosestWord(e,t){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[e],s=t+1,a=t;r[t]!==" "&&(s=this.findNextCharOccurence(r,t,"forward"," "),a=this.findNextCharOccurence(r,t,"backward"," "),a>0&&a++,s>=r.length-1&&e===i.length-1&&s++);let n=this.helper,o=n.getGlobalIndexFromLineAndCharIndexes(i,e,a),l=n.getGlobalIndexFromLineAndCharIndexes(i,e,s);this.setInputSelection(o,l)}findNextCharOccurence(e,t,i,r=" "){let s=Math.max(0,e.length-1),a=i==="forward"?s:0,n=i==="forward"?1:-1,o=Math.max(Math.min(t,s),0);for(;o!==a;)if(o+=n,e.charAt(o)===r)return o;return a}getPointOnPlane(){let e=this.virtualInput?.data;if(!(!this.virtualInput||!e)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new I);let t=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(t){this.planeIntersection.copy(this.virtualInput.worldToLocal(t));let i=typeof e.geometry.width=="number"?e.geometry.width:1,r=typeof e.geometry.height=="number"?e.geometry.height:1;this.projected.set(t.x+i*.5,t.y-r*.5)}}}updatePlane(){let e=this.virtualInput?.data;this.virtualInput&&e&&(T3.getNormalMatrix(this.virtualInput.matrixWorld),E3.copy(ioe).applyMatrix3(T3).normalize(),this.virtualInput.localToWorld(C3.set(0,0,e.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(E3,C3))}setInputSelection(e,t=e){this.htmlInput?.setSelectionRange(e,t),Iu&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let e=this.virtualInput?.data;this.virtualInput&&e&&this.htmlInput&&(this.htmlInput.style.fontSize=e.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=e.geometry.letterSpacing*e.geometry.fontSize+"px",this.htmlInput.style.lineHeight=e.geometry.fontSize*e.geometry.lineHeight+"px",this.htmlInput.style.width=e.geometry.width+"px",this.htmlInput.style.height=e.geometry.height+"px",this.htmlInput.style.textAlign=soe(e.geometry.horizontalAlign))}};function soe(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}var XO=(e,t)=>{if(typeof e=="string"){let i=t.data(e);if(i)return XO(i.value,t)}return ps.getDisplayedValue(e)};function P3(e,t){let i=e.text,r="";if(typeof i=="string"){let s=t.variables.data(r);s&&(r=XO(s.value,t.variables))}else r=i.textValue.toString();return r}var aoe=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this._textInputs=[],this.sceneHelpers=new Zs,this.helper=new LI,this._onMouseDownFocusIn=i=>{if(It.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let s of this._textInputs)if(this.eventContext.raycaster.intersectObject(s,!0).length>0){r=s;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDown,!1),s.removeEventListener("pointerup",this._onMouseUp,!1),s.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),s.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:s,helper:a}=this.textInputManager;if(!r||!s)return;let n=r.value;s.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=s.data;a.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new roe(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof Bw&&e.push(r)}),this._textInputs=e,e.length===0)return;let{domElement:t}=this.eventContext;t.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:t,sharedAssets:i}=this.eventContext;t.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(r=>{let s=P3(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(s,i)}),t.removeEventListener("pointerdown",this._onMouseDown,!1),t.removeEventListener("pointerup",this._onMouseUp,!1),t.removeEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let t=this.textInputManager.htmlInput;if(!t||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=P3(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);t.value=i,t.setSelectionRange(0,0),this.textInputManager.helper.show(e),t.style.display="block",t.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}},noe=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:i,frequencies:r})=>{this.events.forEach(s=>{s.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantListener"&&!t.data.disabled).forEach(t=>{this.events.push(new ooe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},ooe=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},loe=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:i,direction:r})=>{let s=this.events.find(a=>a.data.description===i);s&&(r==="backward"?s.dispatchReverse():s.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantTrigger"&&!t.data.disabled).forEach(t=>{this.events.push(new hoe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},hoe=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(t=>t.reverseFromCurrent()),e.Particles.forEach(t=>t.reverseFromCurrent()),e.Animation.forEach(t=>t.reverseFromCurrent()),e.SwitchCamera.forEach(t=>t.reverseFromCurrent()),e.Create.forEach(t=>t.dispatchStop())}},coe=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=a=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(a.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=a.touches?.length>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(e=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new kae(this.eventContext),VariableChange:new gne(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),API:new Kne(this.eventContext,this),WEBHOOK:new $ne(this.eventContext,this),AIAssistantListener:new noe(this.eventContext,this),AIAssistantTrigger:new loe(this.eventContext,this),Conditional:new Wae(this.eventContext,this),Start:new fne(this.eventContext,this),Basic:new Nae(this.eventContext,this,this.needsRaycast),MouseHover:new hne(this.eventContext,this),Scroll:new dne(this.eventContext,this),Follow:new tne(this.eventContext,this),DragDrop:new Zae(this.eventContext,this),LookAt:new nne(this.eventContext),Resize:new Zne(this.eventContext,this),Textfields:new aoe(this.eventContext,this)};let{page:t,domElement:i}=this.eventContext;this.hideCursor&&(i.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),i.addEventListener("wheel",this.onMouseWheelPreventScroll),i.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,e||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(e=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:i}=this.eventContext;i.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),e||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length)for(let r of i.data.events)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(t);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(t);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(t);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.type==="API"||r.data.actions.forEach(t)})}},uoe=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new re().copy(i),this._editorSize=new re().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=doe(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function doe(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var poe=class{get sharedAssets(){return this.shared}constructor(e,t={},i=!0){this.shared=new Aw(e.shared,t,!0,i),this.scene=new kw(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof Qr&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Ar&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},foe=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function moe(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function ip(e){return e instanceof Ap?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function goe(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Ns)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Ns&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!Jr.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!Jr.isMergable(l.material))return;a=Jr.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][ip(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][ip(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][ip(r)].push(l)}),i}function voe(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function yoe(e,t){let i=goe(t,e),r=voe(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),u=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof Ns&&(n[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),n[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&moe(n[m]);let g=mh(n.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new zi(g,l[0].material);break}default:{m=new zi(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let y=x=>{u=0;for(let b of x)b.children&&y(b.children),b instanceof Ns&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][ip(b)]&&i[b.material.uuid][ip(b)].length>1||(c[u++]=b));for(let b=0;b<u;b++)t.attach(c[b])};for(let x=0;x<h;x++){let b=l[x];y(b.children),s[a++]=b}}}for(let d=0;d<a;d++)s[d].removeFromParent()}var xoe=Ll(OB(),1),boe=new re;function woe(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}function D3(e){let t=new ms(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}finally{return t}}var $w=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,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=s=>{if(this.time=s,this._lastTime&&(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}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(a=>{a.type==="ParticleSystem"&&(a.update(this.dt),this._skipRender=!1)}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let a=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=a,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=s=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=boe.set(this._viewportWidth,this._viewportHeight)),s){let a=this._viewportWidth,n=this._viewportHeight;this._renderer.setSize(a-1,n-1,!1),this._renderer.setSize(a,n,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);if(this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let a=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(a!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=dp(this._resize,10),this._onScroll=s=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,r&&(this._wasmPath=rX(r,"/")),this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new foe({x:10,y:10})),gX(e)}async load(e,t,i){woe(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await Wne(e);this._data=r;let s=qne(r);r.version&&(0,xoe.default)(r.version,"1.10.54")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([s.length&&Hne(this._wasmPath),JE(r)&&SK(this._wasmPath),C$(r)&&xK(this._wasmPath),vp.physicsEnabled(r.scene.objects)&&wX(),YE(r)&&s$(),TC(r)&&kre(),i$(r)&&t$(),xC(r)&&Aie(),Cne(r)&&xX(this._wasmPath)].filter(Boolean)),s.length&&await Xne(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=new poe(r);if(a.resetPersonalCameraFromDocumentData(),this._scene=a.scene,this._sharedAssetsManager=a.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();yoe(r,a.scene);let h=performance.now();console.log("Merged geometries in ",h-l," ms")}JE(r)&&this._scene.traverse(l=>{Po(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Ea&&l.pendingMediaLoad&&l.update()})}),this._scene?.traverse(l=>{l.type==="ParticleSystem"&&(l.wakeUp(),l.data.autoPlay?l.start():l.stop())});let n=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);if(Promise.all(n).then(()=>{a.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),YE(r)&&Fne(r)&&await Promise.all(n),xC(r)){let l=[];this._scene.traverseEntity(h=>{(h instanceof ws||h instanceof Qr)&&h.uiCanvas&&l.push(h.uiCanvas)}),await Promise.all(l.map(h=>h.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),Kw(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new cie({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let l=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),h=this._getPixelRatio(l()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(h),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let c=this._sharedAssetsManager.getImage("SplineWatermark");await c.loadPromise;let u=c.getTexture(1001);this._renderer.pipeline.setWatermark(u)}}TC(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",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 uoe(this._renderer,this._camera,new re(this._viewportWidth,this._viewportHeight),new re(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let l=new zae(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new kne(l),this._animationControls=new Nne(this._scene,this._requestRenderAutoMode),this._eventManager=new coe(r.scene.publish,this._controls,this._animationControls,l,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),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),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&ps.isTextValue(e)?ps.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Ru&&!this._scene.isInvisibleObjects(t)&&!(t instanceof Qr)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof qO&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=D3(e);this._scene?.activePage.setBackgroundColor(t),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{iA.unsubscribe(e)}),this._variablesCache.clear(),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(),this.dt=0,vX(this.canvas),document.removeEventListener("scroll",this._onScroll)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene||e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(o=>{o instanceof Qr&&(t=o.name)});let i=this._sharedAssetsManager,r={shared:i,scene:this._scene},s=o=>{if(o===null||o==="Base State")return null;if(o&&e.data.states){let l=e.data.states.find(h=>h.data.name===o);return l?l.id:void 0}},a={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof Qr||e instanceof kw?void 0:e.parent?.uuid,emitEvent(o){e.dispatchEvent({type:"userEvent",eventName:o})},emitEventReverse(o){e.dispatchEvent({type:"userEvent",eventName:o,reverse:!0})},hide(){e.visible&&(e.visible=!1,r.shared.requestRender())},show(){e.visible||(e.visible=!0,r.shared.requestRender())},get state(){let o=e.stateSelection;if(o!==null)return e.data.states.find(({id:l})=>l===o)?.data.name},set state(o){let l;if(o!==void 0){let h=typeof o=="string"?e.data.states.find(({id:c})=>c===o):e.data.states[o];if(h)l=h.id;else{let c=typeof o=="string"?s(o):void 0;c&&(l=c)}}e.changeSelectedState(l??null,r),e.currentState=l??null,e.dispatchEvent({type:"completeState",state:l??null}),r.shared.requestRender()},transition(o){let l=this,h,c=ep.timeline({autoplay:o.autoPlay??!0}),u={transition({from:d,to:p,duration:f,delay:g,...m}){let y=s(d);y===void 0&&(y=h);let x=s(p);h=x;let b=new ub(e,y,x,{state:x,repeat:0,delay:g??0,delayDirection:"start-once",direction:"normal",duration:f??1e3,...m,...m.easing===6?Xy.defaultData:m.easing===5?Yy.defaultData:{}},i,!1);return c.add({...b.params,begin:()=>{(d&&y||d==="Base State"&&!y)&&(l.state=y??void 0)},complete:()=>{l.state=x??void 0}},c.duration),this},play(){return c.play(),this},pause(){return c.pause(),this},reset(){return c.reset(),this},seek(d){return c.seek(d),this}};return u.transition(o),u},set color(o){let l=D3(o);if(qg.is(e)){e.color=l;return}else if(e.type!=="Mesh"||!("material"in e)||!(e instanceof Uh))return;let h={r:l.r,g:l.g,b:l.b,a:l.a},c=Array.isArray(e.material)?e.material[0]:e.material,u=c.data.layers.find(d=>d.data.type==="color")?.id;u&&c.updateByOp({type:0,path:["layers",u],props:{color:{...h}}},c.data,r)}},n=iA(a,(o,l)=>{typeof e[o]!="object"&&Object.getOwnPropertyDescriptor(e,o)?.writable&&(e[o]=l),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,n),n}setUIWasmUrl(e){dI.skiaWasmUrl=e}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}};var Pv=window,Dv=Pv.ShadowRoot&&(Pv.ShadyCSS===void 0||Pv.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e_=Symbol(),YO=new WeakMap,jp=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==e_)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(Dv&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=YO.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&YO.set(i,t))}return t}toString(){return this.cssText}},QO=e=>new jp(typeof e=="string"?e:e+"",void 0,e_),t_=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[a+1],e[0]);return new jp(i,e,e_)},i_=(e,t)=>{Dv?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Pv.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Iv=Dv?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return QO(i)})(e):e;var r_,Ov=window,ZO=Ov.trustedTypes,_oe=ZO?ZO.emptyScript:"",KO=Ov.reactiveElementPolyfillSupport,a_={toAttribute(e,t){switch(t){case Boolean:e=e?_oe:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},JO=(e,t)=>t!==e&&(t==t||e==e),s_={attribute:!0,type:String,converter:a_,reflect:!1,hasChanged:JO},Uo=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=s_){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let a=this[t];this[i]=s,this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||s_}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Iv(s))}else t!==void 0&&i.push(Iv(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return i_(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=s_){var s;let a=this.constructor._$Ep(t,r);if(a!==void 0&&r.reflect===!0){let n=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:a_).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(a):this.setAttribute(a,n),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,a=s._$Ev.get(t);if(a!==void 0&&this._$El!==a){let n=s.getPropertyOptions(a),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:a_;this._$El=a,this[a]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||JO)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,a)=>this[a]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var a;return(a=s.hostUpdate)===null||a===void 0?void 0:a.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Uo.finalized=!0,Uo.elementProperties=new Map,Uo.elementStyles=[],Uo.shadowRootOptions={mode:"open"},KO?.({ReactiveElement:Uo}),((r_=Ov.reactiveElementVersions)!==null&&r_!==void 0?r_:Ov.reactiveElementVersions=[]).push("1.6.0");var n_,Rv=window,ku=Rv.trustedTypes,$O=ku?ku.createPolicy("lit-html",{createHTML:e=>e}):void 0,kl=`lit$${(Math.random()+"").slice(9)}$`,n4="?"+kl,Soe=`<${n4}>`,Uu=document,Gp=(e="")=>Uu.createComment(e),Wp=e=>e===null||typeof e!="object"&&typeof e!="function",o4=Array.isArray,Aoe=e=>o4(e)||typeof e?.[Symbol.iterator]=="function",Hp=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,e4=/-->/g,t4=/>/g,Vh=RegExp(`>|[
8210
+ `&&t--,this.htmlInput.setSelectionRange(Math.min(e,t),Math.max(e,t))}checkClickedObject(){if(this.virtualInput){let e=this.raycaster.intersectObject(this.virtualInput,!1);if(e.length>0){let t=e[0];if(t.object instanceof Bw)return t.object}}return null}selectClosestWord(e,t){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,r=i[e],s=t+1,a=t;r[t]!==" "&&(s=this.findNextCharOccurence(r,t,"forward"," "),a=this.findNextCharOccurence(r,t,"backward"," "),a>0&&a++,s>=r.length-1&&e===i.length-1&&s++);let n=this.helper,o=n.getGlobalIndexFromLineAndCharIndexes(i,e,a),l=n.getGlobalIndexFromLineAndCharIndexes(i,e,s);this.setInputSelection(o,l)}findNextCharOccurence(e,t,i,r=" "){let s=Math.max(0,e.length-1),a=i==="forward"?s:0,n=i==="forward"?1:-1,o=Math.max(Math.min(t,s),0);for(;o!==a;)if(o+=n,e.charAt(o)===r)return o;return a}getPointOnPlane(){let e=this.virtualInput?.data;if(!(!this.virtualInput||!e)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new I);let t=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(t){this.planeIntersection.copy(this.virtualInput.worldToLocal(t));let i=typeof e.geometry.width=="number"?e.geometry.width:1,r=typeof e.geometry.height=="number"?e.geometry.height:1;this.projected.set(t.x+i*.5,t.y-r*.5)}}}updatePlane(){let e=this.virtualInput?.data;this.virtualInput&&e&&(T3.getNormalMatrix(this.virtualInput.matrixWorld),E3.copy(ioe).applyMatrix3(T3).normalize(),this.virtualInput.localToWorld(C3.set(0,0,e.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(E3,C3))}setInputSelection(e,t=e){this.htmlInput?.setSelectionRange(e,t),Iu&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let e=this.virtualInput?.data;this.virtualInput&&e&&this.htmlInput&&(this.htmlInput.style.fontSize=e.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=e.geometry.letterSpacing*e.geometry.fontSize+"px",this.htmlInput.style.lineHeight=e.geometry.fontSize*e.geometry.lineHeight+"px",this.htmlInput.style.width=e.geometry.width+"px",this.htmlInput.style.height=e.geometry.height+"px",this.htmlInput.style.textAlign=soe(e.geometry.horizontalAlign))}};function soe(e){return e===4?"justify":e===2?"right":e===3?"center":"left"}var XO=(e,t)=>{if(typeof e=="string"){let i=t.data(e);if(i)return XO(i.value,t)}return ps.getDisplayedValue(e)};function P3(e,t){let i=e.text,r="";if(typeof i=="string"){let s=t.variables.data(r);s&&(r=XO(s.value,t.variables))}else r=i.textValue.toString();return r}var aoe=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this._textInputs=[],this.sceneHelpers=new Zs,this.helper=new LI,this._onMouseDownFocusIn=i=>{if(It.length>1)return;this.eventContext.updateRaycaster(i);let r=null;if(this.eventContext.raycaster){for(let s of this._textInputs)if(this.eventContext.raycaster.intersectObject(s,!0).length>0){r=s;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(i),this._onMouseDown(i)},this.onExit=()=>{let{virtualInput:i}=this.textInputManager;if(i===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDown,!1),s.removeEventListener("pointerup",this._onMouseUp,!1),s.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),s.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=i=>{this.eventContext.updateRaycaster(i),this.textInputManager.handleMouseMove()},this._onTextEdit=i=>{let{htmlInput:r,virtualInput:s,helper:a}=this.textInputManager;if(!r||!s)return;let n=r.value;s.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let o=s.data;a.update();let l=o.geometry.text;if(typeof l=="string"){let h=l;this.eventContext.sharedAssets.updateVariable(h,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=i=>{this.textInputManager.handleCaretUpdate(i)},this._onKeyPress=i=>{i.key==="Escape"&&this.onExit()},this.textInputManager=new roe(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(r=>{r instanceof Bw&&e.push(r)}),this._textInputs=e,e.length===0)return;let{domElement:t}=this.eventContext;t.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:t,sharedAssets:i}=this.eventContext;t.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(r=>{let s=P3(r.data.geometry,this.eventContext.sharedAssets.data);r.textGeometry.setText(s,i)}),t.removeEventListener("pointerdown",this._onMouseDown,!1),t.removeEventListener("pointerup",this._onMouseUp,!1),t.removeEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let t=this.textInputManager.htmlInput;if(!t||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=P3(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);t.value=i,t.setSelectionRange(0,0),this.textInputManager.helper.show(e),t.style.display="block",t.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:r}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),r.addEventListener("pointerdown",this._onMouseDown,!1),r.addEventListener("pointerup",this._onMouseUp,!1),r.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}},noe=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:i,frequencies:r})=>{this.events.forEach(s=>{s.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantListener"&&!t.data.disabled).forEach(t=>{this.events.push(new ooe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},ooe=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}},loe=class extends Ms{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:i,direction:r})=>{let s=this.events.find(a=>a.data.description===i);s&&(r==="backward"?s.dispatchReverse():s.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(t=>t.data.type==="AIAssistantTrigger"&&!t.data.disabled).forEach(t=>{this.events.push(new hoe(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},hoe=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=Cr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Particles.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch()),e.ClearLocalStorage.forEach(t=>t.dispatch()),e.UserAPI.forEach(t=>t.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(t=>t.reverseFromCurrent()),e.Particles.forEach(t=>t.reverseFromCurrent()),e.Animation.forEach(t=>t.reverseFromCurrent()),e.SwitchCamera.forEach(t=>t.reverseFromCurrent()),e.Create.forEach(t=>t.dispatchStop())}},coe=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onTouchMovePreventScroll=a=>{let n=window.parent!==window,o=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(a.touches.length>1||this.preventTouchScroll||n===!1&&o===!1)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=a.touches?.length>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(e=!1){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new kae(this.eventContext),VariableChange:new gne(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),API:new Kne(this.eventContext,this),WEBHOOK:new $ne(this.eventContext,this),AIAssistantListener:new noe(this.eventContext,this),AIAssistantTrigger:new loe(this.eventContext,this),Conditional:new Wae(this.eventContext,this),Start:new fne(this.eventContext,this),Basic:new Nae(this.eventContext,this,this.needsRaycast),MouseHover:new hne(this.eventContext,this),Scroll:new dne(this.eventContext,this),Follow:new tne(this.eventContext,this),DragDrop:new Zae(this.eventContext,this),LookAt:new nne(this.eventContext),Resize:new Zne(this.eventContext,this),Textfields:new aoe(this.eventContext,this)};let{page:t,domElement:i}=this.eventContext;this.hideCursor&&(i.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),i.addEventListener("wheel",this.onMouseWheelPreventScroll),i.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++,e||this.eventContext.sharedAssets.openAIRealtime?.connect()}deactivate(e=!1){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:t,domElement:i}=this.eventContext;i.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),i.removeEventListener("touchmove",this.onTouchMovePreventScroll),i.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode(),e||this.eventContext.sharedAssets.openAIRealtime?.disconnect()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(!0),this.activate(!0),this.controlsManager.deactivate(),this.controlsManager.activate(this),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length)for(let r of i.data.events)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(t);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(t);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(t);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.type==="API"||r.data.actions.forEach(t)})}},uoe=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new re().copy(i),this._editorSize=new re().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=doe(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function doe(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var poe=class{get sharedAssets(){return this.shared}constructor(e,t={},i=!0){this.shared=new Aw(e.shared,t,!0,i),this.scene=new kw(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof Qr&&!e.uiScene&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Ar&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},foe=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function moe(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function ip(e){return e instanceof Ap?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function goe(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Ns)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Ns&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!Jr.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!Jr.isMergable(l.material))return;a=Jr.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][ip(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][ip(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][ip(r)].push(l)}),i}function voe(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function yoe(e,t){let i=goe(t,e),r=voe(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,c=new Array(r),u=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof Ns&&(n[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),n[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&moe(n[m]);let g=mh(n.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new zi(g,l[0].material);break}default:{m=new zi(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let y=x=>{u=0;for(let b of x)b.children&&y(b.children),b instanceof Ns&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][ip(b)]&&i[b.material.uuid][ip(b)].length>1||(c[u++]=b));for(let b=0;b<u;b++)t.attach(c[b])};for(let x=0;x<h;x++){let b=l[x];y(b.children),s[a++]=b}}}for(let d=0;d<a;d++)s[d].removeFromParent()}var xoe=Ll(OB(),1),boe=new re;function woe(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}function D3(e){let t=new ms(0,0,0,1);try{t.setStyle(e)}catch(i){console.error(i)}finally{return t}}var $w=class{constructor(e,{renderOnDemand:t,renderMode:i="auto",wasmPath:r}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,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=s=>{if(this.time=s,this._lastTime&&(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}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)??!1),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene?.traverseVisibleEntity(a=>{a.type==="ParticleSystem"&&(a.update(this.dt),this._skipRender=!1)}),this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let a=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=a,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=s=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=boe.set(this._viewportWidth,this._viewportHeight)),s){let a=this._viewportWidth,n=this._viewportHeight;this._renderer.setSize(a-1,n-1,!1),this._renderer.setSize(a,n,!1)}else this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1);if(this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let a=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(a!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect()),this._requestRenderAutoMode()}},this._debouncedResize=dp(this._resize,10),this._onScroll=s=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,r&&(this._wasmPath=rX(r,"/")),this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new foe({x:10,y:10})),gX(e)}async load(e,t,i){woe(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await Wne(e);this._data=r;let s=qne(r);r.version&&(0,xoe.default)(r.version,"1.10.56")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),this._wasmPath&&this.setUIWasmUrl(`${this._wasmPath}/ui.wasm`),await Promise.all([s.length&&Hne(this._wasmPath),JE(r)&&SK(this._wasmPath),C$(r)&&xK(this._wasmPath),vp.physicsEnabled(r.scene.objects)&&wX(),YE(r)&&s$(),TC(r)&&kre(),i$(r)&&t$(),xC(r)&&Aie(),Cne(r)&&xX(this._wasmPath)].filter(Boolean)),s.length&&await Xne(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let a=new poe(r);if(a.resetPersonalCameraFromDocumentData(),this._scene=a.scene,this._sharedAssetsManager=a.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let l=performance.now();yoe(r,a.scene);let h=performance.now();console.log("Merged geometries in ",h-l," ms")}JE(r)&&this._scene.traverse(l=>{Po(l)&&l.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(l=>{l instanceof Ea&&l.pendingMediaLoad&&l.update()})}),this._scene?.traverse(l=>{l.type==="ParticleSystem"&&(l.wakeUp(),l.data.autoPlay?l.start():l.stop())});let n=Object.keys(r.shared.fonts).map(l=>this._sharedAssetsManager.getFont(l).loadingPromise);if(Promise.all(n).then(()=>{a.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),YE(r)&&Fne(r)&&await Promise.all(n),xC(r)){let l=[];this._scene.traverseEntity(h=>{(h instanceof ws||h instanceof Qr)&&h.uiCanvas&&l.push(h.uiCanvas)}),await Promise.all(l.map(h=>h.promise))}if(this._scene.rewriteEventsBeforeGoToPlayMode(),Kw(this._scene.activePage,this._sharedAssetsManager),!this._renderer){this._renderer=new cie({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0;let l=()=>/Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),h=this._getPixelRatio(l()?r.scene.publish.settings.web.pixelRatioMobile:r.scene.publish.settings.web.pixelRatioDesktop);if(this._renderer.setPixelRatio(h),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode),r.shared.images.SplineWatermark){let c=this._sharedAssetsManager.getImage("SplineWatermark");await c.loadPromise;let u=c.getTexture(1001);this._renderer.pipeline.setWatermark(u)}}TC(r)&&this._scene.initializeSplatViewer(),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let o=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(o.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",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 uoe(this._renderer,this._camera,new re(this._viewportWidth,this._viewportHeight),new re(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(o.allowResponsive??!1)&&o.preset==="fullscreen"),t){let l=new zae(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,o);this._scene.updateMatrixWorld(!0),this._controls=new kne(l),this._animationControls=new Nne(this._scene,this._requestRenderAutoMode),this._eventManager=new coe(r.scene.publish,this._controls,this._animationControls,l,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this._scene.activePage.data.postprocessing.depthOfField.enabled&&Promise.all(this._sharedAssetsManager.getImageLoadPromises()).then(()=>{this._resize(!0)}),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),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),document.addEventListener("scroll",this._onScroll)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&ps.isTextValue(e)?ps.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}_getPixelRatio(e){switch(e){case 0:return window.devicePixelRatio;case 1:return 1;case 2:return 2}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==Ru&&!this._scene.isInvisibleObjects(t)&&!(t instanceof Qr)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof qO&&this._controls?.orbitControls.setZoom(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let t=D3(e);this._scene?.activePage.setBackgroundColor(t),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{iA.unsubscribe(e)}),this._variablesCache.clear(),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(),this.dt=0,vX(this.canvas),document.removeEventListener("scroll",this._onScroll)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(!this._scene||e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(o=>{o instanceof Qr&&(t=o.name)});let i=this._sharedAssetsManager,r={shared:i,scene:this._scene},s=o=>{if(o===null||o==="Base State")return null;if(o&&e.data.states){let l=e.data.states.find(h=>h.data.name===o);return l?l.id:void 0}},a={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof Qr||e instanceof kw?void 0:e.parent?.uuid,emitEvent(o){e.dispatchEvent({type:"userEvent",eventName:o})},emitEventReverse(o){e.dispatchEvent({type:"userEvent",eventName:o,reverse:!0})},hide(){e.visible&&(e.visible=!1,r.shared.requestRender())},show(){e.visible||(e.visible=!0,r.shared.requestRender())},get state(){let o=e.stateSelection;if(o!==null)return e.data.states.find(({id:l})=>l===o)?.data.name},set state(o){let l;if(o!==void 0){let h=typeof o=="string"?e.data.states.find(({id:c})=>c===o):e.data.states[o];if(h)l=h.id;else{let c=typeof o=="string"?s(o):void 0;c&&(l=c)}}e.changeSelectedState(l??null,r),e.currentState=l??null,e.dispatchEvent({type:"completeState",state:l??null}),r.shared.requestRender()},transition(o){let l=this,h,c=ep.timeline({autoplay:o.autoPlay??!0}),u={transition({from:d,to:p,duration:f,delay:g,...m}){let y=s(d);y===void 0&&(y=h);let x=s(p);h=x;let b=new ub(e,y,x,{state:x,repeat:0,delay:g??0,delayDirection:"start-once",direction:"normal",duration:f??1e3,...m,...m.easing===6?Xy.defaultData:m.easing===5?Yy.defaultData:{}},i,!1);return c.add({...b.params,begin:()=>{(d&&y||d==="Base State"&&!y)&&(l.state=y??void 0)},complete:()=>{l.state=x??void 0}},c.duration),this},play(){return c.play(),this},pause(){return c.pause(),this},reset(){return c.reset(),this},seek(d){return c.seek(d),this}};return u.transition(o),u},set color(o){let l=D3(o);if(qg.is(e)){e.color=l;return}else if(e.type!=="Mesh"||!("material"in e)||!(e instanceof Uh))return;let h={r:l.r,g:l.g,b:l.b,a:l.a},c=Array.isArray(e.material)?e.material[0]:e.material,u=c.data.layers.find(d=>d.data.type==="color")?.id;u&&c.updateByOp({type:0,path:["layers",u],props:{color:{...h}}},c.data,r)}},n=iA(a,(o,l)=>{typeof e[o]!="object"&&Object.getOwnPropertyDescriptor(e,o)?.writable&&(e[o]=l),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,n),n}setUIWasmUrl(e){dI.skiaWasmUrl=e}pauseGameControls(){this._eventManager?.controlsManager.gameControl?.pause()}resumeGameControls(){this._eventManager?.controlsManager.gameControl?.resume()}};var Pv=window,Dv=Pv.ShadowRoot&&(Pv.ShadyCSS===void 0||Pv.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e_=Symbol(),YO=new WeakMap,jp=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==e_)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(Dv&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=YO.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&YO.set(i,t))}return t}toString(){return this.cssText}},QO=e=>new jp(typeof e=="string"?e:e+"",void 0,e_),t_=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[a+1],e[0]);return new jp(i,e,e_)},i_=(e,t)=>{Dv?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Pv.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Iv=Dv?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return QO(i)})(e):e;var r_,Ov=window,ZO=Ov.trustedTypes,_oe=ZO?ZO.emptyScript:"",KO=Ov.reactiveElementPolyfillSupport,a_={toAttribute(e,t){switch(t){case Boolean:e=e?_oe:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},JO=(e,t)=>t!==e&&(t==t||e==e),s_={attribute:!0,type:String,converter:a_,reflect:!1,hasChanged:JO},Uo=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=s_){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let a=this[t];this[i]=s,this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||s_}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Iv(s))}else t!==void 0&&i.push(Iv(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return i_(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=s_){var s;let a=this.constructor._$Ep(t,r);if(a!==void 0&&r.reflect===!0){let n=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:a_).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(a):this.setAttribute(a,n),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,a=s._$Ev.get(t);if(a!==void 0&&this._$El!==a){let n=s.getPropertyOptions(a),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:a_;this._$El=a,this[a]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||JO)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,a)=>this[a]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var a;return(a=s.hostUpdate)===null||a===void 0?void 0:a.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Uo.finalized=!0,Uo.elementProperties=new Map,Uo.elementStyles=[],Uo.shadowRootOptions={mode:"open"},KO?.({ReactiveElement:Uo}),((r_=Ov.reactiveElementVersions)!==null&&r_!==void 0?r_:Ov.reactiveElementVersions=[]).push("1.6.0");var n_,Rv=window,ku=Rv.trustedTypes,$O=ku?ku.createPolicy("lit-html",{createHTML:e=>e}):void 0,kl=`lit$${(Math.random()+"").slice(9)}$`,n4="?"+kl,Soe=`<${n4}>`,Uu=document,Gp=(e="")=>Uu.createComment(e),Wp=e=>e===null||typeof e!="object"&&typeof e!="function",o4=Array.isArray,Aoe=e=>o4(e)||typeof e?.[Symbol.iterator]=="function",Hp=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,e4=/-->/g,t4=/>/g,Vh=RegExp(`>|[
8211
8211
  \f\r](?:([^\\s"'>=/]+)([
8212
8212
  \f\r]*=[
8213
8213
  \f\r]*(?:[^