@splinetool/viewer 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/spline-viewer.cjs
CHANGED
|
@@ -3151,10 +3151,10 @@ void main() {
|
|
|
3151
3151
|
squared_mean = squared_mean / samples;
|
|
3152
3152
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3153
3153
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3154
|
-
}`;function Gz(e,t,i){let r=new lx,s=new $,a=new $,n=new Et,o=new tC({depthPacking:VE}),l=new Uz,h={},u=i.maxTextureSize,c={[ka]:Or,[Or]:ka,[Rs]:Rs},d=new ni({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $},radius:{value:4}},vertexShader:Vz,fragmentShader:jz}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new ut;f.setAttribute("position",new At(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new yr(f,d),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ix,this.render=function(_,S,M){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||_.length===0)return;let C=e.getRenderTarget(),A=e.getActiveCubeFace(),T=e.getActiveMipmapLevel(),P=e.state;P.setBlending(hr),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 N=_[R],B=N.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",N,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;s.copy(B.mapSize);let V=B.getFrameExtents();if(s.multiply(V),a.copy(B.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(a.x=Math.floor(u/V.x),s.x=a.x*V.x,B.mapSize.x=a.x),s.y>u&&(a.y=Math.floor(u/V.y),s.y=a.y*V.y,B.mapSize.y=a.y)),B.map===null){let X=this.type!==qu?{minFilter:si,magFilter:si}:{};B.map=new ai(s.x,s.y,X),B.map.texture.name=N.name+".shadowMap",B.camera.updateProjectionMatrix()}e.setRenderTarget(B.map),e.clear();let H=B.getViewportCount();for(let X=0;X<H;X++){let G=B.getViewport(X);n.set(a.x*G.x,a.y*G.y,a.x*G.z,a.y*G.w),P.viewport(n),B.updateMatrices(N,X),r=B.getFrustum(),b(S,M,B.camera,N,this.type)}B.isPointLightShadow!==!0&&this.type===qu&&y(B,M),B.needsUpdate=!1}v.needsUpdate=!1,e.setRenderTarget(C,A,T)};function y(_,S){let M=t.update(m);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 ai(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(S,null,M,d,m,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(S,null,M,p,m,null)}function x(_,S,M,C,A,T){let P=null,R=M.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)P=R;else if(P=M.isPointLight===!0?l:o,e.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let z=P.uuid,N=S.uuid,B=h[z];B===void 0&&(B={},h[z]=B);let V=B[N];V===void 0&&(V=P.clone(),B[N]=V),P=V}return P.visible=S.visible,P.wireframe=S.wireframe,T===qu?P.side=S.shadowSide!==null?S.shadowSide:S.side:P.side=S.shadowSide!==null?S.shadowSide:c[S.side],P.alphaMap=S.alphaMap,P.alphaTest=S.alphaTest,P.map=S.map,P.clipShadows=S.clipShadows,P.clippingPlanes=S.clippingPlanes,P.clipIntersection=S.clipIntersection,P.displacementMap=S.displacementMap,P.displacementScale=S.displacementScale,P.displacementBias=S.displacementBias,P.wireframeLinewidth=S.wireframeLinewidth,P.linewidth=S.linewidth,M.isPointLight===!0&&P.isMeshDistanceMaterial===!0&&(P.referencePosition.setFromMatrixPosition(M.matrixWorld),P.nearDistance=C,P.farDistance=A),P}function b(_,S,M,C,A){if(_.visible===!1)return;if(_.layers.test(S.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&A===qu)&&(!_.frustumCulled||r.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,_.matrixWorld);let P=t.update(_),R=_.material;if(Array.isArray(R)){let z=P.groups;for(let N=0,B=z.length;N<B;N++){let V=z[N],H=R[V.materialIndex];if(H&&H.visible){let X=x(_,H,C,M.near,M.far,A);e.renderBufferDirect(M,null,P,X,_,V)}}}else if(R.visible){let z=x(_,R,C,M.near,M.far,A);e.renderBufferDirect(M,null,P,z,_,null)}}let T=_.children;for(let P=0,R=T.length;P<R;P++)b(T[P],S,M,C,A)}}function Hz(e,t,i){let r=i.isWebGL2;function s(){let ce=!1,we=new Et,Ue=null,We=new Et(0,0,0,0);return{setMask:function(pt){Ue!==pt&&!ce&&(e.colorMask(pt,pt,pt,pt),Ue=pt)},setLocked:function(pt){ce=pt},setClear:function(pt,$t,xi,ki,Zr){Zr===!0&&(pt*=ki,$t*=ki,xi*=ki),we.set(pt,$t,xi,ki),We.equals(we)===!1&&(e.clearColor(pt,$t,xi,ki),We.copy(we))},reset:function(){ce=!1,Ue=null,We.set(-1,0,0,0)}}}function a(){let ce=!1,we=null,Ue=null,We=null;return{setTest:function(pt){pt?be(2929):ue(2929)},setMask:function(pt){we!==pt&&!ce&&(e.depthMask(pt),we=pt)},setFunc:function(pt){if(Ue!==pt){switch(pt){case cI:e.depthFunc(512);break;case uI:e.depthFunc(519);break;case dI:e.depthFunc(513);break;case ty:e.depthFunc(515);break;case pI:e.depthFunc(514);break;case fI:e.depthFunc(518);break;case mI:e.depthFunc(516);break;case gI:e.depthFunc(517);break;default:e.depthFunc(515)}Ue=pt}},setLocked:function(pt){ce=pt},setClear:function(pt){We!==pt&&(e.clearDepth(pt),We=pt)},reset:function(){ce=!1,we=null,Ue=null,We=null}}}function n(){let ce=!1,we=null,Ue=null,We=null,pt=null,$t=null,xi=null,ki=null,Zr=null;return{setTest:function(Si){ce||(Si?be(2960):ue(2960))},setMask:function(Si){we!==Si&&!ce&&(e.stencilMask(Si),we=Si)},setFunc:function(Si,Ns,Kr){(Ue!==Si||We!==Ns||pt!==Kr)&&(e.stencilFunc(Si,Ns,Kr),Ue=Si,We=Ns,pt=Kr)},setOp:function(Si,Ns,Kr){($t!==Si||xi!==Ns||ki!==Kr)&&(e.stencilOp(Si,Ns,Kr),$t=Si,xi=Ns,ki=Kr)},setLocked:function(Si){ce=Si},setClear:function(Si){Zr!==Si&&(e.clearStencil(Si),Zr=Si)},reset:function(){ce=!1,we=null,Ue=null,We=null,pt=null,$t=null,xi=null,ki=null,Zr=null}}}let o=new s,l=new a,h=new n,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,m=[],v=null,y=!1,x=null,b=null,_=null,S=null,M=null,C=null,A=null,T=!1,P=null,R=null,z=null,N=null,B=null,V=e.getParameter(35661),H=!1,X=0,G=e.getParameter(7938);G.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=X>=1):G.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=X>=2);let se=null,ae={},J=e.getParameter(3088),K=e.getParameter(2978),ne=new Et().fromArray(J),te=new Et().fromArray(K);function oe(ce,we,Ue){let We=new Uint8Array(4),pt=e.createTexture();e.bindTexture(ce,pt),e.texParameteri(ce,10241,9728),e.texParameteri(ce,10240,9728);for(let $t=0;$t<Ue;$t++)e.texImage2D(we+$t,0,6408,1,1,0,6408,5121,We);return pt}let ie={};ie[3553]=oe(3553,3553,1),ie[34067]=oe(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),be(2929),l.setFunc(ty),Je(!1),$e(Rw),be(2884),Ze(hr);function be(ce){d[ce]!==!0&&(e.enable(ce),d[ce]=!0)}function ue(ce){d[ce]!==!1&&(e.disable(ce),d[ce]=!1)}function ye(ce,we){return p[ce]!==we?(e.bindFramebuffer(ce,we),p[ce]=we,r&&(ce===36009&&(p[36160]=we),ce===36160&&(p[36009]=we)),!0):!1}function de(ce,we){let Ue=m,We=!1;if(ce)if(Ue=f.get(we),Ue===void 0&&(Ue=[],f.set(we,Ue)),ce.isWebGLMultipleRenderTargets){let pt=ce.texture;if(Ue.length!==pt.length||Ue[0]!==36064){for(let $t=0,xi=pt.length;$t<xi;$t++)Ue[$t]=36064+$t;Ue.length=pt.length,We=!0}}else Ue[0]!==36064&&(Ue[0]=36064,We=!0);else Ue[0]!==1029&&(Ue[0]=1029,We=!0);We&&(i.isWebGL2?e.drawBuffers(Ue):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ue))}function Be(ce){return v!==ce?(e.useProgram(ce),v=ce,!0):!1}let Ce={[Xh]:32774,[$O]:32778,[eI]:32779};if(r)Ce[kw]=32775,Ce[Nw]=32776;else{let ce=t.get("EXT_blend_minmax");ce!==null&&(Ce[kw]=ce.MIN_EXT,Ce[Nw]=ce.MAX_EXT)}let _e={[tI]:0,[iI]:1,[rI]:768,[RE]:770,[hI]:776,[oI]:774,[aI]:772,[sI]:769,[BE]:771,[lI]:775,[nI]:773};function Ze(ce,we,Ue,We,pt,$t,xi,ki){if(ce===hr){y===!0&&(ue(3042),y=!1);return}if(y===!1&&(be(3042),y=!0),ce!==JO){if(ce!==x||ki!==T){if((b!==Xh||M!==Xh)&&(e.blendEquation(32774),b=Xh,M=Xh),ki)switch(ce){case Bl:e.blendFuncSeparate(1,771,1,771);break;case Bw:e.blendFunc(1,1);break;case Lw:e.blendFuncSeparate(0,769,0,1);break;case zw:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",ce);break}else switch(ce){case Bl:e.blendFuncSeparate(770,771,1,771);break;case Bw:e.blendFunc(770,1);break;case Lw:e.blendFuncSeparate(0,769,0,1);break;case zw:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",ce);break}_=null,S=null,C=null,A=null,x=ce,T=ki}return}pt=pt||we,$t=$t||Ue,xi=xi||We,(we!==b||pt!==M)&&(e.blendEquationSeparate(Ce[we],Ce[pt]),b=we,M=pt),(Ue!==_||We!==S||$t!==C||xi!==A)&&(e.blendFuncSeparate(_e[Ue],_e[We],_e[$t],_e[xi]),_=Ue,S=We,C=$t,A=xi),x=ce,T=!1}function Qe(ce,we){ce.side===Rs?ue(2884):be(2884);let Ue=ce.side===Or;we&&(Ue=!Ue),Je(Ue),ce.blending===Bl&&ce.transparent===!1?Ze(hr):Ze(ce.blending,ce.blendEquation,ce.blendSrc,ce.blendDst,ce.blendEquationAlpha,ce.blendSrcAlpha,ce.blendDstAlpha,ce.premultipliedAlpha),l.setFunc(ce.depthFunc),l.setTest(ce.depthTest),l.setMask(ce.depthWrite),o.setMask(ce.colorWrite);let We=ce.stencilWrite;h.setTest(We),We&&(h.setMask(ce.stencilWriteMask),h.setFunc(ce.stencilFunc,ce.stencilRef,ce.stencilFuncMask),h.setOp(ce.stencilFail,ce.stencilZFail,ce.stencilZPass)),je(ce.polygonOffset,ce.polygonOffsetFactor,ce.polygonOffsetUnits),ce.alphaToCoverage===!0?be(32926):ue(32926)}function Je(ce){P!==ce&&(ce?e.frontFace(2304):e.frontFace(2305),P=ce)}function $e(ce){ce!==QO?(be(2884),ce!==R&&(ce===Rw?e.cullFace(1029):ce===ZO?e.cullFace(1028):e.cullFace(1032))):ue(2884),R=ce}function He(ce){ce!==z&&(H&&e.lineWidth(ce),z=ce)}function je(ce,we,Ue){ce?(be(32823),(N!==we||B!==Ue)&&(e.polygonOffset(we,Ue),N=we,B=Ue)):ue(32823)}function ot(ce){ce?be(3089):ue(3089)}function gt(ce){ce===void 0&&(ce=33984+V-1),se!==ce&&(e.activeTexture(ce),se=ce)}function Q(ce,we,Ue){Ue===void 0&&(se===null?Ue=33984+V-1:Ue=se);let We=ae[Ue];We===void 0&&(We={type:void 0,texture:void 0},ae[Ue]=We),(We.type!==ce||We.texture!==we)&&(se!==Ue&&(e.activeTexture(Ue),se=Ue),e.bindTexture(ce,we||ie[ce]),We.type=ce,We.texture=we)}function j(){let ce=ae[se];ce!==void 0&&ce.type!==void 0&&(e.bindTexture(ce.type,null),ce.type=void 0,ce.texture=void 0)}function ge(){try{e.compressedTexImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ne(){try{e.compressedTexImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Te(){try{e.texSubImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ge(){try{e.texSubImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function lt(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ve(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function De(){try{e.texStorage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Fe(){try{e.texStorage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function ht(){try{e.texImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ke(){try{e.texImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function vt(ce){ne.equals(ce)===!1&&(e.scissor(ce.x,ce.y,ce.z,ce.w),ne.copy(ce))}function dt(ce){te.equals(ce)===!1&&(e.viewport(ce.x,ce.y,ce.z,ce.w),te.copy(ce))}function Wt(ce,we){let Ue=c.get(we);Ue===void 0&&(Ue=new WeakMap,c.set(we,Ue));let We=Ue.get(ce);We===void 0&&(We=e.getUniformBlockIndex(we,ce.name),Ue.set(ce,We))}function ui(ce,we){let Ue=c.get(we).get(ce);u.get(we)!==Ue&&(e.uniformBlockBinding(we,Ue,ce.__bindingPointIndex),u.set(we,Ue))}function Di(){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,ae={},p={},f=new WeakMap,m=[],v=null,y=!1,x=null,b=null,_=null,S=null,M=null,C=null,A=null,T=!1,P=null,R=null,z=null,N=null,B=null,ne.set(0,0,e.canvas.width,e.canvas.height),te.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:be,disable:ue,bindFramebuffer:ye,drawBuffers:de,useProgram:Be,setBlending:Ze,setMaterial:Qe,setFlipSided:Je,setCullFace:$e,setLineWidth:He,setPolygonOffset:je,setScissorTest:ot,activeTexture:gt,bindTexture:Q,unbindTexture:j,compressedTexImage2D:ge,compressedTexImage3D:Ne,texImage2D:ht,texImage3D:Ke,updateUBOMapping:Wt,uniformBlockBinding:ui,texStorage2D:De,texStorage3D:Fe,texSubImage2D:Te,texSubImage3D:Ge,compressedTexSubImage2D:lt,compressedTexSubImage3D:Ve,scissor:vt,viewport:dt,reset:Di}}function Wz(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,u=s.maxTextureSize,c=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,m,v=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(Q,j){return y?new OffscreenCanvas(Q,j):gd("canvas")}function b(Q,j,ge,Ne){let Te=1;if((Q.width>Ne||Q.height>Ne)&&(Te=Ne/Math.max(Q.width,Q.height)),Te<1||j===!0)if(typeof HTMLImageElement<"u"&&Q instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Q instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Q instanceof ImageBitmap){let Ge=j?lm:Math.floor,lt=Ge(Te*Q.width),Ve=Ge(Te*Q.height);m===void 0&&(m=x(lt,Ve));let De=ge?x(lt,Ve):m;return De.width=lt,De.height=Ve,De.getContext("2d").drawImage(Q,0,0,lt,Ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+lt+"x"+Ve+")."),De}else return"data"in Q&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),Q;return Q}function _(Q){return oy(Q.width)&&oy(Q.height)}function S(Q){return o?!1:Q.wrapS!==Pi||Q.wrapT!==Pi||Q.minFilter!==si&&Q.minFilter!==zt}function M(Q,j){return Q.generateMipmaps&&j&&Q.minFilter!==si&&Q.minFilter!==zt}function C(Q){e.generateMipmap(Q)}function A(Q,j,ge,Ne,Te=!1){if(o===!1)return j;if(Q!==null){if(e[Q]!==void 0)return e[Q];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Q+"'")}let Ge=j;return j===6403&&(ge===5126&&(Ge=33326),ge===5131&&(Ge=33325),ge===5121&&(Ge=33321)),j===33319&&(ge===5126&&(Ge=33328),ge===5131&&(Ge=33327),ge===5121&&(Ge=33323)),j===6408&&(ge===5126&&(Ge=34836),ge===5131&&(Ge=34842),ge===5121&&(Ge=Ne===Rt&&Te===!1?35907:32856),ge===32819&&(Ge=32854),ge===32820&&(Ge=32855)),(Ge===33325||Ge===33326||Ge===33327||Ge===33328||Ge===34842||Ge===34836)&&t.get("EXT_color_buffer_float"),Ge}function T(Q,j,ge){return M(Q,ge)===!0||Q.isFramebufferTexture&&Q.minFilter!==si&&Q.minFilter!==zt?Math.log2(Math.max(j.width,j.height))+1:Q.mipmaps!==void 0&&Q.mipmaps.length>0?Q.mipmaps.length:Q.isCompressedTexture&&Array.isArray(Q.image)?j.mipmaps.length:1}function P(Q){return Q===si||Q===Fw||Q===Qg?9728:9729}function R(Q){let j=Q.target;j.removeEventListener("dispose",R),N(j),j.isVideoTexture&&f.delete(j)}function z(Q){let j=Q.target;j.removeEventListener("dispose",z),V(j)}function N(Q){let j=r.get(Q);if(j.__webglInit===void 0)return;let ge=Q.source,Ne=v.get(ge);if(Ne){let Te=Ne[j.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&B(Q),Object.keys(Ne).length===0&&v.delete(ge)}r.remove(Q)}function B(Q){let j=r.get(Q);e.deleteTexture(j.__webglTexture);let ge=Q.source,Ne=v.get(ge);delete Ne[j.__cacheKey],n.memory.textures--}function V(Q){let j=Q.texture,ge=r.get(Q),Ne=r.get(j);if(Ne.__webglTexture!==void 0&&(e.deleteTexture(Ne.__webglTexture),n.memory.textures--),Q.depthTexture&&Q.depthTexture.dispose(),Q.isWebGLCubeRenderTarget)for(let Te=0;Te<6;Te++)e.deleteFramebuffer(ge.__webglFramebuffer[Te]),ge.__webglDepthbuffer&&e.deleteRenderbuffer(ge.__webglDepthbuffer[Te]);else{if(e.deleteFramebuffer(ge.__webglFramebuffer),ge.__webglDepthbuffer&&e.deleteRenderbuffer(ge.__webglDepthbuffer),ge.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ge.__webglMultisampledFramebuffer),ge.__webglColorRenderbuffer)for(let Te=0;Te<ge.__webglColorRenderbuffer.length;Te++)ge.__webglColorRenderbuffer[Te]&&e.deleteRenderbuffer(ge.__webglColorRenderbuffer[Te]);ge.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ge.__webglDepthRenderbuffer)}if(Q.isWebGLMultipleRenderTargets)for(let Te=0,Ge=j.length;Te<Ge;Te++){let lt=r.get(j[Te]);lt.__webglTexture&&(e.deleteTexture(lt.__webglTexture),n.memory.textures--),r.remove(j[Te])}r.remove(j),r.remove(Q)}let H=0;function X(){H=0}function G(){let Q=H;return Q>=l&&console.warn("THREE.WebGLTextures: Trying to use "+Q+" texture units while this GPU supports only "+l),H+=1,Q}function se(Q){let j=[];return j.push(Q.wrapS),j.push(Q.wrapT),j.push(Q.wrapR||0),j.push(Q.magFilter),j.push(Q.minFilter),j.push(Q.anisotropy),j.push(Q.internalFormat),j.push(Q.format),j.push(Q.type),j.push(Q.generateMipmaps),j.push(Q.premultiplyAlpha),j.push(Q.flipY),j.push(Q.unpackAlignment),j.push(Q.encoding),j.join()}function ae(Q,j){let ge=r.get(Q);if(Q.isVideoTexture&&ot(Q),Q.isRenderTargetTexture===!1&&Q.version>0&&ge.__version!==Q.version){let Ne=Q.image;if(Ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ue(ge,Q,j);return}}i.bindTexture(3553,ge.__webglTexture,33984+j)}function J(Q,j){let ge=r.get(Q);if(Q.version>0&&ge.__version!==Q.version){ue(ge,Q,j);return}i.bindTexture(35866,ge.__webglTexture,33984+j)}function K(Q,j){let ge=r.get(Q);if(Q.version>0&&ge.__version!==Q.version){ue(ge,Q,j);return}i.bindTexture(32879,ge.__webglTexture,33984+j)}function ne(Q,j){let ge=r.get(Q);if(Q.version>0&&ge.__version!==Q.version){ye(ge,Q,j);return}i.bindTexture(34067,ge.__webglTexture,33984+j)}let te={[eo]:10497,[Pi]:33071,[sy]:33648},oe={[si]:9728,[Fw]:9984,[Qg]:9986,[zt]:9729,[AI]:9985,[_c]:9987};function ie(Q,j,ge){if(ge?(e.texParameteri(Q,10242,te[j.wrapS]),e.texParameteri(Q,10243,te[j.wrapT]),(Q===32879||Q===35866)&&e.texParameteri(Q,32882,te[j.wrapR]),e.texParameteri(Q,10240,oe[j.magFilter]),e.texParameteri(Q,10241,oe[j.minFilter])):(e.texParameteri(Q,10242,33071),e.texParameteri(Q,10243,33071),(Q===32879||Q===35866)&&e.texParameteri(Q,32882,33071),(j.wrapS!==Pi||j.wrapT!==Pi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(Q,10240,P(j.magFilter)),e.texParameteri(Q,10241,P(j.minFilter)),j.minFilter!==si&&j.minFilter!==zt&&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 Ne=t.get("EXT_texture_filter_anisotropic");if(j.magFilter===si||j.minFilter!==Qg&&j.minFilter!==_c||j.type===lr&&t.has("OES_texture_float_linear")===!1||o===!1&&j.type===Hl&&t.has("OES_texture_half_float_linear")===!1)return;(j.anisotropy>1||r.get(j).__currentAnisotropy)&&(e.texParameterf(Q,Ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,s.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy)}}function be(Q,j){let ge=!1;Q.__webglInit===void 0&&(Q.__webglInit=!0,j.addEventListener("dispose",R));let Ne=j.source,Te=v.get(Ne);Te===void 0&&(Te={},v.set(Ne,Te));let Ge=se(j);if(Ge!==Q.__cacheKey){Te[Ge]===void 0&&(Te[Ge]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,ge=!0),Te[Ge].usedTimes++;let lt=Te[Q.__cacheKey];lt!==void 0&&(Te[Q.__cacheKey].usedTimes--,lt.usedTimes===0&&B(j)),Q.__cacheKey=Ge,Q.__webglTexture=Te[Ge].texture}return ge}function ue(Q,j,ge){let Ne=3553;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(Ne=35866),j.isData3DTexture&&(Ne=32879);let Te=be(Q,j),Ge=j.source;i.bindTexture(Ne,Q.__webglTexture,33984+ge);let lt=r.get(Ge);if(Ge.version!==lt.__version||Te===!0){i.activeTexture(33984+ge),e.pixelStorei(37440,j.flipY),e.pixelStorei(37441,j.premultiplyAlpha),e.pixelStorei(3317,j.unpackAlignment),e.pixelStorei(37443,0);let Ve=S(j)&&_(j.image)===!1,De=b(j.image,Ve,!1,u);De=gt(j,De);let Fe=_(De)||o,ht=a.convert(j.format,j.encoding),Ke=a.convert(j.type),vt=A(j.internalFormat,ht,Ke,j.encoding,j.isVideoTexture);ie(Ne,j,Fe);let dt,Wt=j.mipmaps,ui=o&&j.isVideoTexture!==!0,Di=lt.__version===void 0||Te===!0,ce=T(j,De,Fe);if(j.isDepthTexture)vt=6402,o?j.type===lr?vt=36012:j.type===to?vt=33190:j.type===Ll?vt=35056:vt=33189:j.type===lr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),j.format===zl&&vt===6402&&j.type!==kE&&j.type!==to&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),j.type=to,Ke=a.convert(j.type)),j.format===Wl&&vt===6402&&(vt=34041,j.type!==Ll&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),j.type=Ll,Ke=a.convert(j.type))),Di&&(ui?i.texStorage2D(3553,1,vt,De.width,De.height):i.texImage2D(3553,0,vt,De.width,De.height,0,ht,Ke,null));else if(j.isDataTexture)if(Wt.length>0&&Fe){ui&&Di&&i.texStorage2D(3553,ce,vt,Wt[0].width,Wt[0].height);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],ui?i.texSubImage2D(3553,we,0,0,dt.width,dt.height,ht,Ke,dt.data):i.texImage2D(3553,we,vt,dt.width,dt.height,0,ht,Ke,dt.data);j.generateMipmaps=!1}else ui?(Di&&i.texStorage2D(3553,ce,vt,De.width,De.height),i.texSubImage2D(3553,0,0,0,De.width,De.height,ht,Ke,De.data)):i.texImage2D(3553,0,vt,De.width,De.height,0,ht,Ke,De.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){ui&&Di&&i.texStorage3D(35866,ce,vt,Wt[0].width,Wt[0].height,De.depth);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],j.format!==Pr?ht!==null?ui?i.compressedTexSubImage3D(35866,we,0,0,0,dt.width,dt.height,De.depth,ht,dt.data,0,0):i.compressedTexImage3D(35866,we,vt,dt.width,dt.height,De.depth,0,dt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ui?i.texSubImage3D(35866,we,0,0,0,dt.width,dt.height,De.depth,ht,Ke,dt.data):i.texImage3D(35866,we,vt,dt.width,dt.height,De.depth,0,ht,Ke,dt.data)}else{ui&&Di&&i.texStorage2D(3553,ce,vt,Wt[0].width,Wt[0].height);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],j.format!==Pr?ht!==null?ui?i.compressedTexSubImage2D(3553,we,0,0,dt.width,dt.height,ht,dt.data):i.compressedTexImage2D(3553,we,vt,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ui?i.texSubImage2D(3553,we,0,0,dt.width,dt.height,ht,Ke,dt.data):i.texImage2D(3553,we,vt,dt.width,dt.height,0,ht,Ke,dt.data)}else if(j.isDataArrayTexture)ui?(Di&&i.texStorage3D(35866,ce,vt,De.width,De.height,De.depth),i.texSubImage3D(35866,0,0,0,0,De.width,De.height,De.depth,ht,Ke,De.data)):i.texImage3D(35866,0,vt,De.width,De.height,De.depth,0,ht,Ke,De.data);else if(j.isData3DTexture)ui?(Di&&i.texStorage3D(32879,ce,vt,De.width,De.height,De.depth),i.texSubImage3D(32879,0,0,0,0,De.width,De.height,De.depth,ht,Ke,De.data)):i.texImage3D(32879,0,vt,De.width,De.height,De.depth,0,ht,Ke,De.data);else if(j.isFramebufferTexture){if(Di)if(ui)i.texStorage2D(3553,ce,vt,De.width,De.height);else{let we=De.width,Ue=De.height;for(let We=0;We<ce;We++)i.texImage2D(3553,We,vt,we,Ue,0,ht,Ke,null),we>>=1,Ue>>=1}}else if(Wt.length>0&&Fe){ui&&Di&&i.texStorage2D(3553,ce,vt,Wt[0].width,Wt[0].height);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],ui?i.texSubImage2D(3553,we,0,0,ht,Ke,dt):i.texImage2D(3553,we,vt,ht,Ke,dt);j.generateMipmaps=!1}else ui?(Di&&i.texStorage2D(3553,ce,vt,De.width,De.height),i.texSubImage2D(3553,0,0,0,ht,Ke,De)):i.texImage2D(3553,0,vt,ht,Ke,De);M(j,Fe)&&C(Ne),lt.__version=Ge.version,j.onUpdate&&j.onUpdate(j)}Q.__version=j.version}function ye(Q,j,ge){if(j.image.length!==6)return;let Ne=be(Q,j),Te=j.source;i.bindTexture(34067,Q.__webglTexture,33984+ge);let Ge=r.get(Te);if(Te.version!==Ge.__version||Ne===!0){i.activeTexture(33984+ge),e.pixelStorei(37440,j.flipY),e.pixelStorei(37441,j.premultiplyAlpha),e.pixelStorei(3317,j.unpackAlignment),e.pixelStorei(37443,0);let lt=j.isCompressedTexture||j.image[0].isCompressedTexture,Ve=j.image[0]&&j.image[0].isDataTexture,De=[];for(let we=0;we<6;we++)!lt&&!Ve?De[we]=b(j.image[we],!1,!0,h):De[we]=Ve?j.image[we].image:j.image[we],De[we]=gt(j,De[we]);let Fe=De[0],ht=_(Fe)||o,Ke=a.convert(j.format,j.encoding),vt=a.convert(j.type),dt=A(j.internalFormat,Ke,vt,j.encoding),Wt=o&&j.isVideoTexture!==!0,ui=Ge.__version===void 0||Ne===!0,Di=T(j,Fe,ht);ie(34067,j,ht);let ce;if(lt){Wt&&ui&&i.texStorage2D(34067,Di,dt,Fe.width,Fe.height);for(let we=0;we<6;we++){ce=De[we].mipmaps;for(let Ue=0;Ue<ce.length;Ue++){let We=ce[Ue];j.format!==Pr?Ke!==null?Wt?i.compressedTexSubImage2D(34069+we,Ue,0,0,We.width,We.height,Ke,We.data):i.compressedTexImage2D(34069+we,Ue,dt,We.width,We.height,0,We.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Wt?i.texSubImage2D(34069+we,Ue,0,0,We.width,We.height,Ke,vt,We.data):i.texImage2D(34069+we,Ue,dt,We.width,We.height,0,Ke,vt,We.data)}}}else{ce=j.mipmaps,Wt&&ui&&(ce.length>0&&Di++,i.texStorage2D(34067,Di,dt,De[0].width,De[0].height));for(let we=0;we<6;we++)if(Ve){Wt?i.texSubImage2D(34069+we,0,0,0,De[we].width,De[we].height,Ke,vt,De[we].data):i.texImage2D(34069+we,0,dt,De[we].width,De[we].height,0,Ke,vt,De[we].data);for(let Ue=0;Ue<ce.length;Ue++){let We=ce[Ue].image[we].image;Wt?i.texSubImage2D(34069+we,Ue+1,0,0,We.width,We.height,Ke,vt,We.data):i.texImage2D(34069+we,Ue+1,dt,We.width,We.height,0,Ke,vt,We.data)}}else{Wt?i.texSubImage2D(34069+we,0,0,0,Ke,vt,De[we]):i.texImage2D(34069+we,0,dt,Ke,vt,De[we]);for(let Ue=0;Ue<ce.length;Ue++){let We=ce[Ue];Wt?i.texSubImage2D(34069+we,Ue+1,0,0,Ke,vt,We.image[we]):i.texImage2D(34069+we,Ue+1,dt,Ke,vt,We.image[we])}}}M(j,ht)&&C(34067),Ge.__version=Te.version,j.onUpdate&&j.onUpdate(j)}Q.__version=j.version}function de(Q,j,ge,Ne,Te){let Ge=a.convert(ge.format,ge.encoding),lt=a.convert(ge.type),Ve=A(ge.internalFormat,Ge,lt,ge.encoding);r.get(j).__hasExternalTextures||(Te===32879||Te===35866?i.texImage3D(Te,0,Ve,j.width,j.height,j.depth,0,Ge,lt,null):i.texImage2D(Te,0,Ve,j.width,j.height,0,Ge,lt,null)),i.bindFramebuffer(36160,Q),je(j)?d.framebufferTexture2DMultisampleEXT(36160,Ne,Te,r.get(ge).__webglTexture,0,He(j)):(Te===3553||Te>=34069&&Te<=34074)&&e.framebufferTexture2D(36160,Ne,Te,r.get(ge).__webglTexture,0),i.bindFramebuffer(36160,null)}function Be(Q,j,ge){if(e.bindRenderbuffer(36161,Q),j.depthBuffer&&!j.stencilBuffer){let Ne=33189;if(ge||je(j)){let Te=j.depthTexture;Te&&Te.isDepthTexture&&(Te.type===lr?Ne=36012:Te.type===to&&(Ne=33190));let Ge=He(j);je(j)?d.renderbufferStorageMultisampleEXT(36161,Ge,Ne,j.width,j.height):e.renderbufferStorageMultisample(36161,Ge,Ne,j.width,j.height)}else e.renderbufferStorage(36161,Ne,j.width,j.height);e.framebufferRenderbuffer(36160,36096,36161,Q)}else if(j.depthBuffer&&j.stencilBuffer){let Ne=He(j);ge&&je(j)===!1?e.renderbufferStorageMultisample(36161,Ne,35056,j.width,j.height):je(j)?d.renderbufferStorageMultisampleEXT(36161,Ne,35056,j.width,j.height):e.renderbufferStorage(36161,34041,j.width,j.height),e.framebufferRenderbuffer(36160,33306,36161,Q)}else{let Ne=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let Te=0;Te<Ne.length;Te++){let Ge=Ne[Te],lt=a.convert(Ge.format,Ge.encoding),Ve=a.convert(Ge.type),De=A(Ge.internalFormat,lt,Ve,Ge.encoding),Fe=He(j);ge&&je(j)===!1?e.renderbufferStorageMultisample(36161,Fe,De,j.width,j.height):je(j)?d.renderbufferStorageMultisampleEXT(36161,Fe,De,j.width,j.height):e.renderbufferStorage(36161,De,j.width,j.height)}}e.bindRenderbuffer(36161,null)}function Ce(Q,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,Q),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(j.depthTexture).__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),ae(j.depthTexture,0);let ge=r.get(j.depthTexture).__webglTexture,Ne=He(j);if(j.depthTexture.format===zl)je(j)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ge,0,Ne):e.framebufferTexture2D(36160,36096,3553,ge,0);else if(j.depthTexture.format===Wl)je(j)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ge,0,Ne):e.framebufferTexture2D(36160,33306,3553,ge,0);else throw new Error("Unknown depthTexture format")}function _e(Q){let j=r.get(Q),ge=Q.isWebGLCubeRenderTarget===!0;if(Q.depthTexture&&!j.__autoAllocateDepthBuffer){if(ge)throw new Error("target.depthTexture not supported in Cube render targets");Ce(j.__webglFramebuffer,Q)}else if(ge){j.__webglDepthbuffer=[];for(let Ne=0;Ne<6;Ne++)i.bindFramebuffer(36160,j.__webglFramebuffer[Ne]),j.__webglDepthbuffer[Ne]=e.createRenderbuffer(),Be(j.__webglDepthbuffer[Ne],Q,!1)}else i.bindFramebuffer(36160,j.__webglFramebuffer),j.__webglDepthbuffer=e.createRenderbuffer(),Be(j.__webglDepthbuffer,Q,!1);i.bindFramebuffer(36160,null)}function Ze(Q,j,ge){let Ne=r.get(Q);j!==void 0&&de(Ne.__webglFramebuffer,Q,Q.texture,36064,3553),ge!==void 0&&_e(Q)}function Qe(Q){let j=Q.texture,ge=r.get(Q),Ne=r.get(j);Q.addEventListener("dispose",z),Q.isWebGLMultipleRenderTargets!==!0&&(Ne.__webglTexture===void 0&&(Ne.__webglTexture=e.createTexture()),Ne.__version=j.version,n.memory.textures++);let Te=Q.isWebGLCubeRenderTarget===!0,Ge=Q.isWebGLMultipleRenderTargets===!0,lt=_(Q)||o;if(Te){ge.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)ge.__webglFramebuffer[Ve]=e.createFramebuffer()}else{if(ge.__webglFramebuffer=e.createFramebuffer(),Ge)if(s.drawBuffers){let Ve=Q.texture;for(let De=0,Fe=Ve.length;De<Fe;De++){let ht=r.get(Ve[De]);ht.__webglTexture===void 0&&(ht.__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&&Q.samples>0&&je(Q)===!1){let Ve=Ge?j:[j];ge.__webglMultisampledFramebuffer=e.createFramebuffer(),ge.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ge.__webglMultisampledFramebuffer);for(let De=0;De<Ve.length;De++){let Fe=Ve[De];ge.__webglColorRenderbuffer[De]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ge.__webglColorRenderbuffer[De]);let ht=a.convert(Fe.format,Fe.encoding),Ke=a.convert(Fe.type),vt=A(Fe.internalFormat,ht,Ke,Fe.encoding,Q.isXRRenderTarget===!0),dt=He(Q);e.renderbufferStorageMultisample(36161,dt,vt,Q.width,Q.height),e.framebufferRenderbuffer(36160,36064+De,36161,ge.__webglColorRenderbuffer[De])}e.bindRenderbuffer(36161,null),Q.depthBuffer&&(ge.__webglDepthRenderbuffer=e.createRenderbuffer(),Be(ge.__webglDepthRenderbuffer,Q,!0)),i.bindFramebuffer(36160,null)}}if(Te){i.bindTexture(34067,Ne.__webglTexture),ie(34067,j,lt);for(let Ve=0;Ve<6;Ve++)de(ge.__webglFramebuffer[Ve],Q,j,36064,34069+Ve);M(j,lt)&&C(34067),i.unbindTexture()}else if(Ge){let Ve=Q.texture;for(let De=0,Fe=Ve.length;De<Fe;De++){let ht=Ve[De],Ke=r.get(ht);i.bindTexture(3553,Ke.__webglTexture),ie(3553,ht,lt),de(ge.__webglFramebuffer,Q,ht,36064+De,3553),M(ht,lt)&&C(3553)}i.unbindTexture()}else{let Ve=3553;(Q.isWebGL3DRenderTarget||Q.isWebGLArrayRenderTarget)&&(o?Ve=Q.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ve,Ne.__webglTexture),ie(Ve,j,lt),de(ge.__webglFramebuffer,Q,j,36064,Ve),M(j,lt)&&C(Ve),i.unbindTexture()}Q.depthBuffer&&_e(Q)}function Je(Q){let j=_(Q)||o,ge=Q.isWebGLMultipleRenderTargets===!0?Q.texture:[Q.texture];for(let Ne=0,Te=ge.length;Ne<Te;Ne++){let Ge=ge[Ne];if(M(Ge,j)){let lt=Q.isWebGLCubeRenderTarget?34067:3553,Ve=r.get(Ge).__webglTexture;i.bindTexture(lt,Ve),C(lt),i.unbindTexture()}}}function $e(Q){if(o&&Q.samples>0&&je(Q)===!1){let j=Q.isWebGLMultipleRenderTargets?Q.texture:[Q.texture],ge=Q.width,Ne=Q.height,Te=16384,Ge=[],lt=Q.stencilBuffer?33306:36096,Ve=r.get(Q),De=Q.isWebGLMultipleRenderTargets===!0;if(De)for(let Fe=0;Fe<j.length;Fe++)i.bindFramebuffer(36160,Ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,null),i.bindFramebuffer(36160,Ve.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,null,0);i.bindFramebuffer(36008,Ve.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ve.__webglFramebuffer);for(let Fe=0;Fe<j.length;Fe++){Ge.push(36064+Fe),Q.depthBuffer&&Ge.push(lt);let ht=Ve.__ignoreDepthValues!==void 0?Ve.__ignoreDepthValues:!1;if(ht===!1&&(Q.depthBuffer&&(Te|=256),Q.stencilBuffer&&(Te|=1024)),De&&e.framebufferRenderbuffer(36008,36064,36161,Ve.__webglColorRenderbuffer[Fe]),ht===!0&&(e.invalidateFramebuffer(36008,[lt]),e.invalidateFramebuffer(36009,[lt])),De){let Ke=r.get(j[Fe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ke,0)}e.blitFramebuffer(0,0,ge,Ne,0,0,ge,Ne,Te,9728),p&&e.invalidateFramebuffer(36008,Ge)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),De)for(let Fe=0;Fe<j.length;Fe++){i.bindFramebuffer(36160,Ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,Ve.__webglColorRenderbuffer[Fe]);let ht=r.get(j[Fe]).__webglTexture;i.bindFramebuffer(36160,Ve.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,ht,0)}i.bindFramebuffer(36009,Ve.__webglMultisampledFramebuffer)}}function He(Q){return Math.min(c,Q.samples)}function je(Q){let j=r.get(Q);return o&&Q.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function ot(Q){let j=n.render.frame;f.get(Q)!==j&&(f.set(Q,j),Q.update())}function gt(Q,j){let ge=Q.encoding,Ne=Q.format,Te=Q.type;return Q.isCompressedTexture===!0||Q.isVideoTexture===!0||Q.format===ny||ge!==Na&&(ge===Rt?o===!1?t.has("EXT_sRGB")===!0&&Ne===Pr?(Q.format=ny,Q.minFilter=zt,Q.generateMipmaps=!1):j=WE.sRGBToLinear(j):(Ne!==Pr||Te!==ns)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ge)),j}this.allocateTextureUnit=G,this.resetTextureUnits=X,this.setTexture2D=ae,this.setTexture2DArray=J,this.setTexture3D=K,this.setTextureCube=ne,this.rebindTextures=Ze,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=Je,this.updateMultisampleRenderTarget=$e,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=de,this.useMultisampledRTT=je}function qz(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===ns)return 5121;if(a===TI)return 32819;if(a===PI)return 32820;if(a===MI)return 5120;if(a===EI)return 5122;if(a===kE)return 5123;if(a===CI)return 5124;if(a===to)return 5125;if(a===lr)return 5126;if(a===Hl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===DI)return 6406;if(a===Pr)return 6408;if(a===OI)return 6409;if(a===II)return 6410;if(a===zl)return 6402;if(a===Wl)return 34041;if(a===ny)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===RI)return 6403;if(a===BI)return 36244;if(a===rm)return 33319;if(a===LI)return 33320;if(a===NE)return 36249;if(a===Zg||a===Kg||a===Jg||a===$g)if(n===Rt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===Zg)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Kg)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Jg)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===$g)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===Zg)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Kg)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Jg)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===$g)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Uw||a===Vw||a===jw||a===Gw)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Uw)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Vw)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===jw)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Gw)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===zI)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===Hw||a===Ww)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===Hw)return n===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===Ww)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===qw||a===Xw||a===Yw||a===Qw||a===Zw||a===Kw||a===Jw||a===$w||a===e_||a===t_||a===i_||a===r_||a===s_||a===a_)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===qw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Xw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Yw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===Qw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Zw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===Kw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Jw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===$w)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===e_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===t_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===i_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===r_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===s_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===a_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===ev)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===ev)return n===Rt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===kI||a===n_||a===o_||a===l_)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===ev)return o.COMPRESSED_RED_RGTC1_EXT;if(a===n_)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===o_)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===l_)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Ll?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 Xz=class extends es{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ml=class extends ci{constructor(){super(),this.isGroup=!0,this.type="Group"}},Yz={type:"move"},Ev=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ml,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 Ml,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 Ml,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 m=t.getJointPose(f,i),v=this._getHandJoint(l,f);m!==null&&(v.matrix.fromArray(m.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=m.radius),v.visible=m!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],c=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&c>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));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(Yz)))}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 Ml;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ac=class extends Li{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:zl,h!==zl&&h!==Wl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===zl&&(i=to),i===void 0&&h===Wl&&(i=Ll),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:si,this.minFilter=o!==void 0?o:si,this.flipY=!1,this.generateMipmaps=!1}},Qz=class extends Qr{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),m=null,v=null,y=[],x=[],b=new Set,_=new Map,S=new es;S.layers.enable(1),S.viewport=new Et;let M=new es;M.layers.enable(2),M.viewport=new Et;let C=[S,M],A=new Xz;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(J){let K=y[J];return K===void 0&&(K=new Ev,y[J]=K),K.getTargetRaySpace()},this.getControllerGrip=function(J){let K=y[J];return K===void 0&&(K=new Ev,y[J]=K),K.getGripSpace()},this.getHand=function(J){let K=y[J];return K===void 0&&(K=new Ev,y[J]=K),K.getHandSpace()};function R(J){let K=x.indexOf(J.inputSource);if(K===-1)return;let ne=y[K];ne!==void 0&&ne.dispatchEvent({type:J.type,data:J.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",N);for(let J=0;J<y.length;J++){let K=x[J];K!==null&&(x[J]=null,y[J].disconnect(K))}T=null,P=null,e.setRenderTarget(m),d=null,c=null,u=null,r=null,v=null,ae.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){n=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(J){l=J},this.getBaseLayer=function(){return c!==null?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(J){if(r=J,r!==null){if(m=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",N),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let K={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,K),r.updateRenderState({baseLayer:d}),v=new ai(d.framebufferWidth,d.framebufferHeight,{format:Pr,type:ns,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let K=null,ne=null,te=null;f.depth&&(te=f.stencil?35056:33190,K=f.stencil?Wl:zl,ne=f.stencil?Ll:to);let oe={colorFormat:32856,depthFormat:te,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(oe),r.updateRenderState({layers:[c]}),v=new ai(c.textureWidth,c.textureHeight,{format:Pr,type:ns,depthTexture:new Ac(c.textureWidth,c.textureHeight,ne,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let ie=e.properties.get(v);ie.__ignoreDepthValues=c.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),ae.setContext(r),ae.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function N(J){for(let K=0;K<J.removed.length;K++){let ne=J.removed[K],te=x.indexOf(ne);te>=0&&(x[te]=null,y[te].disconnect(ne))}for(let K=0;K<J.added.length;K++){let ne=J.added[K],te=x.indexOf(ne);if(te===-1){for(let ie=0;ie<y.length;ie++)if(ie>=x.length){x.push(ne),te=ie;break}else if(x[ie]===null){x[ie]=ne,te=ie;break}if(te===-1)break}let oe=y[te];oe&&oe.connect(ne)}}let B=new I,V=new I;function H(J,K,ne){B.setFromMatrixPosition(K.matrixWorld),V.setFromMatrixPosition(ne.matrixWorld);let te=B.distanceTo(V),oe=K.projectionMatrix.elements,ie=ne.projectionMatrix.elements,be=oe[14]/(oe[10]-1),ue=oe[14]/(oe[10]+1),ye=(oe[9]+1)/oe[5],de=(oe[9]-1)/oe[5],Be=(oe[8]-1)/oe[0],Ce=(ie[8]+1)/ie[0],_e=be*Be,Ze=be*Ce,Qe=te/(-Be+Ce),Je=Qe*-Be;K.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Je),J.translateZ(Qe),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();let $e=be+Qe,He=ue+Qe,je=_e-Je,ot=Ze+(te-Je),gt=ye*ue/He*$e,Q=de*ue/He*$e;J.projectionMatrix.makePerspective(je,ot,gt,Q,$e,He)}function X(J,K){K===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(K.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(r===null)return;A.near=M.near=S.near=J.near,A.far=M.far=S.far=J.far,(T!==A.near||P!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),T=A.near,P=A.far);let K=J.parent,ne=A.cameras;X(A,K);for(let oe=0;oe<ne.length;oe++)X(ne[oe],K);A.matrixWorld.decompose(A.position,A.quaternion,A.scale),J.matrix.copy(A.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale);let te=J.children;for(let oe=0,ie=te.length;oe<ie;oe++)te[oe].updateMatrixWorld(!0);ne.length===2?H(A,S,M):A.projectionMatrix.copy(S.projectionMatrix)},this.getCamera=function(){return A},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(J){o=J,c!==null&&(c.fixedFoveation=J),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=J)},this.getPlanes=function(){return b};let G=null;function se(J,K){if(h=K.getViewerPose(l||a),p=K,h!==null){let ne=h.views;d!==null&&(e.setRenderTargetFramebuffer(v,d.framebuffer),e.setRenderTarget(v));let te=!1;ne.length!==A.cameras.length&&(A.cameras.length=0,te=!0);for(let oe=0;oe<ne.length;oe++){let ie=ne[oe],be=null;if(d!==null)be=d.getViewport(ie);else{let ye=u.getViewSubImage(c,ie);be=ye.viewport,oe===0&&(e.setRenderTargetTextures(v,ye.colorTexture,c.ignoreDepthValues?void 0:ye.depthStencilTexture),e.setRenderTarget(v))}let ue=C[oe];ue===void 0&&(ue=new es,ue.layers.enable(oe),ue.viewport=new Et,C[oe]=ue),ue.matrix.fromArray(ie.transform.matrix),ue.projectionMatrix.fromArray(ie.projectionMatrix),ue.viewport.set(be.x,be.y,be.width,be.height),oe===0&&A.matrix.copy(ue.matrix),te===!0&&A.cameras.push(ue)}}for(let ne=0;ne<y.length;ne++){let te=x[ne],oe=y[ne];te!==null&&oe!==void 0&&oe.update(te,K,l||a)}if(G&&G(J,K),K.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:K.detectedPlanes});let ne=null;for(let te of b)K.detectedPlanes.has(te)||(ne===null&&(ne=[]),ne.push(te));if(ne!==null)for(let te of ne)b.delete(te),_.delete(te),i.dispatchEvent({type:"planeremoved",data:te});for(let te of K.detectedPlanes)if(!b.has(te))b.add(te),_.set(te,K.lastChangedTime),i.dispatchEvent({type:"planeadded",data:te});else{let oe=_.get(te);te.lastChangedTime>oe&&(_.set(te,te.lastChangedTime),i.dispatchEvent({type:"planechanged",data:te}))}}p=null}let ae=new ZE;ae.setAnimationLoop(se),this.setAnimationLoop=function(J){G=J},this.dispose=function(){}}};function Zz(e,t){function i(m,v){v.color.getRGB(m.fogColor.value,QE(e)),v.isFog?(m.fogNear.value=v.near,m.fogFar.value=v.far):v.isFogExp2&&(m.fogDensity.value=v.density)}function r(m,v,y,x,b){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(m,v):v.isMeshToonMaterial?(s(m,v),u(m,v)):v.isMeshPhongMaterial?(s(m,v),h(m,v)):v.isMeshStandardMaterial?(s(m,v),c(m,v),v.isMeshPhysicalMaterial&&d(m,v,b)):v.isMeshMatcapMaterial?(s(m,v),p(m,v)):v.isMeshDepthMaterial?s(m,v):v.isMeshDistanceMaterial?(s(m,v),f(m,v)):v.isMeshNormalMaterial?s(m,v):v.isLineBasicMaterial?(a(m,v),v.isLineDashedMaterial&&n(m,v)):v.isPointsMaterial?o(m,v,y,x):v.isSpriteMaterial?l(m,v):v.isShadowMaterial?(m.color.value.copy(v.color),m.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(m,v){m.opacity.value=v.opacity,v.color&&m.diffuse.value.copy(v.color),v.emissive&&m.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(m.map.value=v.map),v.alphaMap&&(m.alphaMap.value=v.alphaMap),v.bumpMap&&(m.bumpMap.value=v.bumpMap,m.bumpScale.value=v.bumpScale,v.side===Or&&(m.bumpScale.value*=-1)),v.displacementMap&&(m.displacementMap.value=v.displacementMap,m.displacementScale.value=v.displacementScale,m.displacementBias.value=v.displacementBias),v.emissiveMap&&(m.emissiveMap.value=v.emissiveMap),v.normalMap&&(m.normalMap.value=v.normalMap,m.normalScale.value.copy(v.normalScale),v.side===Or&&m.normalScale.value.negate()),v.specularMap&&(m.specularMap.value=v.specularMap),v.alphaTest>0&&(m.alphaTest.value=v.alphaTest);let y=t.get(v).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=v.reflectivity,m.ior.value=v.ior,m.refractionRatio.value=v.refractionRatio),v.lightMap){m.lightMap.value=v.lightMap;let _=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=v.lightMapIntensity*_}v.aoMap&&(m.aoMap.value=v.aoMap,m.aoMapIntensity.value=v.aoMapIntensity);let x;v.map?x=v.map:v.specularMap?x=v.specularMap:v.displacementMap?x=v.displacementMap:v.normalMap?x=v.normalMap:v.bumpMap?x=v.bumpMap:v.roughnessMap?x=v.roughnessMap:v.metalnessMap?x=v.metalnessMap:v.alphaMap?x=v.alphaMap:v.emissiveMap?x=v.emissiveMap:v.clearcoatMap?x=v.clearcoatMap:v.clearcoatNormalMap?x=v.clearcoatNormalMap:v.clearcoatRoughnessMap?x=v.clearcoatRoughnessMap:v.iridescenceMap?x=v.iridescenceMap:v.iridescenceThicknessMap?x=v.iridescenceThicknessMap:v.specularIntensityMap?x=v.specularIntensityMap:v.specularColorMap?x=v.specularColorMap:v.transmissionMap?x=v.transmissionMap:v.thicknessMap?x=v.thicknessMap:v.sheenColorMap?x=v.sheenColorMap:v.sheenRoughnessMap&&(x=v.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix));let b;v.aoMap?b=v.aoMap:v.lightMap&&(b=v.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function a(m,v){m.diffuse.value.copy(v.color),m.opacity.value=v.opacity}function n(m,v){m.dashSize.value=v.dashSize,m.totalSize.value=v.dashSize+v.gapSize,m.scale.value=v.scale}function o(m,v,y,x){m.diffuse.value.copy(v.color),m.opacity.value=v.opacity,m.size.value=v.size*y,m.scale.value=x*.5,v.map&&(m.map.value=v.map),v.alphaMap&&(m.alphaMap.value=v.alphaMap),v.alphaTest>0&&(m.alphaTest.value=v.alphaTest);let b;v.map?b=v.map:v.alphaMap&&(b=v.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.matrix))}function l(m,v){m.diffuse.value.copy(v.color),m.opacity.value=v.opacity,m.rotation.value=v.rotation,v.map&&(m.map.value=v.map),v.alphaMap&&(m.alphaMap.value=v.alphaMap),v.alphaTest>0&&(m.alphaTest.value=v.alphaTest);let y;v.map?y=v.map:v.alphaMap&&(y=v.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function h(m,v){m.specular.value.copy(v.specular),m.shininess.value=Math.max(v.shininess,1e-4)}function u(m,v){v.gradientMap&&(m.gradientMap.value=v.gradientMap)}function c(m,v){m.roughness.value=v.roughness,m.metalness.value=v.metalness,v.roughnessMap&&(m.roughnessMap.value=v.roughnessMap),v.metalnessMap&&(m.metalnessMap.value=v.metalnessMap),t.get(v).envMap&&(m.envMapIntensity.value=v.envMapIntensity)}function d(m,v,y){m.ior.value=v.ior,v.sheen>0&&(m.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),m.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(m.sheenColorMap.value=v.sheenColorMap),v.sheenRoughnessMap&&(m.sheenRoughnessMap.value=v.sheenRoughnessMap)),v.clearcoat>0&&(m.clearcoat.value=v.clearcoat,m.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(m.clearcoatMap.value=v.clearcoatMap),v.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap),v.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),m.clearcoatNormalMap.value=v.clearcoatNormalMap,v.side===Or&&m.clearcoatNormalScale.value.negate())),v.iridescence>0&&(m.iridescence.value=v.iridescence,m.iridescenceIOR.value=v.iridescenceIOR,m.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(m.iridescenceMap.value=v.iridescenceMap),v.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=v.iridescenceThicknessMap)),v.transmission>0&&(m.transmission.value=v.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),v.transmissionMap&&(m.transmissionMap.value=v.transmissionMap),m.thickness.value=v.thickness,v.thicknessMap&&(m.thicknessMap.value=v.thicknessMap),m.attenuationDistance.value=v.attenuationDistance,m.attenuationColor.value.copy(v.attenuationColor)),m.specularIntensity.value=v.specularIntensity,m.specularColor.value.copy(v.specularColor),v.specularIntensityMap&&(m.specularIntensityMap.value=v.specularIntensityMap),v.specularColorMap&&(m.specularColorMap.value=v.specularColorMap)}function p(m,v){v.matcap&&(m.matcap.value=v.matcap)}function f(m,v){m.referencePosition.value.copy(v.referencePosition),m.nearDistance.value=v.nearDistance,m.farDistance.value=v.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Kz(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),_=u(x),s[x.id]=_,x.addEventListener("dispose",v));let S=b.program;r.updateUBOMapping(x,S);let M=t.render.frame;a[x.id]!==M&&(d(x),a[x.id]=M)}function u(x){let b=c();x.__bindingPointIndex=b;let _=e.createBuffer(),S=x.__size,M=x.usage;return e.bindBuffer(35345,_),e.bufferData(35345,S,M),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,_),_}function c(){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,S=x.__cache;e.bindBuffer(35345,b);for(let M=0,C=_.length;M<C;M++){let A=_[M];if(p(A,M,S)===!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 N=P[z],B=m(N);typeof N=="number"?(A.__data[0]=N,e.bufferSubData(35345,T+R,A.__data)):N.isMatrix3?(A.__data[0]=N.elements[0],A.__data[1]=N.elements[1],A.__data[2]=N.elements[2],A.__data[3]=N.elements[0],A.__data[4]=N.elements[3],A.__data[5]=N.elements[4],A.__data[6]=N.elements[5],A.__data[7]=N.elements[0],A.__data[8]=N.elements[6],A.__data[9]=N.elements[7],A.__data[10]=N.elements[8],A.__data[11]=N.elements[0]):(N.toArray(A.__data,R),R+=B.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,T,A.__data)}}e.bindBuffer(35345,null)}function p(x,b,_){let S=x.value;if(_[b]===void 0){if(typeof S=="number")_[b]=S;else{let M=Array.isArray(S)?S:[S],C=[];for(let A=0;A<M.length;A++)C.push(M[A].clone());_[b]=C}return!0}else if(typeof S=="number"){if(_[b]!==S)return _[b]=S,!0}else{let M=Array.isArray(_[b])?_[b]:[_[b]],C=Array.isArray(S)?S:[S];for(let A=0;A<M.length;A++){let T=M[A];if(T.equals(C[A])===!1)return T.copy(C[A]),!0}}return!1}function f(x){let b=x.uniforms,_=0,S=16,M=0;for(let C=0,A=b.length;C<A;C++){let T=b[C],P={boundary:0,storage:0},R=Array.isArray(T.value)?T.value:[T.value];for(let z=0,N=R.length;z<N;z++){let B=R[z],V=m(B);P.boundary+=V.boundary,P.storage+=V.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=_,C>0){M=_%S;let z=S-M;M!==0&&z-P.boundary<0&&(_+=S-M,T.__offset=_)}_+=P.storage}return M=_%S,M>0&&(_+=S-M),x.__size=_,x.__cache={},this}function m(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 v(x){let b=x.target;b.removeEventListener("dispose",v);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 Jz(){let e=gd("canvas");return e.style.display="block",e}function iC(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:Jz(),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,u;i!==null?u=i.getContextAttributes().alpha:u=e.alpha!==void 0?e.alpha:!1;let c=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Na,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;let m=this,v=!1,y=0,x=0,b=null,_=-1,S=null,M=new Et,C=new Et,A=null,T=t.width,P=t.height,R=1,z=null,N=null,B=new Et(0,0,T,P),V=new Et(0,0,T,P),H=!1,X=new lx,G=!1,se=!1,ae=null,J=new Le,K=new $,ne=new I,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function oe(){return b===null?R:1}let ie=i;function be(Z,ve){for(let Ee=0;Ee<Z.length;Ee++){let me=Z[Ee],Pe=t.getContext(me,ve);if(Pe!==null)return Pe}return null}try{let Z={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${zc}`),t.addEventListener("webglcontextlost",vt,!1),t.addEventListener("webglcontextrestored",dt,!1),t.addEventListener("webglcontextcreationerror",Wt,!1),ie===null){let ve=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ve.shift(),ie=be(ve,Z),ie===null)throw be(ve)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ie.getShaderPrecisionFormat===void 0&&(ie.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Z){throw console.error("THREE.WebGLRenderer: "+Z.message),Z}let ue,ye,de,Be,Ce,_e,Ze,Qe,Je,$e,He,je,ot,gt,Q,j,ge,Ne,Te,Ge,lt,Ve,De,Fe;function ht(){ue=new uL(ie),ye=new aL(ie,ue,e),ue.init(ye),Ve=new qz(ie,ue,ye),de=new Hz(ie,ue,ye),Be=new fL,Ce=new Oz,_e=new Wz(ie,ue,de,Ce,ye,Ve,Be),Ze=new oL(m),Qe=new cL(m),Je=new SR(ie,ye),De=new rL(ie,ue,Je,ye),$e=new dL(ie,Je,Be,De),He=new yL(ie,$e,Je,Be),Te=new vL(ie,ye,_e),j=new nL(Ce),je=new Dz(m,Ze,Qe,ue,ye,De,j),ot=new Zz(m,Ce),gt=new Rz,Q=new Fz(ue,ye),Ne=new iL(m,Ze,Qe,de,He,u,n),ge=new Gz(m,He,ye),Fe=new Kz(ie,Be,ye,de),Ge=new sL(ie,ue,Be,ye),lt=new pL(ie,ue,Be,ye),Be.programs=je.programs,m.capabilities=ye,m.extensions=ue,m.properties=Ce,m.renderLists=gt,m.shadowMap=ge,m.state=de,m.info=Be}ht();let Ke=new Qz(m,ie);this.xr=Ke,this.getContext=function(){return ie},this.getContextAttributes=function(){return ie.getContextAttributes()},this.forceContextLoss=function(){let Z=ue.get("WEBGL_lose_context");Z&&Z.loseContext()},this.forceContextRestore=function(){let Z=ue.get("WEBGL_lose_context");Z&&Z.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(Z){Z!==void 0&&(R=Z,this.setSize(T,P,!1))},this.getSize=function(Z){return Z.set(T,P)},this.setSize=function(Z,ve,Ee){if(Ke.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=Z,P=ve,t.width=Math.floor(Z*R),t.height=Math.floor(ve*R),Ee!==!1&&(t.style.width=Z+"px",t.style.height=ve+"px"),this.setViewport(0,0,Z,ve)},this.getDrawingBufferSize=function(Z){return Z.set(T*R,P*R).floor()},this.setDrawingBufferSize=function(Z,ve,Ee){T=Z,P=ve,R=Ee,t.width=Math.floor(Z*Ee),t.height=Math.floor(ve*Ee),this.setViewport(0,0,Z,ve)},this.getCurrentViewport=function(Z){return Z.copy(M)},this.getViewport=function(Z){return Z.copy(B)},this.setViewport=function(Z,ve,Ee,me){Z.isVector4?B.set(Z.x,Z.y,Z.z,Z.w):B.set(Z,ve,Ee,me),de.viewport(M.copy(B).multiplyScalar(R).floor())},this.getScissor=function(Z){return Z.copy(V)},this.setScissor=function(Z,ve,Ee,me){Z.isVector4?V.set(Z.x,Z.y,Z.z,Z.w):V.set(Z,ve,Ee,me),de.scissor(C.copy(V).multiplyScalar(R).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(Z){de.setScissorTest(H=Z)},this.setOpaqueSort=function(Z){z=Z},this.setTransparentSort=function(Z){N=Z},this.getClearColor=function(Z){return Z.copy(Ne.getClearColor())},this.setClearColor=function(){Ne.setClearColor.apply(Ne,arguments)},this.getClearAlpha=function(){return Ne.getClearAlpha()},this.setClearAlpha=function(){Ne.setClearAlpha.apply(Ne,arguments)},this.clear=function(Z=!0,ve=!0,Ee=!0){let me=0;Z&&(me|=16384),ve&&(me|=256),Ee&&(me|=1024),ie.clear(me)},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",vt,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",Wt,!1),gt.dispose(),Q.dispose(),Ce.dispose(),Ze.dispose(),Qe.dispose(),He.dispose(),De.dispose(),Fe.dispose(),je.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",We),Ke.removeEventListener("sessionend",pt),ae&&(ae.dispose(),ae=null),$t.stop()};function vt(Z){Z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function dt(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;let Z=Be.autoReset,ve=ge.enabled,Ee=ge.autoUpdate,me=ge.needsUpdate,Pe=ge.type;ht(),Be.autoReset=Z,ge.enabled=ve,ge.autoUpdate=Ee,ge.needsUpdate=me,ge.type=Pe}function Wt(Z){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Z.statusMessage)}function ui(Z){let ve=Z.target;ve.removeEventListener("dispose",ui),Di(ve)}function Di(Z){ce(Z),Ce.remove(Z)}function ce(Z){let ve=Ce.get(Z).programs;ve!==void 0&&(ve.forEach(function(Ee){je.releaseProgram(Ee)}),Z.isShaderMaterial&&je.releaseShaderCache(Z))}this.renderBufferDirect=function(Z,ve,Ee,me,Pe,tt){ve===null&&(ve=te);let Pt=Pe.isMesh&&Pe.matrixWorld.determinant()<0,Ut=Ng(Z,ve,Ee,me,Pe);de.setMaterial(me,Pt);let kt=Ee.index,ti=1;me.wireframe===!0&&(kt=$e.getWireframeAttribute(Ee),ti=2);let qt=Ee.drawRange,Xt=Ee.attributes.position,di=qt.start*ti,zr=(qt.start+qt.count)*ti;tt!==null&&(di=Math.max(di,tt.start*ti),zr=Math.min(zr,(tt.start+tt.count)*ti)),kt!==null?(di=Math.max(di,0),zr=Math.min(zr,kt.count)):Xt!=null&&(di=Math.max(di,0),zr=Math.min(zr,Xt.count));let Ni=zr-di;if(Ni<0||Ni===1/0)return;De.setup(Pe,me,Ut,Ee,kt);let ir,Fi=Ge;if(kt!==null&&(ir=Je.get(kt),Fi=lt,Fi.setIndex(ir)),Pe.isMesh)me.wireframe===!0?(de.setLineWidth(me.wireframeLinewidth*oe()),Fi.setMode(1)):Fi.setMode(4);else if(Pe.isLine){let jt=me.linewidth;jt===void 0&&(jt=1),de.setLineWidth(jt*oe()),Pe.isLineSegments?Fi.setMode(1):Pe.isLineLoop?Fi.setMode(2):Fi.setMode(3)}else Pe.isPoints?Fi.setMode(0):Pe.isSprite&&Fi.setMode(4);if(Pe.isInstancedMesh)Fi.renderInstances(di,Ni,Pe.count);else if(Ee.isInstancedBufferGeometry){let jt=Ee._maxInstanceCount!==void 0?Ee._maxInstanceCount:1/0,sl=Math.min(Ee.instanceCount,jt);Fi.renderInstances(di,Ni,sl)}else Fi.render(di,Ni)},this.compile=function(Z,ve){function Ee(me,Pe,tt){me.transparent===!0&&me.side===Rs&&me.forceSinglePass===!1?(me.side=Or,me.needsUpdate=!0,Kr(me,Pe,tt),me.side=ka,me.needsUpdate=!0,Kr(me,Pe,tt),me.side=Rs):Kr(me,Pe,tt)}d=Q.get(Z),d.init(),f.push(d),Z.traverseVisible(function(me){me.isLight&&me.layers.test(ve.layers)&&(d.pushLight(me),me.castShadow&&d.pushShadow(me))}),d.setupLights(m.physicallyCorrectLights),Z.traverse(function(me){let Pe=me.material;if(Pe)if(Array.isArray(Pe))for(let tt=0;tt<Pe.length;tt++){let Pt=Pe[tt];Ee(Pt,Z,me)}else Ee(Pe,Z,me)}),f.pop(),d=null};let we=null;function Ue(Z){we&&we(Z)}function We(){$t.stop()}function pt(){$t.start()}let $t=new ZE;$t.setAnimationLoop(Ue),typeof self<"u"&&$t.setContext(self),this.setAnimationLoop=function(Z){we=Z,Ke.setAnimationLoop(Z),Z===null?$t.stop():$t.start()},Ke.addEventListener("sessionstart",We),Ke.addEventListener("sessionend",pt),this.render=function(Z,ve){if(ve!==void 0&&ve.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),ve.parent===null&&ve.matrixWorldAutoUpdate===!0&&ve.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(ve),ve=Ke.getCamera()),Z.isScene===!0&&Z.onBeforeRender(m,Z,ve,b),d=Q.get(Z,f.length),d.init(),f.push(d),J.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),X.setFromProjectionMatrix(J),se=this.localClippingEnabled,G=j.init(this.clippingPlanes,se),c=gt.get(Z,p.length),c.init(),p.push(c),xi(Z,ve,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(z,N),G===!0&&j.beginShadows();let Ee=d.state.shadowsArray;if(ge.render(Ee,Z,ve),G===!0&&j.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ne.render(c,Z),d.setupLights(m.physicallyCorrectLights),ve.isArrayCamera){let me=ve.cameras;for(let Pe=0,tt=me.length;Pe<tt;Pe++){let Pt=me[Pe];ki(c,Z,Pt,Pt.viewport)}}else ki(c,Z,ve);b!==null&&(_e.updateMultisampleRenderTarget(b),_e.updateRenderTargetMipmap(b)),Z.isScene===!0&&Z.onAfterRender(m,Z,ve),De.resetDefaultState(),_=-1,S=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function xi(Z,ve,Ee,me){if(Z.visible===!1)return;if(Z.layers.test(ve.layers)){if(Z.isGroup)Ee=Z.renderOrder;else if(Z.isLOD)Z.autoUpdate===!0&&Z.update(ve);else if(Z.isLight)d.pushLight(Z),Z.castShadow&&d.pushShadow(Z);else if(Z.isSprite){if(!Z.frustumCulled||X.intersectsSprite(Z)){me&&ne.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(J);let tt=He.update(Z),Pt=Z.material;Pt.visible&&c.push(Z,tt,Pt,Ee,ne.z,null)}}else if((Z.isMesh||Z.isLine||Z.isPoints)&&(Z.isSkinnedMesh&&Z.skeleton.frame!==Be.render.frame&&(Z.skeleton.update(),Z.skeleton.frame=Be.render.frame),!Z.frustumCulled||X.intersectsObject(Z))){me&&ne.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(J);let tt=He.update(Z),Pt=Z.material;if(Array.isArray(Pt)){let Ut=tt.groups;for(let kt=0,ti=Ut.length;kt<ti;kt++){let qt=Ut[kt],Xt=Pt[qt.materialIndex];Xt&&Xt.visible&&c.push(Z,tt,Xt,Ee,ne.z,qt)}}else Pt.visible&&c.push(Z,tt,Pt,Ee,ne.z,null)}}let Pe=Z.children;for(let tt=0,Pt=Pe.length;tt<Pt;tt++)xi(Pe[tt],ve,Ee,me)}function ki(Z,ve,Ee,me){let Pe=Z.opaque,tt=Z.transmissive,Pt=Z.transparent;d.setupLightsView(Ee),G===!0&&j.setGlobalState(m.clippingPlanes,Ee),tt.length>0&&Zr(Pe,ve,Ee),me&&de.viewport(M.copy(me)),Pe.length>0&&Si(Pe,ve,Ee),tt.length>0&&Si(tt,ve,Ee),Pt.length>0&&Si(Pt,ve,Ee),de.buffers.depth.setTest(!0),de.buffers.depth.setMask(!0),de.buffers.color.setMask(!0),de.setPolygonOffset(!1)}function Zr(Z,ve,Ee){let me=ye.isWebGL2;ae===null&&(ae=new ai(1,1,{generateMipmaps:!0,type:ue.has("EXT_color_buffer_half_float")?Hl:ns,minFilter:_c,samples:me&&a===!0?4:0})),m.getDrawingBufferSize(K),me?ae.setSize(K.x,K.y):ae.setSize(lm(K.x),lm(K.y));let Pe=m.getRenderTarget();m.setRenderTarget(ae),m.clear();let tt=m.toneMapping;m.toneMapping=gn,Si(Z,ve,Ee),m.toneMapping=tt,_e.updateMultisampleRenderTarget(ae),_e.updateRenderTargetMipmap(ae),m.setRenderTarget(Pe)}function Si(Z,ve,Ee){let me=ve.isScene===!0?ve.overrideMaterial:null;for(let Pe=0,tt=Z.length;Pe<tt;Pe++){let Pt=Z[Pe],Ut=Pt.object,kt=Pt.geometry,ti=me===null?Pt.material:me,qt=Pt.group;Ut.layers.test(Ee.layers)&&Ns(Ut,ve,Ee,kt,ti,qt)}}function Ns(Z,ve,Ee,me,Pe,tt){Z.onBeforeRender(m,ve,Ee,me,Pe,tt),Z.modelViewMatrix.multiplyMatrices(Ee.matrixWorldInverse,Z.matrixWorld),Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix),Pe.onBeforeRender(m,ve,Ee,me,Z,tt),Pe.transparent===!0&&Pe.side===Rs&&Pe.forceSinglePass===!1?(Pe.side=Or,Pe.needsUpdate=!0,m.renderBufferDirect(Ee,ve,me,Pe,Z,tt),Pe.side=ka,Pe.needsUpdate=!0,m.renderBufferDirect(Ee,ve,me,Pe,Z,tt),Pe.side=Rs):m.renderBufferDirect(Ee,ve,me,Pe,Z,tt),Z.onAfterRender(m,ve,Ee,me,Pe,tt)}function Kr(Z,ve,Ee){ve.isScene!==!0&&(ve=te);let me=Ce.get(Z),Pe=d.state.lights,tt=d.state.shadowsArray,Pt=Pe.state.version,Ut=je.getParameters(Z,Pe.state,tt,ve,Ee),kt=je.getProgramCacheKey(Ut),ti=me.programs;me.environment=Z.isMeshStandardMaterial?ve.environment:null,me.fog=ve.fog,me.envMap=(Z.isMeshStandardMaterial?Qe:Ze).get(Z.envMap||me.environment),ti===void 0&&(Z.addEventListener("dispose",ui),ti=new Map,me.programs=ti);let qt=ti.get(kt);if(qt!==void 0){if(me.currentProgram===qt&&me.lightsStateVersion===Pt)return lh(Z,Ut),qt}else Ut.uniforms=je.getUniforms(Z),Z.onBuild(Ee,Ut,m),Z.onBeforeCompile(Ut,m),qt=je.acquireProgram(Ut,kt),ti.set(kt,qt),me.uniforms=Ut.uniforms;let Xt=me.uniforms;(!Z.isShaderMaterial&&!Z.isRawShaderMaterial||Z.clipping===!0)&&(Xt.clippingPlanes=j.uniform),lh(Z,Ut),me.needsLights=Fg(Z),me.lightsStateVersion=Pt,me.needsLights&&(Xt.ambientLightColor.value=Pe.state.ambient,Xt.lightProbe.value=Pe.state.probe,Xt.directionalLights.value=Pe.state.directional,Xt.directionalLightShadows.value=Pe.state.directionalShadow,Xt.spotLights.value=Pe.state.spot,Xt.spotLightShadows.value=Pe.state.spotShadow,Xt.rectAreaLights.value=Pe.state.rectArea,Xt.ltc_1.value=Pe.state.rectAreaLTC1,Xt.ltc_2.value=Pe.state.rectAreaLTC2,Xt.pointLights.value=Pe.state.point,Xt.pointLightShadows.value=Pe.state.pointShadow,Xt.hemisphereLights.value=Pe.state.hemi,Xt.directionalShadowMap.value=Pe.state.directionalShadowMap,Xt.directionalShadowMatrix.value=Pe.state.directionalShadowMatrix,Xt.spotShadowMap.value=Pe.state.spotShadowMap,Xt.spotLightMatrix.value=Pe.state.spotLightMatrix,Xt.spotLightMap.value=Pe.state.spotLightMap,Xt.pointShadowMap.value=Pe.state.pointShadowMap,Xt.pointShadowMatrix.value=Pe.state.pointShadowMatrix);let di=qt.getUniforms(),zr=Wf.seqWithValue(di.seq,Xt);return me.currentProgram=qt,me.uniformsList=zr,qt}function lh(Z,ve){let Ee=Ce.get(Z);Ee.outputEncoding=ve.outputEncoding,Ee.instancing=ve.instancing,Ee.skinning=ve.skinning,Ee.morphTargets=ve.morphTargets,Ee.morphNormals=ve.morphNormals,Ee.morphColors=ve.morphColors,Ee.morphTargetsCount=ve.morphTargetsCount,Ee.numClippingPlanes=ve.numClippingPlanes,Ee.numIntersection=ve.numClipIntersection,Ee.vertexAlphas=ve.vertexAlphas,Ee.vertexTangents=ve.vertexTangents,Ee.toneMapping=ve.toneMapping}function Ng(Z,ve,Ee,me,Pe){ve.isScene!==!0&&(ve=te),_e.resetTextureUnits();let tt=ve.fog,Pt=me.isMeshStandardMaterial?ve.environment:null,Ut=b===null?m.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:Na,kt=(me.isMeshStandardMaterial?Qe:Ze).get(me.envMap||Pt),ti=me.vertexColors===!0&&!!Ee.attributes.color&&Ee.attributes.color.itemSize===4,qt=!!me.normalMap&&!!Ee.attributes.tangent,Xt=!!Ee.morphAttributes.position,di=!!Ee.morphAttributes.normal,zr=!!Ee.morphAttributes.color,Ni=me.toneMapped?m.toneMapping:gn,ir=Ee.morphAttributes.position||Ee.morphAttributes.normal||Ee.morphAttributes.color,Fi=ir!==void 0?ir.length:0,jt=Ce.get(me),sl=d.state.lights;if(G===!0&&(se===!0||Z!==S)){let hs=Z===S&&me.id===_;j.setState(me,Z,hs)}let nu=!1;me.version===jt.__version?(jt.needsLights&&jt.lightsStateVersion!==sl.state.version||jt.outputEncoding!==Ut||Pe.isInstancedMesh&&jt.instancing===!1||!Pe.isInstancedMesh&&jt.instancing===!0||Pe.isSkinnedMesh&&jt.skinning===!1||!Pe.isSkinnedMesh&&jt.skinning===!0||jt.envMap!==kt||me.fog===!0&&jt.fog!==tt||jt.numClippingPlanes!==void 0&&(jt.numClippingPlanes!==j.numPlanes||jt.numIntersection!==j.numIntersection)||jt.vertexAlphas!==ti||jt.vertexTangents!==qt||jt.morphTargets!==Xt||jt.morphNormals!==di||jt.morphColors!==zr||jt.toneMapping!==Ni||ye.isWebGL2===!0&&jt.morphTargetsCount!==Fi)&&(nu=!0):(nu=!0,jt.__version=me.version);let Cn=jt.currentProgram;nu===!0&&(Cn=Kr(me,ve,Pe));let Es=!1,kr=!1,hh=!1,ur=Cn.getUniforms(),Tn=jt.uniforms;if(de.useProgram(Cn.program)&&(Es=!0,kr=!0,hh=!0),me.id!==_&&(_=me.id,kr=!0),Es||S!==Z){if(ur.setValue(ie,"projectionMatrix",Z.projectionMatrix),ye.logarithmicDepthBuffer&&ur.setValue(ie,"logDepthBufFC",2/(Math.log(Z.far+1)/Math.LN2)),S!==Z&&(S=Z,kr=!0,hh=!0),me.isShaderMaterial||me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshStandardMaterial||me.envMap){let hs=ur.map.cameraPosition;hs!==void 0&&hs.setValue(ie,ne.setFromMatrixPosition(Z.matrixWorld))}(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial)&&ur.setValue(ie,"isOrthographic",Z.isOrthographicCamera===!0),(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial||me.isShadowMaterial||Pe.isSkinnedMesh)&&ur.setValue(ie,"viewMatrix",Z.matrixWorldInverse)}if(Pe.isSkinnedMesh){ur.setOptional(ie,Pe,"bindMatrix"),ur.setOptional(ie,Pe,"bindMatrixInverse");let hs=Pe.skeleton;hs&&(ye.floatVertexTextures?(hs.boneTexture===null&&hs.computeBoneTexture(),ur.setValue(ie,"boneTexture",hs.boneTexture,_e),ur.setValue(ie,"boneTextureSize",hs.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 ou=Ee.morphAttributes;if((ou.position!==void 0||ou.normal!==void 0||ou.color!==void 0&&ye.isWebGL2===!0)&&Te.update(Pe,Ee,me,Cn),(kr||jt.receiveShadow!==Pe.receiveShadow)&&(jt.receiveShadow=Pe.receiveShadow,ur.setValue(ie,"receiveShadow",Pe.receiveShadow)),me.isMeshGouraudMaterial&&me.envMap!==null&&(Tn.envMap.value=kt,Tn.flipEnvMap.value=kt.isCubeTexture&&kt.isRenderTargetTexture===!1?-1:1),kr&&(ur.setValue(ie,"toneMappingExposure",m.toneMappingExposure),jt.needsLights&&au(Tn,hh),tt&&me.fog===!0&&ot.refreshFogUniforms(Tn,tt),ot.refreshMaterialUniforms(Tn,me,R,P,ae),Wf.upload(ie,jt.uniformsList,Tn,_e)),me.isShaderMaterial&&me.uniformsNeedUpdate===!0&&(Wf.upload(ie,jt.uniformsList,Tn,_e),me.uniformsNeedUpdate=!1),me.isSpriteMaterial&&ur.setValue(ie,"center",Pe.center),ur.setValue(ie,"modelViewMatrix",Pe.modelViewMatrix),ur.setValue(ie,"normalMatrix",Pe.normalMatrix),ur.setValue(ie,"modelMatrix",Pe.matrixWorld),Pe.previousModelViewMatrix&&ur.setValue(ie,"previousModelViewMatrix",Pe.previousModelViewMatrix),Z.previousProjectionMatrix&&ur.setValue(ie,"previousProjectionMatrix",Z.previousProjectionMatrix),me.isShaderMaterial||me.isRawShaderMaterial){let hs=me.uniformsGroups;for(let lu=0,Ug=hs.length;lu<Ug;lu++)if(ye.isWebGL2){let op=hs[lu];Fe.update(op,Cn),Fe.bind(op,Cn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Cn}function au(Z,ve){Z.ambientLightColor.needsUpdate=ve,Z.lightProbe.needsUpdate=ve,Z.directionalLights.needsUpdate=ve,Z.directionalLightShadows.needsUpdate=ve,Z.pointLights.needsUpdate=ve,Z.pointLightShadows.needsUpdate=ve,Z.spotLights.needsUpdate=ve,Z.spotLightShadows.needsUpdate=ve,Z.rectAreaLights.needsUpdate=ve,Z.hemisphereLights.needsUpdate=ve}function Fg(Z){return Z.isMeshLambertMaterial||Z.isMeshToonMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isShadowMaterial||Z.isShaderMaterial&&Z.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(Z,ve,Ee){Ce.get(Z.texture).__webglTexture=ve,Ce.get(Z.depthTexture).__webglTexture=Ee;let me=Ce.get(Z);me.__hasExternalTextures=!0,me.__hasExternalTextures&&(me.__autoAllocateDepthBuffer=Ee===void 0,me.__autoAllocateDepthBuffer||ue.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),me.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Z,ve){let Ee=Ce.get(Z);Ee.__webglFramebuffer=ve,Ee.__useDefaultFramebuffer=ve===void 0},this.setRenderTarget=function(Z,ve=0,Ee=0){b=Z,y=ve,x=Ee;let me=!0,Pe=null,tt=!1,Pt=!1;if(Z){let Ut=Ce.get(Z);Ut.__useDefaultFramebuffer!==void 0?(de.bindFramebuffer(36160,null),me=!1):Ut.__webglFramebuffer===void 0?_e.setupRenderTarget(Z):Ut.__hasExternalTextures&&_e.rebindTextures(Z,Ce.get(Z.texture).__webglTexture,Ce.get(Z.depthTexture).__webglTexture);let kt=Z.texture;(kt.isData3DTexture||kt.isDataArrayTexture||kt.isCompressedArrayTexture)&&(Pt=!0);let ti=Ce.get(Z).__webglFramebuffer;Z.isWebGLCubeRenderTarget?(Pe=ti[ve],tt=!0):ye.isWebGL2&&Z.samples>0&&_e.useMultisampledRTT(Z)===!1?Pe=Ce.get(Z).__webglMultisampledFramebuffer:Pe=ti,M.copy(Z.viewport),C.copy(Z.scissor),A=Z.scissorTest}else M.copy(B).multiplyScalar(R).floor(),C.copy(V).multiplyScalar(R).floor(),A=H;if(de.bindFramebuffer(36160,Pe)&&ye.drawBuffers&&me&&de.drawBuffers(Z,Pe),de.viewport(M),de.scissor(C),de.setScissorTest(A),tt){let Ut=Ce.get(Z.texture);ie.framebufferTexture2D(36160,36064,34069+ve,Ut.__webglTexture,Ee)}else if(Pt){let Ut=Ce.get(Z.texture),kt=ve||0;ie.framebufferTextureLayer(36160,36064,Ut.__webglTexture,Ee||0,kt)}_=-1},this.readRenderTargetPixels=function(Z,ve,Ee,me,Pe,tt,Pt){if(!(Z&&Z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=Ce.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&Pt!==void 0&&(Ut=Ut[Pt]),Ut){de.bindFramebuffer(36160,Ut);try{let kt=Z.texture,ti=kt.format,qt=kt.type;if(ti!==Pr&&Ve.convert(ti)!==ie.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Xt=qt===Hl&&(ue.has("EXT_color_buffer_half_float")||ye.isWebGL2&&ue.has("EXT_color_buffer_float"));if(qt!==ns&&Ve.convert(qt)!==ie.getParameter(35738)&&!(qt===lr&&(ye.isWebGL2||ue.has("OES_texture_float")||ue.has("WEBGL_color_buffer_float")))&&!Xt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ve>=0&&ve<=Z.width-me&&Ee>=0&&Ee<=Z.height-Pe&&ie.readPixels(ve,Ee,me,Pe,Ve.convert(ti),Ve.convert(qt),tt)}finally{let kt=b!==null?Ce.get(b).__webglFramebuffer:null;de.bindFramebuffer(36160,kt)}}},this.copyFramebufferToTexture=function(Z,ve,Ee=0){let me=Math.pow(2,-Ee),Pe=Math.floor(ve.image.width*me),tt=Math.floor(ve.image.height*me);_e.setTexture2D(ve,0),ie.copyTexSubImage2D(3553,Ee,0,0,Z.x,Z.y,Pe,tt),de.unbindTexture()},this.copyTextureToTexture=function(Z,ve,Ee,me=0){let Pe=ve.image.width,tt=ve.image.height,Pt=Ve.convert(Ee.format),Ut=Ve.convert(Ee.type);_e.setTexture2D(Ee,0),ie.pixelStorei(37440,Ee.flipY),ie.pixelStorei(37441,Ee.premultiplyAlpha),ie.pixelStorei(3317,Ee.unpackAlignment),ve.isDataTexture?ie.texSubImage2D(3553,me,Z.x,Z.y,Pe,tt,Pt,Ut,ve.image.data):ve.isCompressedTexture?ie.compressedTexSubImage2D(3553,me,Z.x,Z.y,ve.mipmaps[0].width,ve.mipmaps[0].height,Pt,ve.mipmaps[0].data):ie.texSubImage2D(3553,me,Z.x,Z.y,Pt,Ut,ve.image),me===0&&Ee.generateMipmaps&&ie.generateMipmap(3553),de.unbindTexture()},this.copyTextureToTexture3D=function(Z,ve,Ee,me,Pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=Z.max.x-Z.min.x+1,Pt=Z.max.y-Z.min.y+1,Ut=Z.max.z-Z.min.z+1,kt=Ve.convert(me.format),ti=Ve.convert(me.type),qt;if(me.isData3DTexture)_e.setTexture3D(me,0),qt=32879;else if(me.isDataArrayTexture)_e.setTexture2DArray(me,0),qt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ie.pixelStorei(37440,me.flipY),ie.pixelStorei(37441,me.premultiplyAlpha),ie.pixelStorei(3317,me.unpackAlignment);let Xt=ie.getParameter(3314),di=ie.getParameter(32878),zr=ie.getParameter(3316),Ni=ie.getParameter(3315),ir=ie.getParameter(32877),Fi=Ee.isCompressedTexture?Ee.mipmaps[0]:Ee.image;ie.pixelStorei(3314,Fi.width),ie.pixelStorei(32878,Fi.height),ie.pixelStorei(3316,Z.min.x),ie.pixelStorei(3315,Z.min.y),ie.pixelStorei(32877,Z.min.z),Ee.isDataTexture||Ee.isData3DTexture?ie.texSubImage3D(qt,Pe,ve.x,ve.y,ve.z,tt,Pt,Ut,kt,ti,Fi.data):Ee.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ie.compressedTexSubImage3D(qt,Pe,ve.x,ve.y,ve.z,tt,Pt,Ut,kt,Fi.data)):ie.texSubImage3D(qt,Pe,ve.x,ve.y,ve.z,tt,Pt,Ut,kt,ti,Fi),ie.pixelStorei(3314,Xt),ie.pixelStorei(32878,di),ie.pixelStorei(3316,zr),ie.pixelStorei(3315,Ni),ie.pixelStorei(32877,ir),Pe===0&&me.generateMipmaps&&ie.generateMipmap(qt),de.unbindTexture()},this.initTexture=function(Z){Z.isCubeTexture?_e.setTextureCube(Z,0):Z.isData3DTexture?_e.setTexture3D(Z,0):Z.isDataArrayTexture||Z.isCompressedArrayTexture?_e.setTexture2DArray(Z,0):_e.setTexture2D(Z,0),de.unbindTexture()},this.resetState=function(){y=0,x=0,b=null,de.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var $z=class extends iC{};$z.prototype.isWebGL1Renderer=!0;var rC=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new yt(e),this.near=t,this.far=i}clone(){return new rC(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},so=class extends ci{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}},ek=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ay,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ua()}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=ua()),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=ua()),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,hy=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=Ai(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ai(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ai(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ai(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=io(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=io(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=io(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=io(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ai(t,this.array),i=Ai(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=Ai(t,this.array),i=Ai(i,this.array),r=Ai(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=Ai(t,this.array),i=Ai(i,this.array),r=Ai(r,this.array),s=Ai(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 At(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 hy(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}}},sC=class extends ci{constructor(){super(),this.isBone=!0,this.type="Bone"}},ca=class extends Li{constructor(e=null,t=1,i=1,r,s,a,n,o,l=si,h=si,u,c){super(null,a,n,o,l,h,r,s,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},G_=new Le,tk=new Le,ux=class{constructor(e=[],t=[]){this.uuid=ua(),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 Le)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Le;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:tk;G_.multiplyMatrices(n,t[s]),G_.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ux(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=jE(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new ca(t,e,e,Pr,lr);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 sC),this.bones.push(a),this.boneInverses.push(new Le().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}},vd=class extends At{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}},H_=new Le,W_=new Le,Up=[],ik=new Le,Su=new yr,rk=class extends yr{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new vd(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,ik)}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(Su.geometry=this.geometry,Su.material=this.material,Su.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,H_),W_.multiplyMatrices(i,H_),Su.matrixWorld=W_,Su.raycast(e,Up);for(let a=0,n=Up.length;a<n;a++){let o=Up[a];o.instanceId=s,o.object=this,t.push(o)}Up.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new vd(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"})}},$o=class extends jd{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(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}},q_=new I,X_=new I,Y_=new Le,Cv=new kc,Vp=new zs,hm=class extends ci{constructor(e=new ut,t=new $o){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++)q_.fromBufferAttribute(t,r-1),X_.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=q_.distanceTo(X_);e.setAttribute("lineDistance",new et(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(),Vp.copy(i.boundingSphere),Vp.applyMatrix4(r),Vp.radius+=s,e.ray.intersectsSphere(Vp)===!1)return;Y_.copy(r).invert(),Cv.copy(e.ray).applyMatrix4(Y_);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new I,h=new I,u=new I,c=new I,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,a.start),v=Math.min(p.count,a.start+a.count);for(let y=m,x=v-1;y<x;y+=d){let b=p.getX(y),_=p.getX(y+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),Cv.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let S=e.ray.origin.distanceTo(c);S<e.near||S>e.far||t.push({distance:S,point:u.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,a.start),v=Math.min(f.count,a.start+a.count);for(let y=m,x=v-1;y<x;y+=d){if(l.fromBufferAttribute(f,y),h.fromBufferAttribute(f,y+1),Cv.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(c);b<e.near||b>e.far||t.push({distance:b,point:u.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}}}}},Q_=new I,Z_=new I,Gd=class extends hm{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)Q_.fromBufferAttribute(t,r),Z_.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Q_.distanceTo(Z_);e.setAttribute("lineDistance",new et(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},sk=class extends Li{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:zt,this.magFilter=s!==void 0?s:zt,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},ak=class extends Li{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}},An=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],u=i[r+1]-h,c=(a-h)/u;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new $: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 Le;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),u=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),c<=l&&i.set(0,0,1),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(nr(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(nr(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}},hg=class extends An{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 $,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),u=Math.sin(this.aRotation),c=o-this.aX,d=l-this.aY;o=c*h-d*u+this.aX,l=c*u+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},nk=class extends hg{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function dx(){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,u,c){let d=(n-a)/h-(o-a)/(h+u)+(o-n)/u,p=(o-n)/u-(l-n)/(u+c)+(l-o)/c;d*=u,p*=u,s(n,o,d,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var jp=new I,Tv=new dx,Pv=new dx,Dv=new dx,ok=class extends An{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]:(jp.subVectors(r[0],r[1]).add(r[0]),l=jp);let u=r[n%s],c=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(jp.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=jp),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(c),d),m=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),Tv.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,m),Pv.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,m),Dv.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(Tv.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),Pv.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Dv.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Tv.calc(o),Pv.calc(o),Dv.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 K_(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 lk(e,t){let i=1-e;return i*i*t}function hk(e,t){return 2*(1-e)*e*t}function ck(e,t){return e*e*t}function sd(e,t,i,r){return lk(e,t)+hk(e,i)+ck(e,r)}function uk(e,t){let i=1-e;return i*i*i*t}function dk(e,t){let i=1-e;return 3*i*i*e*t}function pk(e,t){return 3*(1-e)*e*e*t}function fk(e,t){return e*e*e*t}function ad(e,t,i,r,s){return uk(e,t)+dk(e,i)+pk(e,r)+fk(e,s)}var Ia=class extends An{constructor(e=new $,t=new $,i=new $,r=new $){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new $){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(ad(e,r.x,s.x,a.x,n.x),ad(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}},qf=class extends An{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(ad(e,r.x,s.x,a.x,n.x),ad(e,r.y,s.y,a.y,n.y),ad(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}},za=class extends An{constructor(e=new $,t=new $){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new $){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 $;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}},aC=class extends An{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}},Zo=class extends An{constructor(e=new $,t=new $,i=new $){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new $){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(sd(e,r.x,s.x,a.x),sd(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}},mk=class extends An{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(sd(e,r.x,s.x,a.x),sd(e,r.y,s.y,a.y),sd(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}},px=class extends An{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new $){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],u=r[a>r.length-3?r.length-1:a+2];return i.set(K_(n,o.x,l.x,h.x,u.x),K_(n,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new $().fromArray(r))}return this}},gk=Object.freeze({__proto__:null,ArcCurve:nk,CatmullRomCurve3:ok,CubicBezierCurve:Ia,CubicBezierCurve3:qf,EllipseCurve:hg,LineCurve:za,LineCurve3:aC,QuadraticBezierCurve:Zo,QuadraticBezierCurve3:mk,SplineCurve:px}),nC=class extends An{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 za(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 gk[r.type]().fromJSON(r))}return this}},cm=class extends nC{constructor(e){super(),this.type="Path",this.currentPoint=new $,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 za(this.currentPoint.clone(),new $(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Zo(this.currentPoint.clone(),new $(e,t),new $(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new Ia(this.currentPoint.clone(),new $(e,t),new $(i,r),new $(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new px(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 hg(e,t,i,r,s,a,n,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},oC=class extends ut{constructor(e=[new $(0,-.5),new $(.5,0),new $(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=nr(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,u=new I,c=new $,d=new I,p=new I,f=new I,m=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,d.x=v*1,d.y=-m,d.z=v*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:m=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,d.x=v*1,d.y=-m,d.z=v*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 S=0;S<=e.length-1;S++){u.x=e[S].x*b,u.y=e[S].y,u.z=e[S].x*_,a.push(u.x,u.y,u.z),c.x=y/t,c.y=S/(e.length-1),n.push(c.x,c.y);let M=o[3*S+0]*b,C=o[3*S+1],A=o[3*S+0]*_;l.push(M,C,A)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){let b=x+y*e.length,_=b,S=b+e.length,M=b+e.length+1,C=b+1;s.push(_,S,C),s.push(M,C,S)}this.setIndex(s),this.setAttribute("position",new et(a,3)),this.setAttribute("uv",new et(n,2)),this.setAttribute("normal",new et(l,3))}static fromJSON(e){return new oC(e.points,e.segments,e.phiStart,e.phiLength)}},fx=class extends ut{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=[],u=[],c=[],d=[],p=0,f=[],m=i/2,v=0;y(),a===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new et(u,3)),this.setAttribute("normal",new et(c,3)),this.setAttribute("uv",new et(d,2));function y(){let b=new I,_=new I,S=0,M=(t-e)/i;for(let C=0;C<=s;C++){let A=[],T=C/s,P=T*(t-e)+e;for(let R=0;R<=r;R++){let z=R/r,N=z*o+n,B=Math.sin(N),V=Math.cos(N);_.x=P*B,_.y=-T*i+m,_.z=P*V,u.push(_.x,_.y,_.z),b.set(B,M,V).normalize(),c.push(b.x,b.y,b.z),d.push(z,1-T),A.push(p++)}f.push(A)}for(let C=0;C<r;C++)for(let A=0;A<s;A++){let T=f[A][C],P=f[A+1][C],R=f[A+1][C+1],z=f[A][C+1];h.push(T,P,z),h.push(P,R,z),S+=6}l.addGroup(v,S,0),v+=S}function x(b){let _=p,S=new $,M=new I,C=0,A=b===!0?e:t,T=b===!0?1:-1;for(let R=1;R<=r;R++)u.push(0,m*T,0),c.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,N=Math.cos(z),B=Math.sin(z);M.x=A*B,M.y=m*T,M.z=A*N,u.push(M.x,M.y,M.z),c.push(0,T,0),S.x=N*.5+.5,S.y=B*.5*T+.5,d.push(S.x,S.y),p++}for(let R=0;R<r;R++){let z=_+R,N=P+R;b===!0?h.push(N,N+1,z):h.push(N+1,N,z),C+=3}l.addGroup(v,C,b===!0?1:2),v+=C}}static fromJSON(e){return new fx(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},mx=class extends fx{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 mx(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},gx=class extends ut{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 et(s,3)),this.setAttribute("normal",new et(s.slice(),3)),this.setAttribute("uv",new et(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(y){let x=new I,b=new I,_=new I;for(let S=0;S<t.length;S+=3)d(t[S+0],x),d(t[S+1],b),d(t[S+2],_),o(x,b,_,y)}function o(y,x,b,_){let S=_+1,M=[];for(let C=0;C<=S;C++){M[C]=[];let A=y.clone().lerp(b,C/S),T=x.clone().lerp(b,C/S),P=S-C;for(let R=0;R<=P;R++)R===0&&C===S?M[C][R]=A:M[C][R]=A.clone().lerp(T,R/P)}for(let C=0;C<S;C++)for(let A=0;A<2*(S-C)-1;A++){let T=Math.floor(A/2);A%2===0?(c(M[C][T+1]),c(M[C+1][T]),c(M[C][T])):(c(M[C][T+1]),c(M[C+1][T+1]),c(M[C+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=m(y)/2/Math.PI+.5,_=v(y)/Math.PI+.5;a.push(b,1-_)}p(),u()}function u(){for(let y=0;y<a.length;y+=6){let x=a[y+0],b=a[y+2],_=a[y+4],S=Math.max(x,b,_),M=Math.min(x,b,_);S>.9&&M<.1&&(x<.2&&(a[y+0]+=1),b<.2&&(a[y+2]+=1),_<.2&&(a[y+4]+=1))}}function c(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,S=new $,M=new $,C=new $;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]),S.set(a[T+0],a[T+1]),M.set(a[T+2],a[T+3]),C.set(a[T+4],a[T+5]),_.copy(y).add(x).add(b).divideScalar(3);let P=m(_);f(S,T+0,y,P),f(M,T+2,x,P),f(C,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 m(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new gx(e.vertices,e.indices,e.radius,e.details)}},lC=class extends gx{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 lC(e.radius,e.detail)}},um=class extends cm{constructor(e){super(e),this.uuid=ua(),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 cm().fromJSON(r))}return this}},vk={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=hC(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,u,c,d,p;if(r&&(a=_k(e,t,a,i)),e.length>80*i){o=h=e[0],l=u=e[1];for(let f=i;f<s;f+=i)c=e[f],d=e[f+1],c<o&&(o=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-o,u-l),p=p!==0?32767/p:0}return yd(a,n,i,o,l,p,0),n}};function hC(e,t,i,r,s){let a,n;if(s===Rk(e,t,i,r)>0)for(a=t;a<i;a+=r)n=J_(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=J_(a,e[a],e[a+1],n);return n&&cg(n,n.next)&&(bd(n),n=n.next),n}function ql(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(cg(i,i.next)||Bi(i.prev,i,i.next)===0)){if(bd(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function yd(e,t,i,r,s,a,n){if(!e)return;!n&&a&&Ck(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?xk(e,r,s,a):yk(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),bd(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=bk(ql(e),t,i),yd(e,t,i,r,s,a,2)):n===2&&wk(e,t,i,r,s,a):yd(ql(e),t,i,r,s,a,1);break}}}function yk(e){let t=e.prev,i=e,r=e.next;if(Bi(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,u=s<a?s<n?s:n:a<n?a:n,c=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>=u&&f.x<=d&&f.y>=c&&f.y<=p&&ic(s,o,a,l,n,h,f.x,f.y)&&Bi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function xk(e,t,i,r){let s=e.prev,a=e,n=e.next;if(Bi(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,u=s.y,c=a.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,v=u>c?u>d?u:d:c>d?c:d,y=cy(p,f,t,i,r),x=cy(m,v,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=v&&b!==s&&b!==n&&ic(o,u,l,c,h,d,b.x,b.y)&&Bi(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=v&&_!==s&&_!==n&&ic(o,u,l,c,h,d,_.x,_.y)&&Bi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=v&&b!==s&&b!==n&&ic(o,u,l,c,h,d,b.x,b.y)&&Bi(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=v&&_!==s&&_!==n&&ic(o,u,l,c,h,d,_.x,_.y)&&Bi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function bk(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!cg(s,a)&&cC(s,r,r.next,a)&&xd(s,a)&&xd(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),bd(r),bd(r.next),r=e=a),r=r.next}while(r!==e);return ql(r)}function wk(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&Dk(n,o)){let l=uC(n,o);n=ql(n,n.next),l=ql(l,l.next),yd(n,t,i,r,s,a,0),yd(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function _k(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=hC(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(Pk(h));for(s.sort(Sk),a=0;a<s.length;a++)i=Ak(s[a],i);return i}function Sk(e,t){return e.x-t.x}function Ak(e,t){let i=Mk(e,t);if(!i)return t;let r=uC(i,e);return ql(r,r.next),ql(i,i.next)}function Mk(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,u=1/0,c;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&ic(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(c=Math.abs(n-i.y)/(a-i.x),xd(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&Ek(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function Ek(e,t){return Bi(e.prev,e,t.prev)<0&&Bi(t.next,e,e.next)<0}function Ck(e,t,i,r){let s=e;do s.z===0&&(s.z=cy(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,Tk(s)}function Tk(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 cy(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 Pk(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 ic(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 Dk(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Ok(e,t)&&(xd(e,t)&&xd(t,e)&&Ik(e,t)&&(Bi(e.prev,e,t.prev)||Bi(e,t.prev,t))||cg(e,t)&&Bi(e.prev,e,e.next)>0&&Bi(t.prev,t,t.next)>0)}function Bi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function cg(e,t){return e.x===t.x&&e.y===t.y}function cC(e,t,i,r){let s=Hp(Bi(e,t,i)),a=Hp(Bi(e,t,r)),n=Hp(Bi(i,r,e)),o=Hp(Bi(i,r,t));return!!(s!==a&&n!==o||s===0&&Gp(e,i,t)||a===0&&Gp(e,r,t)||n===0&&Gp(i,e,r)||o===0&&Gp(i,t,r))}function Gp(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 Hp(e){return e>0?1:e<0?-1:0}function Ok(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&&cC(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function xd(e,t){return Bi(e.prev,e,e.next)<0?Bi(e,t,e.next)>=0&&Bi(e,e.prev,t)>=0:Bi(e,t,e.prev)<0||Bi(e,e.next,t)<0}function Ik(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 uC(e,t){let i=new uy(e.i,e.x,e.y),r=new uy(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 J_(e,t,i,r){let s=new uy(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 bd(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 uy(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 Rk(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 dC=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 dC.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];$_(e),eS(i,e);let a=e.length;t.forEach($_);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,eS(i,t[o]);let n=vk.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function $_(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function eS(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var pC=class extends gx{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 pC(e.radius,e.detail)}},oc=class extends ut{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=[],u=new I,c=new I,d=[],p=[],f=[],m=[];for(let v=0;v<=i;v++){let y=[],x=v/i,b=0;v==0&&a==0?b=.5/t:v==i&&o==Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let S=_/t;u.x=-e*Math.cos(r+S*s)*Math.sin(a+x*n),u.y=e*Math.cos(a+x*n),u.z=e*Math.sin(r+S*s)*Math.sin(a+x*n),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),m.push(S+b,1-x),y.push(l++)}h.push(y)}for(let v=0;v<i;v++)for(let y=0;y<t;y++){let x=h[v][y+1],b=h[v][y],_=h[v+1][y],S=h[v+1][y+1];(v!==0||a>0)&&d.push(x,b,S),(v!==i-1||o<Math.PI)&&d.push(b,_,S)}this.setIndex(d),this.setAttribute("position",new et(p,3)),this.setAttribute("normal",new et(f,3)),this.setAttribute("uv",new et(m,2))}static fromJSON(e){return new oc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},fC=class extends ut{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,u=new I,c=new I;for(let d=0;d<=i;d++)for(let p=0;p<=r;p++){let f=p/r*s,m=d/i*Math.PI*2;u.x=(e+t*Math.cos(m))*Math.cos(f),u.y=(e+t*Math.cos(m))*Math.sin(f),u.z=t*Math.sin(m),n.push(u.x,u.y,u.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),c.subVectors(u,h).normalize(),o.push(c.x,c.y,c.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,m=(r+1)*(d-1)+p-1,v=(r+1)*(d-1)+p,y=(r+1)*d+p;a.push(f,m,y),a.push(m,v,y)}this.setIndex(a),this.setAttribute("position",new et(n,3)),this.setAttribute("normal",new et(o,3)),this.setAttribute("uv",new et(l,2))}static fromJSON(e){return new fC(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},mC=class extends ut{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=[],u=new I,c=new I,d=new I,p=new I,f=new I,m=new I,v=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),m.subVectors(p,d),v.addVectors(p,d),f.crossVectors(m,v),v.crossVectors(f,m),f.normalize(),v.normalize();for(let _=0;_<=r;++_){let S=_/r*Math.PI*2,M=-t*Math.cos(S),C=t*Math.sin(S);u.x=d.x+(M*v.x+C*f.x),u.y=d.y+(M*v.y+C*f.y),u.z=d.z+(M*v.z+C*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.z),h.push(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),S=(r+1)*x+(b-1),M=(r+1)*x+b,C=(r+1)*(x-1)+b;n.push(_,S,C),n.push(S,M,C)}this.setIndex(n),this.setAttribute("position",new et(o,3)),this.setAttribute("normal",new et(l,3)),this.setAttribute("uv",new et(h,2));function y(x,b,_,S,M){let C=Math.cos(x),A=Math.sin(x),T=_/b*x,P=Math.cos(T);M.x=S*(2+P)*.5*C,M.y=S*(2+P)*A*.5,M.z=S*Math.sin(T)*.5}}static fromJSON(e){return new mC(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function bo(e,t,i){return gC(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Wp(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 gC(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Bk(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 tS(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 vC(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 ug=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_(){}},Lk=class extends ug{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:$h,endingEnd:$h}}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 ec:s=e,n=2*t-i;break;case nm: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 ec:a=e,o=2*i-t;break;case nm: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,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,v=-c*m+2*c*f-c*p,y=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,x=(-1-d)*m+(1.5+d)*f+.5*p,b=d*m-d*f;for(let _=0;_!==n;++_)s[_]=v*a[h+_]+y*a[l+_]+x*a[o+_]+b*a[u+_];return s}},yC=class extends ug{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),u=1-h;for(let c=0;c!==n;++c)s[c]=a[l+c]*u+a[o+c]*h;return s}},zk=class extends ug{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Mn=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=Wp(t,this.TimeBufferType),this.values=Wp(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:Wp(e.times,Array),values:Wp(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new zk(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yC(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Lk(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case sm:t=this.InterpolantFactoryMethodDiscrete;break;case am:t=this.InterpolantFactoryMethodLinear;break;case tv: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 sm;case this.InterpolantFactoryMethodLinear:return am;case this.InterpolantFactoryMethodSmooth:return tv}}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=bo(i,s,a),this.values=bo(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&&gC(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=bo(this.times),t=bo(this.values),i=this.getValueSize(),r=this.getInterpolation()===tv,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 u=n*i,c=u-i,d=u+i;for(let p=0;p!==i;++p){let f=t[u+p];if(f!==t[c+p]||f!==t[d+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let u=n*i,c=a*i;for(let d=0;d!==i;++d)t[c+d]=t[u+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=bo(e,0,a),this.values=bo(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=bo(this.times,0),t=bo(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Mn.prototype.TimeBufferType=Float32Array;Mn.prototype.ValueBufferType=Float32Array;Mn.prototype.DefaultInterpolation=am;var Vc=class extends Mn{};Vc.prototype.ValueTypeName="bool";Vc.prototype.ValueBufferType=Array;Vc.prototype.DefaultInterpolation=sm;Vc.prototype.InterpolantFactoryMethodLinear=void 0;Vc.prototype.InterpolantFactoryMethodSmooth=void 0;var xC=class extends Mn{};xC.prototype.ValueTypeName="color";var dm=class extends Mn{};dm.prototype.ValueTypeName="number";var kk=class extends ug{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)Mt.slerpFlat(s,0,a,l-n,a,l,o);return s}},Hd=class extends Mn{InterpolantFactoryMethodLinear(e){return new kk(this.times,this.values,this.getValueSize(),e)}};Hd.prototype.ValueTypeName="quaternion";Hd.prototype.DefaultInterpolation=am;Hd.prototype.InterpolantFactoryMethodSmooth=void 0;var jc=class extends Mn{};jc.prototype.ValueTypeName="string";jc.prototype.ValueBufferType=Array;jc.prototype.DefaultInterpolation=sm;jc.prototype.InterpolantFactoryMethodLinear=void 0;jc.prototype.InterpolantFactoryMethodSmooth=void 0;var pm=class extends Mn{};pm.prototype.ValueTypeName="vector";var dy=class{constructor(e,t=-1,i,r=sx){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ua(),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(Fk(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(Mn.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=Bk(o);o=tS(o,1,h),l=tS(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new dm(".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 u=h[1],c=r[u];c||(r[u]=c=[]),c.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,u,c,d,p){if(c.length!==0){let f=[],m=[];vC(c,f,m,d),f.length!==0&&p.push(new h(u,f,m))}},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 u=l[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){let c={},d;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(let p=0;p<u[d].morphTargets.length;p++)c[u[d].morphTargets[p]]=-1;for(let p in c){let f=[],m=[];for(let v=0;v!==u[d].morphTargets.length;++v){let y=u[d];f.push(y.time),m.push(y.morphTarget===p?1:0)}r.push(new dm(".morphTargetInfluence["+p+"]",f,m))}o=c.length*a}else{let c=".bones["+t[h].name+"]";i(pm,c+".position",u,"pos",r),i(Hd,c+".quaternion",u,"rot",r),i(pm,c+".scale",u,"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 Nk(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return dm;case"vector":case"vector2":case"vector3":case"vector4":return pm;case"color":return xC;case"quaternion":return Hd;case"bool":case"boolean":return Vc;case"string":return jc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Fk(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Nk(e.type);if(e.times===void 0){let i=[],r=[];vC(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 fm={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={}}},bC=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,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,c=l.length;u<c;u+=2){let d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},Uk=new bC,Wd=class{constructor(e){this.manager=e!==void 0?e:Uk,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}},zn={},Vk=class extends Error{constructor(e,t){super(e),this.response=t}},py=class extends Wd{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=fm.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(zn[e]!==void 0){zn[e].push({onLoad:t,onProgress:i,onError:r});return}zn[e]=[],zn[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=zn[e],u=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=c?parseInt(c):0,p=d!==0,f=0,m=new ReadableStream({start(v){y();function y(){u.read().then(({done:x,value:b})=>{if(x)v.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let S=0,M=h.length;S<M;S++){let C=h[S];C.onProgress&&C.onProgress(_)}v.enqueue(b),y()}})}}});return new Response(m)}else throw new Vk(`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),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{fm.add(e,l);let h=zn[e];delete zn[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=zn[e];if(h===void 0)throw this.manager.itemError(e),l;delete zn[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},jk=class extends Wd{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=fm.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let n=gd("img");function o(){h(),fm.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(u){h(),r&&r(u),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}},Gk=class extends Wd{constructor(e){super(e)}load(e,t,i,r){let s=new Li,a=new jk(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}},qd=class extends ci{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(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}},Hk=class extends qd{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ci.DEFAULT_UP),this.updateMatrix(),this.groundColor=new yt(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Ov=new Le,iS=new I,rS=new I,vx=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new $(512,512),this.map=null,this.mapPass=null,this.matrix=new Le,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lx,this._frameExtents=new $(1,1),this._viewportCount=1,this._viewports=[new Et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;iS.setFromMatrixPosition(e.matrixWorld),t.position.copy(iS),rS.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rS),t.updateMatrixWorld(),Ov.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ov),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ov)}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}},Wk=class extends vx{constructor(){super(new es(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=md*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}},qk=class extends qd{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(ci.DEFAULT_UP),this.updateMatrix(),this.target=new ci,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new Wk}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}},sS=new Le,Au=new I,Iv=new I,Xk=class extends vx{constructor(){super(new es(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new $(4,2),this._viewportCount=6,this._viewports=[new Et(2,1,1,1),new Et(0,1,1,1),new Et(3,1,1,1),new Et(1,1,1,1),new Et(3,0,1,1),new Et(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()),Au.setFromMatrixPosition(e.matrixWorld),i.position.copy(Au),Iv.copy(i.position),Iv.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Iv),i.updateMatrixWorld(),r.makeTranslation(-Au.x,-Au.y,-Au.z),sS.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sS)}},Yk=class extends qd{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 Xk}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}},Qk=class extends vx{constructor(){super(new hx(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Zk=class extends qd{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ci.DEFAULT_UP),this.updateMatrix(),this.target=new ci,this.shadow=new Qk}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},wC=class extends ut{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},_C=class extends Wd{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new py(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(c,d){if(t[d]!==void 0)return t[d];let p=c.interleavedBuffers[d],f=s(c,p.buffer),m=wp(p.type,f),v=new ek(m,p.stride);return v.uuid=p.uuid,t[d]=v,v}function s(c,d){if(i[d]!==void 0)return i[d];let p=c.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let a=e.isInstancedBufferGeometry?new wC:new ut,n=e.data.index;if(n!==void 0){let c=wp(n.type,n.array);a.setIndex(new At(c,1))}let o=e.data.attributes;for(let c in o){let d=o[c],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new hy(f,d.itemSize,d.offset,d.normalized)}else{let f=wp(d.type,d.array),m=d.isInstancedBufferAttribute?vd:At;p=new m(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(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,m=d.length;f<m;f++){let v=d[f],y;if(v.isInterleavedBufferAttribute){let x=r(e.data,v.data);y=new hy(x,v.itemSize,v.offset,v.normalized)}else{let x=wp(v.type,v.array);y=new At(x,v.itemSize,v.normalized)}v.name!==void 0&&(y.name=v.name),p.push(y)}a.morphAttributes[c]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,d=h.length;c!==d;++c){let p=h[c];a.addGroup(p.start,p.count,p.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let c=new I;u.center!==void 0&&c.fromArray(u.center),a.boundingSphere=new zs(c,u.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},Kk=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=aS(),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=aS();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function aS(){return(typeof performance>"u"?Date:performance).now()}var Jk=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){Mt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;Mt.multiplyQuaternionsFlat(e,a,e,t,e,i),Mt.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}}},yx="\\[\\]\\.:\\/",$k=new RegExp("["+yx+"]","g"),xx="[^"+yx+"]",e5="[^"+yx.replace("\\.","")+"]",t5=/((?:WC+[\/:])*)/.source.replace("WC",xx),i5=/(WCOD+)?/.source.replace("WCOD",e5),r5=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xx),s5=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xx),a5=new RegExp("^"+t5+i5+r5+s5+"$"),n5=["material","materials","bones","map"],o5=class{constructor(e,t,i){let r=i||bi.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()}},bi=class{constructor(e,t,i){this.path=t,this.parsedPath=i||bi.parseTrackName(t),this.node=bi.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 bi.Composite(e,t,i):new bi(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace($k,"")}static parseTrackName(e){let t=a5.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);n5.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=bi.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}};bi.Composite=o5;bi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};bi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};bi.prototype.GetterByBindingType=[bi.prototype._getValue_direct,bi.prototype._getValue_array,bi.prototype._getValue_arrayElement,bi.prototype._getValue_toArray];bi.prototype.SetterByBindingTypeAndVersioning=[[bi.prototype._setValue_direct,bi.prototype._setValue_direct_setNeedsUpdate,bi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bi.prototype._setValue_array,bi.prototype._setValue_array_setNeedsUpdate,bi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bi.prototype._setValue_arrayElement,bi.prototype._setValue_arrayElement_setNeedsUpdate,bi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bi.prototype._setValue_fromArray,bi.prototype._setValue_fromArray_setNeedsUpdate,bi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var l5=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:$h,endingEnd:$h};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=UE,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 NI:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case sx:default:for(let h=0,u=o.length;h!==u;++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===rx;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===FE){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=ec,r.endingEnd=ec):(e?r.endingStart=this.zeroSlopeAtStart?ec:$h:r.endingStart=nm,t?r.endingEnd=this.zeroSlopeAtEnd?ec:$h:r.endingEnd=nm)}_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}},h5=new Float32Array(1),c5=class extends Qr{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 u=0;u!==s;++u){let c=r[u],d=c.name,p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[u].binding.parsedPath;p=new Jk(bi.create(i,d,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),a[u]=p}n[u].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 u=n.actionByRoot,c=(e._localRoot||this._root).uuid;delete u[c],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 yC(new Float32Array(2),new Float32Array(2),1,h5),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"?dy.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=sx),o!==void 0){let u=o.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new l5(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"?dy.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,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,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))}},Re=class{constructor(e){this.value=e}clone(){return new Re(this.value.clone===void 0?this.value:this.value.clone())}},SC=class{constructor(e,t,i=0,r=1/0){this.ray=new kc(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new nx,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 fy(e,this,i,t),i.sort(nS),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)fy(e[r],this,i,t);return i.sort(nS),i}};function nS(e,t){return e.distance-t.distance}function fy(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++)fy(s[a],t,i,!0)}}var oS=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(nr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},lS=new $,AC=class{constructor(e=new $(1/0,1/0),t=new $(-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=lS.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 lS.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)}},hS=new I,qp=new I,da=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){hS.subVectors(e,this.start),qp.subVectors(this.end,this.start);let i=qp.dot(qp),r=qp.dot(hS)/i;return t&&(r=nr(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)}},cS=new I,u5=class extends ci{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new ut,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 et(r,3));let s=new $o({fog:!1,toneMapped:!1});this.cone=new Gd(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),cS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(cS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},d5=class extends yr{constructor(e,t,i){let r=new oc(t,4,2),s=new Nc({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)}},uS=new I,Xp=new I,dS=new I,p5=class extends ci{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 ut;r.setAttribute("position",new et([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new $o({fog:!1,toneMapped:!1});this.lightPlane=new hm(r,s),this.add(this.lightPlane),r=new ut,r.setAttribute("position",new et([0,0,0,0,0,1],3)),this.targetLine=new hm(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),uS.setFromMatrixPosition(this.light.matrixWorld),Xp.setFromMatrixPosition(this.light.target.matrixWorld),dS.subVectors(Xp,uS),this.lightPlane.lookAt(Xp),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(Xp),this.targetLine.scale.z=dS.length()}},Yp=new I,Ui=new Kl,mm=class extends Gd{constructor(e){let t=new ut,i=new $o({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 et(r,3)),t.setAttribute("color",new et(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 yt(16755200),h=new yt(16711680),u=new yt(43775),c=new yt(16777215),d=new yt(3355443);this.setColors(l,h,u,c,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;Ui.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xi("c",t,e,Ui,0,0,-1),Xi("t",t,e,Ui,0,0,1),Xi("n1",t,e,Ui,-i,-r,-1),Xi("n2",t,e,Ui,i,-r,-1),Xi("n3",t,e,Ui,-i,r,-1),Xi("n4",t,e,Ui,i,r,-1),Xi("f1",t,e,Ui,-i,-r,1),Xi("f2",t,e,Ui,i,-r,1),Xi("f3",t,e,Ui,-i,r,1),Xi("f4",t,e,Ui,i,r,1),Xi("u1",t,e,Ui,i*.7,r*1.1,-1),Xi("u2",t,e,Ui,-i*.7,r*1.1,-1),Xi("u3",t,e,Ui,0,r*2,-1),Xi("cf1",t,e,Ui,-i,0,1),Xi("cf2",t,e,Ui,i,0,1),Xi("cf3",t,e,Ui,0,-r,1),Xi("cf4",t,e,Ui,0,r,1),Xi("cn1",t,e,Ui,-i,0,-1),Xi("cn2",t,e,Ui,i,0,-1),Xi("cn3",t,e,Ui,0,-r,-1),Xi("cn4",t,e,Ui,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Xi(e,t,i,r,s,a,n){Yp.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],Yp.x,Yp.y,Yp.z)}}var gm=class extends Gd{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 ut;s.setIndex(new At(i,1)),s.setAttribute("position",new et(r,3)),super(s,new $o({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()}},f5=class extends Gd{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 ut;r.setAttribute("position",new et(t,3)),r.setAttribute("color",new et(i,3));let s=new $o({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new yt,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()}},Jn=m5();function m5(){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,u=0;for(;(h&8388608)===0;)h<<=1,u-=8388608;h&=-8388609,u+=947912704,a[l]=h|u}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 g5(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=nr(e,-65504,65504),Jn.floatView[0]=e;let t=Jn.uint32View[0],i=t>>23&511;return Jn.baseTable[i]+((t&8388607)>>Jn.shiftTable[i])}function v5(e){let t=e>>10;return Jn.uint32View[0]=Jn.mantissaTable[Jn.offsetTable[t]+(e&1023)]+Jn.exponentTable[t],Jn.floatView[0]}var y5=Object.freeze({__proto__:null,fromHalfFloat:v5,toHalfFloat:g5});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zc);var Mu=".",bx=Symbol("target"),MC=Symbol("unsubscribe");function my(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function x5(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var cn=Array.isArray;function wx(e){return typeof e=="symbol"}var b5={after:(e,t)=>cn(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>cn(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Mu),wx(t)?e+t.toString():e+t):e,initial:e=>{if(cn(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Mu);return t===-1?"":e.slice(0,t)},last:e=>{if(cn(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Mu);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(cn(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Mu);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(Mu,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},na=b5;function w5(e){return typeof e=="object"&&typeof e.next=="function"}function _5(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[bx].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 pS(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&wx(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var S5=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,na.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 gy(e){return toString.call(e)==="[object Object]"}function Qp(){return!0}function Ch(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var EC=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),A5=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),CC={push:Qp,pop:Qp,shift:Qp,unshift:Qp,copyWithin:Ch,reverse:Ch,sort:Ch,splice:Ch,flat:Ch,fill:Ch},M5=new Set([...EC,...A5,...Object.keys(CC)]);function Zp(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var TC=["keys","values","entries"],PC=new Set(["has","toString"]),DC={add:Zp,clear:Zp,delete:Zp,forEach:Zp},E5=new Set([...PC,...Object.keys(DC),...TC]);function Kp(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 C5=new Set([...PC,"get"]),OC={set:Kp,clear:Kp,delete:Kp,forEach:Kp},T5=new Set([...C5,...Object.keys(OC),...TC]),Ko=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 EC.has(e)}_shallowClone(e){let t=e;if(gy(e))t={...e};else if(cn(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?(cn(r)?this._onIsChanged=CC[t]:r instanceof Set?this._onIsChanged=DC[t]:r instanceof Map&&(this._onIsChanged=OC[t]),r):i}update(e,t,i){let r=na.after(e,this._path);if(t!=="length"){let s=this.clone;na.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],na.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},fS=class extends Ko{static isHandledMethod(e){return M5.has(e)}},P5=class extends Ko{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},mS=class extends Ko{static isHandledMethod(e){return E5.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)}},gS=class extends Ko{static isHandledMethod(e){return T5.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)}},D5=class extends Ko{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)}},O5=class extends Ko{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)}},Yh=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gy(e)||cn(e)||my(e)}static isHandledMethod(e,t){return gy(e)?Ko.isHandledMethod(t):cn(e)?fS.isHandledMethod(t):e instanceof Set?mS.isHandledMethod(t):e instanceof Map?gS.isHandledMethod(t):my(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Ko;cn(e)?r=fS:e instanceof Date?r=P5:e instanceof Set?r=mS:e instanceof Map?r=gS:e instanceof WeakSet?r=D5:e instanceof WeakMap&&(r=O5),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=Yh.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}},I5={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},_x=(e,t,i={})=>{i={...I5,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new S5(s),h=typeof i.onValidate=="function",u=new Yh(h),c=(x,b,_,S,M)=>!h||u.isCloning||i.onValidate(na.concat(l.getPath(x),b),_,S,M)===!0,d=(x,b,_,S)=>{!pS(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,S)},p=(x,b,_,S,M)=>{u.isCloning?u.update(x,b,S):t(na.concat(x,b),_,S,M)},f=x=>x&&(x[r]||x),m=(x,b,_,S)=>x5(x)||_==="constructor"||a&&!Yh.isHandledMethod(b,_)||pS(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(S===void 0&&(S=l.getPath(b)),l.getProxy(x,na.concat(S,_),v,r)),v={get(x,b,_){if(wx(b)){if(b===r||b===bx)return x;if(b===MC&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let S=my(x)?Reflect.get(x,b):Reflect.get(x,b,_);return m(S,x,b)},set(x,b,_,S){_=f(_);let M=x[r]||x,C=M[b];if(s(C,_)&&b in x)return!0;let A=c(x,b,_,C);return A&&l.setProperty(M,b,_,S,C)?(d(x,b,x[b],C),!0):!A},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let S=x[b];c(x,b,_.value,S)&&l.defineProperty(x,b,_,S)&&d(x,b,_.value,S)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),S=c(x,b,void 0,_);return S&&l.deleteProperty(x,b,_)?(d(x,b,void 0,_),!0):!S},apply(x,b,_){let S=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,S,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Yh.isHandledType(S)){let M=na.initial(l.getPath(x)),C=Yh.isHandledMethod(S,x.name);u.start(S,M,_);let A=Reflect.apply(x,u.preferredThisArg(x,b,S),C?_.map(R=>f(R)):_),T=u.isChanged(S,s),P=u.stop();if(Yh.isHandledType(A)&&C&&(b instanceof Map&&x.name==="get"&&(M=na.concat(M,_[0])),A=l.getProxy(A,M,v)),T){let R={name:x.name,args:_,result:A},z=u.isCloning?na.initial(M):M,N=u.isCloning?na.last(M):"";c(na.get(e,z),N,S,P,R)?p(z,N,S,P,R):u.undo(S)}return(b instanceof Map||b instanceof Set)&&w5(A)?_5(A,x,b,M,m):A}return Reflect.apply(x,b,_)}},y=l.getProxy(e,i.pathAsArray?[]:"",v);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};_x.target=e=>e&&e[bx]||e;_x.unsubscribe=e=>e[MC]||e;var vS=_x,R5=typeof global=="object"&&global&&global.Object===Object&&global,IC=R5,B5=typeof self=="object"&&self&&self.Object===Object&&self,L5=IC||B5||Function("return this")(),Va=L5,z5=Va.Symbol,fa=z5,RC=Object.prototype,k5=RC.hasOwnProperty,N5=RC.toString,Eu=fa?fa.toStringTag:void 0;function F5(e){var t=k5.call(e,Eu),i=e[Eu];try{e[Eu]=void 0;var r=!0}catch{}var s=N5.call(e);return r&&(t?e[Eu]=i:delete e[Eu]),s}var U5=F5,V5=Object.prototype,j5=V5.toString;function G5(e){return j5.call(e)}var H5=G5,W5="[object Null]",q5="[object Undefined]",yS=fa?fa.toStringTag:void 0;function X5(e){return e==null?e===void 0?q5:W5:yS&&yS in Object(e)?U5(e):H5(e)}var $l=X5;function Y5(e){return e!=null&&typeof e=="object"}var lo=Y5,Q5="[object Symbol]";function Z5(e){return typeof e=="symbol"||lo(e)&&$l(e)==Q5}var dg=Z5;function K5(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 BC=K5,J5=Array.isArray,xn=J5,$5=1/0,xS=fa?fa.prototype:void 0,bS=xS?xS.toString:void 0;function LC(e){if(typeof e=="string")return e;if(xn(e))return BC(e,LC)+"";if(dg(e))return bS?bS.call(e):"";var t=e+"";return t=="0"&&1/e==-$5?"-0":t}var eN=LC,tN=/\s/;function iN(e){for(var t=e.length;t--&&tN.test(e.charAt(t)););return t}var rN=iN,sN=/^\s+/;function aN(e){return e&&e.slice(0,rN(e)+1).replace(sN,"")}var nN=aN;function oN(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Ua=oN,wS=0/0,lN=/^[-+]0x[0-9a-f]+$/i,hN=/^0b[01]+$/i,cN=/^0o[0-7]+$/i,uN=parseInt;function dN(e){if(typeof e=="number")return e;if(dg(e))return wS;if(Ua(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ua(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=nN(e);var i=hN.test(e);return i||cN.test(e)?uN(e.slice(2),i?2:8):lN.test(e)?wS:+e}var _S=dN;function pN(e){return e}var fN=pN,mN="[object AsyncFunction]",gN="[object Function]",vN="[object GeneratorFunction]",yN="[object Proxy]";function xN(e){if(!Ua(e))return!1;var t=$l(e);return t==gN||t==vN||t==mN||t==yN}var zC=xN,bN=Va["__core-js_shared__"],Rv=bN,SS=function(){var e=/[^.]+$/.exec(Rv&&Rv.keys&&Rv.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function wN(e){return!!SS&&SS in e}var _N=wN,SN=Function.prototype,AN=SN.toString;function MN(e){if(e!=null){try{return AN.call(e)}catch{}try{return e+""}catch{}}return""}var eh=MN,EN=/[\\^$.*+?()[\]{}|]/g,CN=/^\[object .+?Constructor\]$/,TN=Function.prototype,PN=Object.prototype,DN=TN.toString,ON=PN.hasOwnProperty,IN=RegExp("^"+DN.call(ON).replace(EN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function RN(e){if(!Ua(e)||_N(e))return!1;var t=zC(e)?IN:CN;return t.test(eh(e))}var BN=RN;function LN(e,t){return e?.[t]}var zN=LN;function kN(e,t){var i=zN(e,t);return BN(i)?i:void 0}var th=kN,NN=th(Va,"WeakMap"),vy=NN,AS=Object.create,FN=function(){function e(){}return function(t){if(!Ua(t))return{};if(AS)return AS(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),UN=FN;function VN(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 jN=VN;function GN(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var HN=GN,WN=800,qN=16,XN=Date.now;function YN(e){var t=0,i=0;return function(){var r=XN(),s=qN-(r-i);if(i=r,s>0){if(++t>=WN)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var QN=YN;function ZN(e){return function(){return e}}var KN=ZN,JN=function(){try{var e=th(Object,"defineProperty");return e({},"",{}),e}catch{}}(),vm=JN,$N=vm?function(e,t){return vm(e,"toString",{configurable:!0,enumerable:!1,value:KN(t),writable:!0})}:fN,eF=$N,tF=QN(eF),iF=tF;function rF(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var sF=rF,aF=9007199254740991,nF=/^(?:0|[1-9]\d*)$/;function oF(e,t){var i=typeof e;return t=t??aF,!!t&&(i=="number"||i!="symbol"&&nF.test(e))&&e>-1&&e%1==0&&e<t}var Sx=oF;function lF(e,t,i){t=="__proto__"&&vm?vm(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var kC=lF;function hF(e,t){return e===t||e!==e&&t!==t}var Ax=hF,cF=Object.prototype,uF=cF.hasOwnProperty;function dF(e,t,i){var r=e[t];(!(uF.call(e,t)&&Ax(r,i))||i===void 0&&!(t in e))&&kC(e,t,i)}var Mx=dF;function pF(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?kC(i,o,l):Mx(i,o,l)}return i}var Xd=pF,MS=Math.max;function fF(e,t,i){return t=MS(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=MS(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),jN(e,this,o)}}var mF=fF,gF=9007199254740991;function vF(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=gF}var Ex=vF;function yF(e){return e!=null&&Ex(e.length)&&!zC(e)}var NC=yF,xF=Object.prototype;function bF(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||xF;return e===i}var Cx=bF;function wF(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var _F=wF,SF="[object Arguments]";function AF(e){return lo(e)&&$l(e)==SF}var ES=AF,FC=Object.prototype,MF=FC.hasOwnProperty,EF=FC.propertyIsEnumerable,CF=ES(function(){return arguments}())?ES:function(e){return lo(e)&&MF.call(e,"callee")&&!EF.call(e,"callee")},Tx=CF;function TF(){return!1}var PF=TF,UC=typeof exports=="object"&&exports&&!exports.nodeType&&exports,CS=UC&&typeof module=="object"&&module&&!module.nodeType&&module,DF=CS&&CS.exports===UC,TS=DF?Va.Buffer:void 0,OF=TS?TS.isBuffer:void 0,IF=OF||PF,ym=IF,RF="[object Arguments]",BF="[object Array]",LF="[object Boolean]",zF="[object Date]",kF="[object Error]",NF="[object Function]",FF="[object Map]",UF="[object Number]",VF="[object Object]",jF="[object RegExp]",GF="[object Set]",HF="[object String]",WF="[object WeakMap]",qF="[object ArrayBuffer]",XF="[object DataView]",YF="[object Float32Array]",QF="[object Float64Array]",ZF="[object Int8Array]",KF="[object Int16Array]",JF="[object Int32Array]",$F="[object Uint8Array]",eU="[object Uint8ClampedArray]",tU="[object Uint16Array]",iU="[object Uint32Array]",Ti={};Ti[YF]=Ti[QF]=Ti[ZF]=Ti[KF]=Ti[JF]=Ti[$F]=Ti[eU]=Ti[tU]=Ti[iU]=!0;Ti[RF]=Ti[BF]=Ti[qF]=Ti[LF]=Ti[XF]=Ti[zF]=Ti[kF]=Ti[NF]=Ti[FF]=Ti[UF]=Ti[VF]=Ti[jF]=Ti[GF]=Ti[HF]=Ti[WF]=!1;function rU(e){return lo(e)&&Ex(e.length)&&!!Ti[$l(e)]}var sU=rU;function aU(e){return function(t){return e(t)}}var Px=aU,VC=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nd=VC&&typeof module=="object"&&module&&!module.nodeType&&module,nU=nd&&nd.exports===VC,Bv=nU&&IC.process,oU=function(){try{var e=nd&&nd.require&&nd.require("util").types;return e||Bv&&Bv.binding&&Bv.binding("util")}catch{}}(),Mc=oU,PS=Mc&&Mc.isTypedArray,lU=PS?Px(PS):sU,jC=lU,hU=Object.prototype,cU=hU.hasOwnProperty;function uU(e,t){var i=xn(e),r=!i&&Tx(e),s=!i&&!r&&ym(e),a=!i&&!r&&!s&&jC(e),n=i||r||s||a,o=n?_F(e.length,String):[],l=o.length;for(var h in e)(t||cU.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Sx(h,l)))&&o.push(h);return o}var GC=uU;function dU(e,t){return function(i){return e(t(i))}}var HC=dU,pU=HC(Object.keys,Object),fU=pU,mU=Object.prototype,gU=mU.hasOwnProperty;function vU(e){if(!Cx(e))return fU(e);var t=[];for(var i in Object(e))gU.call(e,i)&&i!="constructor"&&t.push(i);return t}var yU=vU;function xU(e){return NC(e)?GC(e):yU(e)}var Dx=xU;function bU(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var wU=bU,_U=Object.prototype,SU=_U.hasOwnProperty;function AU(e){if(!Ua(e))return wU(e);var t=Cx(e),i=[];for(var r in e)r=="constructor"&&(t||!SU.call(e,r))||i.push(r);return i}var MU=AU;function EU(e){return NC(e)?GC(e,!0):MU(e)}var El=EU,CU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,TU=/^\w*$/;function PU(e,t){if(xn(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||dg(e)?!0:TU.test(e)||!CU.test(e)||t!=null&&e in Object(t)}var DU=PU,OU=th(Object,"create"),wd=OU;function IU(){this.__data__=wd?wd(null):{},this.size=0}var RU=IU;function BU(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var LU=BU,zU="__lodash_hash_undefined__",kU=Object.prototype,NU=kU.hasOwnProperty;function FU(e){var t=this.__data__;if(wd){var i=t[e];return i===zU?void 0:i}return NU.call(t,e)?t[e]:void 0}var UU=FU,VU=Object.prototype,jU=VU.hasOwnProperty;function GU(e){var t=this.__data__;return wd?t[e]!==void 0:jU.call(t,e)}var HU=GU,WU="__lodash_hash_undefined__";function qU(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=wd&&t===void 0?WU:t,this}var XU=qU;function Gc(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])}}Gc.prototype.clear=RU;Gc.prototype.delete=LU;Gc.prototype.get=UU;Gc.prototype.has=HU;Gc.prototype.set=XU;var DS=Gc;function YU(){this.__data__=[],this.size=0}var QU=YU;function ZU(e,t){for(var i=e.length;i--;)if(Ax(e[i][0],t))return i;return-1}var pg=ZU,KU=Array.prototype,JU=KU.splice;function $U(e){var t=this.__data__,i=pg(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():JU.call(t,i,1),--this.size,!0}var e6=$U;function t6(e){var t=this.__data__,i=pg(t,e);return i<0?void 0:t[i][1]}var i6=t6;function r6(e){return pg(this.__data__,e)>-1}var s6=r6;function a6(e,t){var i=this.__data__,r=pg(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var n6=a6;function Hc(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])}}Hc.prototype.clear=QU;Hc.prototype.delete=e6;Hc.prototype.get=i6;Hc.prototype.has=s6;Hc.prototype.set=n6;var fg=Hc,o6=th(Va,"Map"),_d=o6;function l6(){this.size=0,this.__data__={hash:new DS,map:new(_d||fg),string:new DS}}var h6=l6;function c6(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var u6=c6;function d6(e,t){var i=e.__data__;return u6(t)?i[typeof t=="string"?"string":"hash"]:i.map}var mg=d6;function p6(e){var t=mg(this,e).delete(e);return this.size-=t?1:0,t}var f6=p6;function m6(e){return mg(this,e).get(e)}var g6=m6;function v6(e){return mg(this,e).has(e)}var y6=v6;function x6(e,t){var i=mg(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var b6=x6;function Wc(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])}}Wc.prototype.clear=h6;Wc.prototype.delete=f6;Wc.prototype.get=g6;Wc.prototype.has=y6;Wc.prototype.set=b6;var gg=Wc,w6="Expected a function";function Ox(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(w6);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(Ox.Cache||gg),i}Ox.Cache=gg;var _6=Ox,S6=500;function A6(e){var t=_6(e,function(r){return i.size===S6&&i.clear(),r}),i=t.cache;return t}var M6=A6,E6=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,C6=/\\(\\)?/g,T6=M6(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(E6,function(i,r,s,a){t.push(s?a.replace(C6,"$1"):r||i)}),t}),P6=T6;function D6(e){return e==null?"":eN(e)}var O6=D6;function I6(e,t){return xn(e)?e:DU(e,t)?[e]:P6(O6(e))}var qc=I6,R6=1/0;function B6(e){if(typeof e=="string"||dg(e))return e;var t=e+"";return t=="0"&&1/e==-R6?"-0":t}var vg=B6;function L6(e,t){t=qc(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[vg(t[i++])];return i&&i==r?e:void 0}var WC=L6;function z6(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Ix=z6,OS=fa?fa.isConcatSpreadable:void 0;function k6(e){return xn(e)||Tx(e)||!!(OS&&e&&e[OS])}var N6=k6;function qC(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=N6),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?qC(o,t-1,i,r,s):Ix(s,o):r||(s[s.length]=o)}return s}var F6=qC;function U6(e){var t=e==null?0:e.length;return t?F6(e,1):[]}var V6=U6;function j6(e){return iF(mF(e,void 0,V6),e+"")}var XC=j6,G6=HC(Object.getPrototypeOf,Object),Rx=G6,H6="[object Object]",W6=Function.prototype,q6=Object.prototype,YC=W6.toString,X6=q6.hasOwnProperty,Y6=YC.call(Object);function Q6(e){if(!lo(e)||$l(e)!=H6)return!1;var t=Rx(e);if(t===null)return!0;var i=X6.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&YC.call(i)==Y6}var Z6=Q6;function K6(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 J6=K6;function $6(){this.__data__=new fg,this.size=0}var eV=$6;function tV(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var iV=tV;function rV(e){return this.__data__.get(e)}var sV=rV;function aV(e){return this.__data__.has(e)}var nV=aV,oV=200;function lV(e,t){var i=this.__data__;if(i instanceof fg){var r=i.__data__;if(!_d||r.length<oV-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new gg(r)}return i.set(e,t),this.size=i.size,this}var hV=lV;function Xc(e){var t=this.__data__=new fg(e);this.size=t.size}Xc.prototype.clear=eV;Xc.prototype.delete=iV;Xc.prototype.get=sV;Xc.prototype.has=nV;Xc.prototype.set=hV;var Xf=Xc;function cV(e,t){return e&&Xd(t,Dx(t),e)}var uV=cV;function dV(e,t){return e&&Xd(t,El(t),e)}var pV=dV,QC=typeof exports=="object"&&exports&&!exports.nodeType&&exports,IS=QC&&typeof module=="object"&&module&&!module.nodeType&&module,fV=IS&&IS.exports===QC,RS=fV?Va.Buffer:void 0,BS=RS?RS.allocUnsafe:void 0;function mV(e,t){if(t)return e.slice();var i=e.length,r=BS?BS(i):new e.constructor(i);return e.copy(r),r}var gV=mV;function vV(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 yV=vV;function xV(){return[]}var ZC=xV,bV=Object.prototype,wV=bV.propertyIsEnumerable,LS=Object.getOwnPropertySymbols,_V=LS?function(e){return e==null?[]:(e=Object(e),yV(LS(e),function(t){return wV.call(e,t)}))}:ZC,Bx=_V;function SV(e,t){return Xd(e,Bx(e),t)}var AV=SV,MV=Object.getOwnPropertySymbols,EV=MV?function(e){for(var t=[];e;)Ix(t,Bx(e)),e=Rx(e);return t}:ZC,KC=EV;function CV(e,t){return Xd(e,KC(e),t)}var TV=CV;function PV(e,t,i){var r=t(e);return xn(e)?r:Ix(r,i(e))}var JC=PV;function DV(e){return JC(e,Dx,Bx)}var yy=DV;function OV(e){return JC(e,El,KC)}var $C=OV,IV=th(Va,"DataView"),xy=IV,RV=th(Va,"Promise"),by=RV,BV=th(Va,"Set"),wy=BV,zS="[object Map]",LV="[object Object]",kS="[object Promise]",NS="[object Set]",FS="[object WeakMap]",US="[object DataView]",zV=eh(xy),kV=eh(_d),NV=eh(by),FV=eh(wy),UV=eh(vy),gl=$l;(xy&&gl(new xy(new ArrayBuffer(1)))!=US||_d&&gl(new _d)!=zS||by&&gl(by.resolve())!=kS||wy&&gl(new wy)!=NS||vy&&gl(new vy)!=FS)&&(gl=function(e){var t=$l(e),i=t==LV?e.constructor:void 0,r=i?eh(i):"";if(r)switch(r){case zV:return US;case kV:return zS;case NV:return kS;case FV:return NS;case UV:return FS}return t});var Sd=gl,VV=Object.prototype,jV=VV.hasOwnProperty;function GV(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&jV.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var HV=GV,WV=Va.Uint8Array,xm=WV;function qV(e){var t=new e.constructor(e.byteLength);return new xm(t).set(new xm(e)),t}var Lx=qV;function XV(e,t){var i=t?Lx(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var YV=XV,QV=/\w*$/;function ZV(e){var t=new e.constructor(e.source,QV.exec(e));return t.lastIndex=e.lastIndex,t}var KV=ZV,VS=fa?fa.prototype:void 0,jS=VS?VS.valueOf:void 0;function JV(e){return jS?Object(jS.call(e)):{}}var $V=JV;function ej(e,t){var i=t?Lx(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var tj=ej,ij="[object Boolean]",rj="[object Date]",sj="[object Map]",aj="[object Number]",nj="[object RegExp]",oj="[object Set]",lj="[object String]",hj="[object Symbol]",cj="[object ArrayBuffer]",uj="[object DataView]",dj="[object Float32Array]",pj="[object Float64Array]",fj="[object Int8Array]",mj="[object Int16Array]",gj="[object Int32Array]",vj="[object Uint8Array]",yj="[object Uint8ClampedArray]",xj="[object Uint16Array]",bj="[object Uint32Array]";function wj(e,t,i){var r=e.constructor;switch(t){case cj:return Lx(e);case ij:case rj:return new r(+e);case uj:return YV(e,i);case dj:case pj:case fj:case mj:case gj:case vj:case yj:case xj:case bj:return tj(e,i);case sj:return new r;case aj:case lj:return new r(e);case nj:return KV(e);case oj:return new r;case hj:return $V(e)}}var _j=wj;function Sj(e){return typeof e.constructor=="function"&&!Cx(e)?UN(Rx(e)):{}}var Aj=Sj,Mj="[object Map]";function Ej(e){return lo(e)&&Sd(e)==Mj}var Cj=Ej,GS=Mc&&Mc.isMap,Tj=GS?Px(GS):Cj,Pj=Tj,Dj="[object Set]";function Oj(e){return lo(e)&&Sd(e)==Dj}var Ij=Oj,HS=Mc&&Mc.isSet,Rj=HS?Px(HS):Ij,Bj=Rj,Lj=1,zj=2,kj=4,eT="[object Arguments]",Nj="[object Array]",Fj="[object Boolean]",Uj="[object Date]",Vj="[object Error]",tT="[object Function]",jj="[object GeneratorFunction]",Gj="[object Map]",Hj="[object Number]",iT="[object Object]",Wj="[object RegExp]",qj="[object Set]",Xj="[object String]",Yj="[object Symbol]",Qj="[object WeakMap]",Zj="[object ArrayBuffer]",Kj="[object DataView]",Jj="[object Float32Array]",$j="[object Float64Array]",e8="[object Int8Array]",t8="[object Int16Array]",i8="[object Int32Array]",r8="[object Uint8Array]",s8="[object Uint8ClampedArray]",a8="[object Uint16Array]",n8="[object Uint32Array]",Ei={};Ei[eT]=Ei[Nj]=Ei[Zj]=Ei[Kj]=Ei[Fj]=Ei[Uj]=Ei[Jj]=Ei[$j]=Ei[e8]=Ei[t8]=Ei[i8]=Ei[Gj]=Ei[Hj]=Ei[iT]=Ei[Wj]=Ei[qj]=Ei[Xj]=Ei[Yj]=Ei[r8]=Ei[s8]=Ei[a8]=Ei[n8]=!0;Ei[Vj]=Ei[tT]=Ei[Qj]=!1;function Yf(e,t,i,r,s,a){var n,o=t&Lj,l=t&zj,h=t&kj;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!Ua(e))return e;var u=xn(e);if(u){if(n=HV(e),!o)return HN(e,n)}else{var c=Sd(e),d=c==tT||c==jj;if(ym(e))return gV(e,o);if(c==iT||c==eT||d&&!s){if(n=l||d?{}:Aj(e),!o)return l?TV(e,pV(n,e)):AV(e,uV(n,e))}else{if(!Ei[c])return s?e:{};n=_j(e,c,o)}}a||(a=new Xf);var p=a.get(e);if(p)return p;a.set(e,n),Bj(e)?e.forEach(function(v){n.add(Yf(v,t,i,v,e,a))}):Pj(e)&&e.forEach(function(v,y){n.set(y,Yf(v,t,i,y,e,a))});var f=h?l?$C:yy:l?El:Dx,m=u?void 0:f(e);return sF(m||e,function(v,y){m&&(y=v,v=e[y]),Mx(n,y,Yf(v,t,i,y,e,a))}),n}var rT=Yf,o8=1,l8=4;function h8(e){return rT(e,o8|l8)}var yg=h8,c8="__lodash_hash_undefined__";function u8(e){return this.__data__.set(e,c8),this}var d8=u8;function p8(e){return this.__data__.has(e)}var f8=p8;function bm(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new gg;++t<i;)this.add(e[t])}bm.prototype.add=bm.prototype.push=d8;bm.prototype.has=f8;var m8=bm;function g8(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 v8=g8;function y8(e,t){return e.has(t)}var x8=y8,b8=1,w8=2;function _8(e,t,i,r,s,a){var n=i&b8,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),u=a.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&w8?new m8:void 0;for(a.set(e,t),a.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var v=n?r(m,f,c,t,e,a):r(f,m,c,e,t,a);if(v!==void 0){if(v)continue;d=!1;break}if(p){if(!v8(t,function(y,x){if(!x8(p,x)&&(f===y||s(f,y,i,r,a)))return p.push(x)})){d=!1;break}}else if(!(f===m||s(f,m,i,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}var sT=_8;function S8(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var A8=S8;function M8(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var E8=M8,C8=1,T8=2,P8="[object Boolean]",D8="[object Date]",O8="[object Error]",I8="[object Map]",R8="[object Number]",B8="[object RegExp]",L8="[object Set]",z8="[object String]",k8="[object Symbol]",N8="[object ArrayBuffer]",F8="[object DataView]",WS=fa?fa.prototype:void 0,Lv=WS?WS.valueOf:void 0;function U8(e,t,i,r,s,a,n){switch(i){case F8:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case N8:return!(e.byteLength!=t.byteLength||!a(new xm(e),new xm(t)));case P8:case D8:case R8:return Ax(+e,+t);case O8:return e.name==t.name&&e.message==t.message;case B8:case z8:return e==t+"";case I8:var o=A8;case L8:var l=r&C8;if(o||(o=E8),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=T8,n.set(e,t);var u=sT(o(e),o(t),r,s,a,n);return n.delete(e),u;case k8:if(Lv)return Lv.call(e)==Lv.call(t)}return!1}var V8=U8,j8=1,G8=Object.prototype,H8=G8.hasOwnProperty;function W8(e,t,i,r,s,a){var n=i&j8,o=yy(e),l=o.length,h=yy(t),u=h.length;if(l!=u&&!n)return!1;for(var c=l;c--;){var d=o[c];if(!(n?d in t:H8.call(t,d)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var m=!0;a.set(e,t),a.set(t,e);for(var v=n;++c<l;){d=o[c];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)){m=!1;break}v||(v=d=="constructor")}if(m&&!v){var _=e.constructor,S=t.constructor;_!=S&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof S=="function"&&S instanceof S)&&(m=!1)}return a.delete(e),a.delete(t),m}var q8=W8,X8=1,qS="[object Arguments]",XS="[object Array]",Jp="[object Object]",Y8=Object.prototype,YS=Y8.hasOwnProperty;function Q8(e,t,i,r,s,a){var n=xn(e),o=xn(t),l=n?XS:Sd(e),h=o?XS:Sd(t);l=l==qS?Jp:l,h=h==qS?Jp:h;var u=l==Jp,c=h==Jp,d=l==h;if(d&&ym(e)){if(!ym(t))return!1;n=!0,u=!1}if(d&&!u)return a||(a=new Xf),n||jC(e)?sT(e,t,i,r,s,a):V8(e,t,l,i,r,s,a);if(!(i&X8)){var p=u&&YS.call(e,"__wrapped__"),f=c&&YS.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,v=f?t.value():t;return a||(a=new Xf),s(m,v,i,r,a)}}return d?(a||(a=new Xf),q8(e,t,i,r,s,a)):!1}var Z8=Q8;function aT(e,t,i,r,s){return e===t?!0:e==null||t==null||!lo(e)&&!lo(t)?e!==e&&t!==t:Z8(e,t,i,r,aT,s)}var K8=aT;function J8(e,t){return e!=null&&t in Object(e)}var $8=J8;function eG(e,t,i){t=qc(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=vg(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&&Ex(s)&&Sx(n,s)&&(xn(e)||Tx(e)))}var tG=eG;function iG(e,t){return e!=null&&tG(e,t,$8)}var rG=iG,sG=function(){return Va.Date.now()},zv=sG,aG="Expected a function",nG=Math.max,oG=Math.min;function lG(e,t,i){var r,s,a,n,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(aG);t=_S(t)||0,Ua(i)&&(u=!!i.leading,c="maxWait"in i,a=c?nG(_S(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d);function p(M){var C=r,A=s;return r=s=void 0,h=M,n=e.apply(A,C),n}function f(M){return h=M,o=setTimeout(y,t),u?p(M):n}function m(M){var C=M-l,A=M-h,T=t-C;return c?oG(T,a-A):T}function v(M){var C=M-l,A=M-h;return l===void 0||C>=t||C<0||c&&A>=a}function y(){var M=zv();if(v(M))return x(M);o=setTimeout(y,m(M))}function x(M){return o=void 0,d&&r?p(M):(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(zv())}function S(){var M=zv(),C=v(M);if(r=arguments,s=this,l=M,C){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(y,t),p(l)}return o===void 0&&(o=setTimeout(y,t)),n}return S.cancel=b,S.flush=_,S}var zx=lG;function hG(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var cG=hG;function uG(e,t){return t.length<2?e:WC(e,J6(t,0,-1))}var dG=uG;function pG(e,t){return K8(e,t)}var nT=pG;function fG(e,t){return t=qc(t,e),e=dG(e,t),e==null||delete e[vg(cG(t))]}var mG=fG;function gG(e){return Z6(e)?void 0:e}var vG=gG,yG=1,xG=2,bG=4,wG=XC(function(e,t){var i={};if(e==null)return i;var r=!1;t=BC(t,function(a){return a=qc(a,e),r||(r=a.length>1),a}),Xd(e,$C(e),i),r&&(i=rT(i,yG|xG|bG,vG));for(var s=t.length;s--;)mG(i,t[s]);return i}),_y=wG;function _G(e,t,i,r){if(!Ua(e))return e;t=qc(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=vg(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=Ua(u)?u:Sx(t[s+1])?[]:{})}Mx(o,l,h),o=o[l]}return e}var SG=_G;function AG(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=WC(e,n);i(o,n)&&SG(a,qc(n,e),o)}return a}var MG=AG;function EG(e,t){return MG(e,t,function(i,r){return rG(e,r)})}var CG=EG,TG=XC(function(e,t){return e==null?{}:CG(e,t)}),ao=TG,PG="Expected a function";function DG(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(PG);return Ua(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),zx(e,t,{leading:r,maxWait:t,trailing:s})}var OG=DG;function oT(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function bn(e,t){return Object.setPrototypeOf(e,t),e}var IG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),RG=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),BG=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||xg&&"ontouchend"in document,LG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,zG=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,kG=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},NG=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},FG=()=>{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"},UG=IG(),Ree=UG?FG():void 0,xg=RG(),kx=BG(),VG=LG(),Hs=zG(),QS=kG(),ZS=Number(NG());function lT(e){return Array.isArray(e)?e:[e]}function hT(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 $p(e){return xg?e.metaKey:e.ctrlKey}function jG(e){return e.wheelDeltaY===0||e.deltaY===0?xg&&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 wt=[],wm={},Yu={},Qf={};function cT(e){wt.includes(e)||wt.push(e)}function lc(e){delete wm[e.pointerId];for(let t=0;t<wt.length;t++)if(wt[t].pointerId===e.pointerId){wt.splice(t,1);break}}function GG(){wt.splice(0,wt.length)}function _m(e){if(e.pointerType!=="touch")return;let t=wm[e.pointerId];t===void 0&&(t={x:0,y:0},wm[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function kv(e){let t=e.pointerId===wt[0].pointerId?wt[1]:wt[0];return wm[t.pointerId]}function uT(e){Yu[e.key]=!0,Qf[e.key]=Qf[e.key]===void 0?1:Qf[e.key]+1}function dT(e){if(xg&&Yu.Meta)for(let t in Yu)Yu[t]=!1;else Yu[e.key]=!1;Qf={}}function HG(e){e.addEventListener("pointerdown",cT,!0),e.addEventListener("pointerdown",_m,!0),e.addEventListener("pointermove",_m,!0),e.addEventListener("pointerup",lc,!0),e.addEventListener("pointercancel",lc,!0),e.addEventListener("pointerleave",lc,!0),window.addEventListener("keydown",uT,!0),window.addEventListener("keyup",dT,!0)}function WG(e){e.removeEventListener("pointerdown",cT,!0),e.removeEventListener("pointerdown",_m,!0),e.removeEventListener("pointermove",_m,!0),e.removeEventListener("pointerup",lc,!0),e.removeEventListener("pointercancel",lc,!0),e.removeEventListener("pointerleave",lc,!0),window.removeEventListener("keydown",uT,!0),window.removeEventListener("keyup",dT,!0)}var pT,qG=new Promise(e=>{pT=e}),ef;function XG(){if(ef)return ef;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@1.0.21/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});pT(n)}return ef=e(),ef}var fT,YG=new Promise(e=>{fT=e}),tf;function QG(){if(tf)return tf;async function e(){let t=await import("./physics.js");await t.init(),fT(t)}return tf=e(),tf}var Tt=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,Tt.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,Tt.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,Tt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Nx(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"&&Nx(r)}return Object.freeze(e)}function ZG(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 mT=class extends Error{};function Nv(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function zo(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 Fx(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 KG(){return typeof process<"u"}function gT(e,t){for(let i of e)t(i.id,i.data)!==!0&&gT(i.children,t)}function vT(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)vT(i,t)}var qr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,qr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nx(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&&vT(i,t)}}traverse(e){gT(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,qr.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,u)=>h.fi-u.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 c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new mT("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(c=>c.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((c,d)=>c.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>ZG(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 zo(0,i,i);{let s=r[0].fi;return zo(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 zo(n,n+i,i)}else return zo(s.fi,a.fi,i)}}},Sm;(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})(Sm||(Sm={}));var mt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,mt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nx(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,mt.prototype);let t=e;return KG()||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 zo(0,t,t);{let r=i[0].fi;return zo(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 zo(a,a+t,t)}else return zo(r.fi,s.fi,t)}}};function Ec(e){return e&&typeof e=="object"&&e instanceof cr}var cr=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&&!Ec(i))return null;r+=1}i=i?Nv(i):new cr;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=Nv(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Nv(o);l[e.path[r-1]]=i,i=l}else{let l=new cr;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,cr.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},qo;(e=>{function t(s,a){return Ad(s,a)??s}e.apply=t;function i(s,a){return Vx(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=Wr.zoomOnce(l,o[n]),l===void 0)return a;if(!Ec(l))return;n+=1}if(l===void 0)return a;if(Ec(l))if(a.type===0){let h={...a.props};for(let u of Object.keys(l))delete h[u];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=Ux([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(qo||(qo={}));function Ux(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=Ad(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=Ux(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 JG(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=Ad(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 Ad(e,t){if(!Ec(t))return t;if(e instanceof qr){let i=Ux(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof mt)return JG(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=Ad(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 cr)return Vx(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=Ad(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 Vx(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Ec(t))return t;if(!Ec(e))return qo.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 cr;for(let s of i){let a=Vx(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function $G(e,t){let i={cur:[],result:[],len:0};return e=Md(e,t,i)??e,[e,i.result]}function Am(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Mm(e){e&&(e.len-=1)}function eH(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function yT(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=Md(a.data,t,Am(i,n));Mm(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=yT(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 tH(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=Md(a.data,t,Am(i,n));return Mm(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 Md(e,t,i){if(e instanceof qr){let r=yT(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof mt)return tH(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=Md(a,t,Am(i,n));return Mm(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"&&!Fx(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=Md(n,t,Am(i,a));Mm(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&&eH(i),r}else return}}var Em;(e=>{function t(i,r){let s=Wr.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})(Em||(Em={}));var Dr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let u=h.path;for(var c=[];;){let d;if(l instanceof cr&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof qr||l instanceof mt||l instanceof Tt?d=l.runOp(h):d=Sm.runOp(l,h)),d!==void 0)if(d!==null){let m=d.data;for(let v=c.length-1;v>=0;v--){let y=u[v],x=c[v];if(x instanceof qr){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof mt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof Tt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof cr){let b={...x,[y]:m};m=Object.setPrototypeOf(b,cr.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=m;m=[...x],m[y]=b}else m={...x,[y]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof qr){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof mt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let u=0;u<l.length&&u<h.length;u++)if(l[u]!==h[u])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==h[u])return!1;return!0}e.pathEq=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(u=>h.props[u]!==void 0):!1}e.subsumed=o})(Dr||(Dr={}));var Sy;(e=>{function t(){return[]}e.empty=t;function i(h,u){let c=[];for(let d of h){let[p,...f]=d.path;p===u&&c.push({...d,path:f})}return c}e.removePrefix=i;function r(h,u){return h.map(c=>({...c,path:[u,...c.path]}))}e.addPrefix=r;function s(h,u){return[...h,...u]}e.concat=s;function a(h,u){return[...h.filter(c=>!u.some(d=>Dr.subsumed(c,d))),...u]}e.compress=a;function n(h,u){return h.every(c=>u.every(d=>Dr.commutative(c,d)))}e.commutative=n;function o(h,u){for(let c of u){let d=l(h,c);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,u){var c=h;let d=[],p=[];for(let f of u)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,v,y;if(f.type===3?(m=Wr.zoom(c,[...f.path,f.id]),y=Dr.apply(c,{...f,type:2})):(m=Wr.zoom(c,[...f.path,f.id,"value"]),y=Dr.apply(c,f)),y!==null){c=y.data;let[x,b]=$G(c,{[f.id]:m});c=x;for(let _=0;_<b.length;_++){let S=b[_],M=S.pop();if(typeof M=="number"){let C=[M];for(let T=_+1;T<b.length;T++){let P=b[T],R=P[P.length-1];if(typeof R=="number"&&Wr.equal(S,P.slice(0,P.length-1)))C.push(R),b.splice(T,1);else break}let A=Wr.zoom(c,S);v=A.map((T,P)=>C.includes(P)?f.id:T),m=A,M=S.pop()}else{if(M==="alphaOverride"||M==="alpha"){m/=100;let C=m,A=Wr.zoom(c,S.slice(0,S.length-2)),T=A.layers.map(P=>P.id===S[S.length-1]?{...P,data:{...P.data,[M]:C}}:P);Object.setPrototypeOf(T,Object.getPrototypeOf(A.layers)),A.layers=T}v=f.id}d.push({type:0,path:S,props:{[M]:m}}),p.push({type:0,path:S,props:{[M]:v}})}p.push(y.reverse),d.push(y.actual)}}else{let m=Dr.apply(c,f);m!==null&&(d.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof mT)return null;throw m}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(Sy||(Sy={}));var xT=Symbol(),iH=Symbol(),bg=Symbol(),Yd=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof wT);){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[bg];i&&i(),delete this._children[e]}}}},rH=class extends Yd{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,Sm.runOp(this._current,e),e.path)}},sH=class extends Yd{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,Tt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},bT={get(e,t){if(t===bg)return()=>{e._parent=null};if(t===xT)return e._current;if(t===iH)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=wg(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]}}},aH={...bT,set(e,t,i){let r={type:0,props:{[t]:Ji(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}},nH={...bT,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}},jx=class extends Yd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[bg]=()=>{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=wg(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)}},Gx=class extends Yd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[bg]=()=>{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=wg(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 Fv(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Wr.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var wT=class extends Yd{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){Fv(this.ts,t,e),Fv(this.actual,i,e),Fv(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function wg(e,t,i){return i instanceof qr?new jx(e,t,i):i instanceof mt?new Gx(e,t,i):i instanceof Tt?new Proxy(new sH(e,t,i),nH):i!==null&&typeof i=="object"?Fx(i)?i:new Proxy(new rH(e,t,i),aH):i}function _T(e){let t=new wT(e);return[wg(t,"",e),t]}function Ed(e,t){let[i,r]=_T(e);return t(i),r.result()}function Ji(e){return e instanceof jx||e instanceof Gx?e._current:e!==null&&typeof e=="object"?e[xT]:e}var Wr;(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(u=>{delete h[u]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof qr||a instanceof jx)&&typeof n=="string"||(a instanceof mt||a instanceof Gx)&&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})(Wr||(Wr={}));function oH(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 _i(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 ST=class{},KS=class extends ST{constructor(e){super(),this.id=e}},JS=class extends ST{constructor(e){super(),this.data=e}},Ay;try{Ay=new TextDecoder}catch{}var rt,Xo,fe=0,AT=[],My=AT,Ey=0,Os={},ii,ko,oa=0,un=0,js,no,_s=[],hi,$S={useRecords:!1,mapsAsObjects:!0},MT=class{},ET=new MT;ET.name="MessagePack 0xC1";var Cc=!1,Cm=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(rt)return IT(()=>(Ty(),this?this.unpack(e,t):Cm.prototype.unpack.call($S,e,t)));Xo=t>-1?t:e.length,fe=0,Ey=0,un=0,ko=null,My=AT,js=null,rt=e;try{hi=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw rt=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 Cm){if(Os=this,this.structures)return ii=this.structures,rf();(!ii||ii.length>0)&&(ii=[])}else Os=$S,(!ii||ii.length>0)&&(ii=[]);return rf()}unpackMultiple(e,t){let i,r=0;try{Cc=!0;let s=e.length,a=this?this.unpack(e,s):Sg.unpack(e,s);if(t){for(t(a);fe<s;)if(r=fe,t(rf())===!1)return}else{for(i=[a];fe<s;)r=fe,i.push(rf());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Cc=!1,Ty()}}_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 rf(){try{if(!Os.trusted&&!Cc){let t=ii.sharedLength||0;t<ii.length&&(ii.length=t)}let e=Gi();if(fe==Xo)ii.restoreStructures&&e2(),ii=null,rt=null,no&&(no=null);else if(fe>Xo){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Cc)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw ii.restoreStructures&&e2(),Ty(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function e2(){for(let e in ii.restoreStructures)ii[e]=ii.restoreStructures[e];ii.restoreStructures=null}function Gi(){let e=rt[fe++];if(e<160)if(e<128){if(e<64)return e;{let t=ii[e&63]||Os.getStructures&&CT()[e&63];return t?(t.read||(t.read=Hx(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Os.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[PT()]=Gi();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gi(),Gi());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gi();return t}else if(e<192){let t=e-160;if(un>=fe)return ko.slice(fe-oa,(fe+=t)-oa);if(un==0&&Xo<140){let i=t<16?Wx(t):TT(t);if(i!=null)return i}return Cy(t)}else{let t;switch(e){case 192:return null;case 193:return js?(t=Gi(),t>0?js[1].slice(js.position1,js.position1+=t):js[0].slice(js.position0,js.position0-=t)):ET;case 194:return!1;case 195:return!0;case 196:return Uv(rt[fe++]);case 197:return t=hi.getUint16(fe),fe+=2,Uv(t);case 198:return t=hi.getUint32(fe),fe+=4,Uv(t);case 199:return cl(rt[fe++]);case 200:return t=hi.getUint16(fe),fe+=2,cl(t);case 201:return t=hi.getUint32(fe),fe+=4,cl(t);case 202:if(t=hi.getFloat32(fe),Os.useFloat32>2){let i=qx[(rt[fe]&127)<<1|rt[fe+1]>>7];return fe+=4,(i*t+(t>0?.5:-.5)>>0)/i}return fe+=4,t;case 203:return t=hi.getFloat64(fe),fe+=8,t;case 204:return rt[fe++];case 205:return t=hi.getUint16(fe),fe+=2,t;case 206:return t=hi.getUint32(fe),fe+=4,t;case 207:return Os.int64AsNumber?(t=hi.getUint32(fe)*4294967296,t+=hi.getUint32(fe+4)):t=hi.getBigUint64(fe),fe+=8,t;case 208:return hi.getInt8(fe++);case 209:return t=hi.getInt16(fe),fe+=2,t;case 210:return t=hi.getInt32(fe),fe+=4,t;case 211:return Os.int64AsNumber?(t=hi.getInt32(fe)*4294967296,t+=hi.getUint32(fe+4)):t=hi.getBigInt64(fe),fe+=8,t;case 212:if(t=rt[fe++],t==114)return a2(rt[fe++]&63);{let i=_s[t];if(i)return i.read?(fe++,i.read(Gi())):i.noBuffer?(fe++,i()):i(rt.subarray(fe,++fe));throw new Error("Unknown extension "+t)}case 213:return t=rt[fe],t==114?(fe++,a2(rt[fe++]&63,rt[fe++])):cl(2);case 214:return cl(4);case 215:return cl(8);case 216:return cl(16);case 217:return t=rt[fe++],un>=fe?ko.slice(fe-oa,(fe+=t)-oa):hH(t);case 218:return t=hi.getUint16(fe),fe+=2,un>=fe?ko.slice(fe-oa,(fe+=t)-oa):cH(t);case 219:return t=hi.getUint32(fe),fe+=4,un>=fe?ko.slice(fe-oa,(fe+=t)-oa):uH(t);case 220:return t=hi.getUint16(fe),fe+=2,i2(t);case 221:return t=hi.getUint32(fe),fe+=4,i2(t);case 222:return t=hi.getUint16(fe),fe+=2,r2(t);case 223:return t=hi.getUint32(fe),fe+=4,r2(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 lH=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Hx(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>lH.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(Gi);return e.highByte===0&&(e.read=t2(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=Gi()}return r}return i.count=0,e.highByte===0?t2(t,i):i}var t2=(e,t)=>function(){let i=rt[fe++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=ii[r]||CT()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=Hx(s,e)),s.read()};function CT(){let e=IT(()=>(rt=null,Os.getStructures()));return ii=Os._mergeStructures(e,ii)}var Cy=_g,hH=_g,cH=_g,uH=_g;function _g(e){let t;if(e<16&&(t=Wx(e)))return t;if(e>64&&Ay)return Ay.decode(rt.subarray(fe,fe+=e));let i=fe+e,r=[];for(t="";fe<i;){let s=rt[fe++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=rt[fe++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=rt[fe++]&63,n=rt[fe++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=rt[fe++]&63,n=rt[fe++]&63,o=rt[fe++]&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+=Cr.apply(String,r),r.length=0)}return r.length>0&&(t+=Cr.apply(String,r)),t}function i2(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gi();return t}function r2(e){if(Os.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[PT()]=Gi();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gi(),Gi());return t}}var Cr=String.fromCharCode;function TT(e){let t=fe,i=new Array(e);for(let r=0;r<e;r++){let s=rt[fe++];if((s&128)>0){fe=t;return}i[r]=s}return Cr.apply(String,i)}function Wx(e){if(e<4)if(e<2){if(e===0)return"";{let t=rt[fe++];if((t&128)>1){fe-=1;return}return Cr(t)}}else{let t=rt[fe++],i=rt[fe++];if((t&128)>0||(i&128)>0){fe-=2;return}if(e<3)return Cr(t,i);let r=rt[fe++];if((r&128)>0){fe-=3;return}return Cr(t,i,r)}else{let t=rt[fe++],i=rt[fe++],r=rt[fe++],s=rt[fe++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){fe-=4;return}if(e<6){if(e===4)return Cr(t,i,r,s);{let a=rt[fe++];if((a&128)>0){fe-=5;return}return Cr(t,i,r,s,a)}}else if(e<8){let a=rt[fe++],n=rt[fe++];if((a&128)>0||(n&128)>0){fe-=6;return}if(e<7)return Cr(t,i,r,s,a,n);let o=rt[fe++];if((o&128)>0){fe-=7;return}return Cr(t,i,r,s,a,n,o)}else{let a=rt[fe++],n=rt[fe++],o=rt[fe++],l=rt[fe++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){fe-=8;return}if(e<10){if(e===8)return Cr(t,i,r,s,a,n,o,l);{let h=rt[fe++];if((h&128)>0){fe-=9;return}return Cr(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=rt[fe++],u=rt[fe++];if((h&128)>0||(u&128)>0){fe-=10;return}if(e<11)return Cr(t,i,r,s,a,n,o,l,h,u);let c=rt[fe++];if((c&128)>0){fe-=11;return}return Cr(t,i,r,s,a,n,o,l,h,u,c)}else{let h=rt[fe++],u=rt[fe++],c=rt[fe++],d=rt[fe++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){fe-=12;return}if(e<14){if(e===12)return Cr(t,i,r,s,a,n,o,l,h,u,c,d);{let p=rt[fe++];if((p&128)>0){fe-=13;return}return Cr(t,i,r,s,a,n,o,l,h,u,c,d,p)}}else{let p=rt[fe++],f=rt[fe++];if((p&128)>0||(f&128)>0){fe-=14;return}if(e<15)return Cr(t,i,r,s,a,n,o,l,h,u,c,d,p,f);let m=rt[fe++];if((m&128)>0){fe-=15;return}return Cr(t,i,r,s,a,n,o,l,h,u,c,d,p,f,m)}}}}}function Uv(e){return Os.copyBuffers?Uint8Array.prototype.slice.call(rt,fe,fe+=e):rt.subarray(fe,fe+=e)}function cl(e){let t=rt[fe++];if(_s[t])return _s[t](rt.subarray(fe,fe+=e));throw new Error("Unknown extension type "+t)}var s2=new Array(4096);function PT(){let e=rt[fe++];if(e>=160&&e<192){if(e=e-160,un>=fe)return ko.slice(fe-oa,(fe+=e)-oa);if(!(un==0&&Xo<180))return Cy(e)}else return fe--,Gi();let t=(e<<5^(e>1?hi.getUint16(fe):e>0?rt[fe]:0))&4095,i=s2[t],r=fe,s=fe+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=hi.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=rt[r++],a!=i[n++]){r=1879048192;break}if(r===s)return fe=r,i.string;s-=3,r=fe}for(i=[],s2[t]=i,i.bytes=e;r<s;)a=hi.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=rt[r++],i.push(a);let o=e<16?Wx(e):TT(e);return o!=null?i.string=o:i.string=Cy(e)}var a2=(e,t)=>{var i=Gi();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=ii[e];return s&&s.isShared&&((ii.restoreStructures||(ii.restoreStructures=[]))[e]=s),ii[e]=i,i.read=Hx(i,r),i.read()},DT=typeof self=="object"?self:global;_s[0]=()=>{};_s[0].noBuffer=!0;_s[101]=()=>{let e=Gi();return(DT[e[0]]||Error)(e[1])};_s[105]=e=>{let t=hi.getUint32(fe-4);no||(no=new Map);let i=rt[fe],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};no.set(t,s);let a=Gi();return s.used?Object.assign(r,a):(s.target=a,a)};_s[112]=e=>{let t=hi.getUint32(fe-4),i=no.get(t);return i.used=!0,i.target};_s[115]=()=>new Set(Gi());var OT=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");_s[116]=e=>{let t=e[0],i=OT[t];if(!i)throw new Error("Could not find typed array for code "+t);return new DT[i](Uint8Array.prototype.slice.call(e,1).buffer)};_s[120]=()=>{let e=Gi();return new RegExp(e[0],e[1])};_s[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=fe;fe+=t-4,js=[Gi(),Gi()],js.position0=0,js.position1=0;let r=fe;fe=i;try{return Gi()}finally{fe=r}};_s[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 IT(e){let t=Xo,i=fe,r=Ey,s=oa,a=un,n=ko,o=My,l=no,h=js,u=new Uint8Array(rt.slice(0,Xo)),c=ii,d=ii.slice(0,ii.length),p=Os,f=Cc,m=e();return Xo=t,fe=i,Ey=r,oa=s,un=a,ko=n,My=o,no=l,js=h,rt=u,Cc=f,ii=c,ii.splice(0,ii.length,...d),Os=p,hi=new DataView(rt.buffer,rt.byteOffset,rt.byteLength),m}function Ty(){rt=null,no=null,ii=null}function dH(e){e.unpack?_s[e.type]=e.unpack:_s[e.type]=e}var qx=new Array(147);for(let e=0;e<256;e++)qx[e]=+("1e"+Math.floor(45.15-e*.30103));var Sg=new Cm({useRecords:!1}),Bee=Sg.unpack,Lee=Sg.unpackMultiple,zee=Sg.unpack,pH={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fH=new Float32Array(1),kee=new Uint8Array(fH.buffer,0,4),Zf;try{Zf=new TextEncoder}catch{}var Tm,Xx,Ag=typeof Buffer<"u",Vv=Ag?Buffer.allocUnsafeSlow:Uint8Array,RT=Ag?Buffer:Uint8Array,n2=Ag?4294967296:2144337920,Oe,Yi,xe=0,qa,Xa=null,mH=/[\u0080-\uFFFF]/,Cu=Symbol("record-id"),BT=class extends Cm{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=RT.prototype.utf8Write?function(C,A,T){return Oe.utf8Write(C,A,T)}:Zf&&Zf.encodeInto?function(C,A){return Zf.encodeInto(C,Oe.subarray(A)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),u&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,m=d+64,v=d+p+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],x=0,b=0;this.pack=this.encode=function(C,A){if(Oe||(Oe=new Vv(8192),Yi=new DataView(Oe.buffer,0,8192),xe=0),qa=Oe.length-10,qa-xe<2048?(Oe=new Vv(Oe.length),Yi=new DataView(Oe.buffer,0,Oe.length),qa=Oe.length-10,xe=0):xe=xe+7&2147483640,i=xe,n=h.structuredClone?new Map:null,h.bundleStrings?(Xa=["",""],Oe[xe++]=214,Oe[xe++]=98,Xa.position=xe-i,xe+=4):Xa=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,N=r.transitions;for(let B=0,V=R.length;B<V;B++){let H=R[B];z=N[H],z||(z=N[H]=Object.create(null)),N=z}N[Cu]=P+64}o=T}u||(r.nextId=T+64)}s&&(s=!1),a=r||[];try{if(_(C),Xa){Yi.setUint32(Xa.position+i,xe-Xa.position-i);let T=Xa;Xa=null,_(T[0]),_(T[1])}if(h.offset=xe,n&&n.idsToInsert){xe+=n.idsToInsert.length*6,xe>qa&&M(xe),h.offset=xe;let T=vH(Oe.subarray(i,xe),n.idsToInsert);return n=null,T}return A&yH?(Oe.start=i,Oe.end=xe,Oe):Oe.subarray(i,xe)}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&&!u){for(let T=0,P=y.length;T<P;T++)y[T][Cu]=0;y=[]}if(s&&h.saveStructures){let T=r.sharedLength||d;r.length>T&&(r=r.slice(0,T));let P=Oe.subarray(i,xe);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(C)):(o=T,P)}}A&xH&&(xe=i)}};let _=C=>{xe>qa&&(Oe=M(xe));var A=typeof C,T;if(A==="string"){let P=C.length;if(Xa&&P>=8&&P<4096){let N=mH.test(C);Xa[N?0:1]+=C,Oe[xe++]=193,_(N?-P:P);return}let R;P<32?R=1:P<256?R=2:P<65536?R=3:R=5;let z=P*3;if(xe+z>qa&&(Oe=M(xe+z)),P<64||!l){let N,B,V,H=xe+R;for(N=0;N<P;N++)B=C.charCodeAt(N),B<128?Oe[H++]=B:B<2048?(Oe[H++]=B>>6|192,Oe[H++]=B&63|128):(B&64512)===55296&&((V=C.charCodeAt(N+1))&64512)===56320?(B=65536+((B&1023)<<10)+(V&1023),N++,Oe[H++]=B>>18|240,Oe[H++]=B>>12&63|128,Oe[H++]=B>>6&63|128,Oe[H++]=B&63|128):(Oe[H++]=B>>12|224,Oe[H++]=B>>6&63|128,Oe[H++]=B&63|128);T=H-xe-R}else T=l(C,xe+R,z);T<32?Oe[xe++]=160|T:T<256?(R<2&&Oe.copyWithin(xe+2,xe+1,xe+1+T),Oe[xe++]=217,Oe[xe++]=T):T<65536?(R<3&&Oe.copyWithin(xe+3,xe+2,xe+2+T),Oe[xe++]=218,Oe[xe++]=T>>8,Oe[xe++]=T&255):(R<5&&Oe.copyWithin(xe+5,xe+3,xe+3+T),Oe[xe++]=219,Yi.setUint32(xe,T),xe+=4),xe+=T}else if(A==="number")if(C>>>0===C)C<64?Oe[xe++]=C:C<256?(Oe[xe++]=204,Oe[xe++]=C):C<65536?(Oe[xe++]=205,Oe[xe++]=C>>8,Oe[xe++]=C&255):(Oe[xe++]=206,Yi.setUint32(xe,C),xe+=4);else if(C>>0===C)C>=-32?Oe[xe++]=256+C:C>=-128?(Oe[xe++]=208,Oe[xe++]=C+256):C>=-32768?(Oe[xe++]=209,Yi.setInt16(xe,C),xe+=2):(Oe[xe++]=210,Yi.setInt32(xe,C),xe+=4);else{let P;if((P=this.useFloat32)>0&&C<4294967296&&C>=-2147483648){Oe[xe++]=202,Yi.setFloat32(xe,C);let R;if(P<4||(R=C*qx[(Oe[xe]&127)<<1|Oe[xe+1]>>7])>>0===R){xe+=4;return}else xe--}Oe[xe++]=203,Yi.setFloat64(xe,C),xe+=8}else if(A==="object")if(!C)Oe[xe++]=192;else{if(n){let R=n.get(C);if(R){if(!R.id){let z=n.idsToInsert||(n.idsToInsert=[]);R.id=z.push(R)}Oe[xe++]=214,Oe[xe++]=112,Yi.setUint32(xe,R.id),xe+=4;return}else n.set(C,{offset:xe-i})}let P=C.constructor;if(P===Object)S(C,!0);else if(P===Array){T=C.length,T<16?Oe[xe++]=144|T:T<65536?(Oe[xe++]=220,Oe[xe++]=T>>8,Oe[xe++]=T&255):(Oe[xe++]=221,Yi.setUint32(xe,T),xe+=4);for(let R=0;R<T;R++)_(C[R])}else if(P===Map){T=C.size,T<16?Oe[xe++]=128|T:T<65536?(Oe[xe++]=222,Oe[xe++]=T>>8,Oe[xe++]=T&255):(Oe[xe++]=223,Yi.setUint32(xe,T),xe+=4);for(let[R,z]of C)_(R),_(z)}else{for(let R=0,z=Tm.length;R<z;R++){let N=Xx[R];if(C instanceof N){let B=Tm[R];if(B.write){B.type&&(Oe[xe++]=212,Oe[xe++]=B.type,Oe[xe++]=0),_(B.write.call(this,C));return}let V=Oe,H=Yi,X=xe;Oe=null;let G;try{G=B.pack.call(this,C,se=>(Oe=V,V=null,xe+=se,xe>qa&&M(xe),{target:Oe,targetView:Yi,position:xe-se}),_)}finally{V&&(Oe=V,Yi=H,xe=X,qa=Oe.length-10)}G&&(G.length+xe>qa&&M(G.length+xe),xe=gH(G,Oe,xe,B.type));return}}S(C,!C.hasOwnProperty)}}else if(A==="boolean")Oe[xe++]=C?195:194;else if(A==="bigint"){if(C<BigInt(1)<<BigInt(63)&&C>=-(BigInt(1)<<BigInt(63)))Oe[xe++]=211,Yi.setBigInt64(xe,C);else if(C<BigInt(1)<<BigInt(64)&&C>0)Oe[xe++]=207,Yi.setBigUint64(xe,C);else if(this.largeBigIntToFloat)Oe[xe++]=203,Yi.setFloat64(xe,Number(C));else throw new RangeError(C+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");xe+=8}else if(A==="undefined")this.encodeUndefinedAsNil?Oe[xe++]=192:(Oe[xe++]=212,Oe[xe++]=0,Oe[xe++]=0);else if(A==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},S=this.useRecords===!1?this.variableMapSize?C=>{let A=Object.keys(C),T=A.length;T<16?Oe[xe++]=128|T:T<65536?(Oe[xe++]=222,Oe[xe++]=T>>8,Oe[xe++]=T&255):(Oe[xe++]=223,Yi.setUint32(xe,T),xe+=4);let P;for(let R=0;R<T;R++)_(P=A[R]),_(C[P])}:(C,A)=>{Oe[xe++]=222;let T=xe-i;xe+=2;let P=0;for(let R in C)(A||C.hasOwnProperty(R))&&(_(R),_(C[R]),P++);Oe[T+++i]=P>>8,Oe[T+i]=P&255}:C=>{let A=Object.keys(C),T,P=a.transitions||(a.transitions=Object.create(null)),R=0;for(let N=0,B=A.length;N<B;N++){let V=A[N];T=P[V],T||(T=P[V]=Object.create(null),R++),P=T}let z=P[Cu];if(z)z>=96&&f?(Oe[xe++]=((z-=96)&31)+96,Oe[xe++]=z>>5):Oe[xe++]=z;else{z=a.nextId,z||(z=64),z<m&&this.shouldShareStructure&&!this.shouldShareStructure(A)?(z=a.nextOwnId,z<v||(z=m),a.nextOwnId=z+1):(z>=v&&(z=m),a.nextId=z+1);let N=A.highByte=z>=96&&f?z-96>>5:-1;P[Cu]=z,a[z-64]=A,z<m?(A.isShared=!0,a.sharedLength=z-63,s=!0,N>=0?(Oe[xe++]=(z&31)+96,Oe[xe++]=N):Oe[xe++]=z):(N>=0?(Oe[xe++]=213,Oe[xe++]=114,Oe[xe++]=(z&31)+96,Oe[xe++]=N):(Oe[xe++]=212,Oe[xe++]=114,Oe[xe++]=z),R&&(x+=b*R),y.length>=p&&(y.shift()[Cu]=0),y.push(P),_(A))}for(let N=0,B=A.length;N<B;N++)_(C[A[N]])},M=C=>{let A;if(C>16777216){if(C-i>n2)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(n2,Math.round(Math.max((C-i)*(C>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(C-i<<2,Oe.length-1)>>12)+1<<12;let T=new Vv(A);return Yi=new DataView(T.buffer,0,A),Oe.copy?Oe.copy(T,0,i,C):T.set(Oe.slice(i,C)),xe-=i,i=0,qa=T.length-10,Oe=T}}useBuffer(e){Oe=e,Yi=new DataView(Oe.buffer,Oe.byteOffset,Oe.byteLength),xe=0}};Xx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,MT];Tm=[{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?o2(e,16,t):l2(Ag?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==RT&&this.structuredClone?o2(e,OT.indexOf(i.name),t):l2(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function o2(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 l2(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 gH(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 vH(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 Yc(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)");Xx.unshift(e.Class),Tm.unshift(e)}dH(e)}var LT=new BT({useRecords:!1}),Nee=LT.pack,Fee=LT.pack,{NEVER:Uee,ALWAYS:Vee,DECIMAL_ROUND:jee,DECIMAL_FIT:Gee}=pH,yH=512,xH=1024,h2=new BT({structuredClone:!0});Yc({Class:Tt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Tt.prototype),e}});Yc({Class:mt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,mt.prototype),e}});Yc({Class:qr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,qr.prototype),e}});Yc({Class:KS.prototype.constructor,type:4,write(e){return e.id},read(e){return new KS(e)}});Yc({Class:JS.prototype.constructor,type:5,write(e){return e.data},read(e){return new JS(e)}});Yc({Class:cr.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,cr.prototype),e}});function bH(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 Py(e){if(Fx(e))return e;if(Array.isArray(e))return e.map(Py);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Py(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Dy;(e=>{function t(s){return h2.pack(s)}e.serialize=t;function i(s){return h2.unpack(s)}e.deserialize=i;function r(s){return bH(t(Py(s))).toString()}e.checksum=r})(Dy||(Dy={}));var c2;(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})(c2||(c2={}));var Cs={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},u2;(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,runMode:"Once",actions:new mt}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new mt}}e.defaultData=i})(u2||(u2={}));var Pm;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Pm||(Pm={}));var Oy;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Pm.propertyDefaultData(s),rOperand:{...Pm.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})(Oy||(Oy={}));var d2;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new mt,outActions:new mt,condition:Oy.distanceDefaultData(r)}}e.defaultData=i})(d2||(d2={}));var p2;(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 mt,drop:new mt}})(p2||(p2={}));var Iy;(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 mt})(Iy||(Iy={}));var Ry;(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})(Ry||(Ry={}));var f2;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new mt}}e.defaultData=i})(f2||(f2={}));var m2;(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 mt}}e.defaultData=i})(m2||(m2={}));var g2;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new mt}}e.defaultData=i})(g2||(g2={}));var v2;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new mt}}e.defaultData=i})(v2||(v2={}));var y2;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new mt,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(y2||(y2={}));var By;(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 mt},o={size:"tablet",operator:"<",actions:new mt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new mt},h=new mt;return h.push({id:st.generateUUID(),fi:0,data:n},{id:st.generateUUID(),fi:1,data:o},{id:st.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 mt}}e.defaultBreakpointData=a})(By||(By={}));var Ly;(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 mt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(Ly||(Ly={}));var Qc="personal camera",od="a218fcc3-276b-49b9-b485-49037fd14f5f",wH=2960946,qs=5526619,No;(e=>{function t(d,p){return d[0]===p[0]&&d[1]===p[1]}e.isEqual=t;function i(d,p,f){return[d[0]+(p[0]-d[0])*f,d[1]+(p[1]-d[1])*f]}e.lerp=i;function r(d,p){return[d[0]+p[0],d[1]+p[1]]}e.add=r;function s(d,p){return[d[0]-p[0],d[1]-p[1]]}e.sub=s;function a(d,p){return Math.pow(p[0]-d[0],2)+Math.pow(p[1]-d[1],2)}e.distanceSquared=a;function n(d,p){return Math.sqrt(a(d,p))}e.distance=n;function o(d,p){return d[0]*p[0]+d[1]*p[1]}e.dot=o;function l(d,p){return[d[0]*p,d[1]*p]}e.scalarMultiply=l;function h(d,p,f){let m=e.sub(p,d),v=e.sub(f,d),y=e.dot(m,v)/e.dot(m,m),x=e.scalarMultiply(m,y);return e.add(d,x)}e.projectionOnto=h;function u(d,p,f){return n(d,h(d,p,f))}e.projectionOntoDistance=u;function c(d,p){return[(d[0]+p[0])*.5,(d[1]+p[1])*.5]}e.center=c})(No||(No={}));var Nl;(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,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]}e.lerp=o})(Nl||(Nl={}));var Dm;(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})(Dm||(Dm={}));var Tc;(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})(Tc||(Tc={}));var vs;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.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(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function a(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=a;function n(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=n;function o(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}}e.lerp=o})(vs||(vs={}));var vi;(e=>{e.white={...vs.white,a:1},e.transparent={...vs.white,a:0};function t(o){return{r:o[0],g:o[1],b:o[2],a:o[3]}}e.from0to1=t;function i(o,l){return{...vs.fromHex(o),a:l}}e.fromHexAndA=i;function r(o){return{r:Math.round(o.r*255),g:Math.round(o.g*255),b:Math.round(o.b*255),a:o.a}}e.toRgb255a1=r;function s(o,l){return vs.equals(o,l)&&o.a===l.a}e.equals=s;function a(o,l,h){return{r:o.r+(l.r-o.r)*h,g:o.g+(l.g-o.g)*h,b:o.b+(l.b-o.b)*h,a:o.a+(l.a-o.a)*h}}e.lerp=a;function n({r:o,g:l,b:h,a:u}=e.white){return`rgba(${o*255}, ${l*255}, ${h*255}, ${u})`}e.toStyle=n})(vi||(vi={}));var zy;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zy||(zy={}));var x2;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(x2||(x2={}));var b2;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(b2||(b2={}));var Oo;(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]))(Oo||(Oo={}));function w2(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 Xl;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Xl||(Xl={}));var Pc;(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:i.orthographic.zoom}e.getZoom=t})(Pc||(Pc={}));var Fo;(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(zT.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;kT.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;NT.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;FT.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;UT.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;VT.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(Fo||(Fo={}));var ky;(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})(ky||(ky={}));var zT=["count"],kT=["radius","start","end","position","scale","rotation"],NT=["position","scale","rotation"],FT=["count","size"],UT=["count","position","scale","rotation"],VT=["strength","scale","rotation","position","movement","seed","freqScale"],Ny;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Ny||(Ny={}));var Fy;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:vi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:vi.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:vi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Fy||(Fy={}));var Om;(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",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...e.defaultCollisionData}))(Om||(Om={}));var Dc;(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]})(Dc||(Dc={}));var Uy;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Uy||(Uy={}));var Vy;(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})(Vy||(Vy={}));var jy;(e=>e.defaultData={...Vy.defaultData,...Uy.defaultData})(jy||(jy={}));var _2;(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})(_2||(_2={}));var Im;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Im||(Im={}));var S2;(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})(S2||(S2={}));function _H(e){return e.type!=="displace"}var A2;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(A2||(A2={}));var jT=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],SH=["wrapping","image","video","name"],Tr;(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]},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Im.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...n,type:"color",color:vs.fromHex(qs)};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:{...vs.fromHex(6710886),a:1},colorB:{...vs.fromHex(6710886),a:1},colorC:{...vs.fromHex(16777215),a:1},colorD:{...vs.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:vi.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:vi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:vi.fromHexAndA(0,1),contourColor:vi.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]}};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:{...vs.fromHex(0),a:1},colorB:{...vs.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}}}})(Tr||(Tr={}));var ss;(e=>{function t(u){return!u.layers.some(c=>c.data.type==="texture"&&c.data.projection!==0||c.data.type==="depth"&&!c.data.isWorldSpace||c.data.type==="noise"||c.data.type==="displace")}e.isMergable=t;function i(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{c+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>c+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${f}`})}),c}e.getHash=i;function r(){return{layers:new mt}}e.defaultEmptyData=r;function s(u="layer1",c="layer2"){return n("phong",u,c)}e.defaultData=s;function a(u,c){return{...u,name:c}}e.withName=a;function n(u,c="layer1",d="layer2"){let p=new mt;return p.push({fi:0,data:Tr.defaultData("light",u),id:c}),p.push({fi:1,data:Tr.defaultData("color"),id:d}),{layers:p}}e.defaultTwoLayerData=n;function o(u){let c=Tr.defaultData("texture");u&&Object.assign(c.texture,{image:u});let d=new mt;return d.push({fi:0,data:c,id:"layer1"}),d.push({fi:1,data:{...Tr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Tr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}e.defaultUIObjectMaterial=o;function l(u,c="phong",d="layer1",p="layer2"){let f=Tr.defaultData("texture");Object.assign(f.texture,{image:u});let m=new mt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Tr.defaultData("light",c),id:p}),{layers:m}}e.defaultTwoLayerTextureData=l;function h(u,c="phong",d="layer1",p="layer2"){let f=Tr.defaultData("video");Object.assign(f.texture,{video:u});let m=new mt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Tr.defaultData("light",c),id:p}),{layers:m}}e.defaultTwoLayerVideoTextureData=h})(ss||(ss={}));var Rm;(e=>{function t(){return{points:new mt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Rm||(Rm={}));var Bm;(e=>{function t(){return{points:new mt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Bm||(Bm={}));var GT={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Gy;(e=>{function t(i,r){let s={...i};return WT.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(Gy||(Gy={}));var HT={shape:GT,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},WT=["depth","offset","angle","twist","startScale","endScale"],Lm;(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"}e.isParametricMesh=i})(Lm||(Lm={}));var Hy;(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,Gy.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Hy||(Hy={}));var hc;(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:Bm.defaultData(),extrusion:HT};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Rm.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};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})(hc||(hc={}));var M2=["width","height","depth"],Wy;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:vs.white,near:.1,far:2e3})(Wy||(Wy={}));var zm;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(zm||(zm={}));var qy;(e=>e.defaultData={softShadowQuality:"low"})(qy||(qy={}));var Xy;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Xy||(Xy={}));var Yy;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Yy||(Yy={}));var Oc;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Oc||(Oc={}));var Qy;(e=>e.defaultData={playCamera:Qc,gameControlObject:null})(Qy||(Qy={}));var Zy;(e=>e.defaultData={backgroundColor:vi.fromHexAndA(wH,1),postprocessing:zm.defaultData,fog:Wy.defaultData,globalPhysics:Oc.defaultData,ambient:Xy.defaultData,ao:Yy.defaultData,shadow:qy.defaultData,publish:Qy.defaultData})(Zy||(Zy={}));var Ky;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Ky||(Ky={}));var E2;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(E2||(E2={}));var Ic;(e=>{e.identity={...zy.identity,hiddenMatrix:Tc.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 oT({position:Nl.isEqual(s.position,a.position)?void 0:a.position,rotation:Nl.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:Nl.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:Tc.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(Ic||(Ic={}));var Xr;(e=>e.defaultData={states:new mt,events:new mt,visible:!0,raycastLock:!1,physics:Dc.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ic.identity,cloner:null})(Xr||(Xr={}));var Jy;(e=>e.defaultData={type:"Empty",...Xr.defaultData})(Jy||(Jy={}));var C2;(e=>e.defaultData={type:"ParticleCollider",...Ky.defaultData,...Xr.defaultData})(C2||(C2={}));var T2;(e=>e.defaultData={type:"Component",...Xr.defaultData})(T2||(T2={}));var P2;(e=>e.defaultData={type:"Particle",...Xr.defaultData,...Om.defaultData})(P2||(P2={}));var cc;(e=>e.defaultData={type:"Mesh",...Xr.defaultData,...jy.defaultData})(cc||(cc={}));var Cd;(e=>e.defaultData={...Xr.defaultData,...Ic.identity,position:[0,0,Pc.DefaultTargetOffset],...Pc.defaultData})(Cd||(Cd={}));var $y;(e=>{function t(i){return{...Xr.defaultData,...Fy.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($y||($y={}));var km;(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})(km||(km={}));var Uo;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Xr.defaultData,...s,component:r,overrides:new cr,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Ic.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Uo||(Uo={}));var Rc;(e=>{e.defaultData={type:"Page",...Xr.defaultData,physics:{...Dc.defaultData,fusedBody:!1},...Zy.defaultData,camera:Cd.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(Rc||(Rc={}));var e1;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Tc.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Dc.defaultData,states:new mt,events:new mt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pc.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",...Xr.defaultData,...cc.defaultData,geometry:hc.defaultData("RectangleGeometry"),material:ss.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Xr.defaultData,...cc.defaultData,geometry:hc.defaultData("BooleanGeometry"),material:ss.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Xr.defaultData,...cc.defaultData,geometry:hc.defaultData("TextGeometry"),material:ss.defaultTwoLayerData("phong","layer1","layer2")}))(e1||(e1={}));var Cl;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new cr}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new cr})))):Xl.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=Ed(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(n.material.layers)){let c=l.layers.data(h);c&&Tr.patch(c,u)}}).data),o.materials&&n.materials&&(o.materials=Ed(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=n.materials[h];if(typeof u!="string")for(let[c,d]of Object.entries(u.layers)){let p=l[h]?.layers?.data(c);p&&Tr.patch(p,d)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function u(c,d){for(let[p,f]of Object.entries(d.layers)){let{texture:m,...v}=f;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(y)}if(Object.keys(v).length>0){let y={path:[...c,"layers",p],props:v,type:0};l.push(y)}}}for(let[c,d]of Object.entries(n))if(c!=="name")if(c==="cloner")l.push(...ky.toOps(d,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:d.slide,offset:d.offset},type:0});else if(c==="material")u(["material"],d);else if(c==="materials")for(let[p,f]of Object.entries(d))u(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&d.extrusion!==void 0){let p={path:[c,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[c],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=d;return l}e.toOps=r;function s(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,Ic.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})}),Xl.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:Hy.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Fo.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Fo.merge(o.cloner,n.cloner)});else if(Ny.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=vs.clone(l.color))}return o}e.patch=s})(Cl||(Cl={}));var Nm;(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})(Nm||(Nm={}));var Vo;(e=>e.defaultData={orbitControls:Nm.defaultData,playPage:od,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},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Vo||(Vo={}));var t1;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(t1||(t1={}));var i1;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(i1||(i1={}));var Tl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...t1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:i1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Tl||(Tl={}));var Td;(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=jm.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Td||(Td={}));var Pl;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let a=[],n=e1.defaultMeshObject;s.withLight===!0&&a.push({fi:-1,data:$y.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&a.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]});let o=new qr;return o.push({fi:1,id:od,data:{...Rc.defaultData,name:"Scene 1"},children:a}),o}e.defaultData={objects:t(),publish:Vo.defaultData,styles:Tl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new qr,publish:Vo.defaultData,styles:Tl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Vo.defaultData,styles:Tl.defaultData()}},e.emptyData=function(){return{objects:new qr,publish:{...Vo.defaultData},styles:Tl.defaultData()}};function i(s){return{...e.defaultData,objects:bn(s,qr.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(Pl||(Pl={}));var ld;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ld||(ld={}));var Fm;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Fm||(Fm={}));var Ws;(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})(Ws||(Ws={}));var r1;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(r1||(r1={}));var D2;(e=>e.all=[...r1.all,"components"])(D2||(D2={}));var O2;(e=>{function t(){return{images:new Tt,videos:new Tt,colors:new Tt,audios:new Tt,particles:new Tt,fonts:new Tt,materials:new Tt,components:new Tt,variables:new Tt}}e.defaultData=t})(O2||(O2={}));var Yl;(e=>{function t(){return{images:new Tt,videos:new Tt,colors:new Tt,audios:new Tt,particles:new Tt,fonts:new Tt,materials:new Tt,components:new Tt,variables:new Tt}}e.defaultData=t})(Yl||(Yl={}));var la;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},bn(n,Tt.prototype)}e.defaultColors=t;function i(n){let o={};return n?.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Fm.emptyImage,name:"AI generated image"}),bn(o,Tt.prototype)}e.defaultImages=i;function r(){return{catelogs:new Tt,materials:new Tt,images:new Tt,videos:new Tt,colors:new Tt,audios:new Tt,particles:new Tt,fonts:new Tt,variables:new mt,lib:Yl.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),u=Math.round(n-l*3600-h*60);return{textValue:[l,h,u]}}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})(la||(la={}));var Um;(e=>e.list=["idle","move","jump","run"])(Um||(Um={}));var Vm;(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 mt,move:new mt,jump:new mt,run:new mt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:vi.fromHexAndA(3728051,1)}}))(Vm||(Vm={}));function I2(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={...ao(Ji(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={...Ji(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Io(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Ro(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=ss.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ss.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ss.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==cr.prototype&&t(s.material)})})}function AH(e){Object.assign(e.scene.publish,{orbitControls:{...Nm.defaultData,...Ji(e.scene.publish.orbitControls)}})}function MH(e){Object.assign(e.scene.publish.settings,{video:{...Vo.defaultData.settings.video,...Ji(e.scene.publish.settings.video)}})}function EH(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((jT.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(SH.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 CH(e){e.scene.publish.withBackground=!0}function TH(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function PH(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 DH(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 OH(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Ji(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Ji(i).booleanExclude!==!0)}})}function IH(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 RH(e){function t(r){Object.setPrototypeOf(r,cr.prototype),r.texture&&Object.setPrototypeOf(r.texture,cr.prototype)}function i(r){Object.setPrototypeOf(r,cr.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=Ji(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=Ji(l).layers;i(h),l.layers=h}})})}function R2(e){e.layers===void 0&&Object.assign(e,ss.defaultTwoLayerData("lambert"))}function jv(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={...Ji(t),colors:i,steps:r};Object.assign(t,s)}})}function BH(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function B2(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&jv(r)}):"material"in i&&typeof i.material!="string"&&jv(i.material)}),Object.values(e.shared.materials).forEach(t=>jv(t))}function LH(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 zH(e){e.shared.audios=bn({},Tt.prototype)}function kH(e){e.shared.videos=bn({},Tt.prototype)}function NH(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 FH(e){Object.entries(Ji(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Ji(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function UH(e){e.scene.publish.settings.web.preload=!1}function L2(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 z2(e){e.layers&&e.layers.forEach(t=>{_H(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 VH(e){e.shared.fonts=bn({},Tt.prototype)}function jH(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 GH(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=ss.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=jH(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Xr.defaultData,...cc.defaultData,flatShading:!1,wireframe:!1,geometry:{...hc.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:Ji(s.states),events:Ji(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Ji(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 HH(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 mt,move:new mt,jump:new mt}});else{let a=new mt;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:st.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},u={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(u,ao(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(u,{control1:{...n.control1},control2:{...n.control2}});let c={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,...c,...u},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new mt({fi:0,id:st.generateUUID(),data:h},{fi:1,id:st.generateUUID(),data:d})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function WH(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new mt,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===a){let c;o.push(h),l.interaction==="play"?c={...ao(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...ao(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&n.push({fi:u,id:h,data:c})}}),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:st.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function k2(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Tr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function N2(e){Io(e,k2),Ro(e,k2)}function qH(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function XH(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 YH(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=ss.defaultTwoLayerData("phong"))})}function QH(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 ZH(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 KH(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 JH(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function $H(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function e9(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function t9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Vm.defaultDataThirdPerson.navmesh)})})}function i9(e){e.scene.styles||(e.scene.styles=Tl.defaultData())}function F2(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function r9(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}),Ro(e,F2),Io(e,F2)}function s9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new mt})})})}function a9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function U2(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function n9(e,t){if(t<1&&(Ro(e,I2),Io(e,I2),e.schema=1),t<2&&(AH(e),e.schema=2),t<3&&(EH(e),e.schema=3),t<4&&(CH(e),e.schema=4),t<5&&(TH(e),e.schema=5),t<6&&(PH(e),e.schema=6),t<7&&(DH(e),e.schema=7),t<8&&(e.schema=8),t<9&&(B2(e),e.schema=9),t<10&&(BH(e),e.schema=10),t<11&&(LH(e),e.schema=11),t<12&&(B2(e),e.schema=12),t<13&&(zH(e),e.schema=13),t<14&&(NH(e),e.schema=14),t<15&&(FH(e),e.schema=15),t<16&&(UH(e),e.schema=16),t<17&&(Ro(e,L2),Io(e,L2),e.schema=17),t<18&&(Ro(e,R2),Io(e,R2),e.schema=18),t<19&&(MH(e),e.schema=19),t<20&&(VH(e),GH(e),e.schema=20),t<21&&(HH(e),WH(e),e.schema=21),t<22&&(N2(e),e.schema=22),t<23&&(qH(e),e.schema=23),t<24&&(XH(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(kH(e),t<25&&(e.schema=25)),t<26&&(OH(e),e.schema=26),t<27&&(IH(e),e.schema=27),t<28&&(N2(e),e.schema=28),t<29&&(RH(e),e.schema=29),t<30&&(YH(e),e.schema=30),t<31&&(QH(e),e.schema=31),t<33&&(ZH(e),e.schema=33),t<34&&(KH(e),e.schema=34),t<35&&(JH(e),e.schema=35),t<36&&($H(e),e.schema=36),t<37&&(e9(e),e.schema=37),t<38&&(Ro(e,z2),Io(e,z2),e.schema=38),t<39&&(t9(e),e.schema=39),t<40&&(i9(e),e.schema=40),t<41&&(r9(e),e.schema=41),t<42&&(s9(e),e.schema=42),t<43&&(a9(e),e.schema=43),t<99){Ro(e,U2),Io(e,U2),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Qc);let i=Ji(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=od,r.insertBefore(null,null,[{id:od,data:{...Rc.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:ao(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:ao(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Oc.defaultData,...ao(e.scene.environment,"usePhysics","gravity")},camera:Ji(e.scene.ownerCamera)??Rc.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Pl.TRASH_CAN_ID&&r.move(od,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,Dc.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function V2(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function o9(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 l9(e){Array.isArray(Ji(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 Qh=180/Math.PI;function j2(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Qh)}function qT(e){j2(e),e.type==="Page"&&j2(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Qh))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Qh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Qh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Qh,t.extrusion.twist*=Qh),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(Ji(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 h9(e){e.shared.variables=bn({},Tt.prototype)}function c9(e){let t=Ji(e.shared.variables);e.shared.variables=bn(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),mt.prototype)}var Yn=111;function XT(e,t){t(e.data);for(let i of e.children)XT(i,t)}function u9(e){let t=e.schema??104;t!==Yn&&t<105&&(XT(e.asset,qT),e.schema=105)}function d9(e){e.shared.particles=bn({},Tt.prototype),e.shared.lib&&(e.shared.lib.particles=Yl.defaultData().particles)}function p9(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 YT(e){let t=e.schema??0;if(t!==Yn){console.warn("updating from ",t,"to ",Yn),n9(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Vo.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Ro(e,V2),Io(e,V2),e.schema=101),t<102&&(o9(e),e.schema=102),t<104&&(e.shared.catelogs=new Tt,e.shared.lib=Yl.defaultData(),e.schema=104),t<105&&(h9(e),e.scene.objects.traverse((i,r)=>{qT(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))u9(i);t<106&&(c9(e),e.schema=106),t<107&&(e.shared.lib.variables=Yl.defaultData().variables,e.schema=107),t<109&&(d9(e),e.schema=109),t<110&&(p9(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{l9(r)}),e.schema=111)}}var jm;(e=>{e.defaultData={schema:Yn,scene:Pl.defaultData,frames:new Tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ld.defaultData),shared:{...la.emptyData(),colors:la.defaultColors()}},e.emptyDataForImports=function(s){let a=Pl.emptyDataWithPage(s);return{schema:Yn,scene:a,frames:new Tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ld.defaultData),shared:{...la.emptyData(),colors:la.defaultColors(),images:la.defaultImages(s)}}},e.emptyData=function(){return{schema:Yn,scene:Pl.emptyDataWithPage(),frames:new Tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ld.defaultData),shared:la.emptyData()}},e.clipboard2dData=function(){return{schema:Yn,scene:Pl.emptyData(),frames:new Tt,shared:la.emptyData()}},e.collabHelper={...Sy,updateSchema(s){return(s.schema??0)<Yn?Ed(s,YT):(s.schema??0)-Yn}};function t(s){let a=e.collabHelper.updateSchema(s);return typeof a=="number"?a===0?s:null:a.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:Yl.defaultData()}}}e.withoutLib=i;function r(s,a){let n=s.scene.objects.get(a);if(n&&n.data.type==="Component")return n;{let o=s.shared.lib.components[a];if(o)return o.asset}}e.getComponentData=r})(jm||(jm={}));var G2;(e=>{function t(i){return!0}e.is=t})(G2||(G2={}));var Gm;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0};function t(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale}}e.merge=t;function i(r,s){return oT({position:No.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:No.isEqual(r.scale,s.scale)?void 0:s.scale})}e.diff=i})(Gm||(Gm={}));var s1;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(s1||(s1={}));var Hm;(e=>e.defaultData={opacity:1,fill:{color:vi.white,enabled:!0},stroke:{color:vi.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:vi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:vi.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Hm||(Hm={}));var Dl;(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 u of h)u in l&&u in o&&o[u]!==void 0&&Object.assign(l,{[u]:o[u]});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,Gm.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=s;function a(n,o){let l,h=[];for(let[u,c]of Object.entries(o))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[u]=c);return h}e.toOps=a})(Dl||(Dl={}));var Pd;(e=>e.defaultData={...Gm.defaultData,...s1.defaultData,states:new mt,events:new mt,visible:!0,raycastLock:!1})(Pd||(Pd={}));var Dd;(e=>e.defaultData={...Pd.defaultData,...Hm.defaultData})(Dd||(Dd={}));var Wm;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Wm||(Wm={}));var a1;(e=>e.defaultData={...Dd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(a1||(a1={}));var Od;(e=>e.defaultData={...Dd.defaultData,...Wm.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Od||(Od={}));var n1;(e=>e.defaultData={...Dd.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"})(n1||(n1={}));var H2;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"}e.is=t})(H2||(H2={}));var qm;(e=>e.defaultData={...Pd.defaultData,name:"Group",type:"group2d"})(qm||(qm={}));var o1;(e=>e.defaultData={...Pd.defaultData,...Wm.defaultData,...Hm.defaultData,name:"Frame",type:"frame2d",width:200,height:200,fill:{color:vi.fromHexAndA(qs,1),enabled:!0},stroke:{color:vi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(o1||(o1={}));var Fl;(e=>{function t(a){switch(a){case"rectangle2d":return{...Od.defaultData};case"ellipse2d":return{...a1.defaultData};case"text2d":return{...n1.defaultData};case"vector2d":return{...Od.defaultData};case"frame2d":return{...o1.defaultData};case"group2d":return{...qm.defaultData}}}e.defaultData=t;function i(a){return"width"in a&&"height"in a?[typeof a.width=="number"?a.width*.5:0,typeof a.height=="number"?a.height*.5:0]:[0,0]}e.getPivot=i;function r(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}e.isResizeable=r;function s(a){return a.type==="rectangle2d"||a.type==="frame2d"}e.hasCorners=s})(Fl||(Fl={}));var l1;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new qr},e.emptyData=function(){return{type:"scene2d",objects:new qr}}))(l1||(l1={}));function Ol(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 ut,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(i){let u=0,c=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+u);u+=e[d].attributes.position.count}l.setIndex(c)}for(let u in a){let c=W2(a[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(let u in n){let c=n[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){let p=[];for(let m=0;m<n[u].length;++m)p.push(n[u][m][d]);let f=W2(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}return l}function W2(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 At(a,i,r)}var f9=Math.pow(2,-24),sf=class{constructor(){}};function dn(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 q2(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 X2(e,t){t.set(e)}function Y2(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 af(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 Tu(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 m9(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 At(s,1));for(let a=0;a<i;a++)s[a]=a}}function g9(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 Gv(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,v=-1/0,y=s!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],S=e[x+1],M=_-S,C=_+S;M<a&&(a=M),C>l&&(l=C),y&&_<c&&(c=_),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>m&&(m=A);let z=e[x+4],N=e[x+5],B=z-N,V=z+N;B<o&&(o=B),V>u&&(u=V),y&&z<p&&(p=z),y&&z>v&&(v=z)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=u,y&&(s[0]=c,s[1]=d,s[2]=p,s[3]=f,s[4]=m,s[5]=v)}function v9(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 u=t*6,c=(t+i)*6;u<c;u+=6){let d=e[u+0];d<s&&(s=d),d>o&&(o=d);let p=e[u+2];p<a&&(a=p),p>l&&(l=p);let f=e[u+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 y9(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 u=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=u;let c=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=c;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 Gn=32,x9=(e,t)=>e.candidate-t.candidate,wo=new Array(Gn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),nf=new Float32Array(6);function b9(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=q2(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=q2(e),n!==-1&&(o=w9(i,r,s,n));else if(a===2){let l=Tu(e),h=1.25*s,u=r*6,c=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/Gn;if(s<Gn/4){let m=[...wo];m.length=s;let v=0;for(let x=u;x<c;x+=6,v++){let b=m[v];b.candidate=i[x+2*d],b.count=0;let{bounds:_,leftCacheBounds:S,rightCacheBounds:M}=b;for(let C=0;C<3;C++)M[C]=1/0,M[C+3]=-1/0,S[C]=1/0,S[C+3]=-1/0,_[C]=1/0,_[C+3]=-1/0;af(x,i,_)}m.sort(x9);let y=s;for(let x=0;x<y;x++){let b=m[x];for(;x+1<y&&m[x+1].candidate===b.candidate;)m.splice(x+1,1),y--}for(let x=u;x<c;x+=6){let b=i[x+2*d];for(let _=0;_<y;_++){let S=m[_];b>=S.candidate?af(x,i,S.rightCacheBounds):(af(x,i,S.leftCacheBounds),S.count++)}}for(let x=0;x<y;x++){let b=m[x],_=b.count,S=s-b.count,M=b.leftCacheBounds,C=b.rightCacheBounds,A=0;_!==0&&(A=Tu(M)/l);let T=0;S!==0&&(T=Tu(C)/l);let P=1+1.25*(A*_+T*S);P<h&&(n=d,h=P,o=b.candidate)}}else{for(let y=0;y<Gn;y++){let x=wo[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=u;y<c;y+=6){let x=~~((i[y+2*d]-p)/f);x>=Gn&&(x=Gn-1);let b=wo[x];b.count++,af(y,i,b.bounds)}let m=wo[Gn-1];X2(m.bounds,m.rightCacheBounds);for(let y=Gn-2;y>=0;y--){let x=wo[y],b=wo[y+1];Y2(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let v=0;for(let y=0;y<Gn-1;y++){let x=wo[y],b=x.count,_=x.bounds,S=wo[y+1].rightCacheBounds;b!==0&&(v===0?X2(_,nf):Y2(_,nf,nf)),v+=b;let M=0,C=0;v!==0&&(M=Tu(nf)/l);let A=s-v;A!==0&&(C=Tu(S)/l);let T=1+1.25*(M*v+C*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 w9(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 _9(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 u=["getX","getY","getZ"];for(let c=0;c<s;c++){let d=c*3,p=c*6,f,m,v;n?(f=r[d+0],m=r[d+1],v=r[d+2]):(f=r[d+0]*h+l,m=r[d+1]*h+l,v=r[d+2]*h+l);for(let y=0;y<3;y++){let x,b,_;n?(x=i[u[y]](f),b=i[u[y]](m),_=i[u[y]](v)):(x=o[f+y],b=o[m+y],_=o[v+y]);let S=x;b<S&&(S=b),_<S&&(S=_);let M=x;b>M&&(M=b),_>M&&(M=_);let C=(M-S)/2,A=y*2;a[p+A+0]=S+C,a[p+A+1]=C+(Math.abs(S)+C)*f9,S<t[y]&&(t[y]=S),M>t[y+3]&&(t[y+3]=M)}}return a}function S9(e,t){function i(y){d&&d(y/p)}function r(y,x,b,_=null,S=0){if(!f&&S>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=u||S>=l)return i(x+b),y.offset=x,y.count=b,y;let M=b9(y.boundingData,_,n,x,b,c);if(M.axis===-1)return i(x+b),y.offset=x,y.count=b,y;let C=y9(o,n,x,b,M);if(C===x||C===x+b)i(x+b),y.offset=x,y.count=b;else{y.splitAxis=M.axis;let A=new sf,T=x,P=C-x;y.left=A,A.boundingData=new Float32Array(6),Gv(n,T,P,A.boundingData,a),r(A,T,P,a,S+1);let R=new sf,z=C,N=b-P;y.right=R,R.boundingData=new Float32Array(6),Gv(n,z,N,R.boundingData,a),r(R,z,N,a,S+1)}return y}m9(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=_9(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],v=g9(e);if(v.length===1){let y=v[0],x=new sf;x.boundingData=s,v9(n,y.offset,y.count,a),r(x,y.offset,y.count,a),m.push(x)}else for(let y of v){let x=new sf;x.boundingData=new Float32Array(6),Gv(n,y.offset,y.count,x.boundingData,a),r(x,y.offset,y.count,a),m.push(x)}return m}function A9(e,t){let i=S9(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){let c=i[u],d=l(c),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,c),n.push(p)}return n;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function h(u,c){let d=u/4,p=u/2,f=!!c.count,m=c.boundingData;for(let v=0;v<6;v++)r[d+v]=m[v];if(f){let v=c.offset,y=c.count;return s[d+6]=v,a[p+14]=y,a[p+15]=65535,u+32}else{let v=c.left,y=c.right,x=c.splitAxis,b;if(b=h(u+32,v),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 wn=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}};wn.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 u=t.dot(e);a=Math.min(u,a),n=Math.max(u,n)}this.min=a,this.max=n}}();var Hee=function(){let e=new wn;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 u=a[h],c=s[h];if(e.setFromPoints(c,n),u.isSeparated(e))return!1}for(let h=0;h<3;h++){let u=l[h],c=o[h];if(e.setFromPoints(c,r),u.isSeparated(e))return!1}}}(),M9=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 u=i.dot(h),c=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-c*c,m,v;f!==0?m=(u*c-p*d)/f:m=0,v=(u+m*c)/d,a.x=m,a.y=v}}(),Yx=function(){let e=new $,t=new I,i=new I;return function(r,s,a,n){M9(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 u;l<0?u=s.start:u=s.end;let c=t,d=i;if(r.closestPointToPoint(u,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(u)<=d.distanceToSquared(h)){a.copy(c),n.copy(u);return}else{a.copy(h),n.copy(d);return}}}}(),E9=function(){let e=new I,t=new I,i=new Gs,r=new da;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c:u}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let c=a.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=n){let d=c.projectPoint(o,t);if(a.containsPoint(d))return!0}return!1}}(),C9=1e-15;function Th(e){return Math.abs(e)<C9}var ho=class extends Hr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new wn),this.points=[this.a,this.b,this.c],this.sphere=new zs,this.plane=new Gs,this.needsUpdate=!0}intersectsSphere(e){return E9(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 u=s[2],c=a[2];u.subVectors(t,i),c.setFromPoints(u,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}};ho.prototype.closestPointToSegment=function(){let e=new I,t=new I,i=new da;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,u=1/0;for(let c=0;c<3;c++){let d=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[d]),Yx(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(u)}}();ho.prototype.intersectsTriangle=function(){let e=new ho,t=new Array(3),i=new Array(3),r=new wn,s=new wn,a=new I,n=new I,o=new I,l=new I,h=new da,u=new da,c=new da;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 m=this.plane,v=d.plane;if(Math.abs(m.normal.dot(v.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 S=0;S<4;S++){let M=y[S],C=x[S];if(r.setFromPoints(C,i),M.isSeparated(r))return!1}let b=d.satBounds,_=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){let M=b[S],C=_[S];if(r.setFromPoints(C,t),M.isSeparated(r))return!1}for(let S=0;S<4;S++){let M=x[S];for(let C=0;C<4;C++){let A=_[C];if(a.crossVectors(M,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 N=0;N<3;N++){let B=y[N],V=y[(N+1)%3];h.start.copy(B),h.end.copy(V),h.delta(n);let H=x?u.start:u.end,X=Th(v.distanceToPoint(B));if(Th(v.normal.dot(n))&&X){u.copy(h),b=2;break}if((v.intersectLine(h,H)||X)&&!Th(H.distanceTo(V))){if(b++,x)break;x=!0}}if(b===1&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(b!==2)return!1;let _=d.points,S=!1,M=0;for(let N=0;N<3;N++){let B=_[N],V=_[(N+1)%3];h.start.copy(B),h.end.copy(V),h.delta(o);let H=S?c.start:c.end,X=Th(m.distanceToPoint(B));if(Th(m.normal.dot(o))&&X){c.copy(h),M=2;break}if((m.intersectLine(h,H)||X)&&!Th(H.distanceTo(V))){if(M++,S)break;S=!0}}if(M===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(M!==2)return!1;if(u.delta(n),c.delta(o),n.dot(o)<0){let N=c.start;c.start=c.end,c.end=N}let C=u.start.dot(n),A=u.end.dot(n),T=c.start.dot(n),P=c.end.dot(n),R=A<T,z=C<P;return C!==P&&T!==A&&R===z?!1:(p&&(l.subVectors(u.start,c.start),l.dot(n)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(n)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();ho.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ho.prototype.distanceToTriangle=function(){let e=new I,t=new I,i=["a","b","c"],r=new da,s=new da;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 u=0;u<3;u++){let c,d=i[u],p=a[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,n&&n.copy(e),o&&o.copy(p));let f=this[d];a.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,n&&n.copy(f),o&&o.copy(e))}for(let u=0;u<3;u++){let c=i[u],d=i[(u+1)%3];r.set(this[c],this[d]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];s.set(a[f],a[m]),Yx(r,s,e,t);let v=e.distanceToSquared(t);v<h&&(h=v,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var _n=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new Le,this.invMatrix=new Le,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 wn),this.alignedSatBounds=new Array(3).fill().map(()=>new wn),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}};_n.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){let c=1*l|2*h|4*u,d=r[c];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],u=s[l],c=1<<l,d=r[c];h.subVectors(n,d),u.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();_n.prototype.intersectsBox=function(){let e=new wn;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}}();_n.prototype.intersectsTriangle=function(){let e=new ho,t=new Array(3),i=new wn,r=new wn,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 c=0;c<3;c++){let d=n[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,u=this.points;for(let c=0;c<3;c++){let d=l[c],p=h[c];if(i.setFromPoints(p,u),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}();_n.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}}();_n.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();_n.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new da),i=new Array(12).fill().map(()=>new da),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,u=a.min,c=a.max,d=this.points,p=1/0;for(let m=0;m<8;m++){let v=d[m];s.copy(v).clamp(u,c);let y=v.distanceToSquared(s);if(y<p&&(p=y,o&&o.copy(v),l&&l.copy(s),y<h))return Math.sqrt(y)}let f=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){let x=(m+1)%3,b=(m+2)%3,_=v<<x|y<<b,S=1<<m|v<<x|y<<b,M=d[_],C=d[S];t[f].set(M,C);let A=e[m],T=e[x],P=e[b],R=i[f],z=R.start,N=R.end;z[A]=u[A],z[T]=v?u[T]:c[T],z[P]=y?u[P]:c[T],N[A]=c[A],N[T]=v?u[T]:c[T],N[P]=y?u[P]:c[T],f++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?c.x:u.x,s.y=v?c.y:u.y,s.z=y?c.z:u.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 m=0;m<12;m++){let v=t[m];for(let y=0;y<12;y++){let x=i[y];Yx(v,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 Ph=new I,Dh=new I,Oh=new I,of=new $,lf=new $,hf=new $,Q2=new I,Z2=new I,K2=new I,cf=new I;function T9(e,t,i,r,s,a){let n;return a===Or?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Rs,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function P9(e,t,i,r,s,a,n,o,l){Ph.fromBufferAttribute(t,a),Dh.fromBufferAttribute(t,n),Oh.fromBufferAttribute(t,o);let h=T9(e,Ph,Dh,Oh,cf,l);if(h){r&&(of.fromBufferAttribute(r,a),lf.fromBufferAttribute(r,n),hf.fromBufferAttribute(r,o),h.uv=Hr.getInterpolation(cf,Ph,Dh,Oh,of,lf,hf,new $)),s&&(of.fromBufferAttribute(s,a),lf.fromBufferAttribute(s,n),hf.fromBufferAttribute(s,o),h.uv1=Hr.getInterpolation(cf,Ph,Dh,Oh,of,lf,hf,new $)),i&&(Q2.fromBufferAttribute(i,a),Z2.fromBufferAttribute(i,n),K2.fromBufferAttribute(i,o),h.normal=Hr.getInterpolation(cf,Ph,Dh,Oh,Q2,Z2,K2,new I),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:n,c:o,normal:new I,materialIndex:0};Hr.getNormal(Ph,Dh,Oh,u.normal),h.face=u,h.faceIndex=a}return h}function QT(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:u,uv:c,uv1:d}=e.attributes,p=P9(i,h,u,c,d,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function D9(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)QT(e,t,i,n,a)}function O9(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=QT(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function hn(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 J2(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(hn(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var ZT=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 Bo(e,t){return t[e+15]===65535}function uc(e,t){return t[e+6]}function Id(e,t){return t[e+14]}function Rd(e){return e+8}function Bd(e,t){return t[e+6]}function I9(e,t){return t[e+7]}var rc=new er,Xm=new I,R9=["x","y","z"];function h1(e,t,i,r,s){let a=e*2,n=Zc,o=Yo,l=Qo;if(Bo(a,o)){let h=uc(e,l),u=Id(a,o);D9(t,i,r,h,u,s)}else{let h=Rd(e);Ym(h,n,r,Xm)&&h1(h,t,i,r,s);let u=Bd(e,l);Ym(u,n,r,Xm)&&h1(u,t,i,r,s)}}function c1(e,t,i,r){let s=e*2,a=Zc,n=Yo,o=Qo;if(Bo(s,n)){let l=uc(e,o),h=Id(s,n);return O9(t,i,r,l,h)}else{let l=I9(e,o),h=R9[l],u=r.direction[h]>=0,c,d;u?(c=Rd(e),d=Bd(e,o)):(c=Bd(e,o),d=Rd(e));let p=Ym(c,a,r,Xm)?c1(c,t,i,r):null;if(p){let m=p.point[h];if(u?m<=a[d+l]:m>=a[d+l+3])return p}let f=Ym(d,a,r,Xm)?c1(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var B9=function(){let e,t,i=[],r=new ZT(()=>new er);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,u=0,c=0){function d(x){let b=x*2,_=Yo,S=Qo;for(;!Bo(b,_);)x=Rd(x),b=x*2;return uc(x,S)}function p(x){let b=x*2,_=Yo,S=Qo;for(;!Bo(b,_);)x=Bd(x,S),b=x*2;return uc(x,S)+Id(b,_)}let f=a*2,m=Zc,v=Yo,y=Qo;if(Bo(f,v)){let x=uc(a,y),b=Id(f,v);return dn(a,m,e),l(x,b,!1,c,u+a,e)}else{let x=Rd(a),b=Bd(a,y),_=x,S=b,M,C,A,T;if(h&&(A=e,T=t,dn(_,m,A),dn(S,m,T),M=h(A),C=h(T),C<M)){_=b,S=x;let H=M;M=C,C=H,A=T}A||(A=e,dn(_,m,A));let P=Bo(_*2,v),R=o(A,P,M,c+1,u+_),z;if(R===2){let H=d(_),X=p(_)-H;z=l(H,X,!0,c+1,u+_,A)}else z=R&&s(_,n,o,l,h,u,c+1);if(z)return!0;T=t,dn(S,m,T);let N=Bo(S*2,v),B=o(T,N,C,c+1,u+S),V;if(B===2){let H=d(S),X=p(S)-H;V=l(H,X,!0,c+1,u+S,T)}else V=B&&s(S,n,o,l,h,u,c+1);return!!V}}}(),L9=function(){let e=new ho,t=new ho,i=new Le,r=new _n,s=new _n;return function a(n,o,l,h,u=null){let c=n*2,d=Zc,p=Yo,f=Qo;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),Bo(c,p)){let m=o,v=m.index,y=m.attributes.position,x=l.index,b=l.attributes.position,_=uc(n,f),S=Id(c,p);if(i.copy(h).invert(),l.boundsTree)return dn(n,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:M=>s.intersectsBox(M),intersectsTriangle:M=>{M.a.applyMatrix4(h),M.b.applyMatrix4(h),M.c.applyMatrix4(h),M.needsUpdate=!0;for(let C=_*3,A=(S+_)*3;C<A;C+=3)if(hn(t,C,v,y),t.needsUpdate=!0,M.intersectsTriangle(t))return!0;return!1}});for(let M=_*3,C=S+_*3;M<C;M+=3){hn(e,M,v,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(hn(t,A,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,v=f[n+6];return dn(m,d,rc),!!(u.intersectsBox(rc)&&a(m,o,l,h,u)||(dn(v,d,rc),u.intersectsBox(rc)&&a(v,o,l,h,u)))}}}();function Ym(e,t,i,r){return dn(e,t,rc),i.intersectBox(rc,r)}var u1=[],Kf,Zc,Yo,Qo;function Qu(e){Kf&&u1.push(Kf),Kf=e,Zc=new Float32Array(e),Yo=new Uint16Array(e),Qo=new Uint32Array(e)}function uf(){Kf=null,Zc=null,Yo=null,Qo=null,u1.length&&Qu(u1.pop())}var Hv=Symbol("skip tree generation"),Wv=new er,qv=new er,Ih=new Le,ul=new _n,Pu=new _n,Du=new I,df=new I,z9=new I,k9=new I,N9=new I,$2=new er,Ya=new ZT(()=>new ho),hd=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."),hd.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."),hd.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 hd(t,{...i,[Hv]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new At(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,[Hv]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Hv]||(this._roots=A9(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new er))),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 c=0,d=h.length;c<d;c++)s=h[c],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),u(0,l),l+=s.byteLength;function u(c,d,p=!1){let f=c*2;if(n[f+15]===65535){let m=a[c+6],v=n[f+14],y=1/0,x=1/0,b=1/0,_=-1/0,S=-1/0,M=-1/0;for(let C=3*m,A=3*(m+v);C<A;C++){let T=i[C],P=r.getX(T),R=r.getY(T),z=r.getZ(T);P<y&&(y=P),P>_&&(_=P),R<x&&(x=R),R>S&&(S=R),z<b&&(b=z),z>M&&(M=z)}return o[c+0]!==y||o[c+1]!==x||o[c+2]!==b||o[c+3]!==_||o[c+4]!==S||o[c+5]!==M?(o[c+0]=y,o[c+1]=x,o[c+2]=b,o[c+3]=_,o[c+4]=S,o[c+5]=M,!0):!1}else{let m=c+8,v=a[c+6],y=m+d,x=v+d,b=p,_=!1,S=!1;e?b||(_=e.has(y),S=e.has(x),b=!_&&!S):(_=!0,S=!0);let M=b||_,C=b||S,A=!1;M&&(A=u(m,d,b));let T=!1;C&&(T=u(v,d,b));let P=A||T;if(P)for(let R=0;R<3;R++){let z=m+R,N=v+R,B=o[z],V=o[z+3],H=o[N],X=o[N+3];o[c+R]=B<H?B:H,o[c+R+3]=V>X?V:X}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 u=r[n+6],c=s[l+14];e(o,h,new Float32Array(i,n*4,6),u,c)}else{let u=n+8,c=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(a(u,o+1),a(c,o+1))}}}raycast(e,t=ka){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,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l,d=s.length;if(Qu(i[h]),h1(0,r,c,e,s),uf(),n){let p=o[h].materialIndex;for(let f=d,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=ka){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,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l;Qu(i[h]);let d=c1(0,r,c,e);uf(),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(Qu(s),r=L9(0,i,e,t),uf(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(d,p,f,m)=>{let v=p*3;return c(d,v,v+1,v+2,f,m)}}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=Ya.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,m,v)=>c(d,p,f,m,v)?!0:J2(d,p,r,l,f,m,s)}else o||(l?o=(c,d,p,f)=>J2(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(Qu(c),h=B9(0,r,n,o,a,u),uf(),h)break;u+=c.byteLength}return Ya.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;Ih.copy(t).invert();let h=Ya.getPrimitive(),u=Ya.getPrimitive();if(s){let d=function(p,f,m,v,y,x,b,_){for(let S=m,M=m+v;S<M;S++){hn(u,S*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=p,A=p+f;C<A;C++)if(hn(h,C*3,a,n),h.needsUpdate=!0,s(h,u,C,S,y,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,m,v,y,x,b,_,S){return p(f,m,v,y,x,b,_,S)?!0:d(f,m,v,y,x,b,_,S)}}else r=d}e.getBoundingBox(qv),qv.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>qv.intersectsBox(d),intersectsRange:(d,p,f,m,v,y)=>(Wv.copy(y),Wv.applyMatrix4(Ih),e.shapecast({intersectsBounds:x=>Wv.intersectsBox(x),intersectsRange:(x,b,_,S,M)=>r(d,p,x,b,m,v,S,M)}))});return Ya.releasePrimitive(h),Ya.releasePrimitive(u),c}intersectsBox(e,t){return ul.set(e.min,e.max,t),ul.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ul.intersectsBox(i),intersectsTriangle:i=>ul.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(),ul.set(e.boundingBox.min,e.boundingBox.max,t),ul.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,u=e.index,c=Ya.getPrimitive(),d=Ya.getPrimitive(),p=df,f=z9,m=null,v=null;r&&(m=k9,v=N9);let y=1/0,x=null,b=null;return Ih.copy(t).invert(),Pu.matrix.copy(Ih),this.shapecast({boundsTraverseOrder:_=>ul.distanceToBox(_),intersectsBounds:(_,S,M)=>M<y&&M<a?(S&&(Pu.min.copy(_.min),Pu.max.copy(_.max),Pu.needsUpdate=!0),!0):!1,intersectsRange:(_,S)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>Pu.distanceToBox(M),intersectsBounds:(M,C,A)=>A<y&&A<a,intersectsRange:(M,C)=>{for(let A=M*3,T=(M+C)*3;A<T;A+=3){hn(d,A,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=_*3,R=(_+S)*3;P<R;P+=3){hn(c,P,l,o),c.needsUpdate=!0;let z=c.distanceToTriangle(d,p,m);if(z<y&&(f.copy(p),v&&v.copy(m),y=z,x=P/3,b=A/3),z<s)return!0}}}});{let M=u?u.count:h.count;for(let C=0,A=M;C<A;C+=3){hn(d,C,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let T=_*3,P=(_+S)*3;T<P;T+=3){hn(c,T,l,o),c.needsUpdate=!0;let R=c.distanceToTriangle(d,p,m);if(R<y&&(f.copy(p),v&&v.copy(m),y=R,x=T/3,b=C/3),R<s)return!0}}}}}),Ya.releasePrimitive(c),Ya.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(v):r.point=v.clone(),r.point.applyMatrix4(Ih),f.applyMatrix4(Ih),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=>(Du.copy(e).clamp(h.min,h.max),Du.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<n&&c<a,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,Du);let c=e.distanceToSquared(Du);return c<n&&(df.copy(Du),n=c,o=u),c<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(df):t.point=df.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{dn(0,new Float32Array(t),$2),e.union($2)}),e}},Ou=Br(zO()),F9=.5*(Math.sqrt(3)-1),Iu=(3-Math.sqrt(3))/6,U9=1/3,Qa=1/6,Wee=(Math.sqrt(5)-1)/4,qee=(5-Math.sqrt(5))/20,cd=e=>Math.floor(e)|0,eA=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]),Xv=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 Yv(e=Math.random){let t=KT(e),i=new Float64Array(t).map(s=>eA[s%12*2]),r=new Float64Array(t).map(s=>eA[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*F9,u=cd(s+h),c=cd(a+h),d=(u+c)*Iu,p=u-d,f=c-d,m=s-p,v=a-f,y,x;m>v?(y=1,x=0):(y=0,x=1);let b=m-y+Iu,_=v-x+Iu,S=m-1+2*Iu,M=v-1+2*Iu,C=u&255,A=c&255,T=.5-m*m-v*v;if(T>=0){let z=C+t[A],N=i[z],B=r[z];T*=T,n=T*T*(N*m+B*v)}let P=.5-b*b-_*_;if(P>=0){let z=C+y+t[A+x],N=i[z],B=r[z];P*=P,o=P*P*(N*b+B*_)}let R=.5-S*S-M*M;if(R>=0){let z=C+1+t[A+1],N=i[z],B=r[z];R*=R,l=R*R*(N*S+B*M)}return 70*(n+o+l)}}function V9(e=Math.random){let t=KT(e),i=new Float64Array(t).map(a=>Xv[a%12*3]),r=new Float64Array(t).map(a=>Xv[a%12*3+1]),s=new Float64Array(t).map(a=>Xv[a%12*3+2]);return function(a,n,o){let l,h,u,c,d=(a+n+o)*U9,p=cd(a+d),f=cd(n+d),m=cd(o+d),v=(p+f+m)*Qa,y=p-v,x=f-v,b=m-v,_=a-y,S=n-x,M=o-b,C,A,T,P,R,z;_>=S?S>=M?(C=1,A=0,T=0,P=1,R=1,z=0):_>=M?(C=1,A=0,T=0,P=1,R=0,z=1):(C=0,A=0,T=1,P=1,R=0,z=1):S<M?(C=0,A=0,T=1,P=0,R=1,z=1):_<M?(C=0,A=1,T=0,P=0,R=1,z=1):(C=0,A=1,T=0,P=1,R=1,z=0);let N=_-C+Qa,B=S-A+Qa,V=M-T+Qa,H=_-P+2*Qa,X=S-R+2*Qa,G=M-z+2*Qa,se=_-1+3*Qa,ae=S-1+3*Qa,J=M-1+3*Qa,K=p&255,ne=f&255,te=m&255,oe=.6-_*_-S*S-M*M;if(oe<0)l=0;else{let ye=K+t[ne+t[te]];oe*=oe,l=oe*oe*(i[ye]*_+r[ye]*S+s[ye]*M)}let ie=.6-N*N-B*B-V*V;if(ie<0)h=0;else{let ye=K+C+t[ne+A+t[te+T]];ie*=ie,h=ie*ie*(i[ye]*N+r[ye]*B+s[ye]*V)}let be=.6-H*H-X*X-G*G;if(be<0)u=0;else{let ye=K+P+t[ne+R+t[te+z]];be*=be,u=be*be*(i[ye]*H+r[ye]*X+s[ye]*G)}let ue=.6-se*se-ae*ae-J*J;if(ue<0)c=0;else{let ye=K+1+t[ne+1+t[te+1]];ue*=ue,c=ue*ue*(i[ye]*se+r[ye]*ae+s[ye]*J)}return 32*(l+h+u+c)}}function KT(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 Sa=new Hr,j9=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;Sa.a.fromBufferAttribute(e,r),Sa.b.fromBufferAttribute(e,r+1),Sa.c.fromBufferAttribute(e,r+2),s*=Sa.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),Sa.a.fromBufferAttribute(this.positionAttribute,e*3),Sa.b.fromBufferAttribute(this.positionAttribute,e*3+1),Sa.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Sa.a,r).addScaledVector(Sa.b,s).addScaledVector(Sa.c,1-(r+s)),Sa.getNormal(i),this}},G9=Br(IE()),H9=new Le,W9=new Le,q9=new Le,Ld;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Ld||(Ld={}));var Qx=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new Le,this.copyPreviousMatrix=!0,this.hiddenMatrix=new Le,this.matrixWorldRigid=new Le,this.shearScale=new Le,this.shearScaleInv=new Le}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof ci&&(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)Ld.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Ld.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,G9.SVD)(i),n=H9.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=W9.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=q9.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 Le().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Le?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)}},X9=class extends Qx(ci){},Y9=e=>e.type==="Mesh",is=class extends X9{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 is(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 Y9(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}},wl=new I,_l=new I,dc=new Le,JT=[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)],Q9=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Z9=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],tA=(e,t,i)=>{e.updateEntityBoxSize(wl,_l),dc.copy(t).multiply(e.matrixWorld),_l.x===0&&_l.y===0&&_l.z===0?i.push(new I(wl.x,wl.y,wl.z).applyMatrix4(dc)):JT.forEach(r=>{i.push(r.clone().multiply(_l).add(wl).applyMatrix4(dc))})},iA=class extends er{constructor(){super(...arguments),this.matrix=new Le,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 Le().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}tA(s,t,r)}}):tA(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(dc.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(_l).multiplyScalar(.5),this.getCenter(wl),dc.copy(this.matrix).setPosition(wl),this.vertices=JT.map(e=>e.clone().multiply(_l).applyMatrix4(dc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Q9.map(([e,t])=>new da(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=Z9.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},jo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},K9=class extends nC{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),u=o.getPoints(h);for(let c=0;c<u.length;c++){let d=u[c];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},d1=.001;function p1(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=d1}function Qv(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 p1(i,r,a)&&p1(i,s,a)}function $T(e){let t=e.points.map(u=>new I(...u.data.position)),i=[e.points[0]],r=new I(...i[0].data.position);for(let u=0;u<e.points.length-1;u++)p1(r,t[u],t[u+1])||(i.push(e.points[u]),r=t[u]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let u=0;u<n;u++){let c=i[u].data,d=new I(...c.position),p=new I(...c.controlPrevious.position),f=new I(...c.controlNext.position),m={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===n-1)){o[u]={...m,removedLength:0};continue}let v=s&&u==0?n-1:u-1,y=s&&u==n-1?0:u+1,x=i[v].data,b=i[y].data,_=new I(...x.position),S=new I(...b.position),M=_.clone().sub(d).normalize(),C=S.clone().sub(d).normalize();Object.assign(m,{prevDir:M,nextDir:C});let A=Qv(x,c),T=Qv(c,b);if(!A||!T)o[u]={...m,removedLength:0};else{let P=M.clone().add(C).normalize(),R=P.clone().cross(M).length()/M.dot(P);o[u]={...m,tan:R,removedLength:c.roundness/R}}}for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d],m=null;if(!Qv(i[c].data,i[d].data))p.position.distanceTo(f.position)>d1&&(m=new qf(p.position,p.controlNext,f.controlPrevious,f.position));else{let v=p.position.clone(),y=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&v.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&y.add(f.prevDir.clone().setLength(f.removedLength))),v.distanceTo(y)>d1&&(m=new qf(v,v.clone().lerp(y,.3),y.clone().lerp(v,.3),y))}l[2*u+1]=m}for(let u=0;u<n;u++){let c=o[u];if(c.removedLength===0){l[2*u]=null;continue}let d=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(d),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(d),m=c.tan*c.removedLength,v=c.prevDir.clone().add(c.nextDir).normalize(),y=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=v.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(y),_=v.clone().multiplyScalar(-m).add(b),S=d.distanceTo(_)/d.distanceTo(y),M=c.prevDir.clone().multiplyScalar(S*d.distanceTo(p)).add(d),C=M.clone().lerp(_,2),A=p.clone().lerp(M,4/3),T=f.clone().lerp(C,4/3);l[2*u]=new qf(p,A,T,f)}let h=new K9;return l.forEach(u=>{u&&h.add(u)}),h}var Yt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(Yt||(Yt={}));var Qn=e=>Yt.is(e),J9={type:"completeState",isfromEntity:!0},$9=["x","y","z"],Zv=new I,eW=new I().set(0,1,0),Zx=e=>class extends Qx(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 iA,this._recursiveBBox=new iA,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(Yt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Yt.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(Yt.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)Cl.toOps(this.data,s.data).forEach(a=>{let n=Em.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=Cl.patch(this.data,s),Cl.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=>{Qn(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(Yt.is(i[r]))return i[r];if(Yt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Yt.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)Qn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{Yt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Qn(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Qn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Qn(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=>Qn(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*st.RAD2DEG,this.rotation.y*st.RAD2DEG,this.rotation.z*st.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return _y(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,$9[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Zv.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(st.DEG2RAD),this.rotation.setFromVector3(Zv),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??Tc.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)Yt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Yt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return _y(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=_i(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(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=Wr.zoom(u,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(h[d]=c[d])}}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:u,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:u,...c}=l;l=c}let h=Wr.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Cl.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),_i(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[u],c.updateState(qo.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=Wr.zoom(u.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=c[p]);t={...t,props:d}}u.overrideData=km.resolve(i.overrides,l),u.updateByOp(t,Dr.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Uo.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Uo.rootOverrideProps)if(_i(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=qo.filterOp(h.overrideData,l);u&&h.updateByOp(u,Dr.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=qo.filterOp(h.overrideData,t);if(u){let c;a===h.data&&t===u?c=i:c=Dr.applySimple(h.data,u),h.updateByOp(u,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Xl.is(t.props.type)&&jo.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){jo.changeEntityProptotype(this,i,r);for(let s of this.children)Yt.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),_i(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),_i(t.path,["cloner"])!==null){let s=Dr.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=$T(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h);if(u===null)return;let c=this.parent?this.parent?.matrixWorld:new Le;n.updateMatrixWorld();let d=new Le().multiplyMatrices(c.clone().invert(),n.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new Le().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(u),v=new Le().lookAt(u,m,eW),y=Zv.setFromEuler(new vr().setFromRotationMatrix(v)).multiplyScalar(st.RAD2DEG);p={...p,rotation:y.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(J9)})}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 jo.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 jo.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"})}},e3=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);i.thetaLength=st.clamp(i.thetaLength,0,360);let r=i.width/2,s=i.radiusTop??r,a=i.radiusBottom??r;return s===a?(s=r,a=r):s>a?(s=r,a=a*r/s):(s=s*r/a,a=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:a})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new ut,f.setAttribute("position",new et([],3))):c||p?f=new t3(h,u,r,s,a,n,o,l*Math.PI/180,c,c,d,p):f=new fx(h,u,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 rA(e){return new $(e.y,-e.x)}var t3=class extends ut{constructor(e,t,i,r,s,a,n,o,l,h,u,c,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,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=[],m=[],v=[],y=0,x=i/2,b=new I,_=new I;d&&e==0&&(e=l),d&&t==0&&(t=h);let S=new $(e,x),M=new $(t,-x),C=null,A=null,T=null,P=null,R=S.clone().sub(M),z=0,N=0,B=0;c>0&&(z=Math.min(e,t)*(1-c),N=e-z,B=t-z);let V=S.clone();V.x-=z;let H=Math.PI-R.angle(),X=R.angle(),G=Math.tan(X/2),se=Math.tan(H/2),ae=G+se,J=c?ae:se,K=c?ae:G;if(l=Math.min(l,(e-N)/J,R.length()/ae),h=Math.min(h,(t-B)/K,R.length()/ae),l>0){let ue=l/G;C=S.clone().sub(new $(ue,l)),c&&(T=C.clone(),T.x-=z-ae*l),S.sub(R.clone().setLength(ue))}if(h>0){let ue=h/se;A=M.clone().sub(new $(ue,-h)),M.add(R.clone().setLength(ue)),c&&(P=A.clone(),P.x-=z-ae*h,V.sub(R.clone().setLength(ue)))}R=S.clone().sub(M);let ne=R.length()<.5,te=[];for(let ue=0;ue<=r;ue++){let ye=[],de=ue/r,Be=de*o+n,Ce=new $(Math.sin(Be),Math.cos(Be));P&&A?(oe(ye,de,Ce,H,h,P,-1,!0),oe(ye,de,Ce,X,h,A,-1,!1)):A?(ie(ye,Ce,A.x,0,-1),oe(ye,de,Ce,X,h,A,-1,!1)):a||ie(ye,Ce,t,B,-1);let _e=rA(R).normalize();if(_o(_e,Ce,b),!ne)for(let Ze=0;Ze<=s;Ze++){let Qe=Ze/s,Je=R.clone().multiplyScalar(Qe).add(M);_o(Je,Ce,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),v.push(de,.5+_.y/i),ye.push(y++)}if(T&&C?(oe(ye,de,Ce,H,l,C,1,!1),oe(ye,de,Ce,X,l,T,1,!0)):C?(oe(ye,de,Ce,H,l,C,1,!1),ie(ye,Ce,C.x,0,1)):a||ie(ye,Ce,e,N,1),c&&!ne){let Ze=rA(R).multiplyScalar(-1).normalize();_o(Ze,Ce,b);for(let Qe=0;Qe<=s;Qe++){let Je=Qe/s,$e=R.clone().multiplyScalar(-Je).add(V);_o($e,Ce,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),v.push(de,.5+_.y/i),ye.push(y++)}}c&&!a&&ye.push(ye[0]),te.push(ye)}for(let ue=0;ue<te.length-1;ue++)for(let ye=0;ye<te[0].length-1;ye++){if(a&&c&&ye==s)continue;let de=te[ue][ye],Be=te[ue+1][ye],Ce=te[ue+1][ye+1],_e=te[ue][ye+1],Ze=f[Ce*3+0],Qe=f[Ce*3+2];p.push(de,Be,_e),(Ze!=0||Qe!=0)&&p.push(Be,Ce,_e)}o<Math.PI*2&&(be(-1,te[0],n),be(1,te[te.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new et(f,3)),this.setAttribute("normal",new et(m,3)),this.setAttribute("uv",new et(v,2));function oe(ue,ye,de,Be,Ce,_e,Ze,Qe){for(let Je=0;Je<u+1;Je++){let $e=Je/u,He=Ze<0?$e:1-$e;Qe&&(He-=1),He*=Be;let je=new $(Math.sin(He),Math.cos(He)*Ze),ot=je.clone().multiplyScalar(Ce).add(_e);_o(ot,de,_),f.push(_.x,_.y,_.z),_o(je,de,b),m.push(b.x,b.y,b.z),v.push(ye,.5+_.y/i),ue.push(y++)}}function ie(ue,ye,de,Be,Ce){let _e=new I,Ze=new $,Qe=[de,Be];Ce<0&&Qe.reverse();for(let Je of Qe)Ze.set(Je,x*Ce),_o(Ze,ye,_e),f.push(_e.x,_e.y,_e.z),m.push(0,Ce,0),v.push(.5,.5),ue.push(y++)}function be(ue,ye,de){let Be=new $(Math.sin(de),Math.cos(de)),Ce=new $(-Math.cos(de),Math.sin(de)),_e=new I,Ze=ue<0?($e,He,je)=>p.push($e,He,je):($e,He,je)=>p.push($e,je,He),Qe=new $((e+t+N+B)/4,0);_o(Qe,Be,_e),f.push(_e.x,_e.y,_e.z),m.push(Ce.x,0,Ce.y),v.push(.5,.5);let Je=y++;for(let $e of ye){let He=f.slice($e*3,$e*3+3);f.push(...He),m.push(Ce.x,0,Ce.y);let je=v.slice($e*2,$e*2+2);v.push(...je),y++}for(let $e=Je+1;$e<y-1;$e++)Ze(Je,$e,$e+1);Ze(Je,y-1,Je+1)}}},tW=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=st.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:u,cornerSegments:c}=e.parameters,d;return l===0?(d=new ut,d.setAttribute("position",new et([],3))):h>0||u>0||l<360?d=new t3(0,t/2,r,s,a,n,o,l*Math.PI/180,h,u,c,0,!0):d=new mx(t/2,r,s,a,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},iW=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 Fa(t,i,r,s,a,n):h=new rW(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Kv=Math.PI/2,rW=class extends ut{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;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 h=[],u=[],c=[],d=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),n>0&&(v("z","y","x",-1,-1,1,i,t,e,a,0),v("z","y","x",1,-1,-1,i,t,e,a,1),v("z","y","x",-1,1,-1,i,t,e,a,1),v("z","y","x",1,1,1,i,t,e,a,0),v("x","y","z",-1,-1,-1,e,t,i,r,0),v("x","y","z",1,-1,1,e,t,i,r,1),v("x","y","z",-1,1,1,e,t,i,r,0),v("x","y","z",1,1,-1,e,t,i,r,1),v("y","x","z",-1,-1,1,t,e,i,s,0),v("y","x","z",1,-1,-1,t,e,i,s,1),v("y","x","z",1,1,1,t,e,i,s,1),v("y","x","z",-1,1,-1,t,e,i,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new et(u,3)),this.setAttribute("normal",new et(c,3)),this.setAttribute("uv",new et(d,2));function m(x,b,_,S,M,C,A,T,P,R,z){let N=(C-2*n)/P,B=(A-2*n)/R,V=C/2-n,H=A/2-n,X=T/2,G=P+1,se=R+1,ae=0,J=0,K=new I;for(let ne=0;ne<se;ne++){let te=ne*B-H;for(let oe=0;oe<G;oe++){let ie=oe*N-V;K[x]=ie*S,K[b]=te*M,K[_]=X,u.push(K.x,K.y,K.z),K[x]=0,K[b]=0,K[_]=T>0?1:-1,c.push(K.x,K.y,K.z),d.push(oe/P),d.push(1-ne/R),ae+=1}}for(let ne=0;ne<R;ne++)for(let te=0;te<P;te++){let oe=p+te+G*ne,ie=p+te+G*(ne+1),be=p+(te+1)+G*(ne+1),ue=p+(te+1)+G*ne;h.push(oe,ie,ue),h.push(ie,be,ue),J+=6}l.addGroup(f,J,z),f+=J,p+=ae}function v(x,b,_,S,M,C,A,T,P,R,z){let N=(A-2*n)/R,B=A/2-n,V=T/2-n,H=P/2,X=R+1,G=0,se=0,ae=new I,J=new I;for(let K=0;K<o+1;K++){let ne=K/o*Kv,te=Math.sin(ne)*n,oe=(1-Math.cos(ne))*n,ie=Math.sin(ne),be=Math.cos(ne);ae[b]=(V+te)*M,ae[_]=(H-oe)*C,J[x]=0,J[b]=ie*Math.sign(ae[b]),J[_]=be*Math.sign(ae[_]);for(let ue=0;ue<X;ue++){let ye=ue*N-B;ae[x]=ye*S,u.push(ae.x,ae.y,ae.z),c.push(J.x,J.y,J.z),d.push(ue/R),d.push(0),G+=1}}for(let K=0;K<o;K++)for(let ne=0;ne<R;ne++){let te=p+ne+X*K,oe=p+ne+X*(K+1),ie=p+(ne+1)+X*(K+1),be=p+(ne+1)+X*K;h.push(te,oe,be),h.push(oe,ie,be),se+=6}l.addGroup(f,se,z),f+=se,p+=G}function y(x,b,_){let S=new I,M=new I(e/2,t/2,i/2);M.subScalar(n);let C=[],A=x*b*_>0?(P,R,z)=>h.push(P,R,z):(P,R,z)=>h.push(P,z,R);for(let P=0;P<=o;P++){let R=[],z=Kv*(1-P/o),N=Math.cos(z),B=Math.sin(z),V=0;for(let H=0;H<=P;H++){let X=Math.cos(V),G=Math.sin(V);S.x=N*X,S.y=B,S.z=N*G;let se=M.clone().addScaledVector(S,n);u.push(x*se.x,b*se.y,_*se.z),c.push(x*S.x,b*S.y,_*S.z),d.push(0,0),R.push(p++),V+=Kv/P}C.push(R)}let T=C.length-1;for(let P=0;P<T;P++){let R=C[P],z=C[P+1],N=R.length-1;A(R[0],z[1],z[0]);for(let B=1;B<=N;B++)A(R[B-1],R[B],z[B]),A(R[B],z[B+1],z[B])}}}},Kx=class extends ut{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),u(),this.setAttribute("position",new et(n,3)),this.setAttribute("normal",new et(l,3)),this.setAttribute("uv",new et(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new I,p=d.clone(),f=new Hr,m=s*r,v=r-m,y=a+1,x=new I,b=(X,G)=>x.subVectors(X,G).normalize(),_=(X,G)=>Array(X).fill(void 0).map(G),S=_(e.length/3,(X,G)=>new I().fromArray(e,G*3).setLength(r)),M=[],C=1e6;for(let X=0;X<S.length;X++){let G=S[X],se=[],ae,J,K,ne=1e10,te=-1;for(;(te=t.indexOf(X,te+1))!=-1;){let ue=te-te%3;ae=t[ue+(te+1)%3],J=t[ue+(te+2)%3],K=G.distanceToSquared(S[ae]),ne=Math.min(ne,K),se.push([ae,J,K])}ne+=1e-6;let oe=[],ie=0,be=se.length;for(let ue=0;ue<be;ue++){[ae,J,K]=se[ie];let ye=M[ae]?.includes(X)==!0;K<=ne&&oe.push(ae+ +ye*C),ie=se.findIndex(de=>de[0]==J)}M.push(oe)}let A=[];{let X=0,G=0,se,ae,J=c==3;for(let K=0;K<=a;K++){se=K*(K+1)/2,ae=(K+1)*(K+2)/2;for(let ne=0;ne<a-K;ne++)[X,G]=[se+ne+K+2,ae+ne+K+3],A.push(se,ae,...J?[G,se]:[X,ae],G,X),[se,ae]=[X,G];A.push(se,ae,se+a+2)}}let T=d.clone(),P=d.clone(),R=d.clone(),z=d.clone(),N=d.clone(),B=[],V=_(S.length,()=>_(c,()=>d.clone()));for(let X=0;X<S.length;X++){d.copy(S[X]).normalize(),T.copy(d).multiplyScalar(v);let G=M[X];for(let oe=0;oe<G.length;oe++){let ie=G[oe],be=G[(oe+1)%c];f.setFromPointsAndIndices(S,X,ie%C,be%C),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(T,V[X][oe])}let se=[],ae=[],J=[],K=new I;a==0&&[...V[X]].reduce((oe,ie)=>oe.add(ie),K).multiplyScalar(1/c);for(let oe=0;oe<c;oe++){let ie=[],be=(oe-1+c)%c,ue=V[X][be],ye=V[X][oe];d.copy(ue).sub(T),p.copy(ye).sub(T);let de=T.angleTo(d),Be=d.angleTo(p),Ce=Math.cos(de)*m;a==0?P.copy(K):P.copy(T).setLength(v+Ce),ae.push(Ce);let _e=[P,ue,ye];for(let Ze=0;Ze<2;Ze++){let Qe=_e[Ze],Je=_e[Ze+1];z.subVectors(Qe,T),N.subVectors(Je,T),R.crossVectors(z,N).normalize();for(let $e=0;$e<y;$e++){let He=[de,Be][Ze]*$e/y;d.copy(z).applyAxisAngle(R,He).add(T),se.push(d.clone()),Ze&&(b(d,T),ie.push([$e==0?Qe:d.clone(),x.clone()]))}Ze&&(b(Je,T),ie.push([Je,x.clone()]))}J.push(ie)}B.push(J);let ne=2*y,te=2;for(let oe=0;oe<c;oe++){let ie=ne*oe,be=ne*((oe+1)%c),ue=[se[ie]];for(let de=1;de<y;de++){z=se[ie+de],N=se[be+de],ue.push(z);for(let Be=1,Ce=de-te+1;Be<=Ce;Be++)d.lerpVectors(z,N,Be/(Ce+1)),d.sub(T).setLength(ae[oe]).add(T),ue.push(d.clone());ue.push(N)}for(let de=0;de<y;de++)ue.push(se[de+y+ie]);ue.push(se[be+y]);let ye=A.map(de=>ue[de]);n.push(...ye.map(de=>[de.x,de.y,de.z]).flat()),l.push(...ye.map(de=>(b(de,T),[x.x,x.y,x.z])).flat())}}let H=[];for(let X=0;X<M.length;X++)for(let G=0;G<c;G++){let se=M[X][G];if(se<C){let ae=M[se].findIndex(ne=>ne%C==X),J=B[X][G],K=B[se][ae];for(let ne=0;ne<y;ne++){let te=J[ne],oe=K[y-ne],ie=J[ne+1],be=K[y-(ne+1)];[te,oe,ie,ie,oe,be].forEach(ue=>{n.push(ue[0].x,ue[0].y,ue[0].z),l.push(ue[1].x,ue[1].y,ue[1].z)})}H.push(J[0][0],K[y][0],J[y][0],K[0][0])}}for(;H.length;){let X,G,se,ae;[X,G]=H.splice(0,2);let J=[X];for(;X!=G;)J.push(G),se=H.indexOf(G),ae=se%2,G=H.splice(se-ae,2)[1-ae];x.subVectors(J[0],J[1]).cross(d.subVectors(J[0],J[2])).normalize();let K=x.dot(J[0])<0;K&&x.negate();for(let ne=1;ne<=J.length-2;ne++)[J[ne+ +K],J[ne+1-+K],J[0]].forEach(te=>{n.push(te.x,te.y,te.z),l.push(x.x,x.y,x.z)})}}function u(){let c=new I;for(let M=0;M<n.length;M+=3){c.x=n[M+0],c.y=n[M+1],c.z=n[M+2];let C=_(c)/2/Math.PI+.5,A=S(c)/Math.PI+.5;o.push(C,1-A)}let d=new I,p=new I,f=new I,m=new I,v=new $,y=new $,x=new $,b=(M,C,A,T)=>{T<0&&M.x===1&&(o[C]=M.x-1),A.x===0&&A.z===0&&(o[C]=T/2/Math.PI+.5)};for(let M=0,C=0;M<n.length;M+=9,C+=6){d.set(n[M+0],n[M+1],n[M+2]),p.set(n[M+3],n[M+4],n[M+5]),f.set(n[M+6],n[M+7],n[M+8]),v.set(o[C+0],o[C+1]),y.set(o[C+2],o[C+3]),x.set(o[C+4],o[C+5]),m.copy(d).add(p).add(f).divideScalar(3);let A=_(m);b(v,C+0,d,A),b(y,C+2,p,A),b(x,C+4,f,A)}for(let M=0;M<o.length;M+=6){let C=o[M+0],A=o[M+2],T=o[M+4],P=Math.max(C,A,T),R=Math.min(C,A,T);P>.9&&R<.1&&(C<.2&&(o[M+0]+=1),A<.2&&(o[M+2]+=1),T<.2&&(o[M+4]+=1))}function _(M){return Math.atan2(M.z,-M.x)}function S(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(e){return new Kx(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},sW=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 i3(t*.5,a,n):new lC(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},i3=class extends Kx{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 i3(e.radius,e.corner,e.cornerSides)}},Ru=1e-12,Jx=class{constructor(e){this.position=new $,this.startPosition=new $,this.uuid=st.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 Jx(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},f1=class extends Jx{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new f1(this.parent).copy(this)}},pc=class extends Jx{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new f1(this),new f1(this))}static create(e,t){let i=new pc(e,new $(...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 pc(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 $,t=new $){let[i,r]=this.computeTangents();return i&&r&&(sA(i,e),sA(r,t)),[e,t]}computeTangent(e=new $){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new $){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function sA(e,t=new $){let i=e.length();return t.set(-e.y/i,e.x/i)}var $x=e=>e,Kc=new $,Mg=new $,aW=new $,nW=new $,oW=new $,lW=new $,r3=new I,s3=new I;function hW(e){let t=new $;t.addVectors(e.v0,Kc.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new $;return i.addVectors(e.v2,Mg.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Ia(e.v0,t,i,e.v2)}function Zu(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function cW(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function uW(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function a3(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 dW(e,t,i){return nA(e,t)&&nA(t,i)&&m1(e.position,t.position,i.position)}function m1(e,t,i){return Kc.copy(t).sub(e).cross(Mg.copy(i).sub(e))===0}function pW(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 fW(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function mW(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,u=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),c;return a3(t,e,i)>Math.PI&&(u*=-1),Zu(h,o)?c=(o+h)*(r/u-.5)*8/3/(n-l):c=(n+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*n),a.set(i.x+c*h,i.y-c*l),[s,a]}function aA(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function nA(e,t){return m1(e.position,e.controls[1].position,t.position)&&m1(e.position,t.controls[0].position,t.position)}function gW(e,t,i,r,s=.5){let a=Kc.subVectors(t,e).multiplyScalar(s).add(e),n=Mg.subVectors(i,t).multiplyScalar(s).add(t),o=aW.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=nW.subVectors(n,a).multiplyScalar(s).add(a),u=oW.subVectors(o,n).multiplyScalar(s).add(n),c=o,d=lW.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,u.x,u.y,c.x,c.y,r.x,r.y]}function vW(e,t,i=12,r=!0){let s=s3.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=$x(t[l]),u=Kc,c=Ul(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof Ia||h instanceof Zo||h instanceof za){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),a!==void 0&&uW(a,s))continue;a===void 0&&(a=r3),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 yW(e,t,i,r=12,s=!0){let a=s3.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=$x(t[l]),c=Kc,d=Ul(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof Ia||u instanceof Zo||u instanceof za){if(u.getPoint(p/d,c),a.set(c.x,c.y,0),h?.equals(a))continue;h===void 0?h=r3:(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 oA(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=Ul(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=Ul(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Ul(e[0].roundedCurveCorner,t)*.5),r}function Ul(e,t=12){return e&&e instanceof hg?t*2:e&&(e instanceof za||e instanceof aC)?1:e&&e instanceof px?t*e.points.length:t}function xW(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=$x(t[n]),l=Ul(o,i),h=Kc;for(let u=0;u<=l;u++)if(o instanceof Ia||o instanceof Zo||o instanceof za){if(o.getPoint(u/l,h),s!==void 0&&cW(s,h,Ru))continue;s===void 0&&(s=Mg),s.copy(h),e.push(h.x,h.y),a++}}return Zu(e[0],e[e.length-2],Ru)&&Zu(e[1],e[e.length-1],Ru)&&(e.pop(),e.pop()),r&&a>1&&!(Zu(e[a-1],e[1],Ru)&&Zu(e[a-2],e[0],Ru))&&(e.push(e[0],e[1]),a++),e}var Jv=new $,bW=new $,wW=new $,_W=new $,SW=new $,AW=new $,Hi=class extends um{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=st.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Hi;return r.isClosed=e.isClosed,r.points=e.points.map(s=>pc.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Hi.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=Jv.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=st.generateUUID()){let r;e instanceof $?r=e:r=new $(e,t);let s=new pc(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 vW(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=oA(this.points,e,!1),this.roundedCurveDivisions=oA(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return yW(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),xW(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=Ul(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(aA(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Jv.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){aA(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&&dW(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let c=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=u.getLength(),m=Math.min(o,p*.499),v=Math.min(o,f*.499),y=Math.min(m,v),x=1-y/p,b=y/f,_=h.getPointAt(x,Jv),S=u.getPointAt(b,bW);this._subSplitCurve(h,c,x,_,void 0),this._subSplitCurve(u,d,b,void 0,S);let M;if(this.useCubicForRoundedCorners){let C=a3(_,s.position,S)/2,A=Math.tan(C)*_.distanceTo(s.position),[T,P]=pW(_,S,A,wW,_W),R=fW(T,P,s.position),[z,N]=mW(R,_,S,A,SW,AW);M=new Ia(_.clone(),z.clone(),N.clone(),S.clone())}else M=new Zo(_.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=M,this.roundedCurves.splice(i+t,0,M),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof za)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=gW(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 Hi(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],u=e.points[r+6],c=new pc(st.generateUUID(),new $(s,a));c.controls[0].position.set(n,o),c.controls[1].position.set(l,h),c.roundness=u,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Hi;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 Ia&&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 Zo&&(s[n]=hW(s[n]));for(n=0,o=s.length;n<o;n++){let u=s[n],c=n>0?s[n-1]:null,d;u instanceof Ia?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof za&&(d=this.createPoint(u.v1)),d!==void 0&&(c!==null&&i(d,c),a.push(d))}let l=s[s.length-1],h=!1;return l instanceof Ia?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof za&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof um&&(this.shapeHoles=e.holes.map(s=>{let a=new Hi;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)}},g1=Math.PI*2;function $v({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function MW(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 lA(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 EW(e,t,i,r,s,a,n,o,l,h){let u=Math.pow(s,2),c=Math.pow(a,2),d=Math.pow(n,2),p=Math.pow(o,2),f=u*c-u*p-c*d;f<0&&(f=0),f/=u*p+c*d,f=Math.sqrt(f)*(l===h?-1:1);let m=f*s/a*o,v=f*-a/s*n,y=m+(e+i)/2,x=v+(t+r)/2,b=(n-m)/s,_=(o-v)/a,S=(-n-m)/s,M=(-o-v)/a,C=lA(1,0,b,_),A=lA(b,_,S,M);return!h&&A>0&&(A-=g1),h&&A<0&&(A+=g1),{centerx:y,centery:x,ang1:C,ang2:A}}function CW({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,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),a=Math.abs(a);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(a,2);c>1&&(s*=Math.sqrt(c),a*=Math.sqrt(c));let d=EW(e,t,i,r,s,a,h,u,n,o),{ang1:p,ang2:f}=d,{centerx:m,centery:v}=d,y=Math.abs(f)/(g1/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(MW(p,f)),p+=f;return l.map(b=>{let{x:_,y:S}=$v(b[0],s,a,m,v),{x:M,y:C}=$v(b[1],s,a,m,v),{x:A,y:T}=$v(b[2],s,a,m,v);return{x1:_,y1:S,x2:M,y2:C,x:A,y:T}})}var gi;(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"})(gi||(gi={}));var or;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(or||(or={}));function _t(e,t){if(!e)throw t||"Assertion Failed!"}var ft=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){_t(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){_t(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){_t(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){_t(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}(),Bu=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}(),pf=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}(),Zh=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}(),hA=function(){function e(){var t=new Zh,i=new Bu,r=new pf(0),s=new pf(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 pf(0),r=new pf(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;_t(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;_t(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 Zh,i=new Zh,r=new Bu,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 Zh;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Bu;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 Bu;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 Zh;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 Bu;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&&ft.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&ft.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){_t(s.prev===a),l=s.anEdge;do _t(l.Sym!==l),_t(l.Sym.Sym===l),_t(l.Lnext.Onext.Sym===l),_t(l.Onext.Sym.Lnext===l),_t(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(_t(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){_t(n.prev===o),l=n.anEdge;do _t(l.Sym!==l),_t(l.Sym.Sym===l),_t(l.Lnext.Onext.Sym===l),_t(l.Onext.Sym.Lnext===l),_t(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(_t(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)_t(l.Sym.next===h.Sym),_t(l.Sym!==l),_t(l.Sym.Sym===l),_t(l.Org!==null),_t(l.Dst!==null),_t(l.Lnext.Onext.Sym===l),_t(l.Onext.Sym.Lnext===l);_t(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}(),cA=function(){function e(){this.handle=null}return e}(),uA=function(){function e(){this.key=null,this.node=0}return e}(),TW=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 cA,this.handles[r]=new uA;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,_t(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 cA;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new uA}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;_t(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}(),e0=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}(),dA=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),PW=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new dA,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 dA;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}(),DW=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?ft.vertLeq(a.Org,n.Org)?ft.edgeSign(n.Dst,a.Org,n.Org)<=0:ft.edgeSign(a.Dst,n.Org,a.Org)>=0:ft.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return ft.edgeSign(a.Dst,s,a.Org)>=0;var o=ft.edgeEval(a.Dst,s,a.Org),l=ft.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&_t(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){_t(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 e0;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 gi.ODD:return(i&1)!==0;case gi.NONZERO:return i!==0;case gi.POSITIVE:return i>0;case gi.NEGATIVE:return i<0;case gi.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,u,c=!0;h=r;do _t(ft.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,u=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),c=!1,l=o,u=h;l.dirty=!0,_t(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=ft.vertL1dist(i,t),a=ft.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(ft.vertLeq(s.Org,a.Org)){if(ft.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;ft.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(ft.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(_t(!ft.vertEq(s.Dst,a.Dst)),ft.vertLeq(s.Dst,a.Dst)){if(ft.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(ft.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,u,c,d=new Zh,p,f;if(_t(!ft.vertEq(h,l)),_t(ft.edgeSign(l,t.event,n)<=0),_t(ft.edgeSign(h,t.event,o)>=0),_t(n!==t.event&&o!==t.event),_t(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(u=Math.min(n.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(ft.vertLeq(n,o)){if(ft.edgeSign(h,n,o)>0)return!1}else if(ft.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),ft.intersect(l,n,h,o,d),_t(Math.min(n.t,l.t)<=d.t),_t(d.t<=Math.max(o.t,h.t)),_t(Math.min(h.s,l.s)<=d.s),_t(d.s<=Math.max(o.s,n.s)),ft.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=ft.vertLeq(n,o)?n:o,ft.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),ft.vertEq(d,n)||ft.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!ft.vertEq(l,t.event)&&ft.edgeSign(l,t.event,d)>=0||!ft.vertEq(h,t.event)&&ft.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):(ft.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),ft.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),ft.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),ft.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}ft.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,ft.vertEq(s.Org,r)){_t(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!ft.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}_t(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(_t(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),ft.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 e0;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,ft.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=ft.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 u=t.mesh.connect(o.Dnext,i.anEdge);l=u.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);_t(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 e0,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 PW(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||(_t(i.fixUpperEdge),_t(++r===1)),_t(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,ft.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 TW(a,ft.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,_t(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||!ft.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}(),OW=function(){function e(){this.mesh=new hA,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=gi.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],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var v=0;v<3;++v)a=i.coords[v],h[v]=a,f[v]=i,l[v]=a,p[v]=i;for(i=m.next;i!==m;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],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],i=m.next;i!==m;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],d[0]=u[1]*c[2]-u[2]*c[1],d[1]=u[2]*c[0]-u[0]*c[2],d[2]=u[0]*c[1]-u[1]*c[0],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_(u)]=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(;ft.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ft.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(ft.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(ft.edgeGoesLeft(s.Lnext)||ft.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&&(ft.edgeGoesRight(r.Lprev)||ft.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 u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){a=u.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=n,++n}this.elementCount=n,i===or.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 c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(u.inside){a=u.anEdge,l=0;do{var h=a.Org;this.elements[d++]=h.n,l++,a=a.Lnext}while(a!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===or.CONNECTED_POLYGONS){a=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==u.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,u=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[u++]=a,this.elements[u++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new hA),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=gi.ODD),i===void 0&&(i=or.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_(),DW.computeInterior(this,n);var o=this.mesh;return i===or.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===or.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Go(e){var t=e.windingRule,i=t===void 0?gi.ODD:t,r=e.elementType,s=r===void 0?or.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,c=e.contours,d=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,m=e.debug,v=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var y=new OW;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,u,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:v?y.mesh:void 0}}}var Xee=gi.ODD,Yee=gi.NONZERO,Qee=gi.POSITIVE,Zee=gi.NEGATIVE,Kee=gi.ABS_GEQ_TWO,Jee=or.POLYGONS,$ee=or.CONNECTED_POLYGONS,ete=or.BOUNDARY_CONTOURS,v1=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*v1.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*v1.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)}},n3=v1;n3.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var IW=Br(NO()),eb={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},o3={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},l3={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},t0=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),tb=class extends ut{constructor(e,t,i=0,r=12,s=3,a=gi.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 N=P[z-1],B=P[z-0];R.push(N,B)}return R}),h=[],u=[];for(let T=0;T<o.length;T+=2)u.push([o[T],o[T+1]]);h.push(u);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 c;e.isText?c=new AC().setFromPoints(e.points.map(T=>T.position)).getSize(new $).length()*.1:h[0].length===0?c=i:c=(0,IW.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let d;try{d=Go({windingRule:a,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=eb}let p;try{p=Go({windingRule:gi.ODD,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=o3}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 m=1/0,v=-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],N=d.vertices[R+1];z<m&&(m=z),z>v&&(v=z),N<y&&(y=N),N>x&&(x=N)}this._minX=m,this._minY=y,this._width=v-m,this._height=x-y,this._buffer=new n3(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],N=d.elements[R+1],B=z+N,V={start:z,count:N,normals:[],continuous:[],concave:[]},H=z,X=B-1,G=z+1,se=this._shape.roundedCurves.length;do{let te=H-z,oe=d.vertices[X*2+0],ie=d.vertices[X*2+1],be=d.vertices[H*2+0],ue=d.vertices[H*2+1],ye=d.vertices[G*2+0],de=d.vertices[G*2+1],Be=be-oe,Ce=ue-ie,_e=Math.sqrt(Be*Be+Ce*Ce);Be/=_e,Ce/=_e;let Ze=be-ye,Qe=ue-de,Je=Math.sqrt(Ze*Ze+Qe*Qe);Ze/=Je,Qe/=Je,V.normals[te*2+0]=-Qe,V.normals[te*2+1]=Ze,V.concave[te]=Be*Qe-Ce*Ze>0;let $e=d.vertexIndices[H];if(Array.isArray($e))V.continuous[te]=!1;else{let[He,je]=this._shape.getCurveIndexFromVertexId($e-1,!0);if(je>0&&je<1)V.continuous[te]=!0;else{let ot=je===1?He+1:He-1;ot=(ot+se)%se;let gt=je===1?0:1,Q=this._shape.roundedCurves[He].getTangent(je),j=this._shape.roundedCurves[ot].getTangent(gt);V.continuous[te]=Q.dot(j)>.95}}P&&(V.normals[te*2+0]*=-1,V.normals[te*2+1]*=-1),[X,H,G]=[H,G,G+1],G>=B&&(G-=N)}while(G!==z+1);let ae=[];ae.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(z*2,B*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((te,oe)=>[oe,oe]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(z*2,B*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let oe=te/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,be=[],ue=[],ye=[],de=[],Be=0;for(let _e=0;_e<N;_e++){let Ze=_e*2,Qe=(_e-1+N)%N*2,Je=d.vertices[V.start*2+Ze+0],$e=d.vertices[V.start*2+Ze+1],He=-V.normals[Qe+0]*ie,je=-V.normals[Qe+1]*ie,ot=-V.normals[Ze+0]*ie,gt=-V.normals[Ze+1]*ie;if(V.concave[_e]||!V.concave[_e]&&P){let Q=Math.atan2(je,He),j=Math.atan2(gt,ot);j>Q&&(j-=Math.PI*2);let ge=j-Q;if(V.continuous[_e]||P){let Ne=Q+ge/2,Te=Math.cos(Ne)*ie,Ge=Math.sin(Ne)*ie;be[2*Be+0]=Je+Te*(P?-1:1),be[2*Be+1]=$e+Ge*(P?-1:1),de[Be]=_e,Be++}else{let Ne=Math.max(1,Math.floor(r/4*Math.abs(ge)/Math.PI));for(let Te=0;Te<=Ne;Te++){let Ge=Q+ge*(Te/Ne),lt=Math.cos(Ge)*ie,Ve=Math.sin(Ge)*ie;be[2*Be+0]=Je+lt,be[2*Be+1]=$e+Ve,de[Be]=_e,Be++}}}else be[2*Be+0]=Je+He,be[2*Be+1]=$e+je,de[Be]=_e,ue[_e]=Be,Be++,be[2*Be+0]=Je,be[2*Be+1]=$e,de[Be]=_e,Be++,be[2*Be+0]=Je+ot,be[2*Be+1]=$e+gt,de[Be]=_e,ye[_e]=Be,Be++}let Ce=Go({windingRule:gi.POSITIVE,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[be],edgeCreateCallback:_e=>{let Ze=_e.Org.idx,Qe=de[Ze],Je=de[(Ze+1)%de.length];_e.idx=[Qe,Je],_e.Sym.idx=[Je,Qe]},vertexIdCallback:_e=>{let Ze=_e.Lprev.idx;return[Ze?Ze[1]:0,_e.idx?_e.idx[0]:0]}});if(!Ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!Ce.vertexCount){let _e=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(_e))*this._bevel;break}for(let _e=0;_e<Ce.vertexIndices.length;_e++){let[Ze,Qe]=Ce.vertexIndices[_e];if(Ze===Qe)continue;let Je=Qe;Qe<Ze&&(Je+=N);for(let $e=Ze;$e<Je;$e++){let He=$e%N,je=($e+1)%N;if(!V.continuous[He]||!V.continuous[je]){Ce.vertexIndices[_e]=[Ze,He],Ce.vertexIndices.splice(_e+1,0,[je,Qe]),Ce.vertices.splice((_e+1)*2,0,Ce.vertices[_e*2],Ce.vertices[_e*2+1]);break}}}ae.push({bevelI:te,angle:oe,size:ie,boundary:Ce,reverseMap:de,insetPoints:be})}let K=(te,oe,ie)=>{let be=0,ue=te.boundary.vertexIndices.length;for(;be<ue&&ie(te.boundary.vertexIndices[oe]);)oe=(oe+1)%ue,be++;return be},ne=b.length;for(let te=1;te<ae.length;te++){let oe=ae[te-1],ie=ae[te],be=oe.boundary.vertexIndices.length,ue=ie.boundary.vertexIndices.length;if(!be||!ue)break;let ye=V.concave.length,de=0,Be=t0(de,N);for(;!oe.boundary.vertexIndices.filter(Be).length||!ie.boundary.vertexIndices.filter(Be).length;)de++,Be=t0(de,N);let Ce=oe.boundary.vertexIndices.findIndex(Be),_e=ie.boundary.vertexIndices.findIndex(Be);do Ce=(Ce+1)%be;while(Be(oe.boundary.vertexIndices[Ce]));do _e=(_e+1)%ue;while(Be(ie.boundary.vertexIndices[_e]));de=(de+1)%N;let Ze=de,Qe=0,Je=this._buildBevelVert(V,oe,(Ce-1+be)%be,void 0,Qe),$e=this._buildBevelVert(V,ie,(_e-1+ue)%ue,void 0,Qe),He=Je,je=$e,ot,gt,Q=!1;do{Qe=(de||ye)/ye,Be=t0(de,N);let j=K(oe,Ce,Be),ge=K(ie,_e,Be),Ne=Q;if(Q=!1,j&&!ge){for(let Te=0;Te<j;Te++)ot=this._buildBevelVert(V,oe,(Ce+Te)%be,Te/(j-1),Qe),b.push(He.topN,ot.topP,je.topN),n===!1&&b.push(ot.bottomP,He.bottomN,je.bottomN),He=ot;Q=!0}else if(!j&&ge)for(let Te=0;Te<ge;Te++)gt=this._buildBevelVert(V,ie,(_e+Te)%ue,Te/(ge-1),Qe),b.push(je.topN,He.topP,gt.topP),n===!1&&b.push(He.bottomP,je.bottomN,gt.bottomP),je=gt;else if(j&&ge)if(ot=this._buildBevelVert(V,oe,Ce,0,Qe),gt=this._buildBevelVert(V,ie,_e,0,Qe),Ne?(b.push(He.topN,gt.topP,je.topN),b.push(He.topN,ot.topP,gt.topP),n===!1&&(b.push(gt.bottomP,He.bottomN,je.bottomN),b.push(gt.bottomP,ot.bottomP,He.bottomN))):(b.push(je.topN,He.topN,ot.topP),b.push(je.topN,ot.topP,gt.topP),n===!1&&(b.push(ot.bottomP,He.bottomN,je.bottomN),b.push(ot.bottomP,je.bottomN,gt.bottomP))),He=ot,je=gt,j===ge)for(let Te=1;Te<j;Te++)ot=this._buildBevelVert(V,oe,(Ce+Te)%be,Te/(j-1),Qe),gt=this._buildBevelVert(V,ie,(_e+Te)%ue,Te/(ge-1),Qe),b.push(He.topN,ot.topP,je.topN),b.push(je.topN,ot.topP,gt.topP),n===!1&&(b.push(ot.bottomP,He.bottomN,je.bottomN),b.push(ot.bottomP,je.bottomN,gt.bottomP)),He=ot,je=gt;else if(j>ge){let Te=j/ge,Ge=0;for(let lt=1;lt<j;lt++)ot=this._buildBevelVert(V,oe,(Ce+lt)%be,lt/(j-1),Qe),b.push(He.topN,ot.topP,je.topN),n===!1&&b.push(ot.bottomP,He.bottomN,je.bottomN),He=ot,lt>(Ge+1)*Te&&(Ge++,gt=this._buildBevelVert(V,ie,(_e+Ge)%ue,Ge/(ge-1),Qe),b.push(je.topN,ot.topP,gt.topP),n===!1&&b.push(ot.bottomP,je.bottomN,gt.bottomP),je=gt)}else{let Te=ge/j,Ge=0;for(let lt=1;lt<ge;lt++)gt=this._buildBevelVert(V,ie,(_e+lt)%ue,lt/(ge-1),Qe),b.push(je.topN,ot.topP,gt.topP),n===!1&&b.push(ot.bottomP,je.bottomN,gt.bottomP),je=gt,lt>(Ge+1)*Te&&(Ge++,ot=this._buildBevelVert(V,oe,(Ce+Ge)%be,Ge/(j-1),Qe),b.push(He.topN,ot.topP,je.topN),n===!1&&b.push(ot.bottomP,He.bottomN,je.bottomN),He=ot)}Ce=(Ce+j)%be,_e=(_e+ge)%ue,de=(de+1)%ye}while(de!==Ze)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(ae,V,b),P){let te=[];for(let oe=b.length-1;oe>=ne+2;oe-=3){let ie=b[oe-2],be=b[oe-1],ue=b[oe-0];te.push(ue,be,ie)}b.splice(ne,b.length-ne,...te)}if(P){let te=[];for(let oe=ae[ae.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=ae[ae.length-1].boundary.vertices[oe-1],be=ae[ae.length-1].boundary.vertices[oe-0];te.push(ie,be)}_.push(te)}if(!P){let te=ae[ae.length-1],oe;try{oe=Go({windingRule:ae.length>1?gi.POSITIVE:gi.ODD,elementType:or.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,..._]})}catch{oe=l3}if(!oe)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ie=0;ie<oe.elementCount*3;ie+=3){let be=this._buildSurfaceVert(oe,oe.elements[ie+0],J),ue=this._buildSurfaceVert(oe,oe.elements[ie+1],J),ye=this._buildSurfaceVert(oe,oe.elements[ie+2],J);b.push(be.top,ue.top,ye.top),n===!1&&b.push(ye.bottom,ue.bottom,be.bottom)}}this.vertexCache={}}this._buffer.shrink();let S=new At(Uint32Array.from(b),1),M=new At(this._buffer.positions,3),C=new At(this._buffer.normals,3),A=new At(this._buffer.uvs,2);M.needsUpdate=!0,C.needsUpdate=!0,A.needsUpdate=!0,S.needsUpdate=!0,this.setAttribute("position",M),this.setAttribute("normal",C),this.setAttribute("uv",A),this.setIndex(S)}_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,u=l*2,c={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[u+0]=n,this._buffer.uvs[u+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[u+2]=n,this._buffer.uvs[u+3]=o),this.vertexCache[r]=c,c}_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,u,c;n!==o?(h=n,l=o,c=!1,u=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,u=e.continuous[l]||c);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,v=h*2,y=t.boundary.vertices[f+0],x=t.boundary.vertices[f+1],b=(1-p)*this._bevel,_=(y-this._minX)/this._width,S=(x-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(_=s),S=1);let M=e.normals[m+0],C=e.normals[m+1],A=e.normals[v+0],T=e.normals[v+1];if(c){let B=A-M,V=T-C;M=M+B*(1-r),C=C+V*(1-r);let H=Math.sqrt(M*M+C*C);M/=H,C/=H}let P=this.forPathBevel?this._buffer.get(u?1:2):this._buffer.get(u?2:4),R=P*3,z=P*2,N={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]=M*d,this._buffer.normals[R+1]=C*d,this._buffer.normals[R+2]=p,this._buffer.uvs[z+0]=_,this._buffer.uvs[z+1]=S,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]=M*d,this._buffer.normals[R+4]=C*d,this._buffer.normals[R+5]=-p,this._buffer.uvs[z+2]=S,this._buffer.uvs[z+3]=_),u||(this.forPathBevel?(P+=1,R+=3,z+=2):(P+=2,R+=6,z+=4),N.topP=P+0,N.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]=S,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]=S,this._buffer.uvs[z+3]=_)),this.vertexCache[a]=N,N}clone(){let e=new tb(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yg(this.userData),e}},h3=class extends ut{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=gi.ODD,this.elementType=or.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:gi.ODD,elementType:or.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,m=r[f+0],v=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&v!==h&&(o=!1),l=m,h=v,!n&&!o)break}if(!n&&!o)try{a=Go({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=eb}let u=a?.vertexCount??1,c=a?.elementCount??1;if(this._positionAttribute=new At(new Float32Array(u*3),3),this._normalAttribute=new At(new Float32Array(u*3),3),this._uvAttribute=new At(new Float32Array(u*2),2),this._indexAttribute=new At(new Uint32Array(c*3),1),a){let d=1/0,p=-1/0,f=1/0,m=-1/0;for(let x=0,b=u;x<b;x++){let _=x*2,S=a.vertices[_+0],M=a.vertices[_+1];S<d&&(d=S),S>p&&(p=S),M<f&&(f=M),M>m&&(m=M)}let v=p-d,y=m-f;for(let x=0,b=u;x<b;x++){let _=x*2,S=a.vertices[_+0],M=a.vertices[_+1],C=(S-d)/v,A=(M-f)/y;this._positionAttribute.setXYZ(x,S,M,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,C,A)}for(let x=0,b=c;x<b;x++){let _=x*3,S=a.elements[_+0],M=a.elements[_+1],C=a.elements[_+2];this._indexAttribute.setX(_+0,S),this._indexAttribute.setX(_+1,M),this._indexAttribute.setX(_+2,C)}}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 h3(this._shape,this._curveSegments);return e.userData=yg(this.userData),e}},c3=class extends tb{constructor(e,t,i=0,r=12,s=3,a=gi.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 c3(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yg(this.userData),e}},ih=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:gi.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 Hi?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new Hi(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new Hi(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 h3(e.shape,s,{windingRule:n}):o=new c3(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},u3=Math.PI*2,ib=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=st.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof Hi?e.shape:new Hi,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,u=t*.5,c=i*.5,d=RW(h,u,c,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new ut,p.setAttribute("position",new et([],3))):p=ih.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function RW(e,t,i,r,s,a){if(r>=u3)return s>30||s%4===0?(LW(e,t,i,a),Math.round(s/4)):pA(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=CW({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?BW(e,n.x,n.y,h,s,t,i,a):pA(e,r,s,t,i,a)}function BW(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(fc(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=fc(c.x,c.y);d.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?d3(e,a,n,o):e.addPoint(fc(0,0)),l}function pA(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,u=Math.cos(l)*s;e.addPoint(fc(h,u))}return t<u3?a>0?d3(e,r,s,a):e.addPoint(fc(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&p3(e,r,s,a)),1}function LW(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(ff(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(ff(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(ff(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(ff(s,a-i,s+o,a-i,s-o,a-i)),r>0&&p3(e,t,i,r)}function fc(e,t){return new pc(st.generateUUID(),new $(e,t))}function ff(e,t,i,r,s,a){let n=fc(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function d3(e,t,i,r){f3(e,t,i,r).forEach(s=>e.addPoint(s))}function p3(e,t,i,r){let s=f3(e,t,i,r),a=new Hi;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function f3(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new $(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=st.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),u=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var zW=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:u,cornerSegments:c}=e.parameters,d=new m3(!1,t,i,r,s,a,n,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},i0=new nc([0,0,0],1),m3=class extends ut{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,u=1,c=1){if(super(),a===0)return;let d=e&&a===1;d&&(c=0),u>100&&(u=100),u===0&&(c=0);let p=()=>new I,f=new I,m=p(),v=p(),y=p(),x,b,_,S,M,C,A,T,P=p(),R=p(),z=p(),N=p(),B=p(),V=p(),H=p(),X=p(),G=i-2*o+.001,se=G/a,ae=Math.ceil(n*a),J=ae+1,K=G/ae,ne=-G/2,te=h+1,oe=2*Math.PI/h,ie=Math.PI/2/c,be=.01,ue=Math.min((1-u/100)*o,o-be),ye=o-ue,de=0,Be=2,Ce=c*Be+Be,_e=te*Ce/Be,Ze=_e+te*J,Qe=Math.max(0,te*(J+Ce)),[Je,$e,He]=[3,3,2].map(Fe=>Array(Qe*Fe).fill(0)),je=[],ot=s-o;function gt(Fe,ht){let Ke=Math.PI/2;C=ht*K,T=2*Math.PI*(C%se)/se+Ke,C+=ne,A=Math.sin(T)*ot,M=Math.cos(T)*ot,e?Fe.set(M,A,C):Fe.set(M,C,A)}gt(f,-1e-10),gt(m,0),P.copy(f),gt(f,1);let Q=f.distanceTo(m),j=d?0:ye+ue,ge=Q*ae+2*j,Ne=ue,Te=ge-j;for(let Fe=0;Fe<=ae;Fe++){gt(v,Fe),X.subVectors(v,P).normalize(),P.copy(v),V.copy(v).setComponent(+e+1,0).normalize(),H.crossVectors(X,V).normalize();let ht=Fe===0,Ke=Fe===ae,vt=ht?3*Math.PI/2:ie,dt=ht?Ne:Te,Wt=ht?te:Ze,ui=ht?0:Qe-te,Di=X.clone().multiplyScalar(ht?-ye:ye).add(v),ce=X.clone().multiplyScalar(ht?-1:1).normalize();for(let we=0;we<te;we++){let Ue=we*oe;if(R.addVectors(f.copy(V).multiplyScalar(o*Math.cos(Ue)),m.copy(H).multiplyScalar(o*Math.sin(Ue))),z.copy(R).normalize(),ht||Ke){d||(de=ui+we,[0,1,2].forEach(We=>{Je[de*3+We]=Di.getComponent(We),$e[de*3+We]=ce.getComponent(We)}),He[de*2]=+Ke,He[de*2+1]=we/h),m.copy(z).multiplyScalar(ue),y.addVectors(v,m);for(let We=0;We<c;We++){let pt=We*ie+vt;N.addVectors(f.copy(X).multiplyScalar(ye*Math.sin(pt)),m.copy(z).multiplyScalar(ye*Math.cos(pt))),B.copy(N).normalize(),m.addVectors(y,N),N.normalize(),de=Wt+We*te+we,[0,1,2].forEach(xi=>{Je[de*3+xi]=m.getComponent(xi),$e[de*3+xi]=B.getComponent(xi)});let $t=+ht+Math.sin(pt);He[de*2]=(dt+ye*$t)/ge,He[de*2+1]=we/h}}m.addVectors(v,R),de=_e+Fe*te+we,[0,1,2].forEach(We=>{Je[de*3+We]=m.getComponent(We),$e[de*3+We]=z.getComponent(We)}),He[de*2]=(j+Fe*Q)/ge,He[de*2+1]=we/h}}let Ge=J+2*c+Be,lt=1,[Ve,De]=[+d,Ge-1];for(let Fe=Ve;Fe<=De-1;Fe++){let ht=d&&Fe===De-1;for(let Ke=0;Ke<te-1;Ke++)x=Fe*te+Ke,b=x+1,_=(ht?Ke:x)+te,S=(ht?Ke+1:b)+te,Fe===0?je.push(b,S,_):Fe===Ge-2?je.push(x,b,_):je.push(x,b,_,b,S,_)}this.setIndex(je),this.setAttribute("position",new et(Je,3)),this.setAttribute("normal",new et($e,3)),this.setAttribute("uv",new et(He,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,u=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,a=s+1,n=(u?c:s)+i,o=(u?c+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,i0.array=r,i0.count=r.length,i0}},kW=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 g3(t*.5,a,n):new pC(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},g3=class extends Kx{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 g3(e.radius,e.corner,e.cornerSides)}},NW=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 um;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 oC(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},Za=new Le,r0=new ci,mf=new I,Qm=class extends Qr{constructor(){super(),this.uuid=st.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 Ki().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 Za.makeRotationX(e),this.applyMatrix4(Za),this}rotateY(e){return Za.makeRotationY(e),this.applyMatrix4(Za),this}rotateZ(e){return Za.makeRotationZ(e),this.applyMatrix4(Za),this}translate(e,t,i){return Za.makeTranslation(e,t,i),this.applyMatrix4(Za),this}scale(e,t,i){return Za.makeScale(e,t,i),this.applyMatrix4(Za),this}lookAt(e){return r0.lookAt(e),r0.updateMatrix(),this.applyMatrix4(r0.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 c=0;c<s.count;c++)t.vertices.push(new I().fromBufferAttribute(s,c)),n!==void 0&&t.colors.push(new yt().fromBufferAttribute(n,c));function h(c,d,p,f){let m=n===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],v=a===void 0?[]:[new I().fromBufferAttribute(a,c),new I().fromBufferAttribute(a,d),new I().fromBufferAttribute(a,p)],y=new y1(c,d,p,v,m,f);t.faces.push(y),o!==void 0&&t.faceVertexUvs[0].push([new $().fromBufferAttribute(o,c),new $().fromBufferAttribute(o,d),new $().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new $().fromBufferAttribute(l,c),new $().fromBufferAttribute(l,d),new $().fromBufferAttribute(l,p)])}let u=e.groups;if(u.length>0)for(let c=0;c<u.length;c++){let d=u[c],p=d.start,f=d.count;for(let m=p,v=p+f;m<v;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),d.materialIndex):h(m,m+1,m+2,d.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mf).negate(),this.translate(mf.x,mf.y,mf.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new Le;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 Qm;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 er),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zs),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,u=e.colors;t!==void 0&&(r=new Ki().getNormalMatrix(t));for(let c=0,d=n.length;c<d;c++){let p=n[c].clone();t!==void 0&&p.applyMatrix4(t),a.push(p)}for(let c=0,d=u.length;c<d;c++)h.push(u[c].clone());for(let c=0,d=l.length;c<d;c++){let p=l[c],f,m,v=p.vertexNormals,y=p.vertexColors,x=new y1(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,_=v.length;b<_;b++)f=v[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++)m=y[b],x.vertexColors.push(m.clone());x.materialIndex=p.materialIndex+i,o.push(x)}for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let v=p[f],y=[];for(let x=0,b=v.length;x<b;x++)y.push(v[x].clone());this.faceVertexUvs[c].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],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[u]]}let 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 u=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(u[c]===u[(c+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,u=this.faceVertexUvs.length;h<u;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],m=!0,v=!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,S=f.vertexColors.length>0,M=0;if(M=h(M,0,0),M=h(M,1,m),M=h(M,2,v),M=h(M,3,y),M=h(M,4,x),M=h(M,5,b),M=h(M,6,_),M=h(M,7,S),i.push(M),i.push(f.a,f.b,f.c),i.push(f.materialIndex),y){let C=this.faceVertexUvs[0][p];i.push(d(C[0]),d(C[1]),d(C[2]))}if(x&&i.push(u(f.normal)),b){let C=f.vertexNormals;i.push(u(C[0]),u(C[1]),u(C[2]))}if(_&&i.push(c(f.color)),S){let C=f.vertexColors;i.push(c(C[0]),c(C[1]),c(C[2]))}}function h(p,f,m){return m?p|1<<f:p&~(1<<f)}function u(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return 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 Qm().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,d=t.length;c<d;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,d=i.length;c<d;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,d=r.length;c<d;c++)this.faces.push(r[c].clone());for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let v=p[f],y=[];for(let x=0,b=v.length;x<b;x++){let _=v[x];y.push(_.clone())}this.faceVertexUvs[c].push(y)}}let s=e.morphTargets;for(let c=0,d=s.length;c<d;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let c=0,d=a.length;c<d;c++){let p={};if(a[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=a[c].vertexNormals.length;f<m;f++){let v=a[c].vertexNormals[f],y={};y.a=v.a.clone(),y.b=v.b.clone(),y.c=v.c.clone(),p.vertexNormals.push(y)}}if(a[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=a[c].faceNormals.length;f<m;f++)p.faceNormals.push(a[c].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let c=0,d=n.length;c<d;c++)this.skinWeights.push(n[c].clone());let o=e.skinIndices;for(let c=0,d=o.length;c<d;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,d=l.length;c<d;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new FW().fromGeometry(this),t=new ut,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",gf.call(new At(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",gf.call(new At(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",fA.call(new At(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",mA.call(new At(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",mA.call(new At(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 et(l.data.length*3,3);h.name=l.name,s.push(gf.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new et(e.skinIndices.length*4,4);t.setAttribute("skinIndex",gA.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new et(e.skinWeights.length*4,4);t.setAttribute("skinWeight",gA.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 ut,i=e.geometry;if(e.isPoints||e.isLine){let r=new et(i.vertices.length*3,3),s=new et(i.colors.length*3,3);if(t.setAttribute("position",gf.call(r,i.vertices)),t.setAttribute("color",fA.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new et(i.lineDistances.length,1);t.setAttribute("lineDistance",UW.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}};Qm.prototype.isGeometry=!0;var FW=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 v=0;v<o;v++)l[v]={name:n[v].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let v=0;v<u;v++)c[v]={name:h[v].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let v=0;v<t.length;v++){let y=t[v];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][v];_!==void 0?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new $,new $,new $))}if(a===!0){let _=r[1][v];_!==void 0?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new $,new $,new $))}for(let _=0;_<o;_++){let S=n[_].vertices;l[_].data.push(S[y.a],S[y.b],S[y.c])}for(let _=0;_<u;_++){let S=h[_].vertexNormals[v];c[_].data.push(S.a,S.b,S.c)}f&&this.skinIndices.push(d[y.a],d[y.b],d[y.c]),m&&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}},y1=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 yt,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 UW(e){return this.array.set(e),this}function fA(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 yt),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function mA(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 $),t[i++]=a.x,t[i++]=a.y}return this}function gf(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 gA(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 Et),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var VW=["a","b","c"];function jW(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function s0(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function a0(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 u=i[n],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function GW(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],a0(n.a,n.b,e,r,n,i),a0(n.b,n.c,e,r,n,i),a0(n.c,n.a,e,r,n,i)}function vf(e,t,i,r,s){e.push(new y1(t,i,r,void 0,void 0,s))}function Rh(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function yf(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var HW=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof ut?e=new Qm().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],u=h!==void 0&&h.length>0,c=[],d=new Map;GW(o,l,c,d);let p=[],f,m,v,y,x,b,_;for(let be of Array.from(d.keys())){for(m=d.get(be),v=new I,x=3/8,b=1/8,_=m.faces.length,_!=2&&(x=.5,b=0,_!=1),v.addVectors(m.a,m.b).multiplyScalar(x),t.set(0,0,0),a=0;a<_;a++){for(y=m.faces[a],n=0;n<3&&(f=o[jW(y,VW[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(b),v.add(t),m.newEdge=p.length,p.push(v)}let S,M,C,A,T,P,R,z=[];for(r=0,s=o.length;r<s;r++){for(P=o[r],T=c[r].edges,i=T.length,i==3?S=3/16:i>3&&(S=3/(8*i)),M=1-i*Number(S),C=S,i<=2&&(i==2?(M=3/4,C=1/8):i==1||i==0),R=P.clone().multiplyScalar(M),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(C)),R.add(t),z.push(R)}let N=z.concat(p),B=z.length,V,H,X,G=[],se=[],ae,J,K,ne,te=new $,oe=new $,ie=new $;for(r=0,s=l.length;r<s;r++)y=l[r],V=Number(s0(y.a,y.b,d).newEdge)+B,H=Number(s0(y.b,y.c,d).newEdge)+B,X=Number(s0(y.c,y.a,d).newEdge)+B,vf(G,V,H,X,y.materialIndex),vf(G,y.a,V,X,y.materialIndex),vf(G,y.b,H,V,y.materialIndex),vf(G,y.c,X,H,y.materialIndex),u&&(ae=h[r],J=ae[0],K=ae[1],ne=ae[2],te.set(Rh(J.x,K.x),Rh(J.y,K.y)),oe.set(Rh(K.x,ne.x),Rh(K.y,ne.y)),ie.set(Rh(J.x,ne.x),Rh(J.y,ne.y)),yf(se,te,oe,ie),yf(se,J,te,ie),yf(se,K,oe,te),yf(se,ne,ie,oe));e.vertices=N,e.faces=G,u&&(e.faceVertexUvs[0]=se)}},fr=new I,WW=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new ut().copy(new Fa(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(fr),r={width:fr.x,height:fr.y,depth:fr.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 ut().copy(new Fa(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(fr)):fr.set(n.width,n.height,n.depth),(t!==fr.x||i!==fr.y||r!==fr.z)&&a.scale(fr.x===0?1:t/fr.x,fr.y===0?1:i/fr.y,fr.z===0?1:r/fr.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new HW(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 _C(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(fr);let a=100/fr.x;Object.assign(s.parameters,{width:100,height:fr.y*a,depth:fr.z*a}),t(this.build(s))})}},v3=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 Hi?e.shape:new Hi,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,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let v=p*m,y=c+Math.sin(v)*h,x=d+Math.cos(v)*u;l.addPoint(l.createPoint(y,x))}l.isClosed=!0;for(let m=0,v=l.points.length;m<v;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=ih.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},qW=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 YW(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Lu(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function n0(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 XW(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var YW=class extends ut{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=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,x=new I(0,-d,0),b=new I(0,d,0),_=new $(e,-d),S=new $(f,-d),M=new $(0,b.y).sub(S),C=new $(0,b.y).sub(_),A=new $(M.y,-M.x).normalize(),T=new $(C.y,-C.x).normalize(),P=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-M.angle())/2)-1e-8;a=Math.min(a,P);let R;{let G=new I(A.x,A.y,0),se=new I(Math.cos(m)*G.x,G.y,Math.sin(m)*G.x);R=G.angleTo(se)}let z=a/Math.tan((Math.PI-M.angle())/2),N=a/Math.tan((Math.PI-R)/2),B=new I;if(!s){l.push(x.x,x.y,x.z),h.push(0,-1,0),u.push(0,0);let G=c++,se=[],ae=_.clone(),J=z/Math.cos(Math.PI/i);ae.x-=J;for(let K=0;K<i;K++){let ne=K/i*Math.PI*2+p,te=new $(Math.sin(ne),Math.cos(ne));Lu(ae,te,B),l.push(B.x,B.y,B.z),h.push(0,-1,0),u.push(0,0),se.push(c++)}for(let K=0;K<se.length;K++)o.push(se[K],G,se[(K+1)%se.length])}let V=[];{let G=new I,se=new I,ae=new I,J=new I,K=new I,ne=new I;for(let te=0;te<i;te++){let oe=te/i*Math.PI*2+p,ie=(te+.5)/i*Math.PI*2+p,be=(te+1)/i*Math.PI*2+p,ue=new $(Math.sin(oe),Math.cos(oe)),ye=new $(Math.sin(ie),Math.cos(ie)),de=new $(Math.sin(be),Math.cos(be));Lu(_,ue,se),Lu(_,de,ae),Lu(A,ye,G),n0(b,se,ae,N,N,J),l.push(J.x,J.y,J.z),n0(se,b,ae,N,z,K),l.push(K.x,K.y,K.z),n0(ae,se,b,z,N,ne),l.push(ne.x,ne.y,ne.z),h.push(G.x,G.y,G.z),h.push(G.x,G.y,G.z),h.push(G.x,G.y,G.z),u.push(0,0),u.push(0,0),u.push(0,0);let Be=c++,Ce=c++,_e=c++;if(o.push(Be,Ce,_e),a>0){{let Je=se.clone().add(ae).multiplyScalar(.5),$e=b.clone().sub(Je).normalize(),He=x.clone().sub(Je).normalize().add($e).normalize().multiplyScalar(-1),je=ne.clone().sub(K);H(Je,je,He,M.angle())}let Ze,Qe;{let Je=new I;Lu(T,de,Je);let $e=ne.clone().add(J).multiplyScalar(.5);$e=XW($e,ae,b);let He=ne.clone().sub(J);[Ze,Qe]=H($e,He,Je,R,J.y)}{let Je=Ze,$e=Je.clone().setY(0).normalize(),He=new I(0,-1,0),je=$e.clone().cross(He);X(Je,$e,He,je)}V.concat(Qe);{let Je=M.angle(),$e=Math.PI-Je,He=b.clone();He.y-=a/Math.sin(Je-Math.PI/2);let je=new I,ot=[];for(let Q=0;Q<n;Q++){let j=[],ge=Math.PI/2-$e*Q/n,Ne=Math.cos(ge),Te=Math.sin(ge),Ge=ie;for(let lt=0;lt<=Q;lt++){let Ve=Math.cos(Ge),De=Math.sin(Ge);G.x=Ne*De,G.y=Te,G.z=Ne*Ve,je.copy(He).addScaledVector(G,a),l.push(je.x,je.y,je.z),h.push(G.x,G.y,G.z),u.push(0,0),j.push(c++),Ge+=Math.PI*2/Q/i}ot.push(j)}Qe.reverse(),ot.push(Qe);let gt=ot.length-1;for(let Q=0;Q<gt;Q++){let j=ot[Q],ge=ot[Q+1],Ne=j.length-1;o.push(ge[1],j[0],ge[0]);for(let Te=1;Te<=Ne;Te++)o.push(j[Te],j[Te-1],ge[Te]),o.push(ge[Te+1],j[Te],ge[Te])}}}}}this.setIndex(o),this.setAttribute("position",new et(l,3)),this.setAttribute("normal",new et(h,3)),this.setAttribute("uv",new et(u,2));function H(G,se,ae,J,K){let ne=-J/2,te=(Math.PI-J)/2,oe=se.clone().normalize().cross(ae);G.addScaledVector(ae,-a/Math.sin(te));let ie=new I,be=new I,ue=1,ye=c,de=[];for(let Be=0;Be<=n;Be++){let Ce=ne+Be/n*J;be.set(0,0,0),be.addScaledVector(oe,Math.sin(Ce)),be.addScaledVector(ae,Math.cos(Ce));for(let _e=0;_e<=ue;_e++){let Ze=_e/ue-.5;if(ie.copy(G),ie.addScaledVector(se,Ze),ie.addScaledVector(be,a),K!=null){let Qe=Math.max(0,ie.y-K);ie.addScaledVector(se,-Qe/se.y)}l.push(ie.x,ie.y,ie.z),h.push(be.x,be.y,be.z),u.push(0,0),_e===0&&de.push(c),c++}}for(let Be=0;Be<n;Be++)for(let Ce=0;Ce<ue;Ce++){let _e=ye+Ce+(ue+1)*Be,Ze=_e+(ue+1),Qe=Ze+1,Je=_e+1;o.push(_e,Ze,Je),o.push(Ze,Qe,Je)}return[G.clone().addScaledVector(se,.5),de]}function X(G,se,ae,J){let K=Math.PI/2,ne=C.angle()-K,te=[],oe=new I,ie=new I;for(let ue=0;ue<=n;ue++){let ye=[],de=ue/n;for(let Be=0;Be<=ue;Be++){let Ce=((ue?Be/ue:0)-.5)*y,_e=Math.cos(Ce),Ze=Math.sin(Ce),Qe=Math.atan(Math.tan(ne)*_e),Je=(K+Qe)*de,$e=Math.cos(Je),He=Math.sin(Je);oe.set(0,0,0),oe.addScaledVector(se,He*_e),oe.addScaledVector(ae,$e),oe.addScaledVector(J,He*Ze),ie.copy(G).addScaledVector(oe,a),l.push(ie.x,ie.y,ie.z),h.push(oe.x,oe.y,oe.z),u.push(0,0),ye.push(c++)}te.push(ye)}let be=te.length-1;for(let ue=0;ue<be;ue++){let ye=te[ue],de=te[ue+1],Be=ye.length-1;o.push(ye[0],de[1],de[0]);for(let Ce=1;Ce<=Be;Ce++)o.push(ye[Ce-1],ye[Ce],de[Ce]),o.push(ye[Ce],de[Ce+1],de[Ce])}}}},rb=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 Hi?e.shape:new Hi,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},u={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function d(_,S,M){return S>i&&M>r?Math.min(_*i/S,_*r/M):S>i?_*i/S:M>r?_*r/M:_}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=u.x,m=c.x,v=c.y,y=u.y;t.addPoint(t.createPoint(f,v)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let x=!0;for(let _=0,S=t.points.length;_<S;_++)t.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(x=!1);x&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let b=ih.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},QW=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=st.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,u;return h===0?(u=new ut,u.setAttribute("position",new et([],3))):u=new oc(.5*t,s,a,n,o,l,h*st.DEG2RAD),u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},ZW=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 Jl(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},KW=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 JW(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},JW=class extends ut{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 u=[],c=Math.PI/2,d=(be=0,ue=0,ye=0)=>new I(be,ue,ye),p=d(),f=d(),[m,v,y]=[t/2,e/2,i/2],x=-v,b=+v,[_,S,M]=[d(x,-m,+y),d(x,-m,-y),d(x,+m,-y)],C=(be,ue=!1)=>Math.sin(be-Math.PI/(1+ +ue)),A=(be,ue=!1)=>Math.cos(be-Math.PI/(1+ +ue));M.y=Math.sin(r)*t-m;let T=Math.cos(r)*t-y,P=_.z-h;r<=c?(M.z=Math.min(T,P),M.z==P&&(M.y-=(T-P)/Math.tan(c-r))):S.z=Math.min(S.z-T-y,_.z-h),p.subVectors(_,S),f.subVectors(M,S);let R=Math.min(p.length(),f.length())*s/100,z=R*Math.tan(r/2),N=R/Math.cos(r/2),B=p.clone().normalize().add(f.normalize()).setLength(N).add(S);p.set(0,C(r,!0),A(r,!0)),u.push([M,p.clone()]);let V=(Math.PI-r)/a;for(let be=0;be<=a;be++){let ue=c+r+be*V;p.set(0,Math.sin(ue)*z,Math.cos(ue)*z),p.add(B),f.set(0,C(ue),A(ue)),u.push([p.clone(),f.clone()])}u.push([_,d(0,1,0)]);let H=Math.sin(V/2)*z*2,X=u.length-1,G=u[0][0].distanceTo(u[1][0]),se=u[X-1][0].distanceTo(u[X][0]),ae=G+H*a+se;u[0].push(1);for(let be=0;be<=a;be++)u[be+1].push(1-(G+be*H)/ae);u[X].push(0);let[J,K,ne]=u[0],te,oe,ie;for(let be=1;be<u.length;be++)[te,oe,ie]=u[be],n.push(x,J.y,J.z,x,te.y,te.z,b,J.y,J.z,b,J.y,J.z,x,te.y,te.z,b,te.y,te.z),o.push(0,K.y,K.z,0,oe.y,oe.z,0,K.y,K.z,0,K.y,K.z,0,oe.y,oe.z,0,oe.y,oe.z),l.push(0,ne,0,ie,1,ne,1,ne,0,ie,1,ie),[J,K,ne]=[te,oe,ie];this.setAttribute("position",new et(n,3)),this.setAttribute("normal",new et(o,3)),this.setAttribute("uv",new et(l,2))}},y3=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 Hi?e.shape:new Hi,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,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,m=n*Math.PI/360/s,v=Math.PI/2*3*-1,y=c*r/100,x=d*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let _=0;_<s;_++){let S=m*_,M=p+Math.sin(S)*c,C=f+Math.cos(S)*d;u.addPoint(u.createPoint(M,C))}}else for(let _=0;_<s;_++){let S=p+Math.cos(v)*c,M=f+Math.sin(v)*d;u.addPoint(u.createPoint(S,M)),v+=m,S=p+Math.cos(v)*y,M=f+Math.sin(v)*x,_<=s,u.addPoint(u.createPoint(S,M)),v+=m}u.isClosed=!0;for(let _=0,S=u.points.length;_<S;_++)u.points[_].roundness=a;u.roundness=a,u.update();let b=ih.create({shape:u,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},$W=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 Jl(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},e7=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),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=t7(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 t7(e,t,i,r,s,a,n,o,l,h,u){[t,i]=[i,t],n=t/2;let c=st.clamp(s/360,0,1);if(c===0){let d=new ut;return d.setAttribute("position",new et([],3)),d}return c===1&&(h=0),new m3(!0,e,t,i,r,c,a,n,o,l,h,u)}var i7=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 mC(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},r7=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 Hi?e.shape:new Hi,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,u=i*.5;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let c=ih.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function s7(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var a7=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)})}},n7=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)})}},Me=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Me.version}static addUnaryOp(e){return Me.max_unop_len=Math.max(e.length,Me.max_unop_len),Me.unary_ops[e]=1,Me}static addBinaryOp(e,t,i){return Me.max_binop_len=Math.max(e.length,Me.max_binop_len),Me.binary_ops[e]=t,i?Me.right_associative.add(e):Me.right_associative.delete(e),Me}static addIdentifierChar(e){return Me.additional_identifier_chars.add(e),Me}static addLiteral(e,t){return Me.literals[e]=t,Me}static removeUnaryOp(e){return delete Me.unary_ops[e],e.length===Me.max_unop_len&&(Me.max_unop_len=Me.getMaxKeyLen(Me.unary_ops)),Me}static removeAllUnaryOps(){return Me.unary_ops={},Me.max_unop_len=0,Me}static removeIdentifierChar(e){return Me.additional_identifier_chars.delete(e),Me}static removeBinaryOp(e){return delete Me.binary_ops[e],e.length===Me.max_binop_len&&(Me.max_binop_len=Me.getMaxKeyLen(Me.binary_ops)),Me.right_associative.delete(e),Me}static removeAllBinaryOps(){return Me.binary_ops={},Me.max_binop_len=0,Me}static removeLiteral(e){return delete Me.literals[e],Me}static removeAllLiterals(){return Me.literals={},Me}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 Me(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 Me.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Me.binary_ops[String.fromCharCode(e)]||Me.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Me.isIdentifierStart(e)||Me.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(Me.hooks[e]){let i={context:this,node:t};return Me.hooks.run(e,i),i.node}return t}searchHook(e){if(Me.hooks[e]){let t={context:this};return Me.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===Me.SPACE_CODE||e===Me.TAB_CODE||e===Me.LF_CODE||e===Me.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:Me.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===Me.SEMCOL_CODE||i===Me.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,Me.max_binop_len),t=e.length;for(;t>0;){if(Me.binary_ops.hasOwnProperty(e)&&(!Me.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Me.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:Me.binaryPrecedence(t),right_a:Me.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=Me.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:Me.right_associative.has(t)},l=t;let h=u=>s.right_a&&u.right_a?i>u.prec:i<=u.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:Me.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:Me.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,Me.isDecimalDigit(e)||e===Me.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===Me.SQUOTE_CODE||e===Me.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===Me.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,Me.max_unop_len),i=t.length;i>0;){if(Me.unary_ops.hasOwnProperty(t)&&(!Me.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Me.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:Me.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}Me.isIdentifierStart(e)?(r=this.gobbleIdentifier(),Me.literals.hasOwnProperty(r.name)?r={type:Me.LITERAL,value:Me.literals[r.name],raw:r.name}:r.name===Me.this_str&&(r={type:Me.THIS_EXP})):e===Me.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===Me.PERIOD_CODE||t===Me.OBRACK_CODE||t===Me.OPAREN_CODE||t===Me.QUMARK_CODE;){let i;if(t===Me.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Me.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===Me.OBRACK_CODE?(e={type:Me.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==Me.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===Me.OPAREN_CODE?e={type:Me.CALL_EXP,arguments:this.gobbleArguments(Me.CPAREN_CODE),callee:e}:(t===Me.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:Me.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(;Me.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===Me.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);Me.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++));Me.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);Me.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,Me.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===Me.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Me.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Me.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+=`
|
|
3154
|
+
}`;function Gz(e,t,i){let r=new lx,s=new $,a=new $,n=new Et,o=new tC({depthPacking:VE}),l=new Uz,h={},u=i.maxTextureSize,c={[ka]:Or,[Or]:ka,[Rs]:Rs},d=new ni({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $},radius:{value:4}},vertexShader:Vz,fragmentShader:jz}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new ut;f.setAttribute("position",new At(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new yr(f,d),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ix,this.render=function(_,S,M){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||_.length===0)return;let C=e.getRenderTarget(),A=e.getActiveCubeFace(),T=e.getActiveMipmapLevel(),P=e.state;P.setBlending(hr),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 N=_[R],B=N.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",N,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;s.copy(B.mapSize);let V=B.getFrameExtents();if(s.multiply(V),a.copy(B.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(a.x=Math.floor(u/V.x),s.x=a.x*V.x,B.mapSize.x=a.x),s.y>u&&(a.y=Math.floor(u/V.y),s.y=a.y*V.y,B.mapSize.y=a.y)),B.map===null){let X=this.type!==qu?{minFilter:si,magFilter:si}:{};B.map=new ai(s.x,s.y,X),B.map.texture.name=N.name+".shadowMap",B.camera.updateProjectionMatrix()}e.setRenderTarget(B.map),e.clear();let H=B.getViewportCount();for(let X=0;X<H;X++){let G=B.getViewport(X);n.set(a.x*G.x,a.y*G.y,a.x*G.z,a.y*G.w),P.viewport(n),B.updateMatrices(N,X),r=B.getFrustum(),b(S,M,B.camera,N,this.type)}B.isPointLightShadow!==!0&&this.type===qu&&y(B,M),B.needsUpdate=!1}v.needsUpdate=!1,e.setRenderTarget(C,A,T)};function y(_,S){let M=t.update(m);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 ai(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(S,null,M,d,m,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(S,null,M,p,m,null)}function x(_,S,M,C,A,T){let P=null,R=M.isPointLight===!0?_.customDistanceMaterial:_.customDepthMaterial;if(R!==void 0)P=R;else if(P=M.isPointLight===!0?l:o,e.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0){let z=P.uuid,N=S.uuid,B=h[z];B===void 0&&(B={},h[z]=B);let V=B[N];V===void 0&&(V=P.clone(),B[N]=V),P=V}return P.visible=S.visible,P.wireframe=S.wireframe,T===qu?P.side=S.shadowSide!==null?S.shadowSide:S.side:P.side=S.shadowSide!==null?S.shadowSide:c[S.side],P.alphaMap=S.alphaMap,P.alphaTest=S.alphaTest,P.map=S.map,P.clipShadows=S.clipShadows,P.clippingPlanes=S.clippingPlanes,P.clipIntersection=S.clipIntersection,P.displacementMap=S.displacementMap,P.displacementScale=S.displacementScale,P.displacementBias=S.displacementBias,P.wireframeLinewidth=S.wireframeLinewidth,P.linewidth=S.linewidth,M.isPointLight===!0&&P.isMeshDistanceMaterial===!0&&(P.referencePosition.setFromMatrixPosition(M.matrixWorld),P.nearDistance=C,P.farDistance=A),P}function b(_,S,M,C,A){if(_.visible===!1)return;if(_.layers.test(S.layers)&&(_.isMesh||_.isLine||_.isPoints)&&(_.castShadow||_.receiveShadow&&A===qu)&&(!_.frustumCulled||r.intersectsObject(_))){_.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,_.matrixWorld);let P=t.update(_),R=_.material;if(Array.isArray(R)){let z=P.groups;for(let N=0,B=z.length;N<B;N++){let V=z[N],H=R[V.materialIndex];if(H&&H.visible){let X=x(_,H,C,M.near,M.far,A);e.renderBufferDirect(M,null,P,X,_,V)}}}else if(R.visible){let z=x(_,R,C,M.near,M.far,A);e.renderBufferDirect(M,null,P,z,_,null)}}let T=_.children;for(let P=0,R=T.length;P<R;P++)b(T[P],S,M,C,A)}}function Hz(e,t,i){let r=i.isWebGL2;function s(){let ce=!1,we=new Et,Ue=null,We=new Et(0,0,0,0);return{setMask:function(pt){Ue!==pt&&!ce&&(e.colorMask(pt,pt,pt,pt),Ue=pt)},setLocked:function(pt){ce=pt},setClear:function(pt,$t,xi,ki,Zr){Zr===!0&&(pt*=ki,$t*=ki,xi*=ki),we.set(pt,$t,xi,ki),We.equals(we)===!1&&(e.clearColor(pt,$t,xi,ki),We.copy(we))},reset:function(){ce=!1,Ue=null,We.set(-1,0,0,0)}}}function a(){let ce=!1,we=null,Ue=null,We=null;return{setTest:function(pt){pt?be(2929):ue(2929)},setMask:function(pt){we!==pt&&!ce&&(e.depthMask(pt),we=pt)},setFunc:function(pt){if(Ue!==pt){switch(pt){case cI:e.depthFunc(512);break;case uI:e.depthFunc(519);break;case dI:e.depthFunc(513);break;case ty:e.depthFunc(515);break;case pI:e.depthFunc(514);break;case fI:e.depthFunc(518);break;case mI:e.depthFunc(516);break;case gI:e.depthFunc(517);break;default:e.depthFunc(515)}Ue=pt}},setLocked:function(pt){ce=pt},setClear:function(pt){We!==pt&&(e.clearDepth(pt),We=pt)},reset:function(){ce=!1,we=null,Ue=null,We=null}}}function n(){let ce=!1,we=null,Ue=null,We=null,pt=null,$t=null,xi=null,ki=null,Zr=null;return{setTest:function(Si){ce||(Si?be(2960):ue(2960))},setMask:function(Si){we!==Si&&!ce&&(e.stencilMask(Si),we=Si)},setFunc:function(Si,Ns,Kr){(Ue!==Si||We!==Ns||pt!==Kr)&&(e.stencilFunc(Si,Ns,Kr),Ue=Si,We=Ns,pt=Kr)},setOp:function(Si,Ns,Kr){($t!==Si||xi!==Ns||ki!==Kr)&&(e.stencilOp(Si,Ns,Kr),$t=Si,xi=Ns,ki=Kr)},setLocked:function(Si){ce=Si},setClear:function(Si){Zr!==Si&&(e.clearStencil(Si),Zr=Si)},reset:function(){ce=!1,we=null,Ue=null,We=null,pt=null,$t=null,xi=null,ki=null,Zr=null}}}let o=new s,l=new a,h=new n,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,m=[],v=null,y=!1,x=null,b=null,_=null,S=null,M=null,C=null,A=null,T=!1,P=null,R=null,z=null,N=null,B=null,V=e.getParameter(35661),H=!1,X=0,G=e.getParameter(7938);G.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(G)[1]),H=X>=1):G.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=X>=2);let se=null,ae={},J=e.getParameter(3088),K=e.getParameter(2978),ne=new Et().fromArray(J),te=new Et().fromArray(K);function oe(ce,we,Ue){let We=new Uint8Array(4),pt=e.createTexture();e.bindTexture(ce,pt),e.texParameteri(ce,10241,9728),e.texParameteri(ce,10240,9728);for(let $t=0;$t<Ue;$t++)e.texImage2D(we+$t,0,6408,1,1,0,6408,5121,We);return pt}let ie={};ie[3553]=oe(3553,3553,1),ie[34067]=oe(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),be(2929),l.setFunc(ty),Je(!1),$e(Rw),be(2884),Ze(hr);function be(ce){d[ce]!==!0&&(e.enable(ce),d[ce]=!0)}function ue(ce){d[ce]!==!1&&(e.disable(ce),d[ce]=!1)}function ye(ce,we){return p[ce]!==we?(e.bindFramebuffer(ce,we),p[ce]=we,r&&(ce===36009&&(p[36160]=we),ce===36160&&(p[36009]=we)),!0):!1}function de(ce,we){let Ue=m,We=!1;if(ce)if(Ue=f.get(we),Ue===void 0&&(Ue=[],f.set(we,Ue)),ce.isWebGLMultipleRenderTargets){let pt=ce.texture;if(Ue.length!==pt.length||Ue[0]!==36064){for(let $t=0,xi=pt.length;$t<xi;$t++)Ue[$t]=36064+$t;Ue.length=pt.length,We=!0}}else Ue[0]!==36064&&(Ue[0]=36064,We=!0);else Ue[0]!==1029&&(Ue[0]=1029,We=!0);We&&(i.isWebGL2?e.drawBuffers(Ue):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ue))}function Be(ce){return v!==ce?(e.useProgram(ce),v=ce,!0):!1}let Ce={[Xh]:32774,[$O]:32778,[eI]:32779};if(r)Ce[kw]=32775,Ce[Nw]=32776;else{let ce=t.get("EXT_blend_minmax");ce!==null&&(Ce[kw]=ce.MIN_EXT,Ce[Nw]=ce.MAX_EXT)}let _e={[tI]:0,[iI]:1,[rI]:768,[RE]:770,[hI]:776,[oI]:774,[aI]:772,[sI]:769,[BE]:771,[lI]:775,[nI]:773};function Ze(ce,we,Ue,We,pt,$t,xi,ki){if(ce===hr){y===!0&&(ue(3042),y=!1);return}if(y===!1&&(be(3042),y=!0),ce!==JO){if(ce!==x||ki!==T){if((b!==Xh||M!==Xh)&&(e.blendEquation(32774),b=Xh,M=Xh),ki)switch(ce){case Bl:e.blendFuncSeparate(1,771,1,771);break;case Bw:e.blendFunc(1,1);break;case Lw:e.blendFuncSeparate(0,769,0,1);break;case zw:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",ce);break}else switch(ce){case Bl:e.blendFuncSeparate(770,771,1,771);break;case Bw:e.blendFunc(770,1);break;case Lw:e.blendFuncSeparate(0,769,0,1);break;case zw:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",ce);break}_=null,S=null,C=null,A=null,x=ce,T=ki}return}pt=pt||we,$t=$t||Ue,xi=xi||We,(we!==b||pt!==M)&&(e.blendEquationSeparate(Ce[we],Ce[pt]),b=we,M=pt),(Ue!==_||We!==S||$t!==C||xi!==A)&&(e.blendFuncSeparate(_e[Ue],_e[We],_e[$t],_e[xi]),_=Ue,S=We,C=$t,A=xi),x=ce,T=!1}function Qe(ce,we){ce.side===Rs?ue(2884):be(2884);let Ue=ce.side===Or;we&&(Ue=!Ue),Je(Ue),ce.blending===Bl&&ce.transparent===!1?Ze(hr):Ze(ce.blending,ce.blendEquation,ce.blendSrc,ce.blendDst,ce.blendEquationAlpha,ce.blendSrcAlpha,ce.blendDstAlpha,ce.premultipliedAlpha),l.setFunc(ce.depthFunc),l.setTest(ce.depthTest),l.setMask(ce.depthWrite),o.setMask(ce.colorWrite);let We=ce.stencilWrite;h.setTest(We),We&&(h.setMask(ce.stencilWriteMask),h.setFunc(ce.stencilFunc,ce.stencilRef,ce.stencilFuncMask),h.setOp(ce.stencilFail,ce.stencilZFail,ce.stencilZPass)),je(ce.polygonOffset,ce.polygonOffsetFactor,ce.polygonOffsetUnits),ce.alphaToCoverage===!0?be(32926):ue(32926)}function Je(ce){P!==ce&&(ce?e.frontFace(2304):e.frontFace(2305),P=ce)}function $e(ce){ce!==QO?(be(2884),ce!==R&&(ce===Rw?e.cullFace(1029):ce===ZO?e.cullFace(1028):e.cullFace(1032))):ue(2884),R=ce}function He(ce){ce!==z&&(H&&e.lineWidth(ce),z=ce)}function je(ce,we,Ue){ce?(be(32823),(N!==we||B!==Ue)&&(e.polygonOffset(we,Ue),N=we,B=Ue)):ue(32823)}function ot(ce){ce?be(3089):ue(3089)}function gt(ce){ce===void 0&&(ce=33984+V-1),se!==ce&&(e.activeTexture(ce),se=ce)}function Q(ce,we,Ue){Ue===void 0&&(se===null?Ue=33984+V-1:Ue=se);let We=ae[Ue];We===void 0&&(We={type:void 0,texture:void 0},ae[Ue]=We),(We.type!==ce||We.texture!==we)&&(se!==Ue&&(e.activeTexture(Ue),se=Ue),e.bindTexture(ce,we||ie[ce]),We.type=ce,We.texture=we)}function j(){let ce=ae[se];ce!==void 0&&ce.type!==void 0&&(e.bindTexture(ce.type,null),ce.type=void 0,ce.texture=void 0)}function ge(){try{e.compressedTexImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ne(){try{e.compressedTexImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Te(){try{e.texSubImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ge(){try{e.texSubImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function lt(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ve(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function De(){try{e.texStorage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Fe(){try{e.texStorage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function ht(){try{e.texImage2D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function Ke(){try{e.texImage3D.apply(e,arguments)}catch(ce){console.error("THREE.WebGLState:",ce)}}function vt(ce){ne.equals(ce)===!1&&(e.scissor(ce.x,ce.y,ce.z,ce.w),ne.copy(ce))}function dt(ce){te.equals(ce)===!1&&(e.viewport(ce.x,ce.y,ce.z,ce.w),te.copy(ce))}function Wt(ce,we){let Ue=c.get(we);Ue===void 0&&(Ue=new WeakMap,c.set(we,Ue));let We=Ue.get(ce);We===void 0&&(We=e.getUniformBlockIndex(we,ce.name),Ue.set(ce,We))}function ui(ce,we){let Ue=c.get(we).get(ce);u.get(we)!==Ue&&(e.uniformBlockBinding(we,Ue,ce.__bindingPointIndex),u.set(we,Ue))}function Di(){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,ae={},p={},f=new WeakMap,m=[],v=null,y=!1,x=null,b=null,_=null,S=null,M=null,C=null,A=null,T=!1,P=null,R=null,z=null,N=null,B=null,ne.set(0,0,e.canvas.width,e.canvas.height),te.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:be,disable:ue,bindFramebuffer:ye,drawBuffers:de,useProgram:Be,setBlending:Ze,setMaterial:Qe,setFlipSided:Je,setCullFace:$e,setLineWidth:He,setPolygonOffset:je,setScissorTest:ot,activeTexture:gt,bindTexture:Q,unbindTexture:j,compressedTexImage2D:ge,compressedTexImage3D:Ne,texImage2D:ht,texImage3D:Ke,updateUBOMapping:Wt,uniformBlockBinding:ui,texStorage2D:De,texStorage3D:Fe,texSubImage2D:Te,texSubImage3D:Ge,compressedTexSubImage2D:lt,compressedTexSubImage3D:Ve,scissor:vt,viewport:dt,reset:Di}}function Wz(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,u=s.maxTextureSize,c=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,m,v=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(Q,j){return y?new OffscreenCanvas(Q,j):gd("canvas")}function b(Q,j,ge,Ne){let Te=1;if((Q.width>Ne||Q.height>Ne)&&(Te=Ne/Math.max(Q.width,Q.height)),Te<1||j===!0)if(typeof HTMLImageElement<"u"&&Q instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Q instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Q instanceof ImageBitmap){let Ge=j?lm:Math.floor,lt=Ge(Te*Q.width),Ve=Ge(Te*Q.height);m===void 0&&(m=x(lt,Ve));let De=ge?x(lt,Ve):m;return De.width=lt,De.height=Ve,De.getContext("2d").drawImage(Q,0,0,lt,Ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+lt+"x"+Ve+")."),De}else return"data"in Q&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),Q;return Q}function _(Q){return oy(Q.width)&&oy(Q.height)}function S(Q){return o?!1:Q.wrapS!==Pi||Q.wrapT!==Pi||Q.minFilter!==si&&Q.minFilter!==zt}function M(Q,j){return Q.generateMipmaps&&j&&Q.minFilter!==si&&Q.minFilter!==zt}function C(Q){e.generateMipmap(Q)}function A(Q,j,ge,Ne,Te=!1){if(o===!1)return j;if(Q!==null){if(e[Q]!==void 0)return e[Q];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Q+"'")}let Ge=j;return j===6403&&(ge===5126&&(Ge=33326),ge===5131&&(Ge=33325),ge===5121&&(Ge=33321)),j===33319&&(ge===5126&&(Ge=33328),ge===5131&&(Ge=33327),ge===5121&&(Ge=33323)),j===6408&&(ge===5126&&(Ge=34836),ge===5131&&(Ge=34842),ge===5121&&(Ge=Ne===Rt&&Te===!1?35907:32856),ge===32819&&(Ge=32854),ge===32820&&(Ge=32855)),(Ge===33325||Ge===33326||Ge===33327||Ge===33328||Ge===34842||Ge===34836)&&t.get("EXT_color_buffer_float"),Ge}function T(Q,j,ge){return M(Q,ge)===!0||Q.isFramebufferTexture&&Q.minFilter!==si&&Q.minFilter!==zt?Math.log2(Math.max(j.width,j.height))+1:Q.mipmaps!==void 0&&Q.mipmaps.length>0?Q.mipmaps.length:Q.isCompressedTexture&&Array.isArray(Q.image)?j.mipmaps.length:1}function P(Q){return Q===si||Q===Fw||Q===Qg?9728:9729}function R(Q){let j=Q.target;j.removeEventListener("dispose",R),N(j),j.isVideoTexture&&f.delete(j)}function z(Q){let j=Q.target;j.removeEventListener("dispose",z),V(j)}function N(Q){let j=r.get(Q);if(j.__webglInit===void 0)return;let ge=Q.source,Ne=v.get(ge);if(Ne){let Te=Ne[j.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&B(Q),Object.keys(Ne).length===0&&v.delete(ge)}r.remove(Q)}function B(Q){let j=r.get(Q);e.deleteTexture(j.__webglTexture);let ge=Q.source,Ne=v.get(ge);delete Ne[j.__cacheKey],n.memory.textures--}function V(Q){let j=Q.texture,ge=r.get(Q),Ne=r.get(j);if(Ne.__webglTexture!==void 0&&(e.deleteTexture(Ne.__webglTexture),n.memory.textures--),Q.depthTexture&&Q.depthTexture.dispose(),Q.isWebGLCubeRenderTarget)for(let Te=0;Te<6;Te++)e.deleteFramebuffer(ge.__webglFramebuffer[Te]),ge.__webglDepthbuffer&&e.deleteRenderbuffer(ge.__webglDepthbuffer[Te]);else{if(e.deleteFramebuffer(ge.__webglFramebuffer),ge.__webglDepthbuffer&&e.deleteRenderbuffer(ge.__webglDepthbuffer),ge.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ge.__webglMultisampledFramebuffer),ge.__webglColorRenderbuffer)for(let Te=0;Te<ge.__webglColorRenderbuffer.length;Te++)ge.__webglColorRenderbuffer[Te]&&e.deleteRenderbuffer(ge.__webglColorRenderbuffer[Te]);ge.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ge.__webglDepthRenderbuffer)}if(Q.isWebGLMultipleRenderTargets)for(let Te=0,Ge=j.length;Te<Ge;Te++){let lt=r.get(j[Te]);lt.__webglTexture&&(e.deleteTexture(lt.__webglTexture),n.memory.textures--),r.remove(j[Te])}r.remove(j),r.remove(Q)}let H=0;function X(){H=0}function G(){let Q=H;return Q>=l&&console.warn("THREE.WebGLTextures: Trying to use "+Q+" texture units while this GPU supports only "+l),H+=1,Q}function se(Q){let j=[];return j.push(Q.wrapS),j.push(Q.wrapT),j.push(Q.wrapR||0),j.push(Q.magFilter),j.push(Q.minFilter),j.push(Q.anisotropy),j.push(Q.internalFormat),j.push(Q.format),j.push(Q.type),j.push(Q.generateMipmaps),j.push(Q.premultiplyAlpha),j.push(Q.flipY),j.push(Q.unpackAlignment),j.push(Q.encoding),j.join()}function ae(Q,j){let ge=r.get(Q);if(Q.isVideoTexture&&ot(Q),Q.isRenderTargetTexture===!1&&Q.version>0&&ge.__version!==Q.version){let Ne=Q.image;if(Ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ue(ge,Q,j);return}}i.bindTexture(3553,ge.__webglTexture,33984+j)}function J(Q,j){let ge=r.get(Q);if(Q.version>0&&ge.__version!==Q.version){ue(ge,Q,j);return}i.bindTexture(35866,ge.__webglTexture,33984+j)}function K(Q,j){let ge=r.get(Q);if(Q.version>0&&ge.__version!==Q.version){ue(ge,Q,j);return}i.bindTexture(32879,ge.__webglTexture,33984+j)}function ne(Q,j){let ge=r.get(Q);if(Q.version>0&&ge.__version!==Q.version){ye(ge,Q,j);return}i.bindTexture(34067,ge.__webglTexture,33984+j)}let te={[eo]:10497,[Pi]:33071,[sy]:33648},oe={[si]:9728,[Fw]:9984,[Qg]:9986,[zt]:9729,[AI]:9985,[_c]:9987};function ie(Q,j,ge){if(ge?(e.texParameteri(Q,10242,te[j.wrapS]),e.texParameteri(Q,10243,te[j.wrapT]),(Q===32879||Q===35866)&&e.texParameteri(Q,32882,te[j.wrapR]),e.texParameteri(Q,10240,oe[j.magFilter]),e.texParameteri(Q,10241,oe[j.minFilter])):(e.texParameteri(Q,10242,33071),e.texParameteri(Q,10243,33071),(Q===32879||Q===35866)&&e.texParameteri(Q,32882,33071),(j.wrapS!==Pi||j.wrapT!==Pi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(Q,10240,P(j.magFilter)),e.texParameteri(Q,10241,P(j.minFilter)),j.minFilter!==si&&j.minFilter!==zt&&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 Ne=t.get("EXT_texture_filter_anisotropic");if(j.magFilter===si||j.minFilter!==Qg&&j.minFilter!==_c||j.type===lr&&t.has("OES_texture_float_linear")===!1||o===!1&&j.type===Hl&&t.has("OES_texture_half_float_linear")===!1)return;(j.anisotropy>1||r.get(j).__currentAnisotropy)&&(e.texParameterf(Q,Ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,s.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy)}}function be(Q,j){let ge=!1;Q.__webglInit===void 0&&(Q.__webglInit=!0,j.addEventListener("dispose",R));let Ne=j.source,Te=v.get(Ne);Te===void 0&&(Te={},v.set(Ne,Te));let Ge=se(j);if(Ge!==Q.__cacheKey){Te[Ge]===void 0&&(Te[Ge]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,ge=!0),Te[Ge].usedTimes++;let lt=Te[Q.__cacheKey];lt!==void 0&&(Te[Q.__cacheKey].usedTimes--,lt.usedTimes===0&&B(j)),Q.__cacheKey=Ge,Q.__webglTexture=Te[Ge].texture}return ge}function ue(Q,j,ge){let Ne=3553;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(Ne=35866),j.isData3DTexture&&(Ne=32879);let Te=be(Q,j),Ge=j.source;i.bindTexture(Ne,Q.__webglTexture,33984+ge);let lt=r.get(Ge);if(Ge.version!==lt.__version||Te===!0){i.activeTexture(33984+ge),e.pixelStorei(37440,j.flipY),e.pixelStorei(37441,j.premultiplyAlpha),e.pixelStorei(3317,j.unpackAlignment),e.pixelStorei(37443,0);let Ve=S(j)&&_(j.image)===!1,De=b(j.image,Ve,!1,u);De=gt(j,De);let Fe=_(De)||o,ht=a.convert(j.format,j.encoding),Ke=a.convert(j.type),vt=A(j.internalFormat,ht,Ke,j.encoding,j.isVideoTexture);ie(Ne,j,Fe);let dt,Wt=j.mipmaps,ui=o&&j.isVideoTexture!==!0,Di=lt.__version===void 0||Te===!0,ce=T(j,De,Fe);if(j.isDepthTexture)vt=6402,o?j.type===lr?vt=36012:j.type===to?vt=33190:j.type===Ll?vt=35056:vt=33189:j.type===lr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),j.format===zl&&vt===6402&&j.type!==kE&&j.type!==to&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),j.type=to,Ke=a.convert(j.type)),j.format===Wl&&vt===6402&&(vt=34041,j.type!==Ll&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),j.type=Ll,Ke=a.convert(j.type))),Di&&(ui?i.texStorage2D(3553,1,vt,De.width,De.height):i.texImage2D(3553,0,vt,De.width,De.height,0,ht,Ke,null));else if(j.isDataTexture)if(Wt.length>0&&Fe){ui&&Di&&i.texStorage2D(3553,ce,vt,Wt[0].width,Wt[0].height);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],ui?i.texSubImage2D(3553,we,0,0,dt.width,dt.height,ht,Ke,dt.data):i.texImage2D(3553,we,vt,dt.width,dt.height,0,ht,Ke,dt.data);j.generateMipmaps=!1}else ui?(Di&&i.texStorage2D(3553,ce,vt,De.width,De.height),i.texSubImage2D(3553,0,0,0,De.width,De.height,ht,Ke,De.data)):i.texImage2D(3553,0,vt,De.width,De.height,0,ht,Ke,De.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){ui&&Di&&i.texStorage3D(35866,ce,vt,Wt[0].width,Wt[0].height,De.depth);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],j.format!==Pr?ht!==null?ui?i.compressedTexSubImage3D(35866,we,0,0,0,dt.width,dt.height,De.depth,ht,dt.data,0,0):i.compressedTexImage3D(35866,we,vt,dt.width,dt.height,De.depth,0,dt.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ui?i.texSubImage3D(35866,we,0,0,0,dt.width,dt.height,De.depth,ht,Ke,dt.data):i.texImage3D(35866,we,vt,dt.width,dt.height,De.depth,0,ht,Ke,dt.data)}else{ui&&Di&&i.texStorage2D(3553,ce,vt,Wt[0].width,Wt[0].height);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],j.format!==Pr?ht!==null?ui?i.compressedTexSubImage2D(3553,we,0,0,dt.width,dt.height,ht,dt.data):i.compressedTexImage2D(3553,we,vt,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ui?i.texSubImage2D(3553,we,0,0,dt.width,dt.height,ht,Ke,dt.data):i.texImage2D(3553,we,vt,dt.width,dt.height,0,ht,Ke,dt.data)}else if(j.isDataArrayTexture)ui?(Di&&i.texStorage3D(35866,ce,vt,De.width,De.height,De.depth),i.texSubImage3D(35866,0,0,0,0,De.width,De.height,De.depth,ht,Ke,De.data)):i.texImage3D(35866,0,vt,De.width,De.height,De.depth,0,ht,Ke,De.data);else if(j.isData3DTexture)ui?(Di&&i.texStorage3D(32879,ce,vt,De.width,De.height,De.depth),i.texSubImage3D(32879,0,0,0,0,De.width,De.height,De.depth,ht,Ke,De.data)):i.texImage3D(32879,0,vt,De.width,De.height,De.depth,0,ht,Ke,De.data);else if(j.isFramebufferTexture){if(Di)if(ui)i.texStorage2D(3553,ce,vt,De.width,De.height);else{let we=De.width,Ue=De.height;for(let We=0;We<ce;We++)i.texImage2D(3553,We,vt,we,Ue,0,ht,Ke,null),we>>=1,Ue>>=1}}else if(Wt.length>0&&Fe){ui&&Di&&i.texStorage2D(3553,ce,vt,Wt[0].width,Wt[0].height);for(let we=0,Ue=Wt.length;we<Ue;we++)dt=Wt[we],ui?i.texSubImage2D(3553,we,0,0,ht,Ke,dt):i.texImage2D(3553,we,vt,ht,Ke,dt);j.generateMipmaps=!1}else ui?(Di&&i.texStorage2D(3553,ce,vt,De.width,De.height),i.texSubImage2D(3553,0,0,0,ht,Ke,De)):i.texImage2D(3553,0,vt,ht,Ke,De);M(j,Fe)&&C(Ne),lt.__version=Ge.version,j.onUpdate&&j.onUpdate(j)}Q.__version=j.version}function ye(Q,j,ge){if(j.image.length!==6)return;let Ne=be(Q,j),Te=j.source;i.bindTexture(34067,Q.__webglTexture,33984+ge);let Ge=r.get(Te);if(Te.version!==Ge.__version||Ne===!0){i.activeTexture(33984+ge),e.pixelStorei(37440,j.flipY),e.pixelStorei(37441,j.premultiplyAlpha),e.pixelStorei(3317,j.unpackAlignment),e.pixelStorei(37443,0);let lt=j.isCompressedTexture||j.image[0].isCompressedTexture,Ve=j.image[0]&&j.image[0].isDataTexture,De=[];for(let we=0;we<6;we++)!lt&&!Ve?De[we]=b(j.image[we],!1,!0,h):De[we]=Ve?j.image[we].image:j.image[we],De[we]=gt(j,De[we]);let Fe=De[0],ht=_(Fe)||o,Ke=a.convert(j.format,j.encoding),vt=a.convert(j.type),dt=A(j.internalFormat,Ke,vt,j.encoding),Wt=o&&j.isVideoTexture!==!0,ui=Ge.__version===void 0||Ne===!0,Di=T(j,Fe,ht);ie(34067,j,ht);let ce;if(lt){Wt&&ui&&i.texStorage2D(34067,Di,dt,Fe.width,Fe.height);for(let we=0;we<6;we++){ce=De[we].mipmaps;for(let Ue=0;Ue<ce.length;Ue++){let We=ce[Ue];j.format!==Pr?Ke!==null?Wt?i.compressedTexSubImage2D(34069+we,Ue,0,0,We.width,We.height,Ke,We.data):i.compressedTexImage2D(34069+we,Ue,dt,We.width,We.height,0,We.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Wt?i.texSubImage2D(34069+we,Ue,0,0,We.width,We.height,Ke,vt,We.data):i.texImage2D(34069+we,Ue,dt,We.width,We.height,0,Ke,vt,We.data)}}}else{ce=j.mipmaps,Wt&&ui&&(ce.length>0&&Di++,i.texStorage2D(34067,Di,dt,De[0].width,De[0].height));for(let we=0;we<6;we++)if(Ve){Wt?i.texSubImage2D(34069+we,0,0,0,De[we].width,De[we].height,Ke,vt,De[we].data):i.texImage2D(34069+we,0,dt,De[we].width,De[we].height,0,Ke,vt,De[we].data);for(let Ue=0;Ue<ce.length;Ue++){let We=ce[Ue].image[we].image;Wt?i.texSubImage2D(34069+we,Ue+1,0,0,We.width,We.height,Ke,vt,We.data):i.texImage2D(34069+we,Ue+1,dt,We.width,We.height,0,Ke,vt,We.data)}}else{Wt?i.texSubImage2D(34069+we,0,0,0,Ke,vt,De[we]):i.texImage2D(34069+we,0,dt,Ke,vt,De[we]);for(let Ue=0;Ue<ce.length;Ue++){let We=ce[Ue];Wt?i.texSubImage2D(34069+we,Ue+1,0,0,Ke,vt,We.image[we]):i.texImage2D(34069+we,Ue+1,dt,Ke,vt,We.image[we])}}}M(j,ht)&&C(34067),Ge.__version=Te.version,j.onUpdate&&j.onUpdate(j)}Q.__version=j.version}function de(Q,j,ge,Ne,Te){let Ge=a.convert(ge.format,ge.encoding),lt=a.convert(ge.type),Ve=A(ge.internalFormat,Ge,lt,ge.encoding);r.get(j).__hasExternalTextures||(Te===32879||Te===35866?i.texImage3D(Te,0,Ve,j.width,j.height,j.depth,0,Ge,lt,null):i.texImage2D(Te,0,Ve,j.width,j.height,0,Ge,lt,null)),i.bindFramebuffer(36160,Q),je(j)?d.framebufferTexture2DMultisampleEXT(36160,Ne,Te,r.get(ge).__webglTexture,0,He(j)):(Te===3553||Te>=34069&&Te<=34074)&&e.framebufferTexture2D(36160,Ne,Te,r.get(ge).__webglTexture,0),i.bindFramebuffer(36160,null)}function Be(Q,j,ge){if(e.bindRenderbuffer(36161,Q),j.depthBuffer&&!j.stencilBuffer){let Ne=33189;if(ge||je(j)){let Te=j.depthTexture;Te&&Te.isDepthTexture&&(Te.type===lr?Ne=36012:Te.type===to&&(Ne=33190));let Ge=He(j);je(j)?d.renderbufferStorageMultisampleEXT(36161,Ge,Ne,j.width,j.height):e.renderbufferStorageMultisample(36161,Ge,Ne,j.width,j.height)}else e.renderbufferStorage(36161,Ne,j.width,j.height);e.framebufferRenderbuffer(36160,36096,36161,Q)}else if(j.depthBuffer&&j.stencilBuffer){let Ne=He(j);ge&&je(j)===!1?e.renderbufferStorageMultisample(36161,Ne,35056,j.width,j.height):je(j)?d.renderbufferStorageMultisampleEXT(36161,Ne,35056,j.width,j.height):e.renderbufferStorage(36161,34041,j.width,j.height),e.framebufferRenderbuffer(36160,33306,36161,Q)}else{let Ne=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let Te=0;Te<Ne.length;Te++){let Ge=Ne[Te],lt=a.convert(Ge.format,Ge.encoding),Ve=a.convert(Ge.type),De=A(Ge.internalFormat,lt,Ve,Ge.encoding),Fe=He(j);ge&&je(j)===!1?e.renderbufferStorageMultisample(36161,Fe,De,j.width,j.height):je(j)?d.renderbufferStorageMultisampleEXT(36161,Fe,De,j.width,j.height):e.renderbufferStorage(36161,De,j.width,j.height)}}e.bindRenderbuffer(36161,null)}function Ce(Q,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,Q),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(j.depthTexture).__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),ae(j.depthTexture,0);let ge=r.get(j.depthTexture).__webglTexture,Ne=He(j);if(j.depthTexture.format===zl)je(j)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ge,0,Ne):e.framebufferTexture2D(36160,36096,3553,ge,0);else if(j.depthTexture.format===Wl)je(j)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ge,0,Ne):e.framebufferTexture2D(36160,33306,3553,ge,0);else throw new Error("Unknown depthTexture format")}function _e(Q){let j=r.get(Q),ge=Q.isWebGLCubeRenderTarget===!0;if(Q.depthTexture&&!j.__autoAllocateDepthBuffer){if(ge)throw new Error("target.depthTexture not supported in Cube render targets");Ce(j.__webglFramebuffer,Q)}else if(ge){j.__webglDepthbuffer=[];for(let Ne=0;Ne<6;Ne++)i.bindFramebuffer(36160,j.__webglFramebuffer[Ne]),j.__webglDepthbuffer[Ne]=e.createRenderbuffer(),Be(j.__webglDepthbuffer[Ne],Q,!1)}else i.bindFramebuffer(36160,j.__webglFramebuffer),j.__webglDepthbuffer=e.createRenderbuffer(),Be(j.__webglDepthbuffer,Q,!1);i.bindFramebuffer(36160,null)}function Ze(Q,j,ge){let Ne=r.get(Q);j!==void 0&&de(Ne.__webglFramebuffer,Q,Q.texture,36064,3553),ge!==void 0&&_e(Q)}function Qe(Q){let j=Q.texture,ge=r.get(Q),Ne=r.get(j);Q.addEventListener("dispose",z),Q.isWebGLMultipleRenderTargets!==!0&&(Ne.__webglTexture===void 0&&(Ne.__webglTexture=e.createTexture()),Ne.__version=j.version,n.memory.textures++);let Te=Q.isWebGLCubeRenderTarget===!0,Ge=Q.isWebGLMultipleRenderTargets===!0,lt=_(Q)||o;if(Te){ge.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)ge.__webglFramebuffer[Ve]=e.createFramebuffer()}else{if(ge.__webglFramebuffer=e.createFramebuffer(),Ge)if(s.drawBuffers){let Ve=Q.texture;for(let De=0,Fe=Ve.length;De<Fe;De++){let ht=r.get(Ve[De]);ht.__webglTexture===void 0&&(ht.__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&&Q.samples>0&&je(Q)===!1){let Ve=Ge?j:[j];ge.__webglMultisampledFramebuffer=e.createFramebuffer(),ge.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ge.__webglMultisampledFramebuffer);for(let De=0;De<Ve.length;De++){let Fe=Ve[De];ge.__webglColorRenderbuffer[De]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ge.__webglColorRenderbuffer[De]);let ht=a.convert(Fe.format,Fe.encoding),Ke=a.convert(Fe.type),vt=A(Fe.internalFormat,ht,Ke,Fe.encoding,Q.isXRRenderTarget===!0),dt=He(Q);e.renderbufferStorageMultisample(36161,dt,vt,Q.width,Q.height),e.framebufferRenderbuffer(36160,36064+De,36161,ge.__webglColorRenderbuffer[De])}e.bindRenderbuffer(36161,null),Q.depthBuffer&&(ge.__webglDepthRenderbuffer=e.createRenderbuffer(),Be(ge.__webglDepthRenderbuffer,Q,!0)),i.bindFramebuffer(36160,null)}}if(Te){i.bindTexture(34067,Ne.__webglTexture),ie(34067,j,lt);for(let Ve=0;Ve<6;Ve++)de(ge.__webglFramebuffer[Ve],Q,j,36064,34069+Ve);M(j,lt)&&C(34067),i.unbindTexture()}else if(Ge){let Ve=Q.texture;for(let De=0,Fe=Ve.length;De<Fe;De++){let ht=Ve[De],Ke=r.get(ht);i.bindTexture(3553,Ke.__webglTexture),ie(3553,ht,lt),de(ge.__webglFramebuffer,Q,ht,36064+De,3553),M(ht,lt)&&C(3553)}i.unbindTexture()}else{let Ve=3553;(Q.isWebGL3DRenderTarget||Q.isWebGLArrayRenderTarget)&&(o?Ve=Q.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ve,Ne.__webglTexture),ie(Ve,j,lt),de(ge.__webglFramebuffer,Q,j,36064,Ve),M(j,lt)&&C(Ve),i.unbindTexture()}Q.depthBuffer&&_e(Q)}function Je(Q){let j=_(Q)||o,ge=Q.isWebGLMultipleRenderTargets===!0?Q.texture:[Q.texture];for(let Ne=0,Te=ge.length;Ne<Te;Ne++){let Ge=ge[Ne];if(M(Ge,j)){let lt=Q.isWebGLCubeRenderTarget?34067:3553,Ve=r.get(Ge).__webglTexture;i.bindTexture(lt,Ve),C(lt),i.unbindTexture()}}}function $e(Q){if(o&&Q.samples>0&&je(Q)===!1){let j=Q.isWebGLMultipleRenderTargets?Q.texture:[Q.texture],ge=Q.width,Ne=Q.height,Te=16384,Ge=[],lt=Q.stencilBuffer?33306:36096,Ve=r.get(Q),De=Q.isWebGLMultipleRenderTargets===!0;if(De)for(let Fe=0;Fe<j.length;Fe++)i.bindFramebuffer(36160,Ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,null),i.bindFramebuffer(36160,Ve.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,null,0);i.bindFramebuffer(36008,Ve.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ve.__webglFramebuffer);for(let Fe=0;Fe<j.length;Fe++){Ge.push(36064+Fe),Q.depthBuffer&&Ge.push(lt);let ht=Ve.__ignoreDepthValues!==void 0?Ve.__ignoreDepthValues:!1;if(ht===!1&&(Q.depthBuffer&&(Te|=256),Q.stencilBuffer&&(Te|=1024)),De&&e.framebufferRenderbuffer(36008,36064,36161,Ve.__webglColorRenderbuffer[Fe]),ht===!0&&(e.invalidateFramebuffer(36008,[lt]),e.invalidateFramebuffer(36009,[lt])),De){let Ke=r.get(j[Fe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ke,0)}e.blitFramebuffer(0,0,ge,Ne,0,0,ge,Ne,Te,9728),p&&e.invalidateFramebuffer(36008,Ge)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),De)for(let Fe=0;Fe<j.length;Fe++){i.bindFramebuffer(36160,Ve.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,Ve.__webglColorRenderbuffer[Fe]);let ht=r.get(j[Fe]).__webglTexture;i.bindFramebuffer(36160,Ve.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,ht,0)}i.bindFramebuffer(36009,Ve.__webglMultisampledFramebuffer)}}function He(Q){return Math.min(c,Q.samples)}function je(Q){let j=r.get(Q);return o&&Q.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function ot(Q){let j=n.render.frame;f.get(Q)!==j&&(f.set(Q,j),Q.update())}function gt(Q,j){let ge=Q.encoding,Ne=Q.format,Te=Q.type;return Q.isCompressedTexture===!0||Q.isVideoTexture===!0||Q.format===ny||ge!==Na&&(ge===Rt?o===!1?t.has("EXT_sRGB")===!0&&Ne===Pr?(Q.format=ny,Q.minFilter=zt,Q.generateMipmaps=!1):j=WE.sRGBToLinear(j):(Ne!==Pr||Te!==ns)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ge)),j}this.allocateTextureUnit=G,this.resetTextureUnits=X,this.setTexture2D=ae,this.setTexture2DArray=J,this.setTexture3D=K,this.setTextureCube=ne,this.rebindTextures=Ze,this.setupRenderTarget=Qe,this.updateRenderTargetMipmap=Je,this.updateMultisampleRenderTarget=$e,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=de,this.useMultisampledRTT=je}function qz(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===ns)return 5121;if(a===TI)return 32819;if(a===PI)return 32820;if(a===MI)return 5120;if(a===EI)return 5122;if(a===kE)return 5123;if(a===CI)return 5124;if(a===to)return 5125;if(a===lr)return 5126;if(a===Hl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===DI)return 6406;if(a===Pr)return 6408;if(a===OI)return 6409;if(a===II)return 6410;if(a===zl)return 6402;if(a===Wl)return 34041;if(a===ny)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===RI)return 6403;if(a===BI)return 36244;if(a===rm)return 33319;if(a===LI)return 33320;if(a===NE)return 36249;if(a===Zg||a===Kg||a===Jg||a===$g)if(n===Rt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===Zg)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Kg)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===Jg)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===$g)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===Zg)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Kg)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===Jg)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===$g)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Uw||a===Vw||a===jw||a===Gw)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Uw)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Vw)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===jw)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Gw)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===zI)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===Hw||a===Ww)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===Hw)return n===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===Ww)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===qw||a===Xw||a===Yw||a===Qw||a===Zw||a===Kw||a===Jw||a===$w||a===e_||a===t_||a===i_||a===r_||a===s_||a===a_)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===qw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Xw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Yw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===Qw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Zw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===Kw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Jw)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===$w)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===e_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===t_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===i_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===r_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===s_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===a_)return n===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===ev)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===ev)return n===Rt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===kI||a===n_||a===o_||a===l_)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===ev)return o.COMPRESSED_RED_RGTC1_EXT;if(a===n_)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===o_)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===l_)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Ll?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 Xz=class extends es{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Ml=class extends ci{constructor(){super(),this.isGroup=!0,this.type="Group"}},Yz={type:"move"},Ev=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ml,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 Ml,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 Ml,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 m=t.getJointPose(f,i),v=this._getHandJoint(l,f);m!==null&&(v.matrix.fromArray(m.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=m.radius),v.visible=m!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],c=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&c>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));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(Yz)))}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 Ml;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Ac=class extends Li{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:zl,h!==zl&&h!==Wl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===zl&&(i=to),i===void 0&&h===Wl&&(i=Ll),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:si,this.minFilter=o!==void 0?o:si,this.flipY=!1,this.generateMipmaps=!1}},Qz=class extends Qr{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),m=null,v=null,y=[],x=[],b=new Set,_=new Map,S=new es;S.layers.enable(1),S.viewport=new Et;let M=new es;M.layers.enable(2),M.viewport=new Et;let C=[S,M],A=new Xz;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(J){let K=y[J];return K===void 0&&(K=new Ev,y[J]=K),K.getTargetRaySpace()},this.getControllerGrip=function(J){let K=y[J];return K===void 0&&(K=new Ev,y[J]=K),K.getGripSpace()},this.getHand=function(J){let K=y[J];return K===void 0&&(K=new Ev,y[J]=K),K.getHandSpace()};function R(J){let K=x.indexOf(J.inputSource);if(K===-1)return;let ne=y[K];ne!==void 0&&ne.dispatchEvent({type:J.type,data:J.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",N);for(let J=0;J<y.length;J++){let K=x[J];K!==null&&(x[J]=null,y[J].disconnect(K))}T=null,P=null,e.setRenderTarget(m),d=null,c=null,u=null,r=null,v=null,ae.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(J){s=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){n=J,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(J){l=J},this.getBaseLayer=function(){return c!==null?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(J){if(r=J,r!==null){if(m=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",N),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let K={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,K),r.updateRenderState({baseLayer:d}),v=new ai(d.framebufferWidth,d.framebufferHeight,{format:Pr,type:ns,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let K=null,ne=null,te=null;f.depth&&(te=f.stencil?35056:33190,K=f.stencil?Wl:zl,ne=f.stencil?Ll:to);let oe={colorFormat:32856,depthFormat:te,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(oe),r.updateRenderState({layers:[c]}),v=new ai(c.textureWidth,c.textureHeight,{format:Pr,type:ns,depthTexture:new Ac(c.textureWidth,c.textureHeight,ne,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let ie=e.properties.get(v);ie.__ignoreDepthValues=c.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),ae.setContext(r),ae.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function N(J){for(let K=0;K<J.removed.length;K++){let ne=J.removed[K],te=x.indexOf(ne);te>=0&&(x[te]=null,y[te].disconnect(ne))}for(let K=0;K<J.added.length;K++){let ne=J.added[K],te=x.indexOf(ne);if(te===-1){for(let ie=0;ie<y.length;ie++)if(ie>=x.length){x.push(ne),te=ie;break}else if(x[ie]===null){x[ie]=ne,te=ie;break}if(te===-1)break}let oe=y[te];oe&&oe.connect(ne)}}let B=new I,V=new I;function H(J,K,ne){B.setFromMatrixPosition(K.matrixWorld),V.setFromMatrixPosition(ne.matrixWorld);let te=B.distanceTo(V),oe=K.projectionMatrix.elements,ie=ne.projectionMatrix.elements,be=oe[14]/(oe[10]-1),ue=oe[14]/(oe[10]+1),ye=(oe[9]+1)/oe[5],de=(oe[9]-1)/oe[5],Be=(oe[8]-1)/oe[0],Ce=(ie[8]+1)/ie[0],_e=be*Be,Ze=be*Ce,Qe=te/(-Be+Ce),Je=Qe*-Be;K.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Je),J.translateZ(Qe),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();let $e=be+Qe,He=ue+Qe,je=_e-Je,ot=Ze+(te-Je),gt=ye*ue/He*$e,Q=de*ue/He*$e;J.projectionMatrix.makePerspective(je,ot,gt,Q,$e,He)}function X(J,K){K===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(K.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(r===null)return;A.near=M.near=S.near=J.near,A.far=M.far=S.far=J.far,(T!==A.near||P!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),T=A.near,P=A.far);let K=J.parent,ne=A.cameras;X(A,K);for(let oe=0;oe<ne.length;oe++)X(ne[oe],K);A.matrixWorld.decompose(A.position,A.quaternion,A.scale),J.matrix.copy(A.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale);let te=J.children;for(let oe=0,ie=te.length;oe<ie;oe++)te[oe].updateMatrixWorld(!0);ne.length===2?H(A,S,M):A.projectionMatrix.copy(S.projectionMatrix)},this.getCamera=function(){return A},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(J){o=J,c!==null&&(c.fixedFoveation=J),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=J)},this.getPlanes=function(){return b};let G=null;function se(J,K){if(h=K.getViewerPose(l||a),p=K,h!==null){let ne=h.views;d!==null&&(e.setRenderTargetFramebuffer(v,d.framebuffer),e.setRenderTarget(v));let te=!1;ne.length!==A.cameras.length&&(A.cameras.length=0,te=!0);for(let oe=0;oe<ne.length;oe++){let ie=ne[oe],be=null;if(d!==null)be=d.getViewport(ie);else{let ye=u.getViewSubImage(c,ie);be=ye.viewport,oe===0&&(e.setRenderTargetTextures(v,ye.colorTexture,c.ignoreDepthValues?void 0:ye.depthStencilTexture),e.setRenderTarget(v))}let ue=C[oe];ue===void 0&&(ue=new es,ue.layers.enable(oe),ue.viewport=new Et,C[oe]=ue),ue.matrix.fromArray(ie.transform.matrix),ue.projectionMatrix.fromArray(ie.projectionMatrix),ue.viewport.set(be.x,be.y,be.width,be.height),oe===0&&A.matrix.copy(ue.matrix),te===!0&&A.cameras.push(ue)}}for(let ne=0;ne<y.length;ne++){let te=x[ne],oe=y[ne];te!==null&&oe!==void 0&&oe.update(te,K,l||a)}if(G&&G(J,K),K.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:K.detectedPlanes});let ne=null;for(let te of b)K.detectedPlanes.has(te)||(ne===null&&(ne=[]),ne.push(te));if(ne!==null)for(let te of ne)b.delete(te),_.delete(te),i.dispatchEvent({type:"planeremoved",data:te});for(let te of K.detectedPlanes)if(!b.has(te))b.add(te),_.set(te,K.lastChangedTime),i.dispatchEvent({type:"planeadded",data:te});else{let oe=_.get(te);te.lastChangedTime>oe&&(_.set(te,te.lastChangedTime),i.dispatchEvent({type:"planechanged",data:te}))}}p=null}let ae=new ZE;ae.setAnimationLoop(se),this.setAnimationLoop=function(J){G=J},this.dispose=function(){}}};function Zz(e,t){function i(m,v){v.color.getRGB(m.fogColor.value,QE(e)),v.isFog?(m.fogNear.value=v.near,m.fogFar.value=v.far):v.isFogExp2&&(m.fogDensity.value=v.density)}function r(m,v,y,x,b){v.isMeshBasicMaterial||v.isMeshLambertMaterial?s(m,v):v.isMeshToonMaterial?(s(m,v),u(m,v)):v.isMeshPhongMaterial?(s(m,v),h(m,v)):v.isMeshStandardMaterial?(s(m,v),c(m,v),v.isMeshPhysicalMaterial&&d(m,v,b)):v.isMeshMatcapMaterial?(s(m,v),p(m,v)):v.isMeshDepthMaterial?s(m,v):v.isMeshDistanceMaterial?(s(m,v),f(m,v)):v.isMeshNormalMaterial?s(m,v):v.isLineBasicMaterial?(a(m,v),v.isLineDashedMaterial&&n(m,v)):v.isPointsMaterial?o(m,v,y,x):v.isSpriteMaterial?l(m,v):v.isShadowMaterial?(m.color.value.copy(v.color),m.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function s(m,v){m.opacity.value=v.opacity,v.color&&m.diffuse.value.copy(v.color),v.emissive&&m.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(m.map.value=v.map),v.alphaMap&&(m.alphaMap.value=v.alphaMap),v.bumpMap&&(m.bumpMap.value=v.bumpMap,m.bumpScale.value=v.bumpScale,v.side===Or&&(m.bumpScale.value*=-1)),v.displacementMap&&(m.displacementMap.value=v.displacementMap,m.displacementScale.value=v.displacementScale,m.displacementBias.value=v.displacementBias),v.emissiveMap&&(m.emissiveMap.value=v.emissiveMap),v.normalMap&&(m.normalMap.value=v.normalMap,m.normalScale.value.copy(v.normalScale),v.side===Or&&m.normalScale.value.negate()),v.specularMap&&(m.specularMap.value=v.specularMap),v.alphaTest>0&&(m.alphaTest.value=v.alphaTest);let y=t.get(v).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=v.reflectivity,m.ior.value=v.ior,m.refractionRatio.value=v.refractionRatio),v.lightMap){m.lightMap.value=v.lightMap;let _=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=v.lightMapIntensity*_}v.aoMap&&(m.aoMap.value=v.aoMap,m.aoMapIntensity.value=v.aoMapIntensity);let x;v.map?x=v.map:v.specularMap?x=v.specularMap:v.displacementMap?x=v.displacementMap:v.normalMap?x=v.normalMap:v.bumpMap?x=v.bumpMap:v.roughnessMap?x=v.roughnessMap:v.metalnessMap?x=v.metalnessMap:v.alphaMap?x=v.alphaMap:v.emissiveMap?x=v.emissiveMap:v.clearcoatMap?x=v.clearcoatMap:v.clearcoatNormalMap?x=v.clearcoatNormalMap:v.clearcoatRoughnessMap?x=v.clearcoatRoughnessMap:v.iridescenceMap?x=v.iridescenceMap:v.iridescenceThicknessMap?x=v.iridescenceThicknessMap:v.specularIntensityMap?x=v.specularIntensityMap:v.specularColorMap?x=v.specularColorMap:v.transmissionMap?x=v.transmissionMap:v.thicknessMap?x=v.thicknessMap:v.sheenColorMap?x=v.sheenColorMap:v.sheenRoughnessMap&&(x=v.sheenRoughnessMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix));let b;v.aoMap?b=v.aoMap:v.lightMap&&(b=v.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uv2Transform.value.copy(b.matrix))}function a(m,v){m.diffuse.value.copy(v.color),m.opacity.value=v.opacity}function n(m,v){m.dashSize.value=v.dashSize,m.totalSize.value=v.dashSize+v.gapSize,m.scale.value=v.scale}function o(m,v,y,x){m.diffuse.value.copy(v.color),m.opacity.value=v.opacity,m.size.value=v.size*y,m.scale.value=x*.5,v.map&&(m.map.value=v.map),v.alphaMap&&(m.alphaMap.value=v.alphaMap),v.alphaTest>0&&(m.alphaTest.value=v.alphaTest);let b;v.map?b=v.map:v.alphaMap&&(b=v.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),m.uvTransform.value.copy(b.matrix))}function l(m,v){m.diffuse.value.copy(v.color),m.opacity.value=v.opacity,m.rotation.value=v.rotation,v.map&&(m.map.value=v.map),v.alphaMap&&(m.alphaMap.value=v.alphaMap),v.alphaTest>0&&(m.alphaTest.value=v.alphaTest);let y;v.map?y=v.map:v.alphaMap&&(y=v.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function h(m,v){m.specular.value.copy(v.specular),m.shininess.value=Math.max(v.shininess,1e-4)}function u(m,v){v.gradientMap&&(m.gradientMap.value=v.gradientMap)}function c(m,v){m.roughness.value=v.roughness,m.metalness.value=v.metalness,v.roughnessMap&&(m.roughnessMap.value=v.roughnessMap),v.metalnessMap&&(m.metalnessMap.value=v.metalnessMap),t.get(v).envMap&&(m.envMapIntensity.value=v.envMapIntensity)}function d(m,v,y){m.ior.value=v.ior,v.sheen>0&&(m.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),m.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(m.sheenColorMap.value=v.sheenColorMap),v.sheenRoughnessMap&&(m.sheenRoughnessMap.value=v.sheenRoughnessMap)),v.clearcoat>0&&(m.clearcoat.value=v.clearcoat,m.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(m.clearcoatMap.value=v.clearcoatMap),v.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap),v.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),m.clearcoatNormalMap.value=v.clearcoatNormalMap,v.side===Or&&m.clearcoatNormalScale.value.negate())),v.iridescence>0&&(m.iridescence.value=v.iridescence,m.iridescenceIOR.value=v.iridescenceIOR,m.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(m.iridescenceMap.value=v.iridescenceMap),v.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=v.iridescenceThicknessMap)),v.transmission>0&&(m.transmission.value=v.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),v.transmissionMap&&(m.transmissionMap.value=v.transmissionMap),m.thickness.value=v.thickness,v.thicknessMap&&(m.thicknessMap.value=v.thicknessMap),m.attenuationDistance.value=v.attenuationDistance,m.attenuationColor.value.copy(v.attenuationColor)),m.specularIntensity.value=v.specularIntensity,m.specularColor.value.copy(v.specularColor),v.specularIntensityMap&&(m.specularIntensityMap.value=v.specularIntensityMap),v.specularColorMap&&(m.specularColorMap.value=v.specularColorMap)}function p(m,v){v.matcap&&(m.matcap.value=v.matcap)}function f(m,v){m.referencePosition.value.copy(v.referencePosition),m.nearDistance.value=v.nearDistance,m.farDistance.value=v.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Kz(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),_=u(x),s[x.id]=_,x.addEventListener("dispose",v));let S=b.program;r.updateUBOMapping(x,S);let M=t.render.frame;a[x.id]!==M&&(d(x),a[x.id]=M)}function u(x){let b=c();x.__bindingPointIndex=b;let _=e.createBuffer(),S=x.__size,M=x.usage;return e.bindBuffer(35345,_),e.bufferData(35345,S,M),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,_),_}function c(){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,S=x.__cache;e.bindBuffer(35345,b);for(let M=0,C=_.length;M<C;M++){let A=_[M];if(p(A,M,S)===!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 N=P[z],B=m(N);typeof N=="number"?(A.__data[0]=N,e.bufferSubData(35345,T+R,A.__data)):N.isMatrix3?(A.__data[0]=N.elements[0],A.__data[1]=N.elements[1],A.__data[2]=N.elements[2],A.__data[3]=N.elements[0],A.__data[4]=N.elements[3],A.__data[5]=N.elements[4],A.__data[6]=N.elements[5],A.__data[7]=N.elements[0],A.__data[8]=N.elements[6],A.__data[9]=N.elements[7],A.__data[10]=N.elements[8],A.__data[11]=N.elements[0]):(N.toArray(A.__data,R),R+=B.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,T,A.__data)}}e.bindBuffer(35345,null)}function p(x,b,_){let S=x.value;if(_[b]===void 0){if(typeof S=="number")_[b]=S;else{let M=Array.isArray(S)?S:[S],C=[];for(let A=0;A<M.length;A++)C.push(M[A].clone());_[b]=C}return!0}else if(typeof S=="number"){if(_[b]!==S)return _[b]=S,!0}else{let M=Array.isArray(_[b])?_[b]:[_[b]],C=Array.isArray(S)?S:[S];for(let A=0;A<M.length;A++){let T=M[A];if(T.equals(C[A])===!1)return T.copy(C[A]),!0}}return!1}function f(x){let b=x.uniforms,_=0,S=16,M=0;for(let C=0,A=b.length;C<A;C++){let T=b[C],P={boundary:0,storage:0},R=Array.isArray(T.value)?T.value:[T.value];for(let z=0,N=R.length;z<N;z++){let B=R[z],V=m(B);P.boundary+=V.boundary,P.storage+=V.storage}if(T.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),T.__offset=_,C>0){M=_%S;let z=S-M;M!==0&&z-P.boundary<0&&(_+=S-M,T.__offset=_)}_+=P.storage}return M=_%S,M>0&&(_+=S-M),x.__size=_,x.__cache={},this}function m(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 v(x){let b=x.target;b.removeEventListener("dispose",v);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 Jz(){let e=gd("canvas");return e.style.display="block",e}function iC(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:Jz(),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,u;i!==null?u=i.getContextAttributes().alpha:u=e.alpha!==void 0?e.alpha:!1;let c=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Na,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;let m=this,v=!1,y=0,x=0,b=null,_=-1,S=null,M=new Et,C=new Et,A=null,T=t.width,P=t.height,R=1,z=null,N=null,B=new Et(0,0,T,P),V=new Et(0,0,T,P),H=!1,X=new lx,G=!1,se=!1,ae=null,J=new Le,K=new $,ne=new I,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function oe(){return b===null?R:1}let ie=i;function be(Z,ve){for(let Ee=0;Ee<Z.length;Ee++){let me=Z[Ee],Pe=t.getContext(me,ve);if(Pe!==null)return Pe}return null}try{let Z={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${zc}`),t.addEventListener("webglcontextlost",vt,!1),t.addEventListener("webglcontextrestored",dt,!1),t.addEventListener("webglcontextcreationerror",Wt,!1),ie===null){let ve=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ve.shift(),ie=be(ve,Z),ie===null)throw be(ve)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ie.getShaderPrecisionFormat===void 0&&(ie.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Z){throw console.error("THREE.WebGLRenderer: "+Z.message),Z}let ue,ye,de,Be,Ce,_e,Ze,Qe,Je,$e,He,je,ot,gt,Q,j,ge,Ne,Te,Ge,lt,Ve,De,Fe;function ht(){ue=new uL(ie),ye=new aL(ie,ue,e),ue.init(ye),Ve=new qz(ie,ue,ye),de=new Hz(ie,ue,ye),Be=new fL,Ce=new Oz,_e=new Wz(ie,ue,de,Ce,ye,Ve,Be),Ze=new oL(m),Qe=new cL(m),Je=new SR(ie,ye),De=new rL(ie,ue,Je,ye),$e=new dL(ie,Je,Be,De),He=new yL(ie,$e,Je,Be),Te=new vL(ie,ye,_e),j=new nL(Ce),je=new Dz(m,Ze,Qe,ue,ye,De,j),ot=new Zz(m,Ce),gt=new Rz,Q=new Fz(ue,ye),Ne=new iL(m,Ze,Qe,de,He,u,n),ge=new Gz(m,He,ye),Fe=new Kz(ie,Be,ye,de),Ge=new sL(ie,ue,Be,ye),lt=new pL(ie,ue,Be,ye),Be.programs=je.programs,m.capabilities=ye,m.extensions=ue,m.properties=Ce,m.renderLists=gt,m.shadowMap=ge,m.state=de,m.info=Be}ht();let Ke=new Qz(m,ie);this.xr=Ke,this.getContext=function(){return ie},this.getContextAttributes=function(){return ie.getContextAttributes()},this.forceContextLoss=function(){let Z=ue.get("WEBGL_lose_context");Z&&Z.loseContext()},this.forceContextRestore=function(){let Z=ue.get("WEBGL_lose_context");Z&&Z.restoreContext()},this.getPixelRatio=function(){return R},this.setPixelRatio=function(Z){Z!==void 0&&(R=Z,this.setSize(T,P,!1))},this.getSize=function(Z){return Z.set(T,P)},this.setSize=function(Z,ve,Ee){if(Ke.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=Z,P=ve,t.width=Math.floor(Z*R),t.height=Math.floor(ve*R),Ee!==!1&&(t.style.width=Z+"px",t.style.height=ve+"px"),this.setViewport(0,0,Z,ve)},this.getDrawingBufferSize=function(Z){return Z.set(T*R,P*R).floor()},this.setDrawingBufferSize=function(Z,ve,Ee){T=Z,P=ve,R=Ee,t.width=Math.floor(Z*Ee),t.height=Math.floor(ve*Ee),this.setViewport(0,0,Z,ve)},this.getCurrentViewport=function(Z){return Z.copy(M)},this.getViewport=function(Z){return Z.copy(B)},this.setViewport=function(Z,ve,Ee,me){Z.isVector4?B.set(Z.x,Z.y,Z.z,Z.w):B.set(Z,ve,Ee,me),de.viewport(M.copy(B).multiplyScalar(R).floor())},this.getScissor=function(Z){return Z.copy(V)},this.setScissor=function(Z,ve,Ee,me){Z.isVector4?V.set(Z.x,Z.y,Z.z,Z.w):V.set(Z,ve,Ee,me),de.scissor(C.copy(V).multiplyScalar(R).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(Z){de.setScissorTest(H=Z)},this.setOpaqueSort=function(Z){z=Z},this.setTransparentSort=function(Z){N=Z},this.getClearColor=function(Z){return Z.copy(Ne.getClearColor())},this.setClearColor=function(){Ne.setClearColor.apply(Ne,arguments)},this.getClearAlpha=function(){return Ne.getClearAlpha()},this.setClearAlpha=function(){Ne.setClearAlpha.apply(Ne,arguments)},this.clear=function(Z=!0,ve=!0,Ee=!0){let me=0;Z&&(me|=16384),ve&&(me|=256),Ee&&(me|=1024),ie.clear(me)},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",vt,!1),t.removeEventListener("webglcontextrestored",dt,!1),t.removeEventListener("webglcontextcreationerror",Wt,!1),gt.dispose(),Q.dispose(),Ce.dispose(),Ze.dispose(),Qe.dispose(),He.dispose(),De.dispose(),Fe.dispose(),je.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",We),Ke.removeEventListener("sessionend",pt),ae&&(ae.dispose(),ae=null),$t.stop()};function vt(Z){Z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function dt(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;let Z=Be.autoReset,ve=ge.enabled,Ee=ge.autoUpdate,me=ge.needsUpdate,Pe=ge.type;ht(),Be.autoReset=Z,ge.enabled=ve,ge.autoUpdate=Ee,ge.needsUpdate=me,ge.type=Pe}function Wt(Z){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Z.statusMessage)}function ui(Z){let ve=Z.target;ve.removeEventListener("dispose",ui),Di(ve)}function Di(Z){ce(Z),Ce.remove(Z)}function ce(Z){let ve=Ce.get(Z).programs;ve!==void 0&&(ve.forEach(function(Ee){je.releaseProgram(Ee)}),Z.isShaderMaterial&&je.releaseShaderCache(Z))}this.renderBufferDirect=function(Z,ve,Ee,me,Pe,tt){ve===null&&(ve=te);let Pt=Pe.isMesh&&Pe.matrixWorld.determinant()<0,Ut=Ng(Z,ve,Ee,me,Pe);de.setMaterial(me,Pt);let kt=Ee.index,ti=1;me.wireframe===!0&&(kt=$e.getWireframeAttribute(Ee),ti=2);let qt=Ee.drawRange,Xt=Ee.attributes.position,di=qt.start*ti,zr=(qt.start+qt.count)*ti;tt!==null&&(di=Math.max(di,tt.start*ti),zr=Math.min(zr,(tt.start+tt.count)*ti)),kt!==null?(di=Math.max(di,0),zr=Math.min(zr,kt.count)):Xt!=null&&(di=Math.max(di,0),zr=Math.min(zr,Xt.count));let Ni=zr-di;if(Ni<0||Ni===1/0)return;De.setup(Pe,me,Ut,Ee,kt);let ir,Fi=Ge;if(kt!==null&&(ir=Je.get(kt),Fi=lt,Fi.setIndex(ir)),Pe.isMesh)me.wireframe===!0?(de.setLineWidth(me.wireframeLinewidth*oe()),Fi.setMode(1)):Fi.setMode(4);else if(Pe.isLine){let jt=me.linewidth;jt===void 0&&(jt=1),de.setLineWidth(jt*oe()),Pe.isLineSegments?Fi.setMode(1):Pe.isLineLoop?Fi.setMode(2):Fi.setMode(3)}else Pe.isPoints?Fi.setMode(0):Pe.isSprite&&Fi.setMode(4);if(Pe.isInstancedMesh)Fi.renderInstances(di,Ni,Pe.count);else if(Ee.isInstancedBufferGeometry){let jt=Ee._maxInstanceCount!==void 0?Ee._maxInstanceCount:1/0,sl=Math.min(Ee.instanceCount,jt);Fi.renderInstances(di,Ni,sl)}else Fi.render(di,Ni)},this.compile=function(Z,ve){function Ee(me,Pe,tt){me.transparent===!0&&me.side===Rs&&me.forceSinglePass===!1?(me.side=Or,me.needsUpdate=!0,Kr(me,Pe,tt),me.side=ka,me.needsUpdate=!0,Kr(me,Pe,tt),me.side=Rs):Kr(me,Pe,tt)}d=Q.get(Z),d.init(),f.push(d),Z.traverseVisible(function(me){me.isLight&&me.layers.test(ve.layers)&&(d.pushLight(me),me.castShadow&&d.pushShadow(me))}),d.setupLights(m.physicallyCorrectLights),Z.traverse(function(me){let Pe=me.material;if(Pe)if(Array.isArray(Pe))for(let tt=0;tt<Pe.length;tt++){let Pt=Pe[tt];Ee(Pt,Z,me)}else Ee(Pe,Z,me)}),f.pop(),d=null};let we=null;function Ue(Z){we&&we(Z)}function We(){$t.stop()}function pt(){$t.start()}let $t=new ZE;$t.setAnimationLoop(Ue),typeof self<"u"&&$t.setContext(self),this.setAnimationLoop=function(Z){we=Z,Ke.setAnimationLoop(Z),Z===null?$t.stop():$t.start()},Ke.addEventListener("sessionstart",We),Ke.addEventListener("sessionend",pt),this.render=function(Z,ve){if(ve!==void 0&&ve.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),ve.parent===null&&ve.matrixWorldAutoUpdate===!0&&ve.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(ve),ve=Ke.getCamera()),Z.isScene===!0&&Z.onBeforeRender(m,Z,ve,b),d=Q.get(Z,f.length),d.init(),f.push(d),J.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),X.setFromProjectionMatrix(J),se=this.localClippingEnabled,G=j.init(this.clippingPlanes,se),c=gt.get(Z,p.length),c.init(),p.push(c),xi(Z,ve,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(z,N),G===!0&&j.beginShadows();let Ee=d.state.shadowsArray;if(ge.render(Ee,Z,ve),G===!0&&j.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ne.render(c,Z),d.setupLights(m.physicallyCorrectLights),ve.isArrayCamera){let me=ve.cameras;for(let Pe=0,tt=me.length;Pe<tt;Pe++){let Pt=me[Pe];ki(c,Z,Pt,Pt.viewport)}}else ki(c,Z,ve);b!==null&&(_e.updateMultisampleRenderTarget(b),_e.updateRenderTargetMipmap(b)),Z.isScene===!0&&Z.onAfterRender(m,Z,ve),De.resetDefaultState(),_=-1,S=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function xi(Z,ve,Ee,me){if(Z.visible===!1)return;if(Z.layers.test(ve.layers)){if(Z.isGroup)Ee=Z.renderOrder;else if(Z.isLOD)Z.autoUpdate===!0&&Z.update(ve);else if(Z.isLight)d.pushLight(Z),Z.castShadow&&d.pushShadow(Z);else if(Z.isSprite){if(!Z.frustumCulled||X.intersectsSprite(Z)){me&&ne.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(J);let tt=He.update(Z),Pt=Z.material;Pt.visible&&c.push(Z,tt,Pt,Ee,ne.z,null)}}else if((Z.isMesh||Z.isLine||Z.isPoints)&&(Z.isSkinnedMesh&&Z.skeleton.frame!==Be.render.frame&&(Z.skeleton.update(),Z.skeleton.frame=Be.render.frame),!Z.frustumCulled||X.intersectsObject(Z))){me&&ne.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(J);let tt=He.update(Z),Pt=Z.material;if(Array.isArray(Pt)){let Ut=tt.groups;for(let kt=0,ti=Ut.length;kt<ti;kt++){let qt=Ut[kt],Xt=Pt[qt.materialIndex];Xt&&Xt.visible&&c.push(Z,tt,Xt,Ee,ne.z,qt)}}else Pt.visible&&c.push(Z,tt,Pt,Ee,ne.z,null)}}let Pe=Z.children;for(let tt=0,Pt=Pe.length;tt<Pt;tt++)xi(Pe[tt],ve,Ee,me)}function ki(Z,ve,Ee,me){let Pe=Z.opaque,tt=Z.transmissive,Pt=Z.transparent;d.setupLightsView(Ee),G===!0&&j.setGlobalState(m.clippingPlanes,Ee),tt.length>0&&Zr(Pe,ve,Ee),me&&de.viewport(M.copy(me)),Pe.length>0&&Si(Pe,ve,Ee),tt.length>0&&Si(tt,ve,Ee),Pt.length>0&&Si(Pt,ve,Ee),de.buffers.depth.setTest(!0),de.buffers.depth.setMask(!0),de.buffers.color.setMask(!0),de.setPolygonOffset(!1)}function Zr(Z,ve,Ee){let me=ye.isWebGL2;ae===null&&(ae=new ai(1,1,{generateMipmaps:!0,type:ue.has("EXT_color_buffer_half_float")?Hl:ns,minFilter:_c,samples:me&&a===!0?4:0})),m.getDrawingBufferSize(K),me?ae.setSize(K.x,K.y):ae.setSize(lm(K.x),lm(K.y));let Pe=m.getRenderTarget();m.setRenderTarget(ae),m.clear();let tt=m.toneMapping;m.toneMapping=gn,Si(Z,ve,Ee),m.toneMapping=tt,_e.updateMultisampleRenderTarget(ae),_e.updateRenderTargetMipmap(ae),m.setRenderTarget(Pe)}function Si(Z,ve,Ee){let me=ve.isScene===!0?ve.overrideMaterial:null;for(let Pe=0,tt=Z.length;Pe<tt;Pe++){let Pt=Z[Pe],Ut=Pt.object,kt=Pt.geometry,ti=me===null?Pt.material:me,qt=Pt.group;Ut.layers.test(Ee.layers)&&Ns(Ut,ve,Ee,kt,ti,qt)}}function Ns(Z,ve,Ee,me,Pe,tt){Z.onBeforeRender(m,ve,Ee,me,Pe,tt),Z.modelViewMatrix.multiplyMatrices(Ee.matrixWorldInverse,Z.matrixWorld),Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix),Pe.onBeforeRender(m,ve,Ee,me,Z,tt),Pe.transparent===!0&&Pe.side===Rs&&Pe.forceSinglePass===!1?(Pe.side=Or,Pe.needsUpdate=!0,m.renderBufferDirect(Ee,ve,me,Pe,Z,tt),Pe.side=ka,Pe.needsUpdate=!0,m.renderBufferDirect(Ee,ve,me,Pe,Z,tt),Pe.side=Rs):m.renderBufferDirect(Ee,ve,me,Pe,Z,tt),Z.onAfterRender(m,ve,Ee,me,Pe,tt)}function Kr(Z,ve,Ee){ve.isScene!==!0&&(ve=te);let me=Ce.get(Z),Pe=d.state.lights,tt=d.state.shadowsArray,Pt=Pe.state.version,Ut=je.getParameters(Z,Pe.state,tt,ve,Ee),kt=je.getProgramCacheKey(Ut),ti=me.programs;me.environment=Z.isMeshStandardMaterial?ve.environment:null,me.fog=ve.fog,me.envMap=(Z.isMeshStandardMaterial?Qe:Ze).get(Z.envMap||me.environment),ti===void 0&&(Z.addEventListener("dispose",ui),ti=new Map,me.programs=ti);let qt=ti.get(kt);if(qt!==void 0){if(me.currentProgram===qt&&me.lightsStateVersion===Pt)return lh(Z,Ut),qt}else Ut.uniforms=je.getUniforms(Z),Z.onBuild(Ee,Ut,m),Z.onBeforeCompile(Ut,m),qt=je.acquireProgram(Ut,kt),ti.set(kt,qt),me.uniforms=Ut.uniforms;let Xt=me.uniforms;(!Z.isShaderMaterial&&!Z.isRawShaderMaterial||Z.clipping===!0)&&(Xt.clippingPlanes=j.uniform),lh(Z,Ut),me.needsLights=Fg(Z),me.lightsStateVersion=Pt,me.needsLights&&(Xt.ambientLightColor.value=Pe.state.ambient,Xt.lightProbe.value=Pe.state.probe,Xt.directionalLights.value=Pe.state.directional,Xt.directionalLightShadows.value=Pe.state.directionalShadow,Xt.spotLights.value=Pe.state.spot,Xt.spotLightShadows.value=Pe.state.spotShadow,Xt.rectAreaLights.value=Pe.state.rectArea,Xt.ltc_1.value=Pe.state.rectAreaLTC1,Xt.ltc_2.value=Pe.state.rectAreaLTC2,Xt.pointLights.value=Pe.state.point,Xt.pointLightShadows.value=Pe.state.pointShadow,Xt.hemisphereLights.value=Pe.state.hemi,Xt.directionalShadowMap.value=Pe.state.directionalShadowMap,Xt.directionalShadowMatrix.value=Pe.state.directionalShadowMatrix,Xt.spotShadowMap.value=Pe.state.spotShadowMap,Xt.spotLightMatrix.value=Pe.state.spotLightMatrix,Xt.spotLightMap.value=Pe.state.spotLightMap,Xt.pointShadowMap.value=Pe.state.pointShadowMap,Xt.pointShadowMatrix.value=Pe.state.pointShadowMatrix);let di=qt.getUniforms(),zr=Wf.seqWithValue(di.seq,Xt);return me.currentProgram=qt,me.uniformsList=zr,qt}function lh(Z,ve){let Ee=Ce.get(Z);Ee.outputEncoding=ve.outputEncoding,Ee.instancing=ve.instancing,Ee.skinning=ve.skinning,Ee.morphTargets=ve.morphTargets,Ee.morphNormals=ve.morphNormals,Ee.morphColors=ve.morphColors,Ee.morphTargetsCount=ve.morphTargetsCount,Ee.numClippingPlanes=ve.numClippingPlanes,Ee.numIntersection=ve.numClipIntersection,Ee.vertexAlphas=ve.vertexAlphas,Ee.vertexTangents=ve.vertexTangents,Ee.toneMapping=ve.toneMapping}function Ng(Z,ve,Ee,me,Pe){ve.isScene!==!0&&(ve=te),_e.resetTextureUnits();let tt=ve.fog,Pt=me.isMeshStandardMaterial?ve.environment:null,Ut=b===null?m.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:Na,kt=(me.isMeshStandardMaterial?Qe:Ze).get(me.envMap||Pt),ti=me.vertexColors===!0&&!!Ee.attributes.color&&Ee.attributes.color.itemSize===4,qt=!!me.normalMap&&!!Ee.attributes.tangent,Xt=!!Ee.morphAttributes.position,di=!!Ee.morphAttributes.normal,zr=!!Ee.morphAttributes.color,Ni=me.toneMapped?m.toneMapping:gn,ir=Ee.morphAttributes.position||Ee.morphAttributes.normal||Ee.morphAttributes.color,Fi=ir!==void 0?ir.length:0,jt=Ce.get(me),sl=d.state.lights;if(G===!0&&(se===!0||Z!==S)){let hs=Z===S&&me.id===_;j.setState(me,Z,hs)}let nu=!1;me.version===jt.__version?(jt.needsLights&&jt.lightsStateVersion!==sl.state.version||jt.outputEncoding!==Ut||Pe.isInstancedMesh&&jt.instancing===!1||!Pe.isInstancedMesh&&jt.instancing===!0||Pe.isSkinnedMesh&&jt.skinning===!1||!Pe.isSkinnedMesh&&jt.skinning===!0||jt.envMap!==kt||me.fog===!0&&jt.fog!==tt||jt.numClippingPlanes!==void 0&&(jt.numClippingPlanes!==j.numPlanes||jt.numIntersection!==j.numIntersection)||jt.vertexAlphas!==ti||jt.vertexTangents!==qt||jt.morphTargets!==Xt||jt.morphNormals!==di||jt.morphColors!==zr||jt.toneMapping!==Ni||ye.isWebGL2===!0&&jt.morphTargetsCount!==Fi)&&(nu=!0):(nu=!0,jt.__version=me.version);let Cn=jt.currentProgram;nu===!0&&(Cn=Kr(me,ve,Pe));let Es=!1,kr=!1,hh=!1,ur=Cn.getUniforms(),Tn=jt.uniforms;if(de.useProgram(Cn.program)&&(Es=!0,kr=!0,hh=!0),me.id!==_&&(_=me.id,kr=!0),Es||S!==Z){if(ur.setValue(ie,"projectionMatrix",Z.projectionMatrix),ye.logarithmicDepthBuffer&&ur.setValue(ie,"logDepthBufFC",2/(Math.log(Z.far+1)/Math.LN2)),S!==Z&&(S=Z,kr=!0,hh=!0),me.isShaderMaterial||me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshStandardMaterial||me.envMap){let hs=ur.map.cameraPosition;hs!==void 0&&hs.setValue(ie,ne.setFromMatrixPosition(Z.matrixWorld))}(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial)&&ur.setValue(ie,"isOrthographic",Z.isOrthographicCamera===!0),(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial||me.isShadowMaterial||Pe.isSkinnedMesh)&&ur.setValue(ie,"viewMatrix",Z.matrixWorldInverse)}if(Pe.isSkinnedMesh){ur.setOptional(ie,Pe,"bindMatrix"),ur.setOptional(ie,Pe,"bindMatrixInverse");let hs=Pe.skeleton;hs&&(ye.floatVertexTextures?(hs.boneTexture===null&&hs.computeBoneTexture(),ur.setValue(ie,"boneTexture",hs.boneTexture,_e),ur.setValue(ie,"boneTextureSize",hs.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 ou=Ee.morphAttributes;if((ou.position!==void 0||ou.normal!==void 0||ou.color!==void 0&&ye.isWebGL2===!0)&&Te.update(Pe,Ee,me,Cn),(kr||jt.receiveShadow!==Pe.receiveShadow)&&(jt.receiveShadow=Pe.receiveShadow,ur.setValue(ie,"receiveShadow",Pe.receiveShadow)),me.isMeshGouraudMaterial&&me.envMap!==null&&(Tn.envMap.value=kt,Tn.flipEnvMap.value=kt.isCubeTexture&&kt.isRenderTargetTexture===!1?-1:1),kr&&(ur.setValue(ie,"toneMappingExposure",m.toneMappingExposure),jt.needsLights&&au(Tn,hh),tt&&me.fog===!0&&ot.refreshFogUniforms(Tn,tt),ot.refreshMaterialUniforms(Tn,me,R,P,ae),Wf.upload(ie,jt.uniformsList,Tn,_e)),me.isShaderMaterial&&me.uniformsNeedUpdate===!0&&(Wf.upload(ie,jt.uniformsList,Tn,_e),me.uniformsNeedUpdate=!1),me.isSpriteMaterial&&ur.setValue(ie,"center",Pe.center),ur.setValue(ie,"modelViewMatrix",Pe.modelViewMatrix),ur.setValue(ie,"normalMatrix",Pe.normalMatrix),ur.setValue(ie,"modelMatrix",Pe.matrixWorld),Pe.previousModelViewMatrix&&ur.setValue(ie,"previousModelViewMatrix",Pe.previousModelViewMatrix),Z.previousProjectionMatrix&&ur.setValue(ie,"previousProjectionMatrix",Z.previousProjectionMatrix),me.isShaderMaterial||me.isRawShaderMaterial){let hs=me.uniformsGroups;for(let lu=0,Ug=hs.length;lu<Ug;lu++)if(ye.isWebGL2){let op=hs[lu];Fe.update(op,Cn),Fe.bind(op,Cn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Cn}function au(Z,ve){Z.ambientLightColor.needsUpdate=ve,Z.lightProbe.needsUpdate=ve,Z.directionalLights.needsUpdate=ve,Z.directionalLightShadows.needsUpdate=ve,Z.pointLights.needsUpdate=ve,Z.pointLightShadows.needsUpdate=ve,Z.spotLights.needsUpdate=ve,Z.spotLightShadows.needsUpdate=ve,Z.rectAreaLights.needsUpdate=ve,Z.hemisphereLights.needsUpdate=ve}function Fg(Z){return Z.isMeshLambertMaterial||Z.isMeshToonMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isShadowMaterial||Z.isShaderMaterial&&Z.lights===!0}this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(Z,ve,Ee){Ce.get(Z.texture).__webglTexture=ve,Ce.get(Z.depthTexture).__webglTexture=Ee;let me=Ce.get(Z);me.__hasExternalTextures=!0,me.__hasExternalTextures&&(me.__autoAllocateDepthBuffer=Ee===void 0,me.__autoAllocateDepthBuffer||ue.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),me.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Z,ve){let Ee=Ce.get(Z);Ee.__webglFramebuffer=ve,Ee.__useDefaultFramebuffer=ve===void 0},this.setRenderTarget=function(Z,ve=0,Ee=0){b=Z,y=ve,x=Ee;let me=!0,Pe=null,tt=!1,Pt=!1;if(Z){let Ut=Ce.get(Z);Ut.__useDefaultFramebuffer!==void 0?(de.bindFramebuffer(36160,null),me=!1):Ut.__webglFramebuffer===void 0?_e.setupRenderTarget(Z):Ut.__hasExternalTextures&&_e.rebindTextures(Z,Ce.get(Z.texture).__webglTexture,Ce.get(Z.depthTexture).__webglTexture);let kt=Z.texture;(kt.isData3DTexture||kt.isDataArrayTexture||kt.isCompressedArrayTexture)&&(Pt=!0);let ti=Ce.get(Z).__webglFramebuffer;Z.isWebGLCubeRenderTarget?(Pe=ti[ve],tt=!0):ye.isWebGL2&&Z.samples>0&&_e.useMultisampledRTT(Z)===!1?Pe=Ce.get(Z).__webglMultisampledFramebuffer:Pe=ti,M.copy(Z.viewport),C.copy(Z.scissor),A=Z.scissorTest}else M.copy(B).multiplyScalar(R).floor(),C.copy(V).multiplyScalar(R).floor(),A=H;if(de.bindFramebuffer(36160,Pe)&&ye.drawBuffers&&me&&de.drawBuffers(Z,Pe),de.viewport(M),de.scissor(C),de.setScissorTest(A),tt){let Ut=Ce.get(Z.texture);ie.framebufferTexture2D(36160,36064,34069+ve,Ut.__webglTexture,Ee)}else if(Pt){let Ut=Ce.get(Z.texture),kt=ve||0;ie.framebufferTextureLayer(36160,36064,Ut.__webglTexture,Ee||0,kt)}_=-1},this.readRenderTargetPixels=function(Z,ve,Ee,me,Pe,tt,Pt){if(!(Z&&Z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ut=Ce.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&Pt!==void 0&&(Ut=Ut[Pt]),Ut){de.bindFramebuffer(36160,Ut);try{let kt=Z.texture,ti=kt.format,qt=kt.type;if(ti!==Pr&&Ve.convert(ti)!==ie.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Xt=qt===Hl&&(ue.has("EXT_color_buffer_half_float")||ye.isWebGL2&&ue.has("EXT_color_buffer_float"));if(qt!==ns&&Ve.convert(qt)!==ie.getParameter(35738)&&!(qt===lr&&(ye.isWebGL2||ue.has("OES_texture_float")||ue.has("WEBGL_color_buffer_float")))&&!Xt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ve>=0&&ve<=Z.width-me&&Ee>=0&&Ee<=Z.height-Pe&&ie.readPixels(ve,Ee,me,Pe,Ve.convert(ti),Ve.convert(qt),tt)}finally{let kt=b!==null?Ce.get(b).__webglFramebuffer:null;de.bindFramebuffer(36160,kt)}}},this.copyFramebufferToTexture=function(Z,ve,Ee=0){let me=Math.pow(2,-Ee),Pe=Math.floor(ve.image.width*me),tt=Math.floor(ve.image.height*me);_e.setTexture2D(ve,0),ie.copyTexSubImage2D(3553,Ee,0,0,Z.x,Z.y,Pe,tt),de.unbindTexture()},this.copyTextureToTexture=function(Z,ve,Ee,me=0){let Pe=ve.image.width,tt=ve.image.height,Pt=Ve.convert(Ee.format),Ut=Ve.convert(Ee.type);_e.setTexture2D(Ee,0),ie.pixelStorei(37440,Ee.flipY),ie.pixelStorei(37441,Ee.premultiplyAlpha),ie.pixelStorei(3317,Ee.unpackAlignment),ve.isDataTexture?ie.texSubImage2D(3553,me,Z.x,Z.y,Pe,tt,Pt,Ut,ve.image.data):ve.isCompressedTexture?ie.compressedTexSubImage2D(3553,me,Z.x,Z.y,ve.mipmaps[0].width,ve.mipmaps[0].height,Pt,ve.mipmaps[0].data):ie.texSubImage2D(3553,me,Z.x,Z.y,Pt,Ut,ve.image),me===0&&Ee.generateMipmaps&&ie.generateMipmap(3553),de.unbindTexture()},this.copyTextureToTexture3D=function(Z,ve,Ee,me,Pe=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let tt=Z.max.x-Z.min.x+1,Pt=Z.max.y-Z.min.y+1,Ut=Z.max.z-Z.min.z+1,kt=Ve.convert(me.format),ti=Ve.convert(me.type),qt;if(me.isData3DTexture)_e.setTexture3D(me,0),qt=32879;else if(me.isDataArrayTexture)_e.setTexture2DArray(me,0),qt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ie.pixelStorei(37440,me.flipY),ie.pixelStorei(37441,me.premultiplyAlpha),ie.pixelStorei(3317,me.unpackAlignment);let Xt=ie.getParameter(3314),di=ie.getParameter(32878),zr=ie.getParameter(3316),Ni=ie.getParameter(3315),ir=ie.getParameter(32877),Fi=Ee.isCompressedTexture?Ee.mipmaps[0]:Ee.image;ie.pixelStorei(3314,Fi.width),ie.pixelStorei(32878,Fi.height),ie.pixelStorei(3316,Z.min.x),ie.pixelStorei(3315,Z.min.y),ie.pixelStorei(32877,Z.min.z),Ee.isDataTexture||Ee.isData3DTexture?ie.texSubImage3D(qt,Pe,ve.x,ve.y,ve.z,tt,Pt,Ut,kt,ti,Fi.data):Ee.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ie.compressedTexSubImage3D(qt,Pe,ve.x,ve.y,ve.z,tt,Pt,Ut,kt,Fi.data)):ie.texSubImage3D(qt,Pe,ve.x,ve.y,ve.z,tt,Pt,Ut,kt,ti,Fi),ie.pixelStorei(3314,Xt),ie.pixelStorei(32878,di),ie.pixelStorei(3316,zr),ie.pixelStorei(3315,Ni),ie.pixelStorei(32877,ir),Pe===0&&me.generateMipmaps&&ie.generateMipmap(qt),de.unbindTexture()},this.initTexture=function(Z){Z.isCubeTexture?_e.setTextureCube(Z,0):Z.isData3DTexture?_e.setTexture3D(Z,0):Z.isDataArrayTexture||Z.isCompressedArrayTexture?_e.setTexture2DArray(Z,0):_e.setTexture2D(Z,0),de.unbindTexture()},this.resetState=function(){y=0,x=0,b=null,de.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var $z=class extends iC{};$z.prototype.isWebGL1Renderer=!0;var rC=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new yt(e),this.near=t,this.far=i}clone(){return new rC(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},so=class extends ci{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}},ek=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ay,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ua()}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=ua()),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=ua()),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,hy=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=Ai(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ai(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ai(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ai(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=io(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=io(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=io(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=io(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ai(t,this.array),i=Ai(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=Ai(t,this.array),i=Ai(i,this.array),r=Ai(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=Ai(t,this.array),i=Ai(i,this.array),r=Ai(r,this.array),s=Ai(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 At(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 hy(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}}},sC=class extends ci{constructor(){super(),this.isBone=!0,this.type="Bone"}},ca=class extends Li{constructor(e=null,t=1,i=1,r,s,a,n,o,l=si,h=si,u,c){super(null,a,n,o,l,h,r,s,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},G_=new Le,tk=new Le,ux=class{constructor(e=[],t=[]){this.uuid=ua(),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 Le)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Le;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:tk;G_.multiplyMatrices(n,t[s]),G_.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new ux(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=jE(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new ca(t,e,e,Pr,lr);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 sC),this.bones.push(a),this.boneInverses.push(new Le().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}},vd=class extends At{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}},H_=new Le,W_=new Le,Up=[],ik=new Le,Su=new yr,rk=class extends yr{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new vd(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1;for(let r=0;r<i;r++)this.setMatrixAt(r,ik)}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(Su.geometry=this.geometry,Su.material=this.material,Su.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,H_),W_.multiplyMatrices(i,H_),Su.matrixWorld=W_,Su.raycast(e,Up);for(let a=0,n=Up.length;a<n;a++){let o=Up[a];o.instanceId=s,o.object=this,t.push(o)}Up.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new vd(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"})}},$o=class extends jd{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(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}},q_=new I,X_=new I,Y_=new Le,Cv=new kc,Vp=new zs,hm=class extends ci{constructor(e=new ut,t=new $o){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++)q_.fromBufferAttribute(t,r-1),X_.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=q_.distanceTo(X_);e.setAttribute("lineDistance",new et(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(),Vp.copy(i.boundingSphere),Vp.applyMatrix4(r),Vp.radius+=s,e.ray.intersectsSphere(Vp)===!1)return;Y_.copy(r).invert(),Cv.copy(e.ray).applyMatrix4(Y_);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new I,h=new I,u=new I,c=new I,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,a.start),v=Math.min(p.count,a.start+a.count);for(let y=m,x=v-1;y<x;y+=d){let b=p.getX(y),_=p.getX(y+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,_),Cv.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let S=e.ray.origin.distanceTo(c);S<e.near||S>e.far||t.push({distance:S,point:u.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,a.start),v=Math.min(f.count,a.start+a.count);for(let y=m,x=v-1;y<x;y+=d){if(l.fromBufferAttribute(f,y),h.fromBufferAttribute(f,y+1),Cv.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(c);b<e.near||b>e.far||t.push({distance:b,point:u.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}}}}},Q_=new I,Z_=new I,Gd=class extends hm{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)Q_.fromBufferAttribute(t,r),Z_.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Q_.distanceTo(Z_);e.setAttribute("lineDistance",new et(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},sk=class extends Li{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:zt,this.magFilter=s!==void 0?s:zt,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},ak=class extends Li{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}},An=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],u=i[r+1]-h,c=(a-h)/u;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),a=this.getPoint(r),n=t||(s.isVector2?new $: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 Le;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),u=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),c<=l&&i.set(0,0,1),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(nr(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(nr(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}},hg=class extends An{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 $,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),u=Math.sin(this.aRotation),c=o-this.aX,d=l-this.aY;o=c*h-d*u+this.aX,l=c*u+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},nk=class extends hg{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function dx(){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,u,c){let d=(n-a)/h-(o-a)/(h+u)+(o-n)/u,p=(o-n)/u-(l-n)/(u+c)+(l-o)/c;d*=u,p*=u,s(n,o,d,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var jp=new I,Tv=new dx,Pv=new dx,Dv=new dx,ok=class extends An{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]:(jp.subVectors(r[0],r[1]).add(r[0]),l=jp);let u=r[n%s],c=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(jp.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=jp),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(c),d),m=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),Tv.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,m),Pv.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,m),Dv.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(Tv.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),Pv.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Dv.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Tv.calc(o),Pv.calc(o),Dv.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 K_(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 lk(e,t){let i=1-e;return i*i*t}function hk(e,t){return 2*(1-e)*e*t}function ck(e,t){return e*e*t}function sd(e,t,i,r){return lk(e,t)+hk(e,i)+ck(e,r)}function uk(e,t){let i=1-e;return i*i*i*t}function dk(e,t){let i=1-e;return 3*i*i*e*t}function pk(e,t){return 3*(1-e)*e*e*t}function fk(e,t){return e*e*e*t}function ad(e,t,i,r,s){return uk(e,t)+dk(e,i)+pk(e,r)+fk(e,s)}var Ia=class extends An{constructor(e=new $,t=new $,i=new $,r=new $){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new $){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(ad(e,r.x,s.x,a.x,n.x),ad(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}},qf=class extends An{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(ad(e,r.x,s.x,a.x,n.x),ad(e,r.y,s.y,a.y,n.y),ad(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}},za=class extends An{constructor(e=new $,t=new $){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new $){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 $;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}},aC=class extends An{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}},Zo=class extends An{constructor(e=new $,t=new $,i=new $){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new $){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(sd(e,r.x,s.x,a.x),sd(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}},mk=class extends An{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(sd(e,r.x,s.x,a.x),sd(e,r.y,s.y,a.y),sd(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}},px=class extends An{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new $){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],u=r[a>r.length-3?r.length-1:a+2];return i.set(K_(n,o.x,l.x,h.x,u.x),K_(n,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new $().fromArray(r))}return this}},gk=Object.freeze({__proto__:null,ArcCurve:nk,CatmullRomCurve3:ok,CubicBezierCurve:Ia,CubicBezierCurve3:qf,EllipseCurve:hg,LineCurve:za,LineCurve3:aC,QuadraticBezierCurve:Zo,QuadraticBezierCurve3:mk,SplineCurve:px}),nC=class extends An{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 za(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 gk[r.type]().fromJSON(r))}return this}},cm=class extends nC{constructor(e){super(),this.type="Path",this.currentPoint=new $,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 za(this.currentPoint.clone(),new $(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Zo(this.currentPoint.clone(),new $(e,t),new $(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new Ia(this.currentPoint.clone(),new $(e,t),new $(i,r),new $(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new px(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 hg(e,t,i,r,s,a,n,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},oC=class extends ut{constructor(e=[new $(0,-.5),new $(.5,0),new $(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=nr(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,u=new I,c=new $,d=new I,p=new I,f=new I,m=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,d.x=v*1,d.y=-m,d.z=v*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:m=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,d.x=v*1,d.y=-m,d.z=v*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 S=0;S<=e.length-1;S++){u.x=e[S].x*b,u.y=e[S].y,u.z=e[S].x*_,a.push(u.x,u.y,u.z),c.x=y/t,c.y=S/(e.length-1),n.push(c.x,c.y);let M=o[3*S+0]*b,C=o[3*S+1],A=o[3*S+0]*_;l.push(M,C,A)}}for(let y=0;y<t;y++)for(let x=0;x<e.length-1;x++){let b=x+y*e.length,_=b,S=b+e.length,M=b+e.length+1,C=b+1;s.push(_,S,C),s.push(M,C,S)}this.setIndex(s),this.setAttribute("position",new et(a,3)),this.setAttribute("uv",new et(n,2)),this.setAttribute("normal",new et(l,3))}static fromJSON(e){return new oC(e.points,e.segments,e.phiStart,e.phiLength)}},fx=class extends ut{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=[],u=[],c=[],d=[],p=0,f=[],m=i/2,v=0;y(),a===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new et(u,3)),this.setAttribute("normal",new et(c,3)),this.setAttribute("uv",new et(d,2));function y(){let b=new I,_=new I,S=0,M=(t-e)/i;for(let C=0;C<=s;C++){let A=[],T=C/s,P=T*(t-e)+e;for(let R=0;R<=r;R++){let z=R/r,N=z*o+n,B=Math.sin(N),V=Math.cos(N);_.x=P*B,_.y=-T*i+m,_.z=P*V,u.push(_.x,_.y,_.z),b.set(B,M,V).normalize(),c.push(b.x,b.y,b.z),d.push(z,1-T),A.push(p++)}f.push(A)}for(let C=0;C<r;C++)for(let A=0;A<s;A++){let T=f[A][C],P=f[A+1][C],R=f[A+1][C+1],z=f[A][C+1];h.push(T,P,z),h.push(P,R,z),S+=6}l.addGroup(v,S,0),v+=S}function x(b){let _=p,S=new $,M=new I,C=0,A=b===!0?e:t,T=b===!0?1:-1;for(let R=1;R<=r;R++)u.push(0,m*T,0),c.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,N=Math.cos(z),B=Math.sin(z);M.x=A*B,M.y=m*T,M.z=A*N,u.push(M.x,M.y,M.z),c.push(0,T,0),S.x=N*.5+.5,S.y=B*.5*T+.5,d.push(S.x,S.y),p++}for(let R=0;R<r;R++){let z=_+R,N=P+R;b===!0?h.push(N,N+1,z):h.push(N+1,N,z),C+=3}l.addGroup(v,C,b===!0?1:2),v+=C}}static fromJSON(e){return new fx(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},mx=class extends fx{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 mx(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},gx=class extends ut{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 et(s,3)),this.setAttribute("normal",new et(s.slice(),3)),this.setAttribute("uv",new et(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(y){let x=new I,b=new I,_=new I;for(let S=0;S<t.length;S+=3)d(t[S+0],x),d(t[S+1],b),d(t[S+2],_),o(x,b,_,y)}function o(y,x,b,_){let S=_+1,M=[];for(let C=0;C<=S;C++){M[C]=[];let A=y.clone().lerp(b,C/S),T=x.clone().lerp(b,C/S),P=S-C;for(let R=0;R<=P;R++)R===0&&C===S?M[C][R]=A:M[C][R]=A.clone().lerp(T,R/P)}for(let C=0;C<S;C++)for(let A=0;A<2*(S-C)-1;A++){let T=Math.floor(A/2);A%2===0?(c(M[C][T+1]),c(M[C+1][T]),c(M[C][T])):(c(M[C][T+1]),c(M[C+1][T+1]),c(M[C+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=m(y)/2/Math.PI+.5,_=v(y)/Math.PI+.5;a.push(b,1-_)}p(),u()}function u(){for(let y=0;y<a.length;y+=6){let x=a[y+0],b=a[y+2],_=a[y+4],S=Math.max(x,b,_),M=Math.min(x,b,_);S>.9&&M<.1&&(x<.2&&(a[y+0]+=1),b<.2&&(a[y+2]+=1),_<.2&&(a[y+4]+=1))}}function c(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,S=new $,M=new $,C=new $;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]),S.set(a[T+0],a[T+1]),M.set(a[T+2],a[T+3]),C.set(a[T+4],a[T+5]),_.copy(y).add(x).add(b).divideScalar(3);let P=m(_);f(S,T+0,y,P),f(M,T+2,x,P),f(C,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 m(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new gx(e.vertices,e.indices,e.radius,e.details)}},lC=class extends gx{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 lC(e.radius,e.detail)}},um=class extends cm{constructor(e){super(e),this.uuid=ua(),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 cm().fromJSON(r))}return this}},vk={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=hC(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,u,c,d,p;if(r&&(a=_k(e,t,a,i)),e.length>80*i){o=h=e[0],l=u=e[1];for(let f=i;f<s;f+=i)c=e[f],d=e[f+1],c<o&&(o=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-o,u-l),p=p!==0?32767/p:0}return yd(a,n,i,o,l,p,0),n}};function hC(e,t,i,r,s){let a,n;if(s===Rk(e,t,i,r)>0)for(a=t;a<i;a+=r)n=J_(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=J_(a,e[a],e[a+1],n);return n&&cg(n,n.next)&&(bd(n),n=n.next),n}function ql(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(cg(i,i.next)||Bi(i.prev,i,i.next)===0)){if(bd(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function yd(e,t,i,r,s,a,n){if(!e)return;!n&&a&&Ck(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?xk(e,r,s,a):yk(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),bd(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=bk(ql(e),t,i),yd(e,t,i,r,s,a,2)):n===2&&wk(e,t,i,r,s,a):yd(ql(e),t,i,r,s,a,1);break}}}function yk(e){let t=e.prev,i=e,r=e.next;if(Bi(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,u=s<a?s<n?s:n:a<n?a:n,c=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>=u&&f.x<=d&&f.y>=c&&f.y<=p&&ic(s,o,a,l,n,h,f.x,f.y)&&Bi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function xk(e,t,i,r){let s=e.prev,a=e,n=e.next;if(Bi(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,u=s.y,c=a.y,d=n.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,v=u>c?u>d?u:d:c>d?c:d,y=cy(p,f,t,i,r),x=cy(m,v,t,i,r),b=e.prevZ,_=e.nextZ;for(;b&&b.z>=y&&_&&_.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=v&&b!==s&&b!==n&&ic(o,u,l,c,h,d,b.x,b.y)&&Bi(b.prev,b,b.next)>=0||(b=b.prevZ,_.x>=p&&_.x<=m&&_.y>=f&&_.y<=v&&_!==s&&_!==n&&ic(o,u,l,c,h,d,_.x,_.y)&&Bi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=v&&b!==s&&b!==n&&ic(o,u,l,c,h,d,b.x,b.y)&&Bi(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=v&&_!==s&&_!==n&&ic(o,u,l,c,h,d,_.x,_.y)&&Bi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function bk(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!cg(s,a)&&cC(s,r,r.next,a)&&xd(s,a)&&xd(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),bd(r),bd(r.next),r=e=a),r=r.next}while(r!==e);return ql(r)}function wk(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&Dk(n,o)){let l=uC(n,o);n=ql(n,n.next),l=ql(l,l.next),yd(n,t,i,r,s,a,0),yd(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function _k(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=hC(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(Pk(h));for(s.sort(Sk),a=0;a<s.length;a++)i=Ak(s[a],i);return i}function Sk(e,t){return e.x-t.x}function Ak(e,t){let i=Mk(e,t);if(!i)return t;let r=uC(i,e);return ql(r,r.next),ql(i,i.next)}function Mk(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,u=1/0,c;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&ic(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(c=Math.abs(n-i.y)/(a-i.x),xd(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&Ek(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function Ek(e,t){return Bi(e.prev,e,t.prev)<0&&Bi(t.next,e,e.next)<0}function Ck(e,t,i,r){let s=e;do s.z===0&&(s.z=cy(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,Tk(s)}function Tk(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 cy(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 Pk(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 ic(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 Dk(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Ok(e,t)&&(xd(e,t)&&xd(t,e)&&Ik(e,t)&&(Bi(e.prev,e,t.prev)||Bi(e,t.prev,t))||cg(e,t)&&Bi(e.prev,e,e.next)>0&&Bi(t.prev,t,t.next)>0)}function Bi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function cg(e,t){return e.x===t.x&&e.y===t.y}function cC(e,t,i,r){let s=Hp(Bi(e,t,i)),a=Hp(Bi(e,t,r)),n=Hp(Bi(i,r,e)),o=Hp(Bi(i,r,t));return!!(s!==a&&n!==o||s===0&&Gp(e,i,t)||a===0&&Gp(e,r,t)||n===0&&Gp(i,e,r)||o===0&&Gp(i,t,r))}function Gp(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 Hp(e){return e>0?1:e<0?-1:0}function Ok(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&&cC(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function xd(e,t){return Bi(e.prev,e,e.next)<0?Bi(e,t,e.next)>=0&&Bi(e,e.prev,t)>=0:Bi(e,t,e.prev)<0||Bi(e,e.next,t)<0}function Ik(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 uC(e,t){let i=new uy(e.i,e.x,e.y),r=new uy(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 J_(e,t,i,r){let s=new uy(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 bd(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 uy(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 Rk(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 dC=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 dC.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];$_(e),eS(i,e);let a=e.length;t.forEach($_);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,eS(i,t[o]);let n=vk.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function $_(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function eS(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var pC=class extends gx{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 pC(e.radius,e.detail)}},oc=class extends ut{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=[],u=new I,c=new I,d=[],p=[],f=[],m=[];for(let v=0;v<=i;v++){let y=[],x=v/i,b=0;v==0&&a==0?b=.5/t:v==i&&o==Math.PI&&(b=-.5/t);for(let _=0;_<=t;_++){let S=_/t;u.x=-e*Math.cos(r+S*s)*Math.sin(a+x*n),u.y=e*Math.cos(a+x*n),u.z=e*Math.sin(r+S*s)*Math.sin(a+x*n),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),m.push(S+b,1-x),y.push(l++)}h.push(y)}for(let v=0;v<i;v++)for(let y=0;y<t;y++){let x=h[v][y+1],b=h[v][y],_=h[v+1][y],S=h[v+1][y+1];(v!==0||a>0)&&d.push(x,b,S),(v!==i-1||o<Math.PI)&&d.push(b,_,S)}this.setIndex(d),this.setAttribute("position",new et(p,3)),this.setAttribute("normal",new et(f,3)),this.setAttribute("uv",new et(m,2))}static fromJSON(e){return new oc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},fC=class extends ut{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,u=new I,c=new I;for(let d=0;d<=i;d++)for(let p=0;p<=r;p++){let f=p/r*s,m=d/i*Math.PI*2;u.x=(e+t*Math.cos(m))*Math.cos(f),u.y=(e+t*Math.cos(m))*Math.sin(f),u.z=t*Math.sin(m),n.push(u.x,u.y,u.z),h.x=e*Math.cos(f),h.y=e*Math.sin(f),c.subVectors(u,h).normalize(),o.push(c.x,c.y,c.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,m=(r+1)*(d-1)+p-1,v=(r+1)*(d-1)+p,y=(r+1)*d+p;a.push(f,m,y),a.push(m,v,y)}this.setIndex(a),this.setAttribute("position",new et(n,3)),this.setAttribute("normal",new et(o,3)),this.setAttribute("uv",new et(l,2))}static fromJSON(e){return new fC(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},mC=class extends ut{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=[],u=new I,c=new I,d=new I,p=new I,f=new I,m=new I,v=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),m.subVectors(p,d),v.addVectors(p,d),f.crossVectors(m,v),v.crossVectors(f,m),f.normalize(),v.normalize();for(let _=0;_<=r;++_){let S=_/r*Math.PI*2,M=-t*Math.cos(S),C=t*Math.sin(S);u.x=d.x+(M*v.x+C*f.x),u.y=d.y+(M*v.y+C*f.y),u.z=d.z+(M*v.z+C*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.z),h.push(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),S=(r+1)*x+(b-1),M=(r+1)*x+b,C=(r+1)*(x-1)+b;n.push(_,S,C),n.push(S,M,C)}this.setIndex(n),this.setAttribute("position",new et(o,3)),this.setAttribute("normal",new et(l,3)),this.setAttribute("uv",new et(h,2));function y(x,b,_,S,M){let C=Math.cos(x),A=Math.sin(x),T=_/b*x,P=Math.cos(T);M.x=S*(2+P)*.5*C,M.y=S*(2+P)*A*.5,M.z=S*Math.sin(T)*.5}}static fromJSON(e){return new mC(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function bo(e,t,i){return gC(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function Wp(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 gC(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Bk(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 tS(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 vC(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 ug=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_(){}},Lk=class extends ug{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:$h,endingEnd:$h}}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 ec:s=e,n=2*t-i;break;case nm: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 ec:a=e,o=2*i-t;break;case nm: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,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,v=-c*m+2*c*f-c*p,y=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,x=(-1-d)*m+(1.5+d)*f+.5*p,b=d*m-d*f;for(let _=0;_!==n;++_)s[_]=v*a[h+_]+y*a[l+_]+x*a[o+_]+b*a[u+_];return s}},yC=class extends ug{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),u=1-h;for(let c=0;c!==n;++c)s[c]=a[l+c]*u+a[o+c]*h;return s}},zk=class extends ug{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Mn=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=Wp(t,this.TimeBufferType),this.values=Wp(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:Wp(e.times,Array),values:Wp(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new zk(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new yC(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Lk(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case sm:t=this.InterpolantFactoryMethodDiscrete;break;case am:t=this.InterpolantFactoryMethodLinear;break;case tv: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 sm;case this.InterpolantFactoryMethodLinear:return am;case this.InterpolantFactoryMethodSmooth:return tv}}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=bo(i,s,a),this.values=bo(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&&gC(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=bo(this.times),t=bo(this.values),i=this.getValueSize(),r=this.getInterpolation()===tv,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 u=n*i,c=u-i,d=u+i;for(let p=0;p!==i;++p){let f=t[u+p];if(f!==t[c+p]||f!==t[d+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let u=n*i,c=a*i;for(let d=0;d!==i;++d)t[c+d]=t[u+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=bo(e,0,a),this.values=bo(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=bo(this.times,0),t=bo(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Mn.prototype.TimeBufferType=Float32Array;Mn.prototype.ValueBufferType=Float32Array;Mn.prototype.DefaultInterpolation=am;var Vc=class extends Mn{};Vc.prototype.ValueTypeName="bool";Vc.prototype.ValueBufferType=Array;Vc.prototype.DefaultInterpolation=sm;Vc.prototype.InterpolantFactoryMethodLinear=void 0;Vc.prototype.InterpolantFactoryMethodSmooth=void 0;var xC=class extends Mn{};xC.prototype.ValueTypeName="color";var dm=class extends Mn{};dm.prototype.ValueTypeName="number";var kk=class extends ug{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)Mt.slerpFlat(s,0,a,l-n,a,l,o);return s}},Hd=class extends Mn{InterpolantFactoryMethodLinear(e){return new kk(this.times,this.values,this.getValueSize(),e)}};Hd.prototype.ValueTypeName="quaternion";Hd.prototype.DefaultInterpolation=am;Hd.prototype.InterpolantFactoryMethodSmooth=void 0;var jc=class extends Mn{};jc.prototype.ValueTypeName="string";jc.prototype.ValueBufferType=Array;jc.prototype.DefaultInterpolation=sm;jc.prototype.InterpolantFactoryMethodLinear=void 0;jc.prototype.InterpolantFactoryMethodSmooth=void 0;var pm=class extends Mn{};pm.prototype.ValueTypeName="vector";var dy=class{constructor(e,t=-1,i,r=sx){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=ua(),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(Fk(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(Mn.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=Bk(o);o=tS(o,1,h),l=tS(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new dm(".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 u=h[1],c=r[u];c||(r[u]=c=[]),c.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,u,c,d,p){if(c.length!==0){let f=[],m=[];vC(c,f,m,d),f.length!==0&&p.push(new h(u,f,m))}},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 u=l[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){let c={},d;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(let p=0;p<u[d].morphTargets.length;p++)c[u[d].morphTargets[p]]=-1;for(let p in c){let f=[],m=[];for(let v=0;v!==u[d].morphTargets.length;++v){let y=u[d];f.push(y.time),m.push(y.morphTarget===p?1:0)}r.push(new dm(".morphTargetInfluence["+p+"]",f,m))}o=c.length*a}else{let c=".bones["+t[h].name+"]";i(pm,c+".position",u,"pos",r),i(Hd,c+".quaternion",u,"rot",r),i(pm,c+".scale",u,"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 Nk(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return dm;case"vector":case"vector2":case"vector3":case"vector4":return pm;case"color":return xC;case"quaternion":return Hd;case"bool":case"boolean":return Vc;case"string":return jc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Fk(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Nk(e.type);if(e.times===void 0){let i=[],r=[];vC(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 fm={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={}}},bC=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,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,c=l.length;u<c;u+=2){let d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},Uk=new bC,Wd=class{constructor(e){this.manager=e!==void 0?e:Uk,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}},zn={},Vk=class extends Error{constructor(e,t){super(e),this.response=t}},py=class extends Wd{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=fm.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(zn[e]!==void 0){zn[e].push({onLoad:t,onProgress:i,onError:r});return}zn[e]=[],zn[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=zn[e],u=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=c?parseInt(c):0,p=d!==0,f=0,m=new ReadableStream({start(v){y();function y(){u.read().then(({done:x,value:b})=>{if(x)v.close();else{f+=b.byteLength;let _=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let S=0,M=h.length;S<M;S++){let C=h[S];C.onProgress&&C.onProgress(_)}v.enqueue(b),y()}})}}});return new Response(m)}else throw new Vk(`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),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{fm.add(e,l);let h=zn[e];delete zn[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=zn[e];if(h===void 0)throw this.manager.itemError(e),l;delete zn[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},jk=class extends Wd{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=fm.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;let n=gd("img");function o(){h(),fm.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(u){h(),r&&r(u),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}},Gk=class extends Wd{constructor(e){super(e)}load(e,t,i,r){let s=new Li,a=new jk(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}},qd=class extends ci{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(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}},Hk=class extends qd{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ci.DEFAULT_UP),this.updateMatrix(),this.groundColor=new yt(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Ov=new Le,iS=new I,rS=new I,vx=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new $(512,512),this.map=null,this.mapPass=null,this.matrix=new Le,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lx,this._frameExtents=new $(1,1),this._viewportCount=1,this._viewports=[new Et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;iS.setFromMatrixPosition(e.matrixWorld),t.position.copy(iS),rS.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(rS),t.updateMatrixWorld(),Ov.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ov),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ov)}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}},Wk=class extends vx{constructor(){super(new es(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=md*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}},qk=class extends qd{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(ci.DEFAULT_UP),this.updateMatrix(),this.target=new ci,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new Wk}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}},sS=new Le,Au=new I,Iv=new I,Xk=class extends vx{constructor(){super(new es(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new $(4,2),this._viewportCount=6,this._viewports=[new Et(2,1,1,1),new Et(0,1,1,1),new Et(3,1,1,1),new Et(1,1,1,1),new Et(3,0,1,1),new Et(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()),Au.setFromMatrixPosition(e.matrixWorld),i.position.copy(Au),Iv.copy(i.position),Iv.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Iv),i.updateMatrixWorld(),r.makeTranslation(-Au.x,-Au.y,-Au.z),sS.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sS)}},Yk=class extends qd{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 Xk}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}},Qk=class extends vx{constructor(){super(new hx(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Zk=class extends qd{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ci.DEFAULT_UP),this.updateMatrix(),this.target=new ci,this.shadow=new Qk}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},wC=class extends ut{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},_C=class extends Wd{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new py(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(c,d){if(t[d]!==void 0)return t[d];let p=c.interleavedBuffers[d],f=s(c,p.buffer),m=wp(p.type,f),v=new ek(m,p.stride);return v.uuid=p.uuid,t[d]=v,v}function s(c,d){if(i[d]!==void 0)return i[d];let p=c.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let a=e.isInstancedBufferGeometry?new wC:new ut,n=e.data.index;if(n!==void 0){let c=wp(n.type,n.array);a.setIndex(new At(c,1))}let o=e.data.attributes;for(let c in o){let d=o[c],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new hy(f,d.itemSize,d.offset,d.normalized)}else{let f=wp(d.type,d.array),m=d.isInstancedBufferAttribute?vd:At;p=new m(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(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,m=d.length;f<m;f++){let v=d[f],y;if(v.isInterleavedBufferAttribute){let x=r(e.data,v.data);y=new hy(x,v.itemSize,v.offset,v.normalized)}else{let x=wp(v.type,v.array);y=new At(x,v.itemSize,v.normalized)}v.name!==void 0&&(y.name=v.name),p.push(y)}a.morphAttributes[c]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,d=h.length;c!==d;++c){let p=h[c];a.addGroup(p.start,p.count,p.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let c=new I;u.center!==void 0&&c.fromArray(u.center),a.boundingSphere=new zs(c,u.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},Kk=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=aS(),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=aS();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function aS(){return(typeof performance>"u"?Date:performance).now()}var Jk=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){Mt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;Mt.multiplyQuaternionsFlat(e,a,e,t,e,i),Mt.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}}},yx="\\[\\]\\.:\\/",$k=new RegExp("["+yx+"]","g"),xx="[^"+yx+"]",e5="[^"+yx.replace("\\.","")+"]",t5=/((?:WC+[\/:])*)/.source.replace("WC",xx),i5=/(WCOD+)?/.source.replace("WCOD",e5),r5=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xx),s5=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xx),a5=new RegExp("^"+t5+i5+r5+s5+"$"),n5=["material","materials","bones","map"],o5=class{constructor(e,t,i){let r=i||bi.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()}},bi=class{constructor(e,t,i){this.path=t,this.parsedPath=i||bi.parseTrackName(t),this.node=bi.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 bi.Composite(e,t,i):new bi(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace($k,"")}static parseTrackName(e){let t=a5.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);n5.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=bi.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}};bi.Composite=o5;bi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};bi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};bi.prototype.GetterByBindingType=[bi.prototype._getValue_direct,bi.prototype._getValue_array,bi.prototype._getValue_arrayElement,bi.prototype._getValue_toArray];bi.prototype.SetterByBindingTypeAndVersioning=[[bi.prototype._setValue_direct,bi.prototype._setValue_direct_setNeedsUpdate,bi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[bi.prototype._setValue_array,bi.prototype._setValue_array_setNeedsUpdate,bi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[bi.prototype._setValue_arrayElement,bi.prototype._setValue_arrayElement_setNeedsUpdate,bi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[bi.prototype._setValue_fromArray,bi.prototype._setValue_fromArray_setNeedsUpdate,bi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var l5=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:$h,endingEnd:$h};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=UE,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 NI:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case sx:default:for(let h=0,u=o.length;h!==u;++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===rx;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===FE){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=ec,r.endingEnd=ec):(e?r.endingStart=this.zeroSlopeAtStart?ec:$h:r.endingStart=nm,t?r.endingEnd=this.zeroSlopeAtEnd?ec:$h:r.endingEnd=nm)}_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}},h5=new Float32Array(1),c5=class extends Qr{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 u=0;u!==s;++u){let c=r[u],d=c.name,p=h[d];if(p!==void 0)++p.referenceCount,a[u]=p;else{if(p=a[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[u].binding.parsedPath;p=new Jk(bi.create(i,d,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),a[u]=p}n[u].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 u=n.actionByRoot,c=(e._localRoot||this._root).uuid;delete u[c],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 yC(new Float32Array(2),new Float32Array(2),1,h5),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"?dy.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=sx),o!==void 0){let u=o.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new l5(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"?dy.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,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,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))}},Re=class{constructor(e){this.value=e}clone(){return new Re(this.value.clone===void 0?this.value:this.value.clone())}},SC=class{constructor(e,t,i=0,r=1/0){this.ray=new kc(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new nx,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 fy(e,this,i,t),i.sort(nS),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)fy(e[r],this,i,t);return i.sort(nS),i}};function nS(e,t){return e.distance-t.distance}function fy(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++)fy(s[a],t,i,!0)}}var oS=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(nr(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},lS=new $,AC=class{constructor(e=new $(1/0,1/0),t=new $(-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=lS.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 lS.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)}},hS=new I,qp=new I,da=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){hS.subVectors(e,this.start),qp.subVectors(this.end,this.start);let i=qp.dot(qp),r=qp.dot(hS)/i;return t&&(r=nr(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)}},cS=new I,u5=class extends ci{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new ut,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 et(r,3));let s=new $o({fog:!1,toneMapped:!1});this.cone=new Gd(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),cS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(cS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},d5=class extends yr{constructor(e,t,i){let r=new oc(t,4,2),s=new Nc({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)}},uS=new I,Xp=new I,dS=new I,p5=class extends ci{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 ut;r.setAttribute("position",new et([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new $o({fog:!1,toneMapped:!1});this.lightPlane=new hm(r,s),this.add(this.lightPlane),r=new ut,r.setAttribute("position",new et([0,0,0,0,0,1],3)),this.targetLine=new hm(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),uS.setFromMatrixPosition(this.light.matrixWorld),Xp.setFromMatrixPosition(this.light.target.matrixWorld),dS.subVectors(Xp,uS),this.lightPlane.lookAt(Xp),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(Xp),this.targetLine.scale.z=dS.length()}},Yp=new I,Ui=new Kl,mm=class extends Gd{constructor(e){let t=new ut,i=new $o({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 et(r,3)),t.setAttribute("color",new et(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 yt(16755200),h=new yt(16711680),u=new yt(43775),c=new yt(16777215),d=new yt(3355443);this.setColors(l,h,u,c,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;Ui.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xi("c",t,e,Ui,0,0,-1),Xi("t",t,e,Ui,0,0,1),Xi("n1",t,e,Ui,-i,-r,-1),Xi("n2",t,e,Ui,i,-r,-1),Xi("n3",t,e,Ui,-i,r,-1),Xi("n4",t,e,Ui,i,r,-1),Xi("f1",t,e,Ui,-i,-r,1),Xi("f2",t,e,Ui,i,-r,1),Xi("f3",t,e,Ui,-i,r,1),Xi("f4",t,e,Ui,i,r,1),Xi("u1",t,e,Ui,i*.7,r*1.1,-1),Xi("u2",t,e,Ui,-i*.7,r*1.1,-1),Xi("u3",t,e,Ui,0,r*2,-1),Xi("cf1",t,e,Ui,-i,0,1),Xi("cf2",t,e,Ui,i,0,1),Xi("cf3",t,e,Ui,0,-r,1),Xi("cf4",t,e,Ui,0,r,1),Xi("cn1",t,e,Ui,-i,0,-1),Xi("cn2",t,e,Ui,i,0,-1),Xi("cn3",t,e,Ui,0,-r,-1),Xi("cn4",t,e,Ui,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Xi(e,t,i,r,s,a,n){Yp.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],Yp.x,Yp.y,Yp.z)}}var gm=class extends Gd{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 ut;s.setIndex(new At(i,1)),s.setAttribute("position",new et(r,3)),super(s,new $o({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()}},f5=class extends Gd{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 ut;r.setAttribute("position",new et(t,3)),r.setAttribute("color",new et(i,3));let s=new $o({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new yt,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()}},Jn=m5();function m5(){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,u=0;for(;(h&8388608)===0;)h<<=1,u-=8388608;h&=-8388609,u+=947912704,a[l]=h|u}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 g5(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=nr(e,-65504,65504),Jn.floatView[0]=e;let t=Jn.uint32View[0],i=t>>23&511;return Jn.baseTable[i]+((t&8388607)>>Jn.shiftTable[i])}function v5(e){let t=e>>10;return Jn.uint32View[0]=Jn.mantissaTable[Jn.offsetTable[t]+(e&1023)]+Jn.exponentTable[t],Jn.floatView[0]}var y5=Object.freeze({__proto__:null,fromHalfFloat:v5,toHalfFloat:g5});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zc);var Mu=".",bx=Symbol("target"),MC=Symbol("unsubscribe");function my(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function x5(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var cn=Array.isArray;function wx(e){return typeof e=="symbol"}var b5={after:(e,t)=>cn(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>cn(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Mu),wx(t)?e+t.toString():e+t):e,initial:e=>{if(cn(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Mu);return t===-1?"":e.slice(0,t)},last:e=>{if(cn(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Mu);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(cn(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Mu);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(Mu,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},na=b5;function w5(e){return typeof e=="object"&&typeof e.next=="function"}function _5(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[bx].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 pS(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&wx(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var S5=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,na.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 gy(e){return toString.call(e)==="[object Object]"}function Qp(){return!0}function Ch(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var EC=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),A5=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),CC={push:Qp,pop:Qp,shift:Qp,unshift:Qp,copyWithin:Ch,reverse:Ch,sort:Ch,splice:Ch,flat:Ch,fill:Ch},M5=new Set([...EC,...A5,...Object.keys(CC)]);function Zp(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var TC=["keys","values","entries"],PC=new Set(["has","toString"]),DC={add:Zp,clear:Zp,delete:Zp,forEach:Zp},E5=new Set([...PC,...Object.keys(DC),...TC]);function Kp(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 C5=new Set([...PC,"get"]),OC={set:Kp,clear:Kp,delete:Kp,forEach:Kp},T5=new Set([...C5,...Object.keys(OC),...TC]),Ko=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 EC.has(e)}_shallowClone(e){let t=e;if(gy(e))t={...e};else if(cn(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?(cn(r)?this._onIsChanged=CC[t]:r instanceof Set?this._onIsChanged=DC[t]:r instanceof Map&&(this._onIsChanged=OC[t]),r):i}update(e,t,i){let r=na.after(e,this._path);if(t!=="length"){let s=this.clone;na.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],na.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},fS=class extends Ko{static isHandledMethod(e){return M5.has(e)}},P5=class extends Ko{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},mS=class extends Ko{static isHandledMethod(e){return E5.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)}},gS=class extends Ko{static isHandledMethod(e){return T5.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)}},D5=class extends Ko{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)}},O5=class extends Ko{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)}},Yh=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gy(e)||cn(e)||my(e)}static isHandledMethod(e,t){return gy(e)?Ko.isHandledMethod(t):cn(e)?fS.isHandledMethod(t):e instanceof Set?mS.isHandledMethod(t):e instanceof Map?gS.isHandledMethod(t):my(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Ko;cn(e)?r=fS:e instanceof Date?r=P5:e instanceof Set?r=mS:e instanceof Map?r=gS:e instanceof WeakSet?r=D5:e instanceof WeakMap&&(r=O5),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=Yh.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}},I5={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},_x=(e,t,i={})=>{i={...I5,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new S5(s),h=typeof i.onValidate=="function",u=new Yh(h),c=(x,b,_,S,M)=>!h||u.isCloning||i.onValidate(na.concat(l.getPath(x),b),_,S,M)===!0,d=(x,b,_,S)=>{!pS(l,i,b)&&!(n&&l.isDetached(x,e))&&p(l.getPath(x),b,_,S)},p=(x,b,_,S,M)=>{u.isCloning?u.update(x,b,S):t(na.concat(x,b),_,S,M)},f=x=>x&&(x[r]||x),m=(x,b,_,S)=>x5(x)||_==="constructor"||a&&!Yh.isHandledMethod(b,_)||pS(l,i,_)||l.isGetInvariant(b,_)||n&&l.isDetached(b,e)?x:(S===void 0&&(S=l.getPath(b)),l.getProxy(x,na.concat(S,_),v,r)),v={get(x,b,_){if(wx(b)){if(b===r||b===bx)return x;if(b===MC&&!l.isUnsubscribed&&l.getPath(x).length===0)return l.unsubscribe(),x}let S=my(x)?Reflect.get(x,b):Reflect.get(x,b,_);return m(S,x,b)},set(x,b,_,S){_=f(_);let M=x[r]||x,C=M[b];if(s(C,_)&&b in x)return!0;let A=c(x,b,_,C);return A&&l.setProperty(M,b,_,S,C)?(d(x,b,x[b],C),!0):!A},defineProperty(x,b,_){if(!l.isSameDescriptor(_,x,b)){let S=x[b];c(x,b,_.value,S)&&l.defineProperty(x,b,_,S)&&d(x,b,_.value,S)}return!0},deleteProperty(x,b){if(!Reflect.has(x,b))return!0;let _=Reflect.get(x,b),S=c(x,b,void 0,_);return S&&l.deleteProperty(x,b,_)?(d(x,b,void 0,_),!0):!S},apply(x,b,_){let S=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(x,S,_);if((o===!1||o!==!0&&!o.includes(x.name))&&Yh.isHandledType(S)){let M=na.initial(l.getPath(x)),C=Yh.isHandledMethod(S,x.name);u.start(S,M,_);let A=Reflect.apply(x,u.preferredThisArg(x,b,S),C?_.map(R=>f(R)):_),T=u.isChanged(S,s),P=u.stop();if(Yh.isHandledType(A)&&C&&(b instanceof Map&&x.name==="get"&&(M=na.concat(M,_[0])),A=l.getProxy(A,M,v)),T){let R={name:x.name,args:_,result:A},z=u.isCloning?na.initial(M):M,N=u.isCloning?na.last(M):"";c(na.get(e,z),N,S,P,R)?p(z,N,S,P,R):u.undo(S)}return(b instanceof Map||b instanceof Set)&&w5(A)?_5(A,x,b,M,m):A}return Reflect.apply(x,b,_)}},y=l.getProxy(e,i.pathAsArray?[]:"",v);return t=t.bind(y),h&&(i.onValidate=i.onValidate.bind(y)),y};_x.target=e=>e&&e[bx]||e;_x.unsubscribe=e=>e[MC]||e;var vS=_x,R5=typeof global=="object"&&global&&global.Object===Object&&global,IC=R5,B5=typeof self=="object"&&self&&self.Object===Object&&self,L5=IC||B5||Function("return this")(),Va=L5,z5=Va.Symbol,fa=z5,RC=Object.prototype,k5=RC.hasOwnProperty,N5=RC.toString,Eu=fa?fa.toStringTag:void 0;function F5(e){var t=k5.call(e,Eu),i=e[Eu];try{e[Eu]=void 0;var r=!0}catch{}var s=N5.call(e);return r&&(t?e[Eu]=i:delete e[Eu]),s}var U5=F5,V5=Object.prototype,j5=V5.toString;function G5(e){return j5.call(e)}var H5=G5,W5="[object Null]",q5="[object Undefined]",yS=fa?fa.toStringTag:void 0;function X5(e){return e==null?e===void 0?q5:W5:yS&&yS in Object(e)?U5(e):H5(e)}var $l=X5;function Y5(e){return e!=null&&typeof e=="object"}var lo=Y5,Q5="[object Symbol]";function Z5(e){return typeof e=="symbol"||lo(e)&&$l(e)==Q5}var dg=Z5;function K5(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 BC=K5,J5=Array.isArray,xn=J5,$5=1/0,xS=fa?fa.prototype:void 0,bS=xS?xS.toString:void 0;function LC(e){if(typeof e=="string")return e;if(xn(e))return BC(e,LC)+"";if(dg(e))return bS?bS.call(e):"";var t=e+"";return t=="0"&&1/e==-$5?"-0":t}var eN=LC,tN=/\s/;function iN(e){for(var t=e.length;t--&&tN.test(e.charAt(t)););return t}var rN=iN,sN=/^\s+/;function aN(e){return e&&e.slice(0,rN(e)+1).replace(sN,"")}var nN=aN;function oN(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Ua=oN,wS=0/0,lN=/^[-+]0x[0-9a-f]+$/i,hN=/^0b[01]+$/i,cN=/^0o[0-7]+$/i,uN=parseInt;function dN(e){if(typeof e=="number")return e;if(dg(e))return wS;if(Ua(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ua(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=nN(e);var i=hN.test(e);return i||cN.test(e)?uN(e.slice(2),i?2:8):lN.test(e)?wS:+e}var _S=dN;function pN(e){return e}var fN=pN,mN="[object AsyncFunction]",gN="[object Function]",vN="[object GeneratorFunction]",yN="[object Proxy]";function xN(e){if(!Ua(e))return!1;var t=$l(e);return t==gN||t==vN||t==mN||t==yN}var zC=xN,bN=Va["__core-js_shared__"],Rv=bN,SS=function(){var e=/[^.]+$/.exec(Rv&&Rv.keys&&Rv.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function wN(e){return!!SS&&SS in e}var _N=wN,SN=Function.prototype,AN=SN.toString;function MN(e){if(e!=null){try{return AN.call(e)}catch{}try{return e+""}catch{}}return""}var eh=MN,EN=/[\\^$.*+?()[\]{}|]/g,CN=/^\[object .+?Constructor\]$/,TN=Function.prototype,PN=Object.prototype,DN=TN.toString,ON=PN.hasOwnProperty,IN=RegExp("^"+DN.call(ON).replace(EN,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function RN(e){if(!Ua(e)||_N(e))return!1;var t=zC(e)?IN:CN;return t.test(eh(e))}var BN=RN;function LN(e,t){return e?.[t]}var zN=LN;function kN(e,t){var i=zN(e,t);return BN(i)?i:void 0}var th=kN,NN=th(Va,"WeakMap"),vy=NN,AS=Object.create,FN=function(){function e(){}return function(t){if(!Ua(t))return{};if(AS)return AS(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),UN=FN;function VN(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 jN=VN;function GN(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var HN=GN,WN=800,qN=16,XN=Date.now;function YN(e){var t=0,i=0;return function(){var r=XN(),s=qN-(r-i);if(i=r,s>0){if(++t>=WN)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var QN=YN;function ZN(e){return function(){return e}}var KN=ZN,JN=function(){try{var e=th(Object,"defineProperty");return e({},"",{}),e}catch{}}(),vm=JN,$N=vm?function(e,t){return vm(e,"toString",{configurable:!0,enumerable:!1,value:KN(t),writable:!0})}:fN,eF=$N,tF=QN(eF),iF=tF;function rF(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var sF=rF,aF=9007199254740991,nF=/^(?:0|[1-9]\d*)$/;function oF(e,t){var i=typeof e;return t=t??aF,!!t&&(i=="number"||i!="symbol"&&nF.test(e))&&e>-1&&e%1==0&&e<t}var Sx=oF;function lF(e,t,i){t=="__proto__"&&vm?vm(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var kC=lF;function hF(e,t){return e===t||e!==e&&t!==t}var Ax=hF,cF=Object.prototype,uF=cF.hasOwnProperty;function dF(e,t,i){var r=e[t];(!(uF.call(e,t)&&Ax(r,i))||i===void 0&&!(t in e))&&kC(e,t,i)}var Mx=dF;function pF(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?kC(i,o,l):Mx(i,o,l)}return i}var Xd=pF,MS=Math.max;function fF(e,t,i){return t=MS(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=MS(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),jN(e,this,o)}}var mF=fF,gF=9007199254740991;function vF(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=gF}var Ex=vF;function yF(e){return e!=null&&Ex(e.length)&&!zC(e)}var NC=yF,xF=Object.prototype;function bF(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||xF;return e===i}var Cx=bF;function wF(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var _F=wF,SF="[object Arguments]";function AF(e){return lo(e)&&$l(e)==SF}var ES=AF,FC=Object.prototype,MF=FC.hasOwnProperty,EF=FC.propertyIsEnumerable,CF=ES(function(){return arguments}())?ES:function(e){return lo(e)&&MF.call(e,"callee")&&!EF.call(e,"callee")},Tx=CF;function TF(){return!1}var PF=TF,UC=typeof exports=="object"&&exports&&!exports.nodeType&&exports,CS=UC&&typeof module=="object"&&module&&!module.nodeType&&module,DF=CS&&CS.exports===UC,TS=DF?Va.Buffer:void 0,OF=TS?TS.isBuffer:void 0,IF=OF||PF,ym=IF,RF="[object Arguments]",BF="[object Array]",LF="[object Boolean]",zF="[object Date]",kF="[object Error]",NF="[object Function]",FF="[object Map]",UF="[object Number]",VF="[object Object]",jF="[object RegExp]",GF="[object Set]",HF="[object String]",WF="[object WeakMap]",qF="[object ArrayBuffer]",XF="[object DataView]",YF="[object Float32Array]",QF="[object Float64Array]",ZF="[object Int8Array]",KF="[object Int16Array]",JF="[object Int32Array]",$F="[object Uint8Array]",eU="[object Uint8ClampedArray]",tU="[object Uint16Array]",iU="[object Uint32Array]",Ti={};Ti[YF]=Ti[QF]=Ti[ZF]=Ti[KF]=Ti[JF]=Ti[$F]=Ti[eU]=Ti[tU]=Ti[iU]=!0;Ti[RF]=Ti[BF]=Ti[qF]=Ti[LF]=Ti[XF]=Ti[zF]=Ti[kF]=Ti[NF]=Ti[FF]=Ti[UF]=Ti[VF]=Ti[jF]=Ti[GF]=Ti[HF]=Ti[WF]=!1;function rU(e){return lo(e)&&Ex(e.length)&&!!Ti[$l(e)]}var sU=rU;function aU(e){return function(t){return e(t)}}var Px=aU,VC=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nd=VC&&typeof module=="object"&&module&&!module.nodeType&&module,nU=nd&&nd.exports===VC,Bv=nU&&IC.process,oU=function(){try{var e=nd&&nd.require&&nd.require("util").types;return e||Bv&&Bv.binding&&Bv.binding("util")}catch{}}(),Mc=oU,PS=Mc&&Mc.isTypedArray,lU=PS?Px(PS):sU,jC=lU,hU=Object.prototype,cU=hU.hasOwnProperty;function uU(e,t){var i=xn(e),r=!i&&Tx(e),s=!i&&!r&&ym(e),a=!i&&!r&&!s&&jC(e),n=i||r||s||a,o=n?_F(e.length,String):[],l=o.length;for(var h in e)(t||cU.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Sx(h,l)))&&o.push(h);return o}var GC=uU;function dU(e,t){return function(i){return e(t(i))}}var HC=dU,pU=HC(Object.keys,Object),fU=pU,mU=Object.prototype,gU=mU.hasOwnProperty;function vU(e){if(!Cx(e))return fU(e);var t=[];for(var i in Object(e))gU.call(e,i)&&i!="constructor"&&t.push(i);return t}var yU=vU;function xU(e){return NC(e)?GC(e):yU(e)}var Dx=xU;function bU(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var wU=bU,_U=Object.prototype,SU=_U.hasOwnProperty;function AU(e){if(!Ua(e))return wU(e);var t=Cx(e),i=[];for(var r in e)r=="constructor"&&(t||!SU.call(e,r))||i.push(r);return i}var MU=AU;function EU(e){return NC(e)?GC(e,!0):MU(e)}var El=EU,CU=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,TU=/^\w*$/;function PU(e,t){if(xn(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||dg(e)?!0:TU.test(e)||!CU.test(e)||t!=null&&e in Object(t)}var DU=PU,OU=th(Object,"create"),wd=OU;function IU(){this.__data__=wd?wd(null):{},this.size=0}var RU=IU;function BU(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var LU=BU,zU="__lodash_hash_undefined__",kU=Object.prototype,NU=kU.hasOwnProperty;function FU(e){var t=this.__data__;if(wd){var i=t[e];return i===zU?void 0:i}return NU.call(t,e)?t[e]:void 0}var UU=FU,VU=Object.prototype,jU=VU.hasOwnProperty;function GU(e){var t=this.__data__;return wd?t[e]!==void 0:jU.call(t,e)}var HU=GU,WU="__lodash_hash_undefined__";function qU(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=wd&&t===void 0?WU:t,this}var XU=qU;function Gc(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])}}Gc.prototype.clear=RU;Gc.prototype.delete=LU;Gc.prototype.get=UU;Gc.prototype.has=HU;Gc.prototype.set=XU;var DS=Gc;function YU(){this.__data__=[],this.size=0}var QU=YU;function ZU(e,t){for(var i=e.length;i--;)if(Ax(e[i][0],t))return i;return-1}var pg=ZU,KU=Array.prototype,JU=KU.splice;function $U(e){var t=this.__data__,i=pg(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():JU.call(t,i,1),--this.size,!0}var e6=$U;function t6(e){var t=this.__data__,i=pg(t,e);return i<0?void 0:t[i][1]}var i6=t6;function r6(e){return pg(this.__data__,e)>-1}var s6=r6;function a6(e,t){var i=this.__data__,r=pg(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var n6=a6;function Hc(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])}}Hc.prototype.clear=QU;Hc.prototype.delete=e6;Hc.prototype.get=i6;Hc.prototype.has=s6;Hc.prototype.set=n6;var fg=Hc,o6=th(Va,"Map"),_d=o6;function l6(){this.size=0,this.__data__={hash:new DS,map:new(_d||fg),string:new DS}}var h6=l6;function c6(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var u6=c6;function d6(e,t){var i=e.__data__;return u6(t)?i[typeof t=="string"?"string":"hash"]:i.map}var mg=d6;function p6(e){var t=mg(this,e).delete(e);return this.size-=t?1:0,t}var f6=p6;function m6(e){return mg(this,e).get(e)}var g6=m6;function v6(e){return mg(this,e).has(e)}var y6=v6;function x6(e,t){var i=mg(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var b6=x6;function Wc(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])}}Wc.prototype.clear=h6;Wc.prototype.delete=f6;Wc.prototype.get=g6;Wc.prototype.has=y6;Wc.prototype.set=b6;var gg=Wc,w6="Expected a function";function Ox(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(w6);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(Ox.Cache||gg),i}Ox.Cache=gg;var _6=Ox,S6=500;function A6(e){var t=_6(e,function(r){return i.size===S6&&i.clear(),r}),i=t.cache;return t}var M6=A6,E6=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,C6=/\\(\\)?/g,T6=M6(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(E6,function(i,r,s,a){t.push(s?a.replace(C6,"$1"):r||i)}),t}),P6=T6;function D6(e){return e==null?"":eN(e)}var O6=D6;function I6(e,t){return xn(e)?e:DU(e,t)?[e]:P6(O6(e))}var qc=I6,R6=1/0;function B6(e){if(typeof e=="string"||dg(e))return e;var t=e+"";return t=="0"&&1/e==-R6?"-0":t}var vg=B6;function L6(e,t){t=qc(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[vg(t[i++])];return i&&i==r?e:void 0}var WC=L6;function z6(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Ix=z6,OS=fa?fa.isConcatSpreadable:void 0;function k6(e){return xn(e)||Tx(e)||!!(OS&&e&&e[OS])}var N6=k6;function qC(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=N6),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?qC(o,t-1,i,r,s):Ix(s,o):r||(s[s.length]=o)}return s}var F6=qC;function U6(e){var t=e==null?0:e.length;return t?F6(e,1):[]}var V6=U6;function j6(e){return iF(mF(e,void 0,V6),e+"")}var XC=j6,G6=HC(Object.getPrototypeOf,Object),Rx=G6,H6="[object Object]",W6=Function.prototype,q6=Object.prototype,YC=W6.toString,X6=q6.hasOwnProperty,Y6=YC.call(Object);function Q6(e){if(!lo(e)||$l(e)!=H6)return!1;var t=Rx(e);if(t===null)return!0;var i=X6.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&YC.call(i)==Y6}var Z6=Q6;function K6(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 J6=K6;function $6(){this.__data__=new fg,this.size=0}var eV=$6;function tV(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var iV=tV;function rV(e){return this.__data__.get(e)}var sV=rV;function aV(e){return this.__data__.has(e)}var nV=aV,oV=200;function lV(e,t){var i=this.__data__;if(i instanceof fg){var r=i.__data__;if(!_d||r.length<oV-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new gg(r)}return i.set(e,t),this.size=i.size,this}var hV=lV;function Xc(e){var t=this.__data__=new fg(e);this.size=t.size}Xc.prototype.clear=eV;Xc.prototype.delete=iV;Xc.prototype.get=sV;Xc.prototype.has=nV;Xc.prototype.set=hV;var Xf=Xc;function cV(e,t){return e&&Xd(t,Dx(t),e)}var uV=cV;function dV(e,t){return e&&Xd(t,El(t),e)}var pV=dV,QC=typeof exports=="object"&&exports&&!exports.nodeType&&exports,IS=QC&&typeof module=="object"&&module&&!module.nodeType&&module,fV=IS&&IS.exports===QC,RS=fV?Va.Buffer:void 0,BS=RS?RS.allocUnsafe:void 0;function mV(e,t){if(t)return e.slice();var i=e.length,r=BS?BS(i):new e.constructor(i);return e.copy(r),r}var gV=mV;function vV(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 yV=vV;function xV(){return[]}var ZC=xV,bV=Object.prototype,wV=bV.propertyIsEnumerable,LS=Object.getOwnPropertySymbols,_V=LS?function(e){return e==null?[]:(e=Object(e),yV(LS(e),function(t){return wV.call(e,t)}))}:ZC,Bx=_V;function SV(e,t){return Xd(e,Bx(e),t)}var AV=SV,MV=Object.getOwnPropertySymbols,EV=MV?function(e){for(var t=[];e;)Ix(t,Bx(e)),e=Rx(e);return t}:ZC,KC=EV;function CV(e,t){return Xd(e,KC(e),t)}var TV=CV;function PV(e,t,i){var r=t(e);return xn(e)?r:Ix(r,i(e))}var JC=PV;function DV(e){return JC(e,Dx,Bx)}var yy=DV;function OV(e){return JC(e,El,KC)}var $C=OV,IV=th(Va,"DataView"),xy=IV,RV=th(Va,"Promise"),by=RV,BV=th(Va,"Set"),wy=BV,zS="[object Map]",LV="[object Object]",kS="[object Promise]",NS="[object Set]",FS="[object WeakMap]",US="[object DataView]",zV=eh(xy),kV=eh(_d),NV=eh(by),FV=eh(wy),UV=eh(vy),gl=$l;(xy&&gl(new xy(new ArrayBuffer(1)))!=US||_d&&gl(new _d)!=zS||by&&gl(by.resolve())!=kS||wy&&gl(new wy)!=NS||vy&&gl(new vy)!=FS)&&(gl=function(e){var t=$l(e),i=t==LV?e.constructor:void 0,r=i?eh(i):"";if(r)switch(r){case zV:return US;case kV:return zS;case NV:return kS;case FV:return NS;case UV:return FS}return t});var Sd=gl,VV=Object.prototype,jV=VV.hasOwnProperty;function GV(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&jV.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var HV=GV,WV=Va.Uint8Array,xm=WV;function qV(e){var t=new e.constructor(e.byteLength);return new xm(t).set(new xm(e)),t}var Lx=qV;function XV(e,t){var i=t?Lx(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var YV=XV,QV=/\w*$/;function ZV(e){var t=new e.constructor(e.source,QV.exec(e));return t.lastIndex=e.lastIndex,t}var KV=ZV,VS=fa?fa.prototype:void 0,jS=VS?VS.valueOf:void 0;function JV(e){return jS?Object(jS.call(e)):{}}var $V=JV;function ej(e,t){var i=t?Lx(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var tj=ej,ij="[object Boolean]",rj="[object Date]",sj="[object Map]",aj="[object Number]",nj="[object RegExp]",oj="[object Set]",lj="[object String]",hj="[object Symbol]",cj="[object ArrayBuffer]",uj="[object DataView]",dj="[object Float32Array]",pj="[object Float64Array]",fj="[object Int8Array]",mj="[object Int16Array]",gj="[object Int32Array]",vj="[object Uint8Array]",yj="[object Uint8ClampedArray]",xj="[object Uint16Array]",bj="[object Uint32Array]";function wj(e,t,i){var r=e.constructor;switch(t){case cj:return Lx(e);case ij:case rj:return new r(+e);case uj:return YV(e,i);case dj:case pj:case fj:case mj:case gj:case vj:case yj:case xj:case bj:return tj(e,i);case sj:return new r;case aj:case lj:return new r(e);case nj:return KV(e);case oj:return new r;case hj:return $V(e)}}var _j=wj;function Sj(e){return typeof e.constructor=="function"&&!Cx(e)?UN(Rx(e)):{}}var Aj=Sj,Mj="[object Map]";function Ej(e){return lo(e)&&Sd(e)==Mj}var Cj=Ej,GS=Mc&&Mc.isMap,Tj=GS?Px(GS):Cj,Pj=Tj,Dj="[object Set]";function Oj(e){return lo(e)&&Sd(e)==Dj}var Ij=Oj,HS=Mc&&Mc.isSet,Rj=HS?Px(HS):Ij,Bj=Rj,Lj=1,zj=2,kj=4,eT="[object Arguments]",Nj="[object Array]",Fj="[object Boolean]",Uj="[object Date]",Vj="[object Error]",tT="[object Function]",jj="[object GeneratorFunction]",Gj="[object Map]",Hj="[object Number]",iT="[object Object]",Wj="[object RegExp]",qj="[object Set]",Xj="[object String]",Yj="[object Symbol]",Qj="[object WeakMap]",Zj="[object ArrayBuffer]",Kj="[object DataView]",Jj="[object Float32Array]",$j="[object Float64Array]",e8="[object Int8Array]",t8="[object Int16Array]",i8="[object Int32Array]",r8="[object Uint8Array]",s8="[object Uint8ClampedArray]",a8="[object Uint16Array]",n8="[object Uint32Array]",Ei={};Ei[eT]=Ei[Nj]=Ei[Zj]=Ei[Kj]=Ei[Fj]=Ei[Uj]=Ei[Jj]=Ei[$j]=Ei[e8]=Ei[t8]=Ei[i8]=Ei[Gj]=Ei[Hj]=Ei[iT]=Ei[Wj]=Ei[qj]=Ei[Xj]=Ei[Yj]=Ei[r8]=Ei[s8]=Ei[a8]=Ei[n8]=!0;Ei[Vj]=Ei[tT]=Ei[Qj]=!1;function Yf(e,t,i,r,s,a){var n,o=t&Lj,l=t&zj,h=t&kj;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!Ua(e))return e;var u=xn(e);if(u){if(n=HV(e),!o)return HN(e,n)}else{var c=Sd(e),d=c==tT||c==jj;if(ym(e))return gV(e,o);if(c==iT||c==eT||d&&!s){if(n=l||d?{}:Aj(e),!o)return l?TV(e,pV(n,e)):AV(e,uV(n,e))}else{if(!Ei[c])return s?e:{};n=_j(e,c,o)}}a||(a=new Xf);var p=a.get(e);if(p)return p;a.set(e,n),Bj(e)?e.forEach(function(v){n.add(Yf(v,t,i,v,e,a))}):Pj(e)&&e.forEach(function(v,y){n.set(y,Yf(v,t,i,y,e,a))});var f=h?l?$C:yy:l?El:Dx,m=u?void 0:f(e);return sF(m||e,function(v,y){m&&(y=v,v=e[y]),Mx(n,y,Yf(v,t,i,y,e,a))}),n}var rT=Yf,o8=1,l8=4;function h8(e){return rT(e,o8|l8)}var yg=h8,c8="__lodash_hash_undefined__";function u8(e){return this.__data__.set(e,c8),this}var d8=u8;function p8(e){return this.__data__.has(e)}var f8=p8;function bm(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new gg;++t<i;)this.add(e[t])}bm.prototype.add=bm.prototype.push=d8;bm.prototype.has=f8;var m8=bm;function g8(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 v8=g8;function y8(e,t){return e.has(t)}var x8=y8,b8=1,w8=2;function _8(e,t,i,r,s,a){var n=i&b8,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),u=a.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&w8?new m8:void 0;for(a.set(e,t),a.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var v=n?r(m,f,c,t,e,a):r(f,m,c,e,t,a);if(v!==void 0){if(v)continue;d=!1;break}if(p){if(!v8(t,function(y,x){if(!x8(p,x)&&(f===y||s(f,y,i,r,a)))return p.push(x)})){d=!1;break}}else if(!(f===m||s(f,m,i,r,a))){d=!1;break}}return a.delete(e),a.delete(t),d}var sT=_8;function S8(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var A8=S8;function M8(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var E8=M8,C8=1,T8=2,P8="[object Boolean]",D8="[object Date]",O8="[object Error]",I8="[object Map]",R8="[object Number]",B8="[object RegExp]",L8="[object Set]",z8="[object String]",k8="[object Symbol]",N8="[object ArrayBuffer]",F8="[object DataView]",WS=fa?fa.prototype:void 0,Lv=WS?WS.valueOf:void 0;function U8(e,t,i,r,s,a,n){switch(i){case F8:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case N8:return!(e.byteLength!=t.byteLength||!a(new xm(e),new xm(t)));case P8:case D8:case R8:return Ax(+e,+t);case O8:return e.name==t.name&&e.message==t.message;case B8:case z8:return e==t+"";case I8:var o=A8;case L8:var l=r&C8;if(o||(o=E8),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=T8,n.set(e,t);var u=sT(o(e),o(t),r,s,a,n);return n.delete(e),u;case k8:if(Lv)return Lv.call(e)==Lv.call(t)}return!1}var V8=U8,j8=1,G8=Object.prototype,H8=G8.hasOwnProperty;function W8(e,t,i,r,s,a){var n=i&j8,o=yy(e),l=o.length,h=yy(t),u=h.length;if(l!=u&&!n)return!1;for(var c=l;c--;){var d=o[c];if(!(n?d in t:H8.call(t,d)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var m=!0;a.set(e,t),a.set(t,e);for(var v=n;++c<l;){d=o[c];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)){m=!1;break}v||(v=d=="constructor")}if(m&&!v){var _=e.constructor,S=t.constructor;_!=S&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof S=="function"&&S instanceof S)&&(m=!1)}return a.delete(e),a.delete(t),m}var q8=W8,X8=1,qS="[object Arguments]",XS="[object Array]",Jp="[object Object]",Y8=Object.prototype,YS=Y8.hasOwnProperty;function Q8(e,t,i,r,s,a){var n=xn(e),o=xn(t),l=n?XS:Sd(e),h=o?XS:Sd(t);l=l==qS?Jp:l,h=h==qS?Jp:h;var u=l==Jp,c=h==Jp,d=l==h;if(d&&ym(e)){if(!ym(t))return!1;n=!0,u=!1}if(d&&!u)return a||(a=new Xf),n||jC(e)?sT(e,t,i,r,s,a):V8(e,t,l,i,r,s,a);if(!(i&X8)){var p=u&&YS.call(e,"__wrapped__"),f=c&&YS.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,v=f?t.value():t;return a||(a=new Xf),s(m,v,i,r,a)}}return d?(a||(a=new Xf),q8(e,t,i,r,s,a)):!1}var Z8=Q8;function aT(e,t,i,r,s){return e===t?!0:e==null||t==null||!lo(e)&&!lo(t)?e!==e&&t!==t:Z8(e,t,i,r,aT,s)}var K8=aT;function J8(e,t){return e!=null&&t in Object(e)}var $8=J8;function eG(e,t,i){t=qc(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=vg(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&&Ex(s)&&Sx(n,s)&&(xn(e)||Tx(e)))}var tG=eG;function iG(e,t){return e!=null&&tG(e,t,$8)}var rG=iG,sG=function(){return Va.Date.now()},zv=sG,aG="Expected a function",nG=Math.max,oG=Math.min;function lG(e,t,i){var r,s,a,n,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(aG);t=_S(t)||0,Ua(i)&&(u=!!i.leading,c="maxWait"in i,a=c?nG(_S(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d);function p(M){var C=r,A=s;return r=s=void 0,h=M,n=e.apply(A,C),n}function f(M){return h=M,o=setTimeout(y,t),u?p(M):n}function m(M){var C=M-l,A=M-h,T=t-C;return c?oG(T,a-A):T}function v(M){var C=M-l,A=M-h;return l===void 0||C>=t||C<0||c&&A>=a}function y(){var M=zv();if(v(M))return x(M);o=setTimeout(y,m(M))}function x(M){return o=void 0,d&&r?p(M):(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(zv())}function S(){var M=zv(),C=v(M);if(r=arguments,s=this,l=M,C){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(y,t),p(l)}return o===void 0&&(o=setTimeout(y,t)),n}return S.cancel=b,S.flush=_,S}var zx=lG;function hG(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var cG=hG;function uG(e,t){return t.length<2?e:WC(e,J6(t,0,-1))}var dG=uG;function pG(e,t){return K8(e,t)}var nT=pG;function fG(e,t){return t=qc(t,e),e=dG(e,t),e==null||delete e[vg(cG(t))]}var mG=fG;function gG(e){return Z6(e)?void 0:e}var vG=gG,yG=1,xG=2,bG=4,wG=XC(function(e,t){var i={};if(e==null)return i;var r=!1;t=BC(t,function(a){return a=qc(a,e),r||(r=a.length>1),a}),Xd(e,$C(e),i),r&&(i=rT(i,yG|xG|bG,vG));for(var s=t.length;s--;)mG(i,t[s]);return i}),_y=wG;function _G(e,t,i,r){if(!Ua(e))return e;t=qc(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=vg(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=Ua(u)?u:Sx(t[s+1])?[]:{})}Mx(o,l,h),o=o[l]}return e}var SG=_G;function AG(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=WC(e,n);i(o,n)&&SG(a,qc(n,e),o)}return a}var MG=AG;function EG(e,t){return MG(e,t,function(i,r){return rG(e,r)})}var CG=EG,TG=XC(function(e,t){return e==null?{}:CG(e,t)}),ao=TG,PG="Expected a function";function DG(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(PG);return Ua(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),zx(e,t,{leading:r,maxWait:t,trailing:s})}var OG=DG;function oT(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function bn(e,t){return Object.setPrototypeOf(e,t),e}var IG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),RG=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),BG=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||xg&&"ontouchend"in document,LG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,zG=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,kG=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},NG=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},FG=()=>{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"},UG=IG(),Ree=UG?FG():void 0,xg=RG(),kx=BG(),VG=LG(),Hs=zG(),QS=kG(),ZS=Number(NG());function lT(e){return Array.isArray(e)?e:[e]}function hT(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 $p(e){return xg?e.metaKey:e.ctrlKey}function jG(e){return e.wheelDeltaY===0||e.deltaY===0?xg&&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 wt=[],wm={},Yu={},Qf={};function cT(e){wt.includes(e)||wt.push(e)}function lc(e){delete wm[e.pointerId];for(let t=0;t<wt.length;t++)if(wt[t].pointerId===e.pointerId){wt.splice(t,1);break}}function GG(){wt.splice(0,wt.length)}function _m(e){if(e.pointerType!=="touch")return;let t=wm[e.pointerId];t===void 0&&(t={x:0,y:0},wm[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function kv(e){let t=e.pointerId===wt[0].pointerId?wt[1]:wt[0];return wm[t.pointerId]}function uT(e){Yu[e.key]=!0,Qf[e.key]=Qf[e.key]===void 0?1:Qf[e.key]+1}function dT(e){if(xg&&Yu.Meta)for(let t in Yu)Yu[t]=!1;else Yu[e.key]=!1;Qf={}}function HG(e){e.addEventListener("pointerdown",cT,!0),e.addEventListener("pointerdown",_m,!0),e.addEventListener("pointermove",_m,!0),e.addEventListener("pointerup",lc,!0),e.addEventListener("pointercancel",lc,!0),e.addEventListener("pointerleave",lc,!0),window.addEventListener("keydown",uT,!0),window.addEventListener("keyup",dT,!0)}function WG(e){e.removeEventListener("pointerdown",cT,!0),e.removeEventListener("pointerdown",_m,!0),e.removeEventListener("pointermove",_m,!0),e.removeEventListener("pointerup",lc,!0),e.removeEventListener("pointercancel",lc,!0),e.removeEventListener("pointerleave",lc,!0),window.removeEventListener("keydown",uT,!0),window.removeEventListener("keyup",dT,!0)}var pT,qG=new Promise(e=>{pT=e}),ef;function XG(){if(ef)return ef;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@1.0.22/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});pT(n)}return ef=e(),ef}var fT,YG=new Promise(e=>{fT=e}),tf;function QG(){if(tf)return tf;async function e(){let t=await import("./physics.js");await t.init(),fT(t)}return tf=e(),tf}var Tt=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,Tt.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,Tt.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,Tt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function Nx(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"&&Nx(r)}return Object.freeze(e)}function ZG(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 mT=class extends Error{};function Nv(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function zo(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 Fx(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 KG(){return typeof process<"u"}function gT(e,t){for(let i of e)t(i.id,i.data)!==!0&&gT(i.children,t)}function vT(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)vT(i,t)}var qr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,qr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nx(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&&vT(i,t)}}traverse(e){gT(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,qr.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,u)=>h.fi-u.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 c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new mT("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(c=>c.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((c,d)=>c.fi-d.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>ZG(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 zo(0,i,i);{let s=r[0].fi;return zo(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 zo(n,n+i,i)}else return zo(s.fi,a.fi,i)}}},Sm;(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})(Sm||(Sm={}));var mt=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,mt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Nx(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,mt.prototype);let t=e;return KG()||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 zo(0,t,t);{let r=i[0].fi;return zo(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 zo(a,a+t,t)}else return zo(r.fi,s.fi,t)}}};function Ec(e){return e&&typeof e=="object"&&e instanceof cr}var cr=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&&!Ec(i))return null;r+=1}i=i?Nv(i):new cr;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=Nv(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Nv(o);l[e.path[r-1]]=i,i=l}else{let l=new cr;l[e.path[r-1]]=i,i=l}}r-=1}let a=Object.setPrototypeOf(i,cr.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},qo;(e=>{function t(s,a){return Ad(s,a)??s}e.apply=t;function i(s,a){return Vx(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=Wr.zoomOnce(l,o[n]),l===void 0)return a;if(!Ec(l))return;n+=1}if(l===void 0)return a;if(Ec(l))if(a.type===0){let h={...a.props};for(let u of Object.keys(l))delete h[u];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=Ux([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(qo||(qo={}));function Ux(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=Ad(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=Ux(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 JG(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=Ad(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 Ad(e,t){if(!Ec(t))return t;if(e instanceof qr){let i=Ux(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof mt)return JG(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=Ad(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 cr)return Vx(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=Ad(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 Vx(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Ec(t))return t;if(!Ec(e))return qo.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 cr;for(let s of i){let a=Vx(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function $G(e,t){let i={cur:[],result:[],len:0};return e=Md(e,t,i)??e,[e,i.result]}function Am(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Mm(e){e&&(e.len-=1)}function eH(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function yT(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=Md(a.data,t,Am(i,n));Mm(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=yT(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 tH(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=Md(a.data,t,Am(i,n));return Mm(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 Md(e,t,i){if(e instanceof qr){let r=yT(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof mt)return tH(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=Md(a,t,Am(i,n));return Mm(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"&&!Fx(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=Md(n,t,Am(i,a));Mm(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&&eH(i),r}else return}}var Em;(e=>{function t(i,r){let s=Wr.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})(Em||(Em={}));var Dr;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let u=h.path;for(var c=[];;){let d;if(l instanceof cr&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof qr||l instanceof mt||l instanceof Tt?d=l.runOp(h):d=Sm.runOp(l,h)),d!==void 0)if(d!==null){let m=d.data;for(let v=c.length-1;v>=0;v--){let y=u[v],x=c[v];if(x instanceof qr){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof mt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof Tt){if(typeof y=="number")throw new Error("illegal arg");m=x.modifyById(y,m)}else if(x instanceof cr){let b={...x,[y]:m};m=Object.setPrototypeOf(b,cr.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=m;m=[...x],m[y]=b}else m={...x,[y]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof qr){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof mt){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let u=0;u<l.length&&u<h.length;u++)if(l[u]!==h[u])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==h[u])return!1;return!0}e.pathEq=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(u=>h.props[u]!==void 0):!1}e.subsumed=o})(Dr||(Dr={}));var Sy;(e=>{function t(){return[]}e.empty=t;function i(h,u){let c=[];for(let d of h){let[p,...f]=d.path;p===u&&c.push({...d,path:f})}return c}e.removePrefix=i;function r(h,u){return h.map(c=>({...c,path:[u,...c.path]}))}e.addPrefix=r;function s(h,u){return[...h,...u]}e.concat=s;function a(h,u){return[...h.filter(c=>!u.some(d=>Dr.subsumed(c,d))),...u]}e.compress=a;function n(h,u){return h.every(c=>u.every(d=>Dr.commutative(c,d)))}e.commutative=n;function o(h,u){for(let c of u){let d=l(h,c);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,u){var c=h;let d=[],p=[];for(let f of u)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,v,y;if(f.type===3?(m=Wr.zoom(c,[...f.path,f.id]),y=Dr.apply(c,{...f,type:2})):(m=Wr.zoom(c,[...f.path,f.id,"value"]),y=Dr.apply(c,f)),y!==null){c=y.data;let[x,b]=$G(c,{[f.id]:m});c=x;for(let _=0;_<b.length;_++){let S=b[_],M=S.pop();if(typeof M=="number"){let C=[M];for(let T=_+1;T<b.length;T++){let P=b[T],R=P[P.length-1];if(typeof R=="number"&&Wr.equal(S,P.slice(0,P.length-1)))C.push(R),b.splice(T,1);else break}let A=Wr.zoom(c,S);v=A.map((T,P)=>C.includes(P)?f.id:T),m=A,M=S.pop()}else{if(M==="alphaOverride"||M==="alpha"){m/=100;let C=m,A=Wr.zoom(c,S.slice(0,S.length-2)),T=A.layers.map(P=>P.id===S[S.length-1]?{...P,data:{...P.data,[M]:C}}:P);Object.setPrototypeOf(T,Object.getPrototypeOf(A.layers)),A.layers=T}v=f.id}d.push({type:0,path:S,props:{[M]:m}}),p.push({type:0,path:S,props:{[M]:v}})}p.push(y.reverse),d.push(y.actual)}}else{let m=Dr.apply(c,f);m!==null&&(d.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof mT)return null;throw m}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(Sy||(Sy={}));var xT=Symbol(),iH=Symbol(),bg=Symbol(),Yd=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof wT);){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[bg];i&&i(),delete this._children[e]}}}},rH=class extends Yd{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,Sm.runOp(this._current,e),e.path)}},sH=class extends Yd{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,Tt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},bT={get(e,t){if(t===bg)return()=>{e._parent=null};if(t===xT)return e._current;if(t===iH)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=wg(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]}}},aH={...bT,set(e,t,i){let r={type:0,props:{[t]:Ji(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}},nH={...bT,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}},jx=class extends Yd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[bg]=()=>{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=wg(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)}},Gx=class extends Yd{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[bg]=()=>{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=wg(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 Fv(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Wr.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var wT=class extends Yd{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){Fv(this.ts,t,e),Fv(this.actual,i,e),Fv(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function wg(e,t,i){return i instanceof qr?new jx(e,t,i):i instanceof mt?new Gx(e,t,i):i instanceof Tt?new Proxy(new sH(e,t,i),nH):i!==null&&typeof i=="object"?Fx(i)?i:new Proxy(new rH(e,t,i),aH):i}function _T(e){let t=new wT(e);return[wg(t,"",e),t]}function Ed(e,t){let[i,r]=_T(e);return t(i),r.result()}function Ji(e){return e instanceof jx||e instanceof Gx?e._current:e!==null&&typeof e=="object"?e[xT]:e}var Wr;(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(u=>{delete h[u]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof qr||a instanceof jx)&&typeof n=="string"||(a instanceof mt||a instanceof Gx)&&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})(Wr||(Wr={}));function oH(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 _i(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 ST=class{},KS=class extends ST{constructor(e){super(),this.id=e}},JS=class extends ST{constructor(e){super(),this.data=e}},Ay;try{Ay=new TextDecoder}catch{}var rt,Xo,fe=0,AT=[],My=AT,Ey=0,Os={},ii,ko,oa=0,un=0,js,no,_s=[],hi,$S={useRecords:!1,mapsAsObjects:!0},MT=class{},ET=new MT;ET.name="MessagePack 0xC1";var Cc=!1,Cm=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(rt)return IT(()=>(Ty(),this?this.unpack(e,t):Cm.prototype.unpack.call($S,e,t)));Xo=t>-1?t:e.length,fe=0,Ey=0,un=0,ko=null,My=AT,js=null,rt=e;try{hi=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw rt=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 Cm){if(Os=this,this.structures)return ii=this.structures,rf();(!ii||ii.length>0)&&(ii=[])}else Os=$S,(!ii||ii.length>0)&&(ii=[]);return rf()}unpackMultiple(e,t){let i,r=0;try{Cc=!0;let s=e.length,a=this?this.unpack(e,s):Sg.unpack(e,s);if(t){for(t(a);fe<s;)if(r=fe,t(rf())===!1)return}else{for(i=[a];fe<s;)r=fe,i.push(rf());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Cc=!1,Ty()}}_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 rf(){try{if(!Os.trusted&&!Cc){let t=ii.sharedLength||0;t<ii.length&&(ii.length=t)}let e=Gi();if(fe==Xo)ii.restoreStructures&&e2(),ii=null,rt=null,no&&(no=null);else if(fe>Xo){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Cc)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw ii.restoreStructures&&e2(),Ty(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function e2(){for(let e in ii.restoreStructures)ii[e]=ii.restoreStructures[e];ii.restoreStructures=null}function Gi(){let e=rt[fe++];if(e<160)if(e<128){if(e<64)return e;{let t=ii[e&63]||Os.getStructures&&CT()[e&63];return t?(t.read||(t.read=Hx(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Os.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[PT()]=Gi();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gi(),Gi());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gi();return t}else if(e<192){let t=e-160;if(un>=fe)return ko.slice(fe-oa,(fe+=t)-oa);if(un==0&&Xo<140){let i=t<16?Wx(t):TT(t);if(i!=null)return i}return Cy(t)}else{let t;switch(e){case 192:return null;case 193:return js?(t=Gi(),t>0?js[1].slice(js.position1,js.position1+=t):js[0].slice(js.position0,js.position0-=t)):ET;case 194:return!1;case 195:return!0;case 196:return Uv(rt[fe++]);case 197:return t=hi.getUint16(fe),fe+=2,Uv(t);case 198:return t=hi.getUint32(fe),fe+=4,Uv(t);case 199:return cl(rt[fe++]);case 200:return t=hi.getUint16(fe),fe+=2,cl(t);case 201:return t=hi.getUint32(fe),fe+=4,cl(t);case 202:if(t=hi.getFloat32(fe),Os.useFloat32>2){let i=qx[(rt[fe]&127)<<1|rt[fe+1]>>7];return fe+=4,(i*t+(t>0?.5:-.5)>>0)/i}return fe+=4,t;case 203:return t=hi.getFloat64(fe),fe+=8,t;case 204:return rt[fe++];case 205:return t=hi.getUint16(fe),fe+=2,t;case 206:return t=hi.getUint32(fe),fe+=4,t;case 207:return Os.int64AsNumber?(t=hi.getUint32(fe)*4294967296,t+=hi.getUint32(fe+4)):t=hi.getBigUint64(fe),fe+=8,t;case 208:return hi.getInt8(fe++);case 209:return t=hi.getInt16(fe),fe+=2,t;case 210:return t=hi.getInt32(fe),fe+=4,t;case 211:return Os.int64AsNumber?(t=hi.getInt32(fe)*4294967296,t+=hi.getUint32(fe+4)):t=hi.getBigInt64(fe),fe+=8,t;case 212:if(t=rt[fe++],t==114)return a2(rt[fe++]&63);{let i=_s[t];if(i)return i.read?(fe++,i.read(Gi())):i.noBuffer?(fe++,i()):i(rt.subarray(fe,++fe));throw new Error("Unknown extension "+t)}case 213:return t=rt[fe],t==114?(fe++,a2(rt[fe++]&63,rt[fe++])):cl(2);case 214:return cl(4);case 215:return cl(8);case 216:return cl(16);case 217:return t=rt[fe++],un>=fe?ko.slice(fe-oa,(fe+=t)-oa):hH(t);case 218:return t=hi.getUint16(fe),fe+=2,un>=fe?ko.slice(fe-oa,(fe+=t)-oa):cH(t);case 219:return t=hi.getUint32(fe),fe+=4,un>=fe?ko.slice(fe-oa,(fe+=t)-oa):uH(t);case 220:return t=hi.getUint16(fe),fe+=2,i2(t);case 221:return t=hi.getUint32(fe),fe+=4,i2(t);case 222:return t=hi.getUint16(fe),fe+=2,r2(t);case 223:return t=hi.getUint32(fe),fe+=4,r2(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 lH=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Hx(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>lH.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(Gi);return e.highByte===0&&(e.read=t2(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=Gi()}return r}return i.count=0,e.highByte===0?t2(t,i):i}var t2=(e,t)=>function(){let i=rt[fe++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=ii[r]||CT()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=Hx(s,e)),s.read()};function CT(){let e=IT(()=>(rt=null,Os.getStructures()));return ii=Os._mergeStructures(e,ii)}var Cy=_g,hH=_g,cH=_g,uH=_g;function _g(e){let t;if(e<16&&(t=Wx(e)))return t;if(e>64&&Ay)return Ay.decode(rt.subarray(fe,fe+=e));let i=fe+e,r=[];for(t="";fe<i;){let s=rt[fe++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=rt[fe++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=rt[fe++]&63,n=rt[fe++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=rt[fe++]&63,n=rt[fe++]&63,o=rt[fe++]&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+=Cr.apply(String,r),r.length=0)}return r.length>0&&(t+=Cr.apply(String,r)),t}function i2(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Gi();return t}function r2(e){if(Os.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[PT()]=Gi();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Gi(),Gi());return t}}var Cr=String.fromCharCode;function TT(e){let t=fe,i=new Array(e);for(let r=0;r<e;r++){let s=rt[fe++];if((s&128)>0){fe=t;return}i[r]=s}return Cr.apply(String,i)}function Wx(e){if(e<4)if(e<2){if(e===0)return"";{let t=rt[fe++];if((t&128)>1){fe-=1;return}return Cr(t)}}else{let t=rt[fe++],i=rt[fe++];if((t&128)>0||(i&128)>0){fe-=2;return}if(e<3)return Cr(t,i);let r=rt[fe++];if((r&128)>0){fe-=3;return}return Cr(t,i,r)}else{let t=rt[fe++],i=rt[fe++],r=rt[fe++],s=rt[fe++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){fe-=4;return}if(e<6){if(e===4)return Cr(t,i,r,s);{let a=rt[fe++];if((a&128)>0){fe-=5;return}return Cr(t,i,r,s,a)}}else if(e<8){let a=rt[fe++],n=rt[fe++];if((a&128)>0||(n&128)>0){fe-=6;return}if(e<7)return Cr(t,i,r,s,a,n);let o=rt[fe++];if((o&128)>0){fe-=7;return}return Cr(t,i,r,s,a,n,o)}else{let a=rt[fe++],n=rt[fe++],o=rt[fe++],l=rt[fe++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){fe-=8;return}if(e<10){if(e===8)return Cr(t,i,r,s,a,n,o,l);{let h=rt[fe++];if((h&128)>0){fe-=9;return}return Cr(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=rt[fe++],u=rt[fe++];if((h&128)>0||(u&128)>0){fe-=10;return}if(e<11)return Cr(t,i,r,s,a,n,o,l,h,u);let c=rt[fe++];if((c&128)>0){fe-=11;return}return Cr(t,i,r,s,a,n,o,l,h,u,c)}else{let h=rt[fe++],u=rt[fe++],c=rt[fe++],d=rt[fe++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){fe-=12;return}if(e<14){if(e===12)return Cr(t,i,r,s,a,n,o,l,h,u,c,d);{let p=rt[fe++];if((p&128)>0){fe-=13;return}return Cr(t,i,r,s,a,n,o,l,h,u,c,d,p)}}else{let p=rt[fe++],f=rt[fe++];if((p&128)>0||(f&128)>0){fe-=14;return}if(e<15)return Cr(t,i,r,s,a,n,o,l,h,u,c,d,p,f);let m=rt[fe++];if((m&128)>0){fe-=15;return}return Cr(t,i,r,s,a,n,o,l,h,u,c,d,p,f,m)}}}}}function Uv(e){return Os.copyBuffers?Uint8Array.prototype.slice.call(rt,fe,fe+=e):rt.subarray(fe,fe+=e)}function cl(e){let t=rt[fe++];if(_s[t])return _s[t](rt.subarray(fe,fe+=e));throw new Error("Unknown extension type "+t)}var s2=new Array(4096);function PT(){let e=rt[fe++];if(e>=160&&e<192){if(e=e-160,un>=fe)return ko.slice(fe-oa,(fe+=e)-oa);if(!(un==0&&Xo<180))return Cy(e)}else return fe--,Gi();let t=(e<<5^(e>1?hi.getUint16(fe):e>0?rt[fe]:0))&4095,i=s2[t],r=fe,s=fe+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=hi.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=rt[r++],a!=i[n++]){r=1879048192;break}if(r===s)return fe=r,i.string;s-=3,r=fe}for(i=[],s2[t]=i,i.bytes=e;r<s;)a=hi.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=rt[r++],i.push(a);let o=e<16?Wx(e):TT(e);return o!=null?i.string=o:i.string=Cy(e)}var a2=(e,t)=>{var i=Gi();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=ii[e];return s&&s.isShared&&((ii.restoreStructures||(ii.restoreStructures=[]))[e]=s),ii[e]=i,i.read=Hx(i,r),i.read()},DT=typeof self=="object"?self:global;_s[0]=()=>{};_s[0].noBuffer=!0;_s[101]=()=>{let e=Gi();return(DT[e[0]]||Error)(e[1])};_s[105]=e=>{let t=hi.getUint32(fe-4);no||(no=new Map);let i=rt[fe],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};no.set(t,s);let a=Gi();return s.used?Object.assign(r,a):(s.target=a,a)};_s[112]=e=>{let t=hi.getUint32(fe-4),i=no.get(t);return i.used=!0,i.target};_s[115]=()=>new Set(Gi());var OT=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");_s[116]=e=>{let t=e[0],i=OT[t];if(!i)throw new Error("Could not find typed array for code "+t);return new DT[i](Uint8Array.prototype.slice.call(e,1).buffer)};_s[120]=()=>{let e=Gi();return new RegExp(e[0],e[1])};_s[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=fe;fe+=t-4,js=[Gi(),Gi()],js.position0=0,js.position1=0;let r=fe;fe=i;try{return Gi()}finally{fe=r}};_s[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 IT(e){let t=Xo,i=fe,r=Ey,s=oa,a=un,n=ko,o=My,l=no,h=js,u=new Uint8Array(rt.slice(0,Xo)),c=ii,d=ii.slice(0,ii.length),p=Os,f=Cc,m=e();return Xo=t,fe=i,Ey=r,oa=s,un=a,ko=n,My=o,no=l,js=h,rt=u,Cc=f,ii=c,ii.splice(0,ii.length,...d),Os=p,hi=new DataView(rt.buffer,rt.byteOffset,rt.byteLength),m}function Ty(){rt=null,no=null,ii=null}function dH(e){e.unpack?_s[e.type]=e.unpack:_s[e.type]=e}var qx=new Array(147);for(let e=0;e<256;e++)qx[e]=+("1e"+Math.floor(45.15-e*.30103));var Sg=new Cm({useRecords:!1}),Bee=Sg.unpack,Lee=Sg.unpackMultiple,zee=Sg.unpack,pH={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},fH=new Float32Array(1),kee=new Uint8Array(fH.buffer,0,4),Zf;try{Zf=new TextEncoder}catch{}var Tm,Xx,Ag=typeof Buffer<"u",Vv=Ag?Buffer.allocUnsafeSlow:Uint8Array,RT=Ag?Buffer:Uint8Array,n2=Ag?4294967296:2144337920,Oe,Yi,xe=0,qa,Xa=null,mH=/[\u0080-\uFFFF]/,Cu=Symbol("record-id"),BT=class extends Cm{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=RT.prototype.utf8Write?function(C,A,T){return Oe.utf8Write(C,A,T)}:Zf&&Zf.encodeInto?function(C,A){return Zf.encodeInto(C,Oe.subarray(A)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),u&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,m=d+64,v=d+p+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],x=0,b=0;this.pack=this.encode=function(C,A){if(Oe||(Oe=new Vv(8192),Yi=new DataView(Oe.buffer,0,8192),xe=0),qa=Oe.length-10,qa-xe<2048?(Oe=new Vv(Oe.length),Yi=new DataView(Oe.buffer,0,Oe.length),qa=Oe.length-10,xe=0):xe=xe+7&2147483640,i=xe,n=h.structuredClone?new Map:null,h.bundleStrings?(Xa=["",""],Oe[xe++]=214,Oe[xe++]=98,Xa.position=xe-i,xe+=4):Xa=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,N=r.transitions;for(let B=0,V=R.length;B<V;B++){let H=R[B];z=N[H],z||(z=N[H]=Object.create(null)),N=z}N[Cu]=P+64}o=T}u||(r.nextId=T+64)}s&&(s=!1),a=r||[];try{if(_(C),Xa){Yi.setUint32(Xa.position+i,xe-Xa.position-i);let T=Xa;Xa=null,_(T[0]),_(T[1])}if(h.offset=xe,n&&n.idsToInsert){xe+=n.idsToInsert.length*6,xe>qa&&M(xe),h.offset=xe;let T=vH(Oe.subarray(i,xe),n.idsToInsert);return n=null,T}return A&yH?(Oe.start=i,Oe.end=xe,Oe):Oe.subarray(i,xe)}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&&!u){for(let T=0,P=y.length;T<P;T++)y[T][Cu]=0;y=[]}if(s&&h.saveStructures){let T=r.sharedLength||d;r.length>T&&(r=r.slice(0,T));let P=Oe.subarray(i,xe);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(C)):(o=T,P)}}A&xH&&(xe=i)}};let _=C=>{xe>qa&&(Oe=M(xe));var A=typeof C,T;if(A==="string"){let P=C.length;if(Xa&&P>=8&&P<4096){let N=mH.test(C);Xa[N?0:1]+=C,Oe[xe++]=193,_(N?-P:P);return}let R;P<32?R=1:P<256?R=2:P<65536?R=3:R=5;let z=P*3;if(xe+z>qa&&(Oe=M(xe+z)),P<64||!l){let N,B,V,H=xe+R;for(N=0;N<P;N++)B=C.charCodeAt(N),B<128?Oe[H++]=B:B<2048?(Oe[H++]=B>>6|192,Oe[H++]=B&63|128):(B&64512)===55296&&((V=C.charCodeAt(N+1))&64512)===56320?(B=65536+((B&1023)<<10)+(V&1023),N++,Oe[H++]=B>>18|240,Oe[H++]=B>>12&63|128,Oe[H++]=B>>6&63|128,Oe[H++]=B&63|128):(Oe[H++]=B>>12|224,Oe[H++]=B>>6&63|128,Oe[H++]=B&63|128);T=H-xe-R}else T=l(C,xe+R,z);T<32?Oe[xe++]=160|T:T<256?(R<2&&Oe.copyWithin(xe+2,xe+1,xe+1+T),Oe[xe++]=217,Oe[xe++]=T):T<65536?(R<3&&Oe.copyWithin(xe+3,xe+2,xe+2+T),Oe[xe++]=218,Oe[xe++]=T>>8,Oe[xe++]=T&255):(R<5&&Oe.copyWithin(xe+5,xe+3,xe+3+T),Oe[xe++]=219,Yi.setUint32(xe,T),xe+=4),xe+=T}else if(A==="number")if(C>>>0===C)C<64?Oe[xe++]=C:C<256?(Oe[xe++]=204,Oe[xe++]=C):C<65536?(Oe[xe++]=205,Oe[xe++]=C>>8,Oe[xe++]=C&255):(Oe[xe++]=206,Yi.setUint32(xe,C),xe+=4);else if(C>>0===C)C>=-32?Oe[xe++]=256+C:C>=-128?(Oe[xe++]=208,Oe[xe++]=C+256):C>=-32768?(Oe[xe++]=209,Yi.setInt16(xe,C),xe+=2):(Oe[xe++]=210,Yi.setInt32(xe,C),xe+=4);else{let P;if((P=this.useFloat32)>0&&C<4294967296&&C>=-2147483648){Oe[xe++]=202,Yi.setFloat32(xe,C);let R;if(P<4||(R=C*qx[(Oe[xe]&127)<<1|Oe[xe+1]>>7])>>0===R){xe+=4;return}else xe--}Oe[xe++]=203,Yi.setFloat64(xe,C),xe+=8}else if(A==="object")if(!C)Oe[xe++]=192;else{if(n){let R=n.get(C);if(R){if(!R.id){let z=n.idsToInsert||(n.idsToInsert=[]);R.id=z.push(R)}Oe[xe++]=214,Oe[xe++]=112,Yi.setUint32(xe,R.id),xe+=4;return}else n.set(C,{offset:xe-i})}let P=C.constructor;if(P===Object)S(C,!0);else if(P===Array){T=C.length,T<16?Oe[xe++]=144|T:T<65536?(Oe[xe++]=220,Oe[xe++]=T>>8,Oe[xe++]=T&255):(Oe[xe++]=221,Yi.setUint32(xe,T),xe+=4);for(let R=0;R<T;R++)_(C[R])}else if(P===Map){T=C.size,T<16?Oe[xe++]=128|T:T<65536?(Oe[xe++]=222,Oe[xe++]=T>>8,Oe[xe++]=T&255):(Oe[xe++]=223,Yi.setUint32(xe,T),xe+=4);for(let[R,z]of C)_(R),_(z)}else{for(let R=0,z=Tm.length;R<z;R++){let N=Xx[R];if(C instanceof N){let B=Tm[R];if(B.write){B.type&&(Oe[xe++]=212,Oe[xe++]=B.type,Oe[xe++]=0),_(B.write.call(this,C));return}let V=Oe,H=Yi,X=xe;Oe=null;let G;try{G=B.pack.call(this,C,se=>(Oe=V,V=null,xe+=se,xe>qa&&M(xe),{target:Oe,targetView:Yi,position:xe-se}),_)}finally{V&&(Oe=V,Yi=H,xe=X,qa=Oe.length-10)}G&&(G.length+xe>qa&&M(G.length+xe),xe=gH(G,Oe,xe,B.type));return}}S(C,!C.hasOwnProperty)}}else if(A==="boolean")Oe[xe++]=C?195:194;else if(A==="bigint"){if(C<BigInt(1)<<BigInt(63)&&C>=-(BigInt(1)<<BigInt(63)))Oe[xe++]=211,Yi.setBigInt64(xe,C);else if(C<BigInt(1)<<BigInt(64)&&C>0)Oe[xe++]=207,Yi.setBigUint64(xe,C);else if(this.largeBigIntToFloat)Oe[xe++]=203,Yi.setFloat64(xe,Number(C));else throw new RangeError(C+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");xe+=8}else if(A==="undefined")this.encodeUndefinedAsNil?Oe[xe++]=192:(Oe[xe++]=212,Oe[xe++]=0,Oe[xe++]=0);else if(A==="function")_(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},S=this.useRecords===!1?this.variableMapSize?C=>{let A=Object.keys(C),T=A.length;T<16?Oe[xe++]=128|T:T<65536?(Oe[xe++]=222,Oe[xe++]=T>>8,Oe[xe++]=T&255):(Oe[xe++]=223,Yi.setUint32(xe,T),xe+=4);let P;for(let R=0;R<T;R++)_(P=A[R]),_(C[P])}:(C,A)=>{Oe[xe++]=222;let T=xe-i;xe+=2;let P=0;for(let R in C)(A||C.hasOwnProperty(R))&&(_(R),_(C[R]),P++);Oe[T+++i]=P>>8,Oe[T+i]=P&255}:C=>{let A=Object.keys(C),T,P=a.transitions||(a.transitions=Object.create(null)),R=0;for(let N=0,B=A.length;N<B;N++){let V=A[N];T=P[V],T||(T=P[V]=Object.create(null),R++),P=T}let z=P[Cu];if(z)z>=96&&f?(Oe[xe++]=((z-=96)&31)+96,Oe[xe++]=z>>5):Oe[xe++]=z;else{z=a.nextId,z||(z=64),z<m&&this.shouldShareStructure&&!this.shouldShareStructure(A)?(z=a.nextOwnId,z<v||(z=m),a.nextOwnId=z+1):(z>=v&&(z=m),a.nextId=z+1);let N=A.highByte=z>=96&&f?z-96>>5:-1;P[Cu]=z,a[z-64]=A,z<m?(A.isShared=!0,a.sharedLength=z-63,s=!0,N>=0?(Oe[xe++]=(z&31)+96,Oe[xe++]=N):Oe[xe++]=z):(N>=0?(Oe[xe++]=213,Oe[xe++]=114,Oe[xe++]=(z&31)+96,Oe[xe++]=N):(Oe[xe++]=212,Oe[xe++]=114,Oe[xe++]=z),R&&(x+=b*R),y.length>=p&&(y.shift()[Cu]=0),y.push(P),_(A))}for(let N=0,B=A.length;N<B;N++)_(C[A[N]])},M=C=>{let A;if(C>16777216){if(C-i>n2)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(n2,Math.round(Math.max((C-i)*(C>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(C-i<<2,Oe.length-1)>>12)+1<<12;let T=new Vv(A);return Yi=new DataView(T.buffer,0,A),Oe.copy?Oe.copy(T,0,i,C):T.set(Oe.slice(i,C)),xe-=i,i=0,qa=T.length-10,Oe=T}}useBuffer(e){Oe=e,Yi=new DataView(Oe.buffer,Oe.byteOffset,Oe.byteLength),xe=0}};Xx=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,MT];Tm=[{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?o2(e,16,t):l2(Ag?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==RT&&this.structuredClone?o2(e,OT.indexOf(i.name),t):l2(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function o2(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 l2(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 gH(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 vH(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 Yc(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)");Xx.unshift(e.Class),Tm.unshift(e)}dH(e)}var LT=new BT({useRecords:!1}),Nee=LT.pack,Fee=LT.pack,{NEVER:Uee,ALWAYS:Vee,DECIMAL_ROUND:jee,DECIMAL_FIT:Gee}=pH,yH=512,xH=1024,h2=new BT({structuredClone:!0});Yc({Class:Tt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Tt.prototype),e}});Yc({Class:mt.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,mt.prototype),e}});Yc({Class:qr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,qr.prototype),e}});Yc({Class:KS.prototype.constructor,type:4,write(e){return e.id},read(e){return new KS(e)}});Yc({Class:JS.prototype.constructor,type:5,write(e){return e.data},read(e){return new JS(e)}});Yc({Class:cr.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,cr.prototype),e}});function bH(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 Py(e){if(Fx(e))return e;if(Array.isArray(e))return e.map(Py);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Py(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Dy;(e=>{function t(s){return h2.pack(s)}e.serialize=t;function i(s){return h2.unpack(s)}e.deserialize=i;function r(s){return bH(t(Py(s))).toString()}e.checksum=r})(Dy||(Dy={}));var c2;(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})(c2||(c2={}));var Cs={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Particles","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Particles","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Particles","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Particles","Create","Conditional"],Collision:["Transition","Animation","Audio","Particles","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Particles","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Particles","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},u2;(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,runMode:"Once",actions:new mt}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new mt}}e.defaultData=i})(u2||(u2={}));var Pm;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Pm||(Pm={}));var Oy;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Pm.propertyDefaultData(s),rOperand:{...Pm.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})(Oy||(Oy={}));var d2;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new mt,outActions:new mt,condition:Oy.distanceDefaultData(r)}}e.defaultData=i})(d2||(d2={}));var p2;(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 mt,drop:new mt}})(p2||(p2={}));var Iy;(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 mt})(Iy||(Iy={}));var Ry;(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})(Ry||(Ry={}));var f2;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new mt}}e.defaultData=i})(f2||(f2={}));var m2;(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 mt}}e.defaultData=i})(m2||(m2={}));var g2;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new mt}}e.defaultData=i})(g2||(g2={}));var v2;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new mt}}e.defaultData=i})(v2||(v2={}));var y2;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new mt,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(y2||(y2={}));var By;(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 mt},o={size:"tablet",operator:"<",actions:new mt},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new mt},h=new mt;return h.push({id:st.generateUUID(),fi:0,data:n},{id:st.generateUUID(),fi:1,data:o},{id:st.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 mt}}e.defaultBreakpointData=a})(By||(By={}));var Ly;(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 mt,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(Ly||(Ly={}));var Qc="personal camera",od="a218fcc3-276b-49b9-b485-49037fd14f5f",wH=2960946,qs=5526619,No;(e=>{function t(d,p){return d[0]===p[0]&&d[1]===p[1]}e.isEqual=t;function i(d,p,f){return[d[0]+(p[0]-d[0])*f,d[1]+(p[1]-d[1])*f]}e.lerp=i;function r(d,p){return[d[0]+p[0],d[1]+p[1]]}e.add=r;function s(d,p){return[d[0]-p[0],d[1]-p[1]]}e.sub=s;function a(d,p){return Math.pow(p[0]-d[0],2)+Math.pow(p[1]-d[1],2)}e.distanceSquared=a;function n(d,p){return Math.sqrt(a(d,p))}e.distance=n;function o(d,p){return d[0]*p[0]+d[1]*p[1]}e.dot=o;function l(d,p){return[d[0]*p,d[1]*p]}e.scalarMultiply=l;function h(d,p,f){let m=e.sub(p,d),v=e.sub(f,d),y=e.dot(m,v)/e.dot(m,m),x=e.scalarMultiply(m,y);return e.add(d,x)}e.projectionOnto=h;function u(d,p,f){return n(d,h(d,p,f))}e.projectionOntoDistance=u;function c(d,p){return[(d[0]+p[0])*.5,(d[1]+p[1])*.5]}e.center=c})(No||(No={}));var Nl;(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,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]}e.lerp=o})(Nl||(Nl={}));var Dm;(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})(Dm||(Dm={}));var Tc;(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})(Tc||(Tc={}));var vs;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.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(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function a(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=a;function n(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=n;function o(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}}e.lerp=o})(vs||(vs={}));var vi;(e=>{e.white={...vs.white,a:1},e.transparent={...vs.white,a:0};function t(o){return{r:o[0],g:o[1],b:o[2],a:o[3]}}e.from0to1=t;function i(o,l){return{...vs.fromHex(o),a:l}}e.fromHexAndA=i;function r(o){return{r:Math.round(o.r*255),g:Math.round(o.g*255),b:Math.round(o.b*255),a:o.a}}e.toRgb255a1=r;function s(o,l){return vs.equals(o,l)&&o.a===l.a}e.equals=s;function a(o,l,h){return{r:o.r+(l.r-o.r)*h,g:o.g+(l.g-o.g)*h,b:o.b+(l.b-o.b)*h,a:o.a+(l.a-o.a)*h}}e.lerp=a;function n({r:o,g:l,b:h,a:u}=e.white){return`rgba(${o*255}, ${l*255}, ${h*255}, ${u})`}e.toStyle=n})(vi||(vi={}));var zy;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zy||(zy={}));var x2;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(x2||(x2={}));var b2;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(b2||(b2={}));var Oo;(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]))(Oo||(Oo={}));function w2(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 Xl;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Xl||(Xl={}));var Pc;(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:i.orthographic.zoom}e.getZoom=t})(Pc||(Pc={}));var Fo;(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(zT.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;kT.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;NT.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;FT.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;UT.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;VT.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(Fo||(Fo={}));var ky;(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})(ky||(ky={}));var zT=["count"],kT=["radius","start","end","position","scale","rotation"],NT=["position","scale","rotation"],FT=["count","size"],UT=["count","position","scale","rotation"],VT=["strength","scale","rotation","position","movement","seed","freqScale"],Ny;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Ny||(Ny={}));var Fy;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:vi.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:vi.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:vi.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Fy||(Fy={}));var Om;(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",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...e.defaultCollisionData}))(Om||(Om={}));var Dc;(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]})(Dc||(Dc={}));var Uy;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Uy||(Uy={}));var Vy;(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})(Vy||(Vy={}));var jy;(e=>e.defaultData={...Vy.defaultData,...Uy.defaultData})(jy||(jy={}));var _2;(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})(_2||(_2={}));var Im;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Im||(Im={}));var S2;(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})(S2||(S2={}));function _H(e){return e.type!=="displace"}var A2;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(A2||(A2={}));var jT=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],SH=["wrapping","image","video","name","minFilter"],Tr;(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],minFilter:1008},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Im.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],minFilter:1008},crop:!1};case"color":return{...n,type:"color",color:vs.fromHex(qs)};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:{...vs.fromHex(6710886),a:1},colorB:{...vs.fromHex(6710886),a:1},colorC:{...vs.fromHex(16777215),a:1},colorD:{...vs.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:vi.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:vi.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:vi.fromHexAndA(0,1),contourColor:vi.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],minFilter:1008}};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:{...vs.fromHex(0),a:1},colorB:{...vs.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}}}})(Tr||(Tr={}));var ss;(e=>{function t(u){return!u.layers.some(c=>c.data.type==="texture"&&c.data.projection!==0||c.data.type==="depth"&&!c.data.isWorldSpace||c.data.type==="noise"||c.data.type==="displace")}e.isMergable=t;function i(u){let c="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{c+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>c+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${f}`})}),c}e.getHash=i;function r(){return{layers:new mt}}e.defaultEmptyData=r;function s(u="layer1",c="layer2"){return n("phong",u,c)}e.defaultData=s;function a(u,c){return{...u,name:c}}e.withName=a;function n(u,c="layer1",d="layer2"){let p=new mt;return p.push({fi:0,data:Tr.defaultData("light",u),id:c}),p.push({fi:1,data:Tr.defaultData("color"),id:d}),{layers:p}}e.defaultTwoLayerData=n;function o(u){let c=Tr.defaultData("texture");u&&Object.assign(c.texture,{image:u});let d=new mt;return d.push({fi:0,data:c,id:"layer1"}),d.push({fi:1,data:{...Tr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Tr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}e.defaultUIObjectMaterial=o;function l(u,c="phong",d="layer1",p="layer2"){let f=Tr.defaultData("texture");Object.assign(f.texture,{image:u});let m=new mt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Tr.defaultData("light",c),id:p}),{layers:m}}e.defaultTwoLayerTextureData=l;function h(u,c="phong",d="layer1",p="layer2"){let f=Tr.defaultData("video");Object.assign(f.texture,{video:u});let m=new mt;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Tr.defaultData("light",c),id:p}),{layers:m}}e.defaultTwoLayerVideoTextureData=h})(ss||(ss={}));var Rm;(e=>{function t(){return{points:new mt,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Rm||(Rm={}));var Bm;(e=>{function t(){return{points:new mt,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Bm||(Bm={}));var GT={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Gy;(e=>{function t(i,r){let s={...i};return WT.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(Gy||(Gy={}));var HT={shape:GT,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},WT=["depth","offset","angle","twist","startScale","endScale"],Lm;(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"}e.isParametricMesh=i})(Lm||(Lm={}));var Hy;(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,Gy.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Hy||(Hy={}));var hc;(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:Bm.defaultData(),extrusion:HT};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Rm.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};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})(hc||(hc={}));var M2=["width","height","depth"],Wy;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:vs.white,near:.1,far:2e3})(Wy||(Wy={}));var zm;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(zm||(zm={}));var qy;(e=>e.defaultData={softShadowQuality:"low"})(qy||(qy={}));var Xy;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Xy||(Xy={}));var Yy;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Yy||(Yy={}));var Oc;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Oc||(Oc={}));var Qy;(e=>e.defaultData={playCamera:Qc,gameControlObject:null})(Qy||(Qy={}));var Zy;(e=>e.defaultData={backgroundColor:vi.fromHexAndA(wH,1),postprocessing:zm.defaultData,fog:Wy.defaultData,globalPhysics:Oc.defaultData,ambient:Xy.defaultData,ao:Yy.defaultData,shadow:qy.defaultData,publish:Qy.defaultData})(Zy||(Zy={}));var Ky;(e=>e.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Ky||(Ky={}));var E2;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(E2||(E2={}));var Ic;(e=>{e.identity={...zy.identity,hiddenMatrix:Tc.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 oT({position:Nl.isEqual(s.position,a.position)?void 0:a.position,rotation:Nl.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:Nl.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:Tc.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(Ic||(Ic={}));var Xr;(e=>e.defaultData={states:new mt,events:new mt,visible:!0,raycastLock:!1,physics:Dc.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ic.identity,cloner:null})(Xr||(Xr={}));var Jy;(e=>e.defaultData={type:"Empty",...Xr.defaultData})(Jy||(Jy={}));var C2;(e=>e.defaultData={type:"ParticleCollider",...Ky.defaultData,...Xr.defaultData})(C2||(C2={}));var T2;(e=>e.defaultData={type:"Component",...Xr.defaultData})(T2||(T2={}));var P2;(e=>e.defaultData={type:"Particle",...Xr.defaultData,...Om.defaultData})(P2||(P2={}));var cc;(e=>e.defaultData={type:"Mesh",...Xr.defaultData,...jy.defaultData})(cc||(cc={}));var Cd;(e=>e.defaultData={...Xr.defaultData,...Ic.identity,position:[0,0,Pc.DefaultTargetOffset],...Pc.defaultData})(Cd||(Cd={}));var $y;(e=>{function t(i){return{...Xr.defaultData,...Fy.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($y||($y={}));var km;(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})(km||(km={}));var Uo;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Xr.defaultData,...s,component:r,overrides:new cr,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Ic.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Uo||(Uo={}));var Rc;(e=>{e.defaultData={type:"Page",...Xr.defaultData,physics:{...Dc.defaultData,fusedBody:!1},...Zy.defaultData,camera:Cd.defaultData};function t(i){return i.uiScene!==void 0}e.isUIPage=t})(Rc||(Rc={}));var e1;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Tc.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Dc.defaultData,states:new mt,events:new mt,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Pc.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",...Xr.defaultData,...cc.defaultData,geometry:hc.defaultData("RectangleGeometry"),material:ss.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Xr.defaultData,...cc.defaultData,geometry:hc.defaultData("BooleanGeometry"),material:ss.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Xr.defaultData,...cc.defaultData,geometry:hc.defaultData("TextGeometry"),material:ss.defaultTwoLayerData("phong","layer1","layer2")}))(e1||(e1={}));var Cl;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new cr}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new cr})))):Xl.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=Ed(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(n.material.layers)){let c=l.layers.data(h);c&&Tr.patch(c,u)}}).data),o.materials&&n.materials&&(o.materials=Ed(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=n.materials[h];if(typeof u!="string")for(let[c,d]of Object.entries(u.layers)){let p=l[h]?.layers?.data(c);p&&Tr.patch(p,d)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function u(c,d){for(let[p,f]of Object.entries(d.layers)){let{texture:m,...v}=f;if(m!==void 0&&Object.keys(m).length>0){let y={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(y)}if(Object.keys(v).length>0){let y={path:[...c,"layers",p],props:v,type:0};l.push(y)}}}for(let[c,d]of Object.entries(n))if(c!=="name")if(c==="cloner")l.push(...ky.toOps(d,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:d.slide,offset:d.offset},type:0});else if(c==="material")u(["material"],d);else if(c==="materials")for(let[p,f]of Object.entries(d))u(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&d.extrusion!==void 0){let p={path:[c,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[c],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=d;return l}e.toOps=r;function s(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,Ic.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})}),Xl.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:Hy.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Fo.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:Fo.merge(o.cloner,n.cloner)});else if(Ny.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=vs.clone(l.color))}return o}e.patch=s})(Cl||(Cl={}));var Nm;(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})(Nm||(Nm={}));var Vo;(e=>e.defaultData={orbitControls:Nm.defaultData,playPage:od,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},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Vo||(Vo={}));var t1;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(t1||(t1={}));var i1;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(i1||(i1={}));var Tl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...t1.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:i1.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Tl||(Tl={}));var Td;(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=jm.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Td||(Td={}));var Pl;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let a=[],n=e1.defaultMeshObject;s.withLight===!0&&a.push({fi:-1,data:$y.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&a.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]});let o=new qr;return o.push({fi:1,id:od,data:{...Rc.defaultData,name:"Scene 1"},children:a}),o}e.defaultData={objects:t(),publish:Vo.defaultData,styles:Tl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new qr,publish:Vo.defaultData,styles:Tl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Vo.defaultData,styles:Tl.defaultData()}},e.emptyData=function(){return{objects:new qr,publish:{...Vo.defaultData},styles:Tl.defaultData()}};function i(s){return{...e.defaultData,objects:bn(s,qr.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(Pl||(Pl={}));var ld;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ld||(ld={}));var Fm;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Fm||(Fm={}));var Ws;(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})(Ws||(Ws={}));var r1;(e=>e.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(r1||(r1={}));var D2;(e=>e.all=[...r1.all,"components"])(D2||(D2={}));var O2;(e=>{function t(){return{images:new Tt,videos:new Tt,colors:new Tt,audios:new Tt,particles:new Tt,fonts:new Tt,materials:new Tt,components:new Tt,variables:new Tt}}e.defaultData=t})(O2||(O2={}));var Yl;(e=>{function t(){return{images:new Tt,videos:new Tt,colors:new Tt,audios:new Tt,particles:new Tt,fonts:new Tt,materials:new Tt,components:new Tt,variables:new Tt}}e.defaultData=t})(Yl||(Yl={}));var la;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},bn(n,Tt.prototype)}e.defaultColors=t;function i(n){let o={};return n?.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Fm.emptyImage,name:"AI generated image"}),bn(o,Tt.prototype)}e.defaultImages=i;function r(){return{catelogs:new Tt,materials:new Tt,images:new Tt,videos:new Tt,colors:new Tt,audios:new Tt,particles:new Tt,fonts:new Tt,variables:new mt,lib:Yl.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),u=Math.round(n-l*3600-h*60);return{textValue:[l,h,u]}}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})(la||(la={}));var Um;(e=>e.list=["idle","move","jump","run"])(Um||(Um={}));var Vm;(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 mt,move:new mt,jump:new mt,run:new mt},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:vi.fromHexAndA(3728051,1)}}))(Vm||(Vm={}));function I2(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={...ao(Ji(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={...Ji(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Io(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Ro(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=ss.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=ss.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=ss.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&Object.getPrototypeOf(s.material)!==cr.prototype&&t(s.material)})})}function AH(e){Object.assign(e.scene.publish,{orbitControls:{...Nm.defaultData,...Ji(e.scene.publish.orbitControls)}})}function MH(e){Object.assign(e.scene.publish.settings,{video:{...Vo.defaultData.settings.video,...Ji(e.scene.publish.settings.video)}})}function EH(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((jT.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(SH.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 CH(e){e.scene.publish.withBackground=!0}function TH(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function PH(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 DH(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 OH(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=Ji(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Ji(i).booleanExclude!==!0)}})}function IH(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 RH(e){function t(r){Object.setPrototypeOf(r,cr.prototype),r.texture&&Object.setPrototypeOf(r.texture,cr.prototype)}function i(r){Object.setPrototypeOf(r,cr.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=Ji(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=Ji(l).layers;i(h),l.layers=h}})})}function R2(e){e.layers===void 0&&Object.assign(e,ss.defaultTwoLayerData("lambert"))}function jv(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={...Ji(t),colors:i,steps:r};Object.assign(t,s)}})}function BH(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function B2(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&jv(r)}):"material"in i&&typeof i.material!="string"&&jv(i.material)}),Object.values(e.shared.materials).forEach(t=>jv(t))}function LH(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 zH(e){e.shared.audios=bn({},Tt.prototype)}function kH(e){e.shared.videos=bn({},Tt.prototype)}function NH(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 FH(e){Object.entries(Ji(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Ji(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function UH(e){e.scene.publish.settings.web.preload=!1}function L2(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 z2(e){e.layers&&e.layers.forEach(t=>{_H(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 VH(e){e.shared.fonts=bn({},Tt.prototype)}function jH(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 GH(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=ss.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=jH(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Xr.defaultData,...cc.defaultData,flatShading:!1,wireframe:!1,geometry:{...hc.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:Ji(s.states),events:Ji(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Ji(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 HH(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 mt,move:new mt,jump:new mt}});else{let a=new mt;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:st.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},u={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(u,ao(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(u,{control1:{...n.control1},control2:{...n.control2}});let c={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,...c,...u},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new mt({fi:0,id:st.generateUUID(),data:h},{fi:1,id:st.generateUUID(),data:d})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function WH(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new mt,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===a){let c;o.push(h),l.interaction==="play"?c={...ao(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...ao(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&n.push({fi:u,id:h,data:c})}}),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:st.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function k2(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=Tr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function N2(e){Io(e,k2),Ro(e,k2)}function qH(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function XH(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 YH(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=ss.defaultTwoLayerData("phong"))})}function QH(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 ZH(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 KH(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 JH(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function $H(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function e9(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function t9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Vm.defaultDataThirdPerson.navmesh)})})}function i9(e){e.scene.styles||(e.scene.styles=Tl.defaultData())}function F2(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function r9(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}),Ro(e,F2),Io(e,F2)}function s9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new mt})})})}function a9(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function U2(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function n9(e,t){if(t<1&&(Ro(e,I2),Io(e,I2),e.schema=1),t<2&&(AH(e),e.schema=2),t<3&&(EH(e),e.schema=3),t<4&&(CH(e),e.schema=4),t<5&&(TH(e),e.schema=5),t<6&&(PH(e),e.schema=6),t<7&&(DH(e),e.schema=7),t<8&&(e.schema=8),t<9&&(B2(e),e.schema=9),t<10&&(BH(e),e.schema=10),t<11&&(LH(e),e.schema=11),t<12&&(B2(e),e.schema=12),t<13&&(zH(e),e.schema=13),t<14&&(NH(e),e.schema=14),t<15&&(FH(e),e.schema=15),t<16&&(UH(e),e.schema=16),t<17&&(Ro(e,L2),Io(e,L2),e.schema=17),t<18&&(Ro(e,R2),Io(e,R2),e.schema=18),t<19&&(MH(e),e.schema=19),t<20&&(VH(e),GH(e),e.schema=20),t<21&&(HH(e),WH(e),e.schema=21),t<22&&(N2(e),e.schema=22),t<23&&(qH(e),e.schema=23),t<24&&(XH(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(kH(e),t<25&&(e.schema=25)),t<26&&(OH(e),e.schema=26),t<27&&(IH(e),e.schema=27),t<28&&(N2(e),e.schema=28),t<29&&(RH(e),e.schema=29),t<30&&(YH(e),e.schema=30),t<31&&(QH(e),e.schema=31),t<33&&(ZH(e),e.schema=33),t<34&&(KH(e),e.schema=34),t<35&&(JH(e),e.schema=35),t<36&&($H(e),e.schema=36),t<37&&(e9(e),e.schema=37),t<38&&(Ro(e,z2),Io(e,z2),e.schema=38),t<39&&(t9(e),e.schema=39),t<40&&(i9(e),e.schema=40),t<41&&(r9(e),e.schema=41),t<42&&(s9(e),e.schema=42),t<43&&(a9(e),e.schema=43),t<99){Ro(e,U2),Io(e,U2),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=Qc);let i=Ji(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=od,r.insertBefore(null,null,[{id:od,data:{...Rc.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:ao(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:ao(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Oc.defaultData,...ao(e.scene.environment,"usePhysics","gravity")},camera:Ji(e.scene.ownerCamera)??Rc.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==Pl.TRASH_CAN_ID&&r.move(od,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,Dc.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function V2(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function o9(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 l9(e){Array.isArray(Ji(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 Qh=180/Math.PI;function j2(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Qh)}function qT(e){j2(e),e.type==="Page"&&j2(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Qh))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Qh),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Qh),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Qh,t.extrusion.twist*=Qh),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(Ji(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 h9(e){e.shared.variables=bn({},Tt.prototype)}function c9(e){let t=Ji(e.shared.variables);e.shared.variables=bn(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),mt.prototype)}var Yn=111;function XT(e,t){t(e.data);for(let i of e.children)XT(i,t)}function u9(e){let t=e.schema??104;t!==Yn&&t<105&&(XT(e.asset,qT),e.schema=105)}function d9(e){e.shared.particles=bn({},Tt.prototype),e.shared.lib&&(e.shared.lib.particles=Yl.defaultData().particles)}function p9(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 YT(e){let t=e.schema??0;if(t!==Yn){console.warn("updating from ",t,"to ",Yn),n9(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Vo.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Ro(e,V2),Io(e,V2),e.schema=101),t<102&&(o9(e),e.schema=102),t<104&&(e.shared.catelogs=new Tt,e.shared.lib=Yl.defaultData(),e.schema=104),t<105&&(h9(e),e.scene.objects.traverse((i,r)=>{qT(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))u9(i);t<106&&(c9(e),e.schema=106),t<107&&(e.shared.lib.variables=Yl.defaultData().variables,e.schema=107),t<109&&(d9(e),e.schema=109),t<110&&(p9(e),e.schema=110),t<111&&(e.scene.objects.traverse((i,r)=>{l9(r)}),e.schema=111)}}var jm;(e=>{e.defaultData={schema:Yn,scene:Pl.defaultData,frames:new Tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ld.defaultData),shared:{...la.emptyData(),colors:la.defaultColors()}},e.emptyDataForImports=function(s){let a=Pl.emptyDataWithPage(s);return{schema:Yn,scene:a,frames:new Tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ld.defaultData),shared:{...la.emptyData(),colors:la.defaultColors(),images:la.defaultImages(s)}}},e.emptyData=function(){return{schema:Yn,scene:Pl.emptyDataWithPage(),frames:new Tt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ld.defaultData),shared:la.emptyData()}},e.clipboard2dData=function(){return{schema:Yn,scene:Pl.emptyData(),frames:new Tt,shared:la.emptyData()}},e.collabHelper={...Sy,updateSchema(s){return(s.schema??0)<Yn?Ed(s,YT):(s.schema??0)-Yn}};function t(s){let a=e.collabHelper.updateSchema(s);return typeof a=="number"?a===0?s:null:a.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:Yl.defaultData()}}}e.withoutLib=i;function r(s,a){let n=s.scene.objects.get(a);if(n&&n.data.type==="Component")return n;{let o=s.shared.lib.components[a];if(o)return o.asset}}e.getComponentData=r})(jm||(jm={}));var G2;(e=>{function t(i){return!0}e.is=t})(G2||(G2={}));var Gm;(e=>{e.defaultData={position:[0,0],scale:[1,1],rotation:0};function t(r,s){return{position:s?.position??r.position,rotation:s?.rotation??r.rotation,scale:s?.scale??r.scale}}e.merge=t;function i(r,s){return oT({position:No.isEqual(r.position,s.position)?void 0:s.position,rotation:r.rotation===s.rotation?void 0:s.rotation,scale:No.isEqual(r.scale,s.scale)?void 0:s.scale})}e.diff=i})(Gm||(Gm={}));var s1;(e=>e.defaultData={horizontalConstraint:0,verticalConstraint:0})(s1||(s1={}));var Hm;(e=>e.defaultData={opacity:1,fill:{color:vi.white,enabled:!0},stroke:{color:vi.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:vi.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:vi.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Hm||(Hm={}));var Dl;(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 u of h)u in l&&u in o&&o[u]!==void 0&&Object.assign(l,{[u]:o[u]});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,Gm.merge(l,o)),l=i(l,o),l=r(l,o),l}e.patch=s;function a(n,o){let l,h=[];for(let[u,c]of Object.entries(o))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},h.push(l)),l.props[u]=c);return h}e.toOps=a})(Dl||(Dl={}));var Pd;(e=>e.defaultData={...Gm.defaultData,...s1.defaultData,states:new mt,events:new mt,visible:!0,raycastLock:!1})(Pd||(Pd={}));var Dd;(e=>e.defaultData={...Pd.defaultData,...Hm.defaultData})(Dd||(Dd={}));var Wm;(e=>e.defaultData={cornerRadius:[0,0,0,0]})(Wm||(Wm={}));var a1;(e=>e.defaultData={...Dd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(a1||(a1={}));var Od;(e=>e.defaultData={...Dd.defaultData,...Wm.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Od||(Od={}));var n1;(e=>e.defaultData={...Dd.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"})(n1||(n1={}));var H2;(e=>{function t(i){return i.type==="ellipse2d"||i.type==="rectangle2d"||i.type==="text2d"||i.type==="vector2d"}e.is=t})(H2||(H2={}));var qm;(e=>e.defaultData={...Pd.defaultData,name:"Group",type:"group2d"})(qm||(qm={}));var o1;(e=>e.defaultData={...Pd.defaultData,...Wm.defaultData,...Hm.defaultData,name:"Frame",type:"frame2d",width:200,height:200,fill:{color:vi.fromHexAndA(qs,1),enabled:!0},stroke:{color:vi.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(o1||(o1={}));var Fl;(e=>{function t(a){switch(a){case"rectangle2d":return{...Od.defaultData};case"ellipse2d":return{...a1.defaultData};case"text2d":return{...n1.defaultData};case"vector2d":return{...Od.defaultData};case"frame2d":return{...o1.defaultData};case"group2d":return{...qm.defaultData}}}e.defaultData=t;function i(a){return"width"in a&&"height"in a?[typeof a.width=="number"?a.width*.5:0,typeof a.height=="number"?a.height*.5:0]:[0,0]}e.getPivot=i;function r(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}e.isResizeable=r;function s(a){return a.type==="rectangle2d"||a.type==="frame2d"}e.hasCorners=s})(Fl||(Fl={}));var l1;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new qr},e.emptyData=function(){return{type:"scene2d",objects:new qr}}))(l1||(l1={}));function Ol(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 ut,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(i){let u=0,c=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+u);u+=e[d].attributes.position.count}l.setIndex(c)}for(let u in a){let c=W2(a[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(let u in n){let c=n[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){let p=[];for(let m=0;m<n[u].length;++m)p.push(n[u][m][d]);let f=W2(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}return l}function W2(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 At(a,i,r)}var f9=Math.pow(2,-24),sf=class{constructor(){}};function dn(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 q2(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 X2(e,t){t.set(e)}function Y2(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 af(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 Tu(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 m9(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 At(s,1));for(let a=0;a<i;a++)s[a]=a}}function g9(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 Gv(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,v=-1/0,y=s!==null;for(let x=t*6,b=(t+i)*6;x<b;x+=6){let _=e[x+0],S=e[x+1],M=_-S,C=_+S;M<a&&(a=M),C>l&&(l=C),y&&_<c&&(c=_),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>m&&(m=A);let z=e[x+4],N=e[x+5],B=z-N,V=z+N;B<o&&(o=B),V>u&&(u=V),y&&z<p&&(p=z),y&&z>v&&(v=z)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=u,y&&(s[0]=c,s[1]=d,s[2]=p,s[3]=f,s[4]=m,s[5]=v)}function v9(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 u=t*6,c=(t+i)*6;u<c;u+=6){let d=e[u+0];d<s&&(s=d),d>o&&(o=d);let p=e[u+2];p<a&&(a=p),p>l&&(l=p);let f=e[u+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 y9(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 u=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=u;let c=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=c;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 Gn=32,x9=(e,t)=>e.candidate-t.candidate,wo=new Array(Gn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),nf=new Float32Array(6);function b9(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=q2(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=q2(e),n!==-1&&(o=w9(i,r,s,n));else if(a===2){let l=Tu(e),h=1.25*s,u=r*6,c=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/Gn;if(s<Gn/4){let m=[...wo];m.length=s;let v=0;for(let x=u;x<c;x+=6,v++){let b=m[v];b.candidate=i[x+2*d],b.count=0;let{bounds:_,leftCacheBounds:S,rightCacheBounds:M}=b;for(let C=0;C<3;C++)M[C]=1/0,M[C+3]=-1/0,S[C]=1/0,S[C+3]=-1/0,_[C]=1/0,_[C+3]=-1/0;af(x,i,_)}m.sort(x9);let y=s;for(let x=0;x<y;x++){let b=m[x];for(;x+1<y&&m[x+1].candidate===b.candidate;)m.splice(x+1,1),y--}for(let x=u;x<c;x+=6){let b=i[x+2*d];for(let _=0;_<y;_++){let S=m[_];b>=S.candidate?af(x,i,S.rightCacheBounds):(af(x,i,S.leftCacheBounds),S.count++)}}for(let x=0;x<y;x++){let b=m[x],_=b.count,S=s-b.count,M=b.leftCacheBounds,C=b.rightCacheBounds,A=0;_!==0&&(A=Tu(M)/l);let T=0;S!==0&&(T=Tu(C)/l);let P=1+1.25*(A*_+T*S);P<h&&(n=d,h=P,o=b.candidate)}}else{for(let y=0;y<Gn;y++){let x=wo[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=u;y<c;y+=6){let x=~~((i[y+2*d]-p)/f);x>=Gn&&(x=Gn-1);let b=wo[x];b.count++,af(y,i,b.bounds)}let m=wo[Gn-1];X2(m.bounds,m.rightCacheBounds);for(let y=Gn-2;y>=0;y--){let x=wo[y],b=wo[y+1];Y2(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let v=0;for(let y=0;y<Gn-1;y++){let x=wo[y],b=x.count,_=x.bounds,S=wo[y+1].rightCacheBounds;b!==0&&(v===0?X2(_,nf):Y2(_,nf,nf)),v+=b;let M=0,C=0;v!==0&&(M=Tu(nf)/l);let A=s-v;A!==0&&(C=Tu(S)/l);let T=1+1.25*(M*v+C*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 w9(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 _9(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 u=["getX","getY","getZ"];for(let c=0;c<s;c++){let d=c*3,p=c*6,f,m,v;n?(f=r[d+0],m=r[d+1],v=r[d+2]):(f=r[d+0]*h+l,m=r[d+1]*h+l,v=r[d+2]*h+l);for(let y=0;y<3;y++){let x,b,_;n?(x=i[u[y]](f),b=i[u[y]](m),_=i[u[y]](v)):(x=o[f+y],b=o[m+y],_=o[v+y]);let S=x;b<S&&(S=b),_<S&&(S=_);let M=x;b>M&&(M=b),_>M&&(M=_);let C=(M-S)/2,A=y*2;a[p+A+0]=S+C,a[p+A+1]=C+(Math.abs(S)+C)*f9,S<t[y]&&(t[y]=S),M>t[y+3]&&(t[y+3]=M)}}return a}function S9(e,t){function i(y){d&&d(y/p)}function r(y,x,b,_=null,S=0){if(!f&&S>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=u||S>=l)return i(x+b),y.offset=x,y.count=b,y;let M=b9(y.boundingData,_,n,x,b,c);if(M.axis===-1)return i(x+b),y.offset=x,y.count=b,y;let C=y9(o,n,x,b,M);if(C===x||C===x+b)i(x+b),y.offset=x,y.count=b;else{y.splitAxis=M.axis;let A=new sf,T=x,P=C-x;y.left=A,A.boundingData=new Float32Array(6),Gv(n,T,P,A.boundingData,a),r(A,T,P,a,S+1);let R=new sf,z=C,N=b-P;y.right=R,R.boundingData=new Float32Array(6),Gv(n,z,N,R.boundingData,a),r(R,z,N,a,S+1)}return y}m9(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=_9(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],v=g9(e);if(v.length===1){let y=v[0],x=new sf;x.boundingData=s,v9(n,y.offset,y.count,a),r(x,y.offset,y.count,a),m.push(x)}else for(let y of v){let x=new sf;x.boundingData=new Float32Array(6),Gv(n,y.offset,y.count,x.boundingData,a),r(x,y.offset,y.count,a),m.push(x)}return m}function A9(e,t){let i=S9(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){let c=i[u],d=l(c),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,c),n.push(p)}return n;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function h(u,c){let d=u/4,p=u/2,f=!!c.count,m=c.boundingData;for(let v=0;v<6;v++)r[d+v]=m[v];if(f){let v=c.offset,y=c.count;return s[d+6]=v,a[p+14]=y,a[p+15]=65535,u+32}else{let v=c.left,y=c.right,x=c.splitAxis,b;if(b=h(u+32,v),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 wn=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}};wn.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 u=t.dot(e);a=Math.min(u,a),n=Math.max(u,n)}this.min=a,this.max=n}}();var Hee=function(){let e=new wn;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 u=a[h],c=s[h];if(e.setFromPoints(c,n),u.isSeparated(e))return!1}for(let h=0;h<3;h++){let u=l[h],c=o[h];if(e.setFromPoints(c,r),u.isSeparated(e))return!1}}}(),M9=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 u=i.dot(h),c=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-c*c,m,v;f!==0?m=(u*c-p*d)/f:m=0,v=(u+m*c)/d,a.x=m,a.y=v}}(),Yx=function(){let e=new $,t=new I,i=new I;return function(r,s,a,n){M9(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 u;l<0?u=s.start:u=s.end;let c=t,d=i;if(r.closestPointToPoint(u,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(u)<=d.distanceToSquared(h)){a.copy(c),n.copy(u);return}else{a.copy(h),n.copy(d);return}}}}(),E9=function(){let e=new I,t=new I,i=new Gs,r=new da;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c:u}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let c=a.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=n){let d=c.projectPoint(o,t);if(a.containsPoint(d))return!0}return!1}}(),C9=1e-15;function Th(e){return Math.abs(e)<C9}var ho=class extends Hr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new wn),this.points=[this.a,this.b,this.c],this.sphere=new zs,this.plane=new Gs,this.needsUpdate=!0}intersectsSphere(e){return E9(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 u=s[2],c=a[2];u.subVectors(t,i),c.setFromPoints(u,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}};ho.prototype.closestPointToSegment=function(){let e=new I,t=new I,i=new da;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,u=1/0;for(let c=0;c<3;c++){let d=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[d]),Yx(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(u)}}();ho.prototype.intersectsTriangle=function(){let e=new ho,t=new Array(3),i=new Array(3),r=new wn,s=new wn,a=new I,n=new I,o=new I,l=new I,h=new da,u=new da,c=new da;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 m=this.plane,v=d.plane;if(Math.abs(m.normal.dot(v.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 S=0;S<4;S++){let M=y[S],C=x[S];if(r.setFromPoints(C,i),M.isSeparated(r))return!1}let b=d.satBounds,_=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){let M=b[S],C=_[S];if(r.setFromPoints(C,t),M.isSeparated(r))return!1}for(let S=0;S<4;S++){let M=x[S];for(let C=0;C<4;C++){let A=_[C];if(a.crossVectors(M,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 N=0;N<3;N++){let B=y[N],V=y[(N+1)%3];h.start.copy(B),h.end.copy(V),h.delta(n);let H=x?u.start:u.end,X=Th(v.distanceToPoint(B));if(Th(v.normal.dot(n))&&X){u.copy(h),b=2;break}if((v.intersectLine(h,H)||X)&&!Th(H.distanceTo(V))){if(b++,x)break;x=!0}}if(b===1&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(b!==2)return!1;let _=d.points,S=!1,M=0;for(let N=0;N<3;N++){let B=_[N],V=_[(N+1)%3];h.start.copy(B),h.end.copy(V),h.delta(o);let H=S?c.start:c.end,X=Th(m.distanceToPoint(B));if(Th(m.normal.dot(o))&&X){c.copy(h),M=2;break}if((m.intersectLine(h,H)||X)&&!Th(H.distanceTo(V))){if(M++,S)break;S=!0}}if(M===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(M!==2)return!1;if(u.delta(n),c.delta(o),n.dot(o)<0){let N=c.start;c.start=c.end,c.end=N}let C=u.start.dot(n),A=u.end.dot(n),T=c.start.dot(n),P=c.end.dot(n),R=A<T,z=C<P;return C!==P&&T!==A&&R===z?!1:(p&&(l.subVectors(u.start,c.start),l.dot(n)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(n)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();ho.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ho.prototype.distanceToTriangle=function(){let e=new I,t=new I,i=["a","b","c"],r=new da,s=new da;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 u=0;u<3;u++){let c,d=i[u],p=a[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,n&&n.copy(e),o&&o.copy(p));let f=this[d];a.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,n&&n.copy(f),o&&o.copy(e))}for(let u=0;u<3;u++){let c=i[u],d=i[(u+1)%3];r.set(this[c],this[d]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];s.set(a[f],a[m]),Yx(r,s,e,t);let v=e.distanceToSquared(t);v<h&&(h=v,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var _n=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new Le,this.invMatrix=new Le,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 wn),this.alignedSatBounds=new Array(3).fill().map(()=>new wn),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}};_n.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){let c=1*l|2*h|4*u,d=r[c];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],u=s[l],c=1<<l,d=r[c];h.subVectors(n,d),u.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();_n.prototype.intersectsBox=function(){let e=new wn;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}}();_n.prototype.intersectsTriangle=function(){let e=new ho,t=new Array(3),i=new wn,r=new wn,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 c=0;c<3;c++){let d=n[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,u=this.points;for(let c=0;c<3;c++){let d=l[c],p=h[c];if(i.setFromPoints(p,u),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}();_n.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}}();_n.prototype.distanceToPoint=function(){let e=new I;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();_n.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new da),i=new Array(12).fill().map(()=>new da),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,u=a.min,c=a.max,d=this.points,p=1/0;for(let m=0;m<8;m++){let v=d[m];s.copy(v).clamp(u,c);let y=v.distanceToSquared(s);if(y<p&&(p=y,o&&o.copy(v),l&&l.copy(s),y<h))return Math.sqrt(y)}let f=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){let x=(m+1)%3,b=(m+2)%3,_=v<<x|y<<b,S=1<<m|v<<x|y<<b,M=d[_],C=d[S];t[f].set(M,C);let A=e[m],T=e[x],P=e[b],R=i[f],z=R.start,N=R.end;z[A]=u[A],z[T]=v?u[T]:c[T],z[P]=y?u[P]:c[T],N[A]=c[A],N[T]=v?u[T]:c[T],N[P]=y?u[P]:c[T],f++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?c.x:u.x,s.y=v?c.y:u.y,s.z=y?c.z:u.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 m=0;m<12;m++){let v=t[m];for(let y=0;y<12;y++){let x=i[y];Yx(v,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 Ph=new I,Dh=new I,Oh=new I,of=new $,lf=new $,hf=new $,Q2=new I,Z2=new I,K2=new I,cf=new I;function T9(e,t,i,r,s,a){let n;return a===Or?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Rs,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function P9(e,t,i,r,s,a,n,o,l){Ph.fromBufferAttribute(t,a),Dh.fromBufferAttribute(t,n),Oh.fromBufferAttribute(t,o);let h=T9(e,Ph,Dh,Oh,cf,l);if(h){r&&(of.fromBufferAttribute(r,a),lf.fromBufferAttribute(r,n),hf.fromBufferAttribute(r,o),h.uv=Hr.getInterpolation(cf,Ph,Dh,Oh,of,lf,hf,new $)),s&&(of.fromBufferAttribute(s,a),lf.fromBufferAttribute(s,n),hf.fromBufferAttribute(s,o),h.uv1=Hr.getInterpolation(cf,Ph,Dh,Oh,of,lf,hf,new $)),i&&(Q2.fromBufferAttribute(i,a),Z2.fromBufferAttribute(i,n),K2.fromBufferAttribute(i,o),h.normal=Hr.getInterpolation(cf,Ph,Dh,Oh,Q2,Z2,K2,new I),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:n,c:o,normal:new I,materialIndex:0};Hr.getNormal(Ph,Dh,Oh,u.normal),h.face=u,h.faceIndex=a}return h}function QT(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:u,uv:c,uv1:d}=e.attributes,p=P9(i,h,u,c,d,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function D9(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)QT(e,t,i,n,a)}function O9(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=QT(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function hn(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 J2(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(hn(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var ZT=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 Bo(e,t){return t[e+15]===65535}function uc(e,t){return t[e+6]}function Id(e,t){return t[e+14]}function Rd(e){return e+8}function Bd(e,t){return t[e+6]}function I9(e,t){return t[e+7]}var rc=new er,Xm=new I,R9=["x","y","z"];function h1(e,t,i,r,s){let a=e*2,n=Zc,o=Yo,l=Qo;if(Bo(a,o)){let h=uc(e,l),u=Id(a,o);D9(t,i,r,h,u,s)}else{let h=Rd(e);Ym(h,n,r,Xm)&&h1(h,t,i,r,s);let u=Bd(e,l);Ym(u,n,r,Xm)&&h1(u,t,i,r,s)}}function c1(e,t,i,r){let s=e*2,a=Zc,n=Yo,o=Qo;if(Bo(s,n)){let l=uc(e,o),h=Id(s,n);return O9(t,i,r,l,h)}else{let l=I9(e,o),h=R9[l],u=r.direction[h]>=0,c,d;u?(c=Rd(e),d=Bd(e,o)):(c=Bd(e,o),d=Rd(e));let p=Ym(c,a,r,Xm)?c1(c,t,i,r):null;if(p){let m=p.point[h];if(u?m<=a[d+l]:m>=a[d+l+3])return p}let f=Ym(d,a,r,Xm)?c1(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var B9=function(){let e,t,i=[],r=new ZT(()=>new er);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,u=0,c=0){function d(x){let b=x*2,_=Yo,S=Qo;for(;!Bo(b,_);)x=Rd(x),b=x*2;return uc(x,S)}function p(x){let b=x*2,_=Yo,S=Qo;for(;!Bo(b,_);)x=Bd(x,S),b=x*2;return uc(x,S)+Id(b,_)}let f=a*2,m=Zc,v=Yo,y=Qo;if(Bo(f,v)){let x=uc(a,y),b=Id(f,v);return dn(a,m,e),l(x,b,!1,c,u+a,e)}else{let x=Rd(a),b=Bd(a,y),_=x,S=b,M,C,A,T;if(h&&(A=e,T=t,dn(_,m,A),dn(S,m,T),M=h(A),C=h(T),C<M)){_=b,S=x;let H=M;M=C,C=H,A=T}A||(A=e,dn(_,m,A));let P=Bo(_*2,v),R=o(A,P,M,c+1,u+_),z;if(R===2){let H=d(_),X=p(_)-H;z=l(H,X,!0,c+1,u+_,A)}else z=R&&s(_,n,o,l,h,u,c+1);if(z)return!0;T=t,dn(S,m,T);let N=Bo(S*2,v),B=o(T,N,C,c+1,u+S),V;if(B===2){let H=d(S),X=p(S)-H;V=l(H,X,!0,c+1,u+S,T)}else V=B&&s(S,n,o,l,h,u,c+1);return!!V}}}(),L9=function(){let e=new ho,t=new ho,i=new Le,r=new _n,s=new _n;return function a(n,o,l,h,u=null){let c=n*2,d=Zc,p=Yo,f=Qo;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),Bo(c,p)){let m=o,v=m.index,y=m.attributes.position,x=l.index,b=l.attributes.position,_=uc(n,f),S=Id(c,p);if(i.copy(h).invert(),l.boundsTree)return dn(n,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:M=>s.intersectsBox(M),intersectsTriangle:M=>{M.a.applyMatrix4(h),M.b.applyMatrix4(h),M.c.applyMatrix4(h),M.needsUpdate=!0;for(let C=_*3,A=(S+_)*3;C<A;C+=3)if(hn(t,C,v,y),t.needsUpdate=!0,M.intersectsTriangle(t))return!0;return!1}});for(let M=_*3,C=S+_*3;M<C;M+=3){hn(e,M,v,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(hn(t,A,x,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,v=f[n+6];return dn(m,d,rc),!!(u.intersectsBox(rc)&&a(m,o,l,h,u)||(dn(v,d,rc),u.intersectsBox(rc)&&a(v,o,l,h,u)))}}}();function Ym(e,t,i,r){return dn(e,t,rc),i.intersectBox(rc,r)}var u1=[],Kf,Zc,Yo,Qo;function Qu(e){Kf&&u1.push(Kf),Kf=e,Zc=new Float32Array(e),Yo=new Uint16Array(e),Qo=new Uint32Array(e)}function uf(){Kf=null,Zc=null,Yo=null,Qo=null,u1.length&&Qu(u1.pop())}var Hv=Symbol("skip tree generation"),Wv=new er,qv=new er,Ih=new Le,ul=new _n,Pu=new _n,Du=new I,df=new I,z9=new I,k9=new I,N9=new I,$2=new er,Ya=new ZT(()=>new ho),hd=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."),hd.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."),hd.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 hd(t,{...i,[Hv]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new At(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,[Hv]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Hv]||(this._roots=A9(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new er))),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 c=0,d=h.length;c<d;c++)s=h[c],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),u(0,l),l+=s.byteLength;function u(c,d,p=!1){let f=c*2;if(n[f+15]===65535){let m=a[c+6],v=n[f+14],y=1/0,x=1/0,b=1/0,_=-1/0,S=-1/0,M=-1/0;for(let C=3*m,A=3*(m+v);C<A;C++){let T=i[C],P=r.getX(T),R=r.getY(T),z=r.getZ(T);P<y&&(y=P),P>_&&(_=P),R<x&&(x=R),R>S&&(S=R),z<b&&(b=z),z>M&&(M=z)}return o[c+0]!==y||o[c+1]!==x||o[c+2]!==b||o[c+3]!==_||o[c+4]!==S||o[c+5]!==M?(o[c+0]=y,o[c+1]=x,o[c+2]=b,o[c+3]=_,o[c+4]=S,o[c+5]=M,!0):!1}else{let m=c+8,v=a[c+6],y=m+d,x=v+d,b=p,_=!1,S=!1;e?b||(_=e.has(y),S=e.has(x),b=!_&&!S):(_=!0,S=!0);let M=b||_,C=b||S,A=!1;M&&(A=u(m,d,b));let T=!1;C&&(T=u(v,d,b));let P=A||T;if(P)for(let R=0;R<3;R++){let z=m+R,N=v+R,B=o[z],V=o[z+3],H=o[N],X=o[N+3];o[c+R]=B<H?B:H,o[c+R+3]=V>X?V:X}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 u=r[n+6],c=s[l+14];e(o,h,new Float32Array(i,n*4,6),u,c)}else{let u=n+8,c=r[n+6],d=r[n+7];e(o,h,new Float32Array(i,n*4,6),d)||(a(u,o+1),a(c,o+1))}}}raycast(e,t=ka){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,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l,d=s.length;if(Qu(i[h]),h1(0,r,c,e,s),uf(),n){let p=o[h].materialIndex;for(let f=d,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=ka){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,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l;Qu(i[h]);let d=c1(0,r,c,e);uf(),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(Qu(s),r=L9(0,i,e,t),uf(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(d,p,f,m)=>{let v=p*3;return c(d,v,v+1,v+2,f,m)}}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=Ya.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,m,v)=>c(d,p,f,m,v)?!0:J2(d,p,r,l,f,m,s)}else o||(l?o=(c,d,p,f)=>J2(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(Qu(c),h=B9(0,r,n,o,a,u),uf(),h)break;u+=c.byteLength}return Ya.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;Ih.copy(t).invert();let h=Ya.getPrimitive(),u=Ya.getPrimitive();if(s){let d=function(p,f,m,v,y,x,b,_){for(let S=m,M=m+v;S<M;S++){hn(u,S*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=p,A=p+f;C<A;C++)if(hn(h,C*3,a,n),h.needsUpdate=!0,s(h,u,C,S,y,x,b,_))return!0}return!1};if(r){let p=r;r=function(f,m,v,y,x,b,_,S){return p(f,m,v,y,x,b,_,S)?!0:d(f,m,v,y,x,b,_,S)}}else r=d}e.getBoundingBox(qv),qv.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>qv.intersectsBox(d),intersectsRange:(d,p,f,m,v,y)=>(Wv.copy(y),Wv.applyMatrix4(Ih),e.shapecast({intersectsBounds:x=>Wv.intersectsBox(x),intersectsRange:(x,b,_,S,M)=>r(d,p,x,b,m,v,S,M)}))});return Ya.releasePrimitive(h),Ya.releasePrimitive(u),c}intersectsBox(e,t){return ul.set(e.min,e.max,t),ul.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ul.intersectsBox(i),intersectsTriangle:i=>ul.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(),ul.set(e.boundingBox.min,e.boundingBox.max,t),ul.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,u=e.index,c=Ya.getPrimitive(),d=Ya.getPrimitive(),p=df,f=z9,m=null,v=null;r&&(m=k9,v=N9);let y=1/0,x=null,b=null;return Ih.copy(t).invert(),Pu.matrix.copy(Ih),this.shapecast({boundsTraverseOrder:_=>ul.distanceToBox(_),intersectsBounds:(_,S,M)=>M<y&&M<a?(S&&(Pu.min.copy(_.min),Pu.max.copy(_.max),Pu.needsUpdate=!0),!0):!1,intersectsRange:(_,S)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>Pu.distanceToBox(M),intersectsBounds:(M,C,A)=>A<y&&A<a,intersectsRange:(M,C)=>{for(let A=M*3,T=(M+C)*3;A<T;A+=3){hn(d,A,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=_*3,R=(_+S)*3;P<R;P+=3){hn(c,P,l,o),c.needsUpdate=!0;let z=c.distanceToTriangle(d,p,m);if(z<y&&(f.copy(p),v&&v.copy(m),y=z,x=P/3,b=A/3),z<s)return!0}}}});{let M=u?u.count:h.count;for(let C=0,A=M;C<A;C+=3){hn(d,C,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let T=_*3,P=(_+S)*3;T<P;T+=3){hn(c,T,l,o),c.needsUpdate=!0;let R=c.distanceToTriangle(d,p,m);if(R<y&&(f.copy(p),v&&v.copy(m),y=R,x=T/3,b=C/3),R<s)return!0}}}}}),Ya.releasePrimitive(c),Ya.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(v):r.point=v.clone(),r.point.applyMatrix4(Ih),f.applyMatrix4(Ih),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=>(Du.copy(e).clamp(h.min,h.max),Du.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<n&&c<a,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,Du);let c=e.distanceToSquared(Du);return c<n&&(df.copy(Du),n=c,o=u),c<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(df):t.point=df.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{dn(0,new Float32Array(t),$2),e.union($2)}),e}},Ou=Br(zO()),F9=.5*(Math.sqrt(3)-1),Iu=(3-Math.sqrt(3))/6,U9=1/3,Qa=1/6,Wee=(Math.sqrt(5)-1)/4,qee=(5-Math.sqrt(5))/20,cd=e=>Math.floor(e)|0,eA=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]),Xv=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 Yv(e=Math.random){let t=KT(e),i=new Float64Array(t).map(s=>eA[s%12*2]),r=new Float64Array(t).map(s=>eA[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*F9,u=cd(s+h),c=cd(a+h),d=(u+c)*Iu,p=u-d,f=c-d,m=s-p,v=a-f,y,x;m>v?(y=1,x=0):(y=0,x=1);let b=m-y+Iu,_=v-x+Iu,S=m-1+2*Iu,M=v-1+2*Iu,C=u&255,A=c&255,T=.5-m*m-v*v;if(T>=0){let z=C+t[A],N=i[z],B=r[z];T*=T,n=T*T*(N*m+B*v)}let P=.5-b*b-_*_;if(P>=0){let z=C+y+t[A+x],N=i[z],B=r[z];P*=P,o=P*P*(N*b+B*_)}let R=.5-S*S-M*M;if(R>=0){let z=C+1+t[A+1],N=i[z],B=r[z];R*=R,l=R*R*(N*S+B*M)}return 70*(n+o+l)}}function V9(e=Math.random){let t=KT(e),i=new Float64Array(t).map(a=>Xv[a%12*3]),r=new Float64Array(t).map(a=>Xv[a%12*3+1]),s=new Float64Array(t).map(a=>Xv[a%12*3+2]);return function(a,n,o){let l,h,u,c,d=(a+n+o)*U9,p=cd(a+d),f=cd(n+d),m=cd(o+d),v=(p+f+m)*Qa,y=p-v,x=f-v,b=m-v,_=a-y,S=n-x,M=o-b,C,A,T,P,R,z;_>=S?S>=M?(C=1,A=0,T=0,P=1,R=1,z=0):_>=M?(C=1,A=0,T=0,P=1,R=0,z=1):(C=0,A=0,T=1,P=1,R=0,z=1):S<M?(C=0,A=0,T=1,P=0,R=1,z=1):_<M?(C=0,A=1,T=0,P=0,R=1,z=1):(C=0,A=1,T=0,P=1,R=1,z=0);let N=_-C+Qa,B=S-A+Qa,V=M-T+Qa,H=_-P+2*Qa,X=S-R+2*Qa,G=M-z+2*Qa,se=_-1+3*Qa,ae=S-1+3*Qa,J=M-1+3*Qa,K=p&255,ne=f&255,te=m&255,oe=.6-_*_-S*S-M*M;if(oe<0)l=0;else{let ye=K+t[ne+t[te]];oe*=oe,l=oe*oe*(i[ye]*_+r[ye]*S+s[ye]*M)}let ie=.6-N*N-B*B-V*V;if(ie<0)h=0;else{let ye=K+C+t[ne+A+t[te+T]];ie*=ie,h=ie*ie*(i[ye]*N+r[ye]*B+s[ye]*V)}let be=.6-H*H-X*X-G*G;if(be<0)u=0;else{let ye=K+P+t[ne+R+t[te+z]];be*=be,u=be*be*(i[ye]*H+r[ye]*X+s[ye]*G)}let ue=.6-se*se-ae*ae-J*J;if(ue<0)c=0;else{let ye=K+1+t[ne+1+t[te+1]];ue*=ue,c=ue*ue*(i[ye]*se+r[ye]*ae+s[ye]*J)}return 32*(l+h+u+c)}}function KT(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 Sa=new Hr,j9=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;Sa.a.fromBufferAttribute(e,r),Sa.b.fromBufferAttribute(e,r+1),Sa.c.fromBufferAttribute(e,r+2),s*=Sa.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),Sa.a.fromBufferAttribute(this.positionAttribute,e*3),Sa.b.fromBufferAttribute(this.positionAttribute,e*3+1),Sa.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Sa.a,r).addScaledVector(Sa.b,s).addScaledVector(Sa.c,1-(r+s)),Sa.getNormal(i),this}},G9=Br(IE()),H9=new Le,W9=new Le,q9=new Le,Ld;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Ld||(Ld={}));var Qx=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new Le,this.copyPreviousMatrix=!0,this.hiddenMatrix=new Le,this.matrixWorldRigid=new Le,this.shearScale=new Le,this.shearScaleInv=new Le}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof ci&&(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)Ld.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Ld.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,G9.SVD)(i),n=H9.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=W9.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=q9.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 Le().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Le?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)}},X9=class extends Qx(ci){},Y9=e=>e.type==="Mesh",is=class extends X9{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 is(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 Y9(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}},wl=new I,_l=new I,dc=new Le,JT=[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)],Q9=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Z9=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],tA=(e,t,i)=>{e.updateEntityBoxSize(wl,_l),dc.copy(t).multiply(e.matrixWorld),_l.x===0&&_l.y===0&&_l.z===0?i.push(new I(wl.x,wl.y,wl.z).applyMatrix4(dc)):JT.forEach(r=>{i.push(r.clone().multiply(_l).add(wl).applyMatrix4(dc))})},iA=class extends er{constructor(){super(...arguments),this.matrix=new Le,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 Le().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}tA(s,t,r)}}):tA(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(dc.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(_l).multiplyScalar(.5),this.getCenter(wl),dc.copy(this.matrix).setPosition(wl),this.vertices=JT.map(e=>e.clone().multiply(_l).applyMatrix4(dc))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Q9.map(([e,t])=>new da(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=Z9.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},jo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},K9=class extends nC{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),u=o.getPoints(h);for(let c=0;c<u.length;c++){let d=u[c];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},d1=.001;function p1(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=d1}function Qv(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 p1(i,r,a)&&p1(i,s,a)}function $T(e){let t=e.points.map(u=>new I(...u.data.position)),i=[e.points[0]],r=new I(...i[0].data.position);for(let u=0;u<e.points.length-1;u++)p1(r,t[u],t[u+1])||(i.push(e.points[u]),r=t[u]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let u=0;u<n;u++){let c=i[u].data,d=new I(...c.position),p=new I(...c.controlPrevious.position),f=new I(...c.controlNext.position),m={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===n-1)){o[u]={...m,removedLength:0};continue}let v=s&&u==0?n-1:u-1,y=s&&u==n-1?0:u+1,x=i[v].data,b=i[y].data,_=new I(...x.position),S=new I(...b.position),M=_.clone().sub(d).normalize(),C=S.clone().sub(d).normalize();Object.assign(m,{prevDir:M,nextDir:C});let A=Qv(x,c),T=Qv(c,b);if(!A||!T)o[u]={...m,removedLength:0};else{let P=M.clone().add(C).normalize(),R=P.clone().cross(M).length()/M.dot(P);o[u]={...m,tan:R,removedLength:c.roundness/R}}}for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let u=0;u<a;u++){let c=u,d=s&&u===n-1?0:u+1,p=o[c],f=o[d],m=null;if(!Qv(i[c].data,i[d].data))p.position.distanceTo(f.position)>d1&&(m=new qf(p.position,p.controlNext,f.controlPrevious,f.position));else{let v=p.position.clone(),y=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&v.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&y.add(f.prevDir.clone().setLength(f.removedLength))),v.distanceTo(y)>d1&&(m=new qf(v,v.clone().lerp(y,.3),y.clone().lerp(v,.3),y))}l[2*u+1]=m}for(let u=0;u<n;u++){let c=o[u];if(c.removedLength===0){l[2*u]=null;continue}let d=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(d),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(d),m=c.tan*c.removedLength,v=c.prevDir.clone().add(c.nextDir).normalize(),y=p.clone().lerp(f,.5),x=p.distanceTo(f)/2,b=v.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(x,2))).add(y),_=v.clone().multiplyScalar(-m).add(b),S=d.distanceTo(_)/d.distanceTo(y),M=c.prevDir.clone().multiplyScalar(S*d.distanceTo(p)).add(d),C=M.clone().lerp(_,2),A=p.clone().lerp(M,4/3),T=f.clone().lerp(C,4/3);l[2*u]=new qf(p,A,T,f)}let h=new K9;return l.forEach(u=>{u&&h.add(u)}),h}var Yt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(Yt||(Yt={}));var Qn=e=>Yt.is(e),J9={type:"completeState",isfromEntity:!0},$9=["x","y","z"],Zv=new I,eW=new I().set(0,1,0),Zx=e=>class extends Qx(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 iA,this._recursiveBBox=new iA,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(Yt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Yt.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(Yt.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)Cl.toOps(this.data,s.data).forEach(a=>{let n=Em.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=Cl.patch(this.data,s),Cl.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=>{Qn(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(Yt.is(i[r]))return i[r];if(Yt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Yt.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)Qn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{Yt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Qn(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Qn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)Qn(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=>Qn(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*st.RAD2DEG,this.rotation.y*st.RAD2DEG,this.rotation.z*st.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return _y(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,$9[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(Zv.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(st.DEG2RAD),this.rotation.setFromVector3(Zv),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??Tc.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)Yt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Yt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return _y(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=_i(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(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=Wr.zoom(u,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(h[d]=c[d])}}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:u,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:u,...c}=l;l=c}let h=Wr.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Cl.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),_i(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[u],c.updateState(qo.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=Wr.zoom(u.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=c[p]);t={...t,props:d}}u.overrideData=km.resolve(i.overrides,l),u.updateByOp(t,Dr.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Uo.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Uo.rootOverrideProps)if(_i(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=qo.filterOp(h.overrideData,l);u&&h.updateByOp(u,Dr.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=qo.filterOp(h.overrideData,t);if(u){let c;a===h.data&&t===u?c=i:c=Dr.applySimple(h.data,u),h.updateByOp(u,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Xl.is(t.props.type)&&jo.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){jo.changeEntityProptotype(this,i,r);for(let s of this.children)Yt.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),_i(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),_i(t.path,["cloner"])!==null){let s=Dr.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=$T(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h);if(u===null)return;let c=this.parent?this.parent?.matrixWorld:new Le;n.updateMatrixWorld();let d=new Le().multiplyMatrices(c.clone().invert(),n.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new Le().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(u),v=new Le().lookAt(u,m,eW),y=Zv.setFromEuler(new vr().setFromRotationMatrix(v)).multiplyScalar(st.RAD2DEG);p={...p,rotation:y.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(J9)})}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 jo.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 jo.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"})}},e3=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);i.thetaLength=st.clamp(i.thetaLength,0,360);let r=i.width/2,s=i.radiusTop??r,a=i.radiusBottom??r;return s===a?(s=r,a=r):s>a?(s=r,a=a*r/s):(s=s*r/a,a=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:a})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return l===0?(f=new ut,f.setAttribute("position",new et([],3))):c||p?f=new t3(h,u,r,s,a,n,o,l*Math.PI/180,c,c,d,p):f=new fx(h,u,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 rA(e){return new $(e.y,-e.x)}var t3=class extends ut{constructor(e,t,i,r,s,a,n,o,l,h,u,c,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,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=[],m=[],v=[],y=0,x=i/2,b=new I,_=new I;d&&e==0&&(e=l),d&&t==0&&(t=h);let S=new $(e,x),M=new $(t,-x),C=null,A=null,T=null,P=null,R=S.clone().sub(M),z=0,N=0,B=0;c>0&&(z=Math.min(e,t)*(1-c),N=e-z,B=t-z);let V=S.clone();V.x-=z;let H=Math.PI-R.angle(),X=R.angle(),G=Math.tan(X/2),se=Math.tan(H/2),ae=G+se,J=c?ae:se,K=c?ae:G;if(l=Math.min(l,(e-N)/J,R.length()/ae),h=Math.min(h,(t-B)/K,R.length()/ae),l>0){let ue=l/G;C=S.clone().sub(new $(ue,l)),c&&(T=C.clone(),T.x-=z-ae*l),S.sub(R.clone().setLength(ue))}if(h>0){let ue=h/se;A=M.clone().sub(new $(ue,-h)),M.add(R.clone().setLength(ue)),c&&(P=A.clone(),P.x-=z-ae*h,V.sub(R.clone().setLength(ue)))}R=S.clone().sub(M);let ne=R.length()<.5,te=[];for(let ue=0;ue<=r;ue++){let ye=[],de=ue/r,Be=de*o+n,Ce=new $(Math.sin(Be),Math.cos(Be));P&&A?(oe(ye,de,Ce,H,h,P,-1,!0),oe(ye,de,Ce,X,h,A,-1,!1)):A?(ie(ye,Ce,A.x,0,-1),oe(ye,de,Ce,X,h,A,-1,!1)):a||ie(ye,Ce,t,B,-1);let _e=rA(R).normalize();if(_o(_e,Ce,b),!ne)for(let Ze=0;Ze<=s;Ze++){let Qe=Ze/s,Je=R.clone().multiplyScalar(Qe).add(M);_o(Je,Ce,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),v.push(de,.5+_.y/i),ye.push(y++)}if(T&&C?(oe(ye,de,Ce,H,l,C,1,!1),oe(ye,de,Ce,X,l,T,1,!0)):C?(oe(ye,de,Ce,H,l,C,1,!1),ie(ye,Ce,C.x,0,1)):a||ie(ye,Ce,e,N,1),c&&!ne){let Ze=rA(R).multiplyScalar(-1).normalize();_o(Ze,Ce,b);for(let Qe=0;Qe<=s;Qe++){let Je=Qe/s,$e=R.clone().multiplyScalar(-Je).add(V);_o($e,Ce,_),f.push(_.x,_.y,_.z),m.push(b.x,b.y,b.z),v.push(de,.5+_.y/i),ye.push(y++)}}c&&!a&&ye.push(ye[0]),te.push(ye)}for(let ue=0;ue<te.length-1;ue++)for(let ye=0;ye<te[0].length-1;ye++){if(a&&c&&ye==s)continue;let de=te[ue][ye],Be=te[ue+1][ye],Ce=te[ue+1][ye+1],_e=te[ue][ye+1],Ze=f[Ce*3+0],Qe=f[Ce*3+2];p.push(de,Be,_e),(Ze!=0||Qe!=0)&&p.push(Be,Ce,_e)}o<Math.PI*2&&(be(-1,te[0],n),be(1,te[te.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new et(f,3)),this.setAttribute("normal",new et(m,3)),this.setAttribute("uv",new et(v,2));function oe(ue,ye,de,Be,Ce,_e,Ze,Qe){for(let Je=0;Je<u+1;Je++){let $e=Je/u,He=Ze<0?$e:1-$e;Qe&&(He-=1),He*=Be;let je=new $(Math.sin(He),Math.cos(He)*Ze),ot=je.clone().multiplyScalar(Ce).add(_e);_o(ot,de,_),f.push(_.x,_.y,_.z),_o(je,de,b),m.push(b.x,b.y,b.z),v.push(ye,.5+_.y/i),ue.push(y++)}}function ie(ue,ye,de,Be,Ce){let _e=new I,Ze=new $,Qe=[de,Be];Ce<0&&Qe.reverse();for(let Je of Qe)Ze.set(Je,x*Ce),_o(Ze,ye,_e),f.push(_e.x,_e.y,_e.z),m.push(0,Ce,0),v.push(.5,.5),ue.push(y++)}function be(ue,ye,de){let Be=new $(Math.sin(de),Math.cos(de)),Ce=new $(-Math.cos(de),Math.sin(de)),_e=new I,Ze=ue<0?($e,He,je)=>p.push($e,He,je):($e,He,je)=>p.push($e,je,He),Qe=new $((e+t+N+B)/4,0);_o(Qe,Be,_e),f.push(_e.x,_e.y,_e.z),m.push(Ce.x,0,Ce.y),v.push(.5,.5);let Je=y++;for(let $e of ye){let He=f.slice($e*3,$e*3+3);f.push(...He),m.push(Ce.x,0,Ce.y);let je=v.slice($e*2,$e*2+2);v.push(...je),y++}for(let $e=Je+1;$e<y-1;$e++)Ze(Je,$e,$e+1);Ze(Je,y-1,Je+1)}}},tW=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=st.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:u,cornerSegments:c}=e.parameters,d;return l===0?(d=new ut,d.setAttribute("position",new et([],3))):h>0||u>0||l<360?d=new t3(0,t/2,r,s,a,n,o,l*Math.PI/180,h,u,c,0,!0):d=new mx(t/2,r,s,a,n),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},iW=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 Fa(t,i,r,s,a,n):h=new rW(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Kv=Math.PI/2,rW=class extends ut{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;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 h=[],u=[],c=[],d=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),n>0&&(v("z","y","x",-1,-1,1,i,t,e,a,0),v("z","y","x",1,-1,-1,i,t,e,a,1),v("z","y","x",-1,1,-1,i,t,e,a,1),v("z","y","x",1,1,1,i,t,e,a,0),v("x","y","z",-1,-1,-1,e,t,i,r,0),v("x","y","z",1,-1,1,e,t,i,r,1),v("x","y","z",-1,1,1,e,t,i,r,0),v("x","y","z",1,1,-1,e,t,i,r,1),v("y","x","z",-1,-1,1,t,e,i,s,0),v("y","x","z",1,-1,-1,t,e,i,s,1),v("y","x","z",1,1,1,t,e,i,s,1),v("y","x","z",-1,1,-1,t,e,i,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new et(u,3)),this.setAttribute("normal",new et(c,3)),this.setAttribute("uv",new et(d,2));function m(x,b,_,S,M,C,A,T,P,R,z){let N=(C-2*n)/P,B=(A-2*n)/R,V=C/2-n,H=A/2-n,X=T/2,G=P+1,se=R+1,ae=0,J=0,K=new I;for(let ne=0;ne<se;ne++){let te=ne*B-H;for(let oe=0;oe<G;oe++){let ie=oe*N-V;K[x]=ie*S,K[b]=te*M,K[_]=X,u.push(K.x,K.y,K.z),K[x]=0,K[b]=0,K[_]=T>0?1:-1,c.push(K.x,K.y,K.z),d.push(oe/P),d.push(1-ne/R),ae+=1}}for(let ne=0;ne<R;ne++)for(let te=0;te<P;te++){let oe=p+te+G*ne,ie=p+te+G*(ne+1),be=p+(te+1)+G*(ne+1),ue=p+(te+1)+G*ne;h.push(oe,ie,ue),h.push(ie,be,ue),J+=6}l.addGroup(f,J,z),f+=J,p+=ae}function v(x,b,_,S,M,C,A,T,P,R,z){let N=(A-2*n)/R,B=A/2-n,V=T/2-n,H=P/2,X=R+1,G=0,se=0,ae=new I,J=new I;for(let K=0;K<o+1;K++){let ne=K/o*Kv,te=Math.sin(ne)*n,oe=(1-Math.cos(ne))*n,ie=Math.sin(ne),be=Math.cos(ne);ae[b]=(V+te)*M,ae[_]=(H-oe)*C,J[x]=0,J[b]=ie*Math.sign(ae[b]),J[_]=be*Math.sign(ae[_]);for(let ue=0;ue<X;ue++){let ye=ue*N-B;ae[x]=ye*S,u.push(ae.x,ae.y,ae.z),c.push(J.x,J.y,J.z),d.push(ue/R),d.push(0),G+=1}}for(let K=0;K<o;K++)for(let ne=0;ne<R;ne++){let te=p+ne+X*K,oe=p+ne+X*(K+1),ie=p+(ne+1)+X*(K+1),be=p+(ne+1)+X*K;h.push(te,oe,be),h.push(oe,ie,be),se+=6}l.addGroup(f,se,z),f+=se,p+=G}function y(x,b,_){let S=new I,M=new I(e/2,t/2,i/2);M.subScalar(n);let C=[],A=x*b*_>0?(P,R,z)=>h.push(P,R,z):(P,R,z)=>h.push(P,z,R);for(let P=0;P<=o;P++){let R=[],z=Kv*(1-P/o),N=Math.cos(z),B=Math.sin(z),V=0;for(let H=0;H<=P;H++){let X=Math.cos(V),G=Math.sin(V);S.x=N*X,S.y=B,S.z=N*G;let se=M.clone().addScaledVector(S,n);u.push(x*se.x,b*se.y,_*se.z),c.push(x*S.x,b*S.y,_*S.z),d.push(0,0),R.push(p++),V+=Kv/P}C.push(R)}let T=C.length-1;for(let P=0;P<T;P++){let R=C[P],z=C[P+1],N=R.length-1;A(R[0],z[1],z[0]);for(let B=1;B<=N;B++)A(R[B-1],R[B],z[B]),A(R[B],z[B+1],z[B])}}}},Kx=class extends ut{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),u(),this.setAttribute("position",new et(n,3)),this.setAttribute("normal",new et(l,3)),this.setAttribute("uv",new et(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new I,p=d.clone(),f=new Hr,m=s*r,v=r-m,y=a+1,x=new I,b=(X,G)=>x.subVectors(X,G).normalize(),_=(X,G)=>Array(X).fill(void 0).map(G),S=_(e.length/3,(X,G)=>new I().fromArray(e,G*3).setLength(r)),M=[],C=1e6;for(let X=0;X<S.length;X++){let G=S[X],se=[],ae,J,K,ne=1e10,te=-1;for(;(te=t.indexOf(X,te+1))!=-1;){let ue=te-te%3;ae=t[ue+(te+1)%3],J=t[ue+(te+2)%3],K=G.distanceToSquared(S[ae]),ne=Math.min(ne,K),se.push([ae,J,K])}ne+=1e-6;let oe=[],ie=0,be=se.length;for(let ue=0;ue<be;ue++){[ae,J,K]=se[ie];let ye=M[ae]?.includes(X)==!0;K<=ne&&oe.push(ae+ +ye*C),ie=se.findIndex(de=>de[0]==J)}M.push(oe)}let A=[];{let X=0,G=0,se,ae,J=c==3;for(let K=0;K<=a;K++){se=K*(K+1)/2,ae=(K+1)*(K+2)/2;for(let ne=0;ne<a-K;ne++)[X,G]=[se+ne+K+2,ae+ne+K+3],A.push(se,ae,...J?[G,se]:[X,ae],G,X),[se,ae]=[X,G];A.push(se,ae,se+a+2)}}let T=d.clone(),P=d.clone(),R=d.clone(),z=d.clone(),N=d.clone(),B=[],V=_(S.length,()=>_(c,()=>d.clone()));for(let X=0;X<S.length;X++){d.copy(S[X]).normalize(),T.copy(d).multiplyScalar(v);let G=M[X];for(let oe=0;oe<G.length;oe++){let ie=G[oe],be=G[(oe+1)%c];f.setFromPointsAndIndices(S,X,ie%C,be%C),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(T,V[X][oe])}let se=[],ae=[],J=[],K=new I;a==0&&[...V[X]].reduce((oe,ie)=>oe.add(ie),K).multiplyScalar(1/c);for(let oe=0;oe<c;oe++){let ie=[],be=(oe-1+c)%c,ue=V[X][be],ye=V[X][oe];d.copy(ue).sub(T),p.copy(ye).sub(T);let de=T.angleTo(d),Be=d.angleTo(p),Ce=Math.cos(de)*m;a==0?P.copy(K):P.copy(T).setLength(v+Ce),ae.push(Ce);let _e=[P,ue,ye];for(let Ze=0;Ze<2;Ze++){let Qe=_e[Ze],Je=_e[Ze+1];z.subVectors(Qe,T),N.subVectors(Je,T),R.crossVectors(z,N).normalize();for(let $e=0;$e<y;$e++){let He=[de,Be][Ze]*$e/y;d.copy(z).applyAxisAngle(R,He).add(T),se.push(d.clone()),Ze&&(b(d,T),ie.push([$e==0?Qe:d.clone(),x.clone()]))}Ze&&(b(Je,T),ie.push([Je,x.clone()]))}J.push(ie)}B.push(J);let ne=2*y,te=2;for(let oe=0;oe<c;oe++){let ie=ne*oe,be=ne*((oe+1)%c),ue=[se[ie]];for(let de=1;de<y;de++){z=se[ie+de],N=se[be+de],ue.push(z);for(let Be=1,Ce=de-te+1;Be<=Ce;Be++)d.lerpVectors(z,N,Be/(Ce+1)),d.sub(T).setLength(ae[oe]).add(T),ue.push(d.clone());ue.push(N)}for(let de=0;de<y;de++)ue.push(se[de+y+ie]);ue.push(se[be+y]);let ye=A.map(de=>ue[de]);n.push(...ye.map(de=>[de.x,de.y,de.z]).flat()),l.push(...ye.map(de=>(b(de,T),[x.x,x.y,x.z])).flat())}}let H=[];for(let X=0;X<M.length;X++)for(let G=0;G<c;G++){let se=M[X][G];if(se<C){let ae=M[se].findIndex(ne=>ne%C==X),J=B[X][G],K=B[se][ae];for(let ne=0;ne<y;ne++){let te=J[ne],oe=K[y-ne],ie=J[ne+1],be=K[y-(ne+1)];[te,oe,ie,ie,oe,be].forEach(ue=>{n.push(ue[0].x,ue[0].y,ue[0].z),l.push(ue[1].x,ue[1].y,ue[1].z)})}H.push(J[0][0],K[y][0],J[y][0],K[0][0])}}for(;H.length;){let X,G,se,ae;[X,G]=H.splice(0,2);let J=[X];for(;X!=G;)J.push(G),se=H.indexOf(G),ae=se%2,G=H.splice(se-ae,2)[1-ae];x.subVectors(J[0],J[1]).cross(d.subVectors(J[0],J[2])).normalize();let K=x.dot(J[0])<0;K&&x.negate();for(let ne=1;ne<=J.length-2;ne++)[J[ne+ +K],J[ne+1-+K],J[0]].forEach(te=>{n.push(te.x,te.y,te.z),l.push(x.x,x.y,x.z)})}}function u(){let c=new I;for(let M=0;M<n.length;M+=3){c.x=n[M+0],c.y=n[M+1],c.z=n[M+2];let C=_(c)/2/Math.PI+.5,A=S(c)/Math.PI+.5;o.push(C,1-A)}let d=new I,p=new I,f=new I,m=new I,v=new $,y=new $,x=new $,b=(M,C,A,T)=>{T<0&&M.x===1&&(o[C]=M.x-1),A.x===0&&A.z===0&&(o[C]=T/2/Math.PI+.5)};for(let M=0,C=0;M<n.length;M+=9,C+=6){d.set(n[M+0],n[M+1],n[M+2]),p.set(n[M+3],n[M+4],n[M+5]),f.set(n[M+6],n[M+7],n[M+8]),v.set(o[C+0],o[C+1]),y.set(o[C+2],o[C+3]),x.set(o[C+4],o[C+5]),m.copy(d).add(p).add(f).divideScalar(3);let A=_(m);b(v,C+0,d,A),b(y,C+2,p,A),b(x,C+4,f,A)}for(let M=0;M<o.length;M+=6){let C=o[M+0],A=o[M+2],T=o[M+4],P=Math.max(C,A,T),R=Math.min(C,A,T);P>.9&&R<.1&&(C<.2&&(o[M+0]+=1),A<.2&&(o[M+2]+=1),T<.2&&(o[M+4]+=1))}function _(M){return Math.atan2(M.z,-M.x)}function S(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(e){return new Kx(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},sW=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 i3(t*.5,a,n):new lC(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},i3=class extends Kx{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 i3(e.radius,e.corner,e.cornerSides)}},Ru=1e-12,Jx=class{constructor(e){this.position=new $,this.startPosition=new $,this.uuid=st.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 Jx(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},f1=class extends Jx{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new f1(this.parent).copy(this)}},pc=class extends Jx{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new f1(this),new f1(this))}static create(e,t){let i=new pc(e,new $(...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 pc(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 $,t=new $){let[i,r]=this.computeTangents();return i&&r&&(sA(i,e),sA(r,t)),[e,t]}computeTangent(e=new $){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new $){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function sA(e,t=new $){let i=e.length();return t.set(-e.y/i,e.x/i)}var $x=e=>e,Kc=new $,Mg=new $,aW=new $,nW=new $,oW=new $,lW=new $,r3=new I,s3=new I;function hW(e){let t=new $;t.addVectors(e.v0,Kc.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new $;return i.addVectors(e.v2,Mg.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Ia(e.v0,t,i,e.v2)}function Zu(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function cW(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function uW(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function a3(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 dW(e,t,i){return nA(e,t)&&nA(t,i)&&m1(e.position,t.position,i.position)}function m1(e,t,i){return Kc.copy(t).sub(e).cross(Mg.copy(i).sub(e))===0}function pW(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 fW(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function mW(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,u=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),c;return a3(t,e,i)>Math.PI&&(u*=-1),Zu(h,o)?c=(o+h)*(r/u-.5)*8/3/(n-l):c=(n+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*n),a.set(i.x+c*h,i.y-c*l),[s,a]}function aA(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function nA(e,t){return m1(e.position,e.controls[1].position,t.position)&&m1(e.position,t.controls[0].position,t.position)}function gW(e,t,i,r,s=.5){let a=Kc.subVectors(t,e).multiplyScalar(s).add(e),n=Mg.subVectors(i,t).multiplyScalar(s).add(t),o=aW.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=nW.subVectors(n,a).multiplyScalar(s).add(a),u=oW.subVectors(o,n).multiplyScalar(s).add(n),c=o,d=lW.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,u.x,u.y,c.x,c.y,r.x,r.y]}function vW(e,t,i=12,r=!0){let s=s3.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=$x(t[l]),u=Kc,c=Ul(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof Ia||h instanceof Zo||h instanceof za){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),a!==void 0&&uW(a,s))continue;a===void 0&&(a=r3),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 yW(e,t,i,r=12,s=!0){let a=s3.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=$x(t[l]),c=Kc,d=Ul(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof Ia||u instanceof Zo||u instanceof za){if(u.getPoint(p/d,c),a.set(c.x,c.y,0),h?.equals(a))continue;h===void 0?h=r3:(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 oA(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=Ul(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=Ul(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Ul(e[0].roundedCurveCorner,t)*.5),r}function Ul(e,t=12){return e&&e instanceof hg?t*2:e&&(e instanceof za||e instanceof aC)?1:e&&e instanceof px?t*e.points.length:t}function xW(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=$x(t[n]),l=Ul(o,i),h=Kc;for(let u=0;u<=l;u++)if(o instanceof Ia||o instanceof Zo||o instanceof za){if(o.getPoint(u/l,h),s!==void 0&&cW(s,h,Ru))continue;s===void 0&&(s=Mg),s.copy(h),e.push(h.x,h.y),a++}}return Zu(e[0],e[e.length-2],Ru)&&Zu(e[1],e[e.length-1],Ru)&&(e.pop(),e.pop()),r&&a>1&&!(Zu(e[a-1],e[1],Ru)&&Zu(e[a-2],e[0],Ru))&&(e.push(e[0],e[1]),a++),e}var Jv=new $,bW=new $,wW=new $,_W=new $,SW=new $,AW=new $,Hi=class extends um{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=st.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Hi;return r.isClosed=e.isClosed,r.points=e.points.map(s=>pc.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Hi.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=Jv.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=st.generateUUID()){let r;e instanceof $?r=e:r=new $(e,t);let s=new pc(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 vW(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=oA(this.points,e,!1),this.roundedCurveDivisions=oA(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return yW(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),xW(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=Ul(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(aA(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Jv.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){aA(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&&dW(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let c=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=u.getLength(),m=Math.min(o,p*.499),v=Math.min(o,f*.499),y=Math.min(m,v),x=1-y/p,b=y/f,_=h.getPointAt(x,Jv),S=u.getPointAt(b,bW);this._subSplitCurve(h,c,x,_,void 0),this._subSplitCurve(u,d,b,void 0,S);let M;if(this.useCubicForRoundedCorners){let C=a3(_,s.position,S)/2,A=Math.tan(C)*_.distanceTo(s.position),[T,P]=pW(_,S,A,wW,_W),R=fW(T,P,s.position),[z,N]=mW(R,_,S,A,SW,AW);M=new Ia(_.clone(),z.clone(),N.clone(),S.clone())}else M=new Zo(_.clone(),s.position.clone(),S.clone());s.roundedCurveCorner=M,this.roundedCurves.splice(i+t,0,M),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof za)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=gW(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 Hi(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],u=e.points[r+6],c=new pc(st.generateUUID(),new $(s,a));c.controls[0].position.set(n,o),c.controls[1].position.set(l,h),c.roundness=u,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Hi;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 Ia&&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 Zo&&(s[n]=hW(s[n]));for(n=0,o=s.length;n<o;n++){let u=s[n],c=n>0?s[n-1]:null,d;u instanceof Ia?(d=this.createPoint(u.v0),d.controls[1].position.copy(u.v1)):u instanceof za&&(d=this.createPoint(u.v1)),d!==void 0&&(c!==null&&i(d,c),a.push(d))}let l=s[s.length-1],h=!1;return l instanceof Ia?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof za&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof um&&(this.shapeHoles=e.holes.map(s=>{let a=new Hi;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)}},g1=Math.PI*2;function $v({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function MW(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 lA(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 EW(e,t,i,r,s,a,n,o,l,h){let u=Math.pow(s,2),c=Math.pow(a,2),d=Math.pow(n,2),p=Math.pow(o,2),f=u*c-u*p-c*d;f<0&&(f=0),f/=u*p+c*d,f=Math.sqrt(f)*(l===h?-1:1);let m=f*s/a*o,v=f*-a/s*n,y=m+(e+i)/2,x=v+(t+r)/2,b=(n-m)/s,_=(o-v)/a,S=(-n-m)/s,M=(-o-v)/a,C=lA(1,0,b,_),A=lA(b,_,S,M);return!h&&A>0&&(A-=g1),h&&A<0&&(A+=g1),{centerx:y,centery:x,ang1:C,ang2:A}}function CW({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,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),a=Math.abs(a);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(a,2);c>1&&(s*=Math.sqrt(c),a*=Math.sqrt(c));let d=EW(e,t,i,r,s,a,h,u,n,o),{ang1:p,ang2:f}=d,{centerx:m,centery:v}=d,y=Math.abs(f)/(g1/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(MW(p,f)),p+=f;return l.map(b=>{let{x:_,y:S}=$v(b[0],s,a,m,v),{x:M,y:C}=$v(b[1],s,a,m,v),{x:A,y:T}=$v(b[2],s,a,m,v);return{x1:_,y1:S,x2:M,y2:C,x:A,y:T}})}var gi;(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"})(gi||(gi={}));var or;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(or||(or={}));function _t(e,t){if(!e)throw t||"Assertion Failed!"}var ft=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){_t(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){_t(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){_t(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){_t(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}(),Bu=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}(),pf=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}(),Zh=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}(),hA=function(){function e(){var t=new Zh,i=new Bu,r=new pf(0),s=new pf(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 pf(0),r=new pf(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;_t(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;_t(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 Zh,i=new Zh,r=new Bu,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 Zh;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Bu;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 Bu;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 Zh;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 Bu;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&&ft.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&ft.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){_t(s.prev===a),l=s.anEdge;do _t(l.Sym!==l),_t(l.Sym.Sym===l),_t(l.Lnext.Onext.Sym===l),_t(l.Onext.Sym.Lnext===l),_t(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(_t(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){_t(n.prev===o),l=n.anEdge;do _t(l.Sym!==l),_t(l.Sym.Sym===l),_t(l.Lnext.Onext.Sym===l),_t(l.Onext.Sym.Lnext===l),_t(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(_t(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)_t(l.Sym.next===h.Sym),_t(l.Sym!==l),_t(l.Sym.Sym===l),_t(l.Org!==null),_t(l.Dst!==null),_t(l.Lnext.Onext.Sym===l),_t(l.Onext.Sym.Lnext===l);_t(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}(),cA=function(){function e(){this.handle=null}return e}(),uA=function(){function e(){this.key=null,this.node=0}return e}(),TW=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 cA,this.handles[r]=new uA;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,_t(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 cA;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new uA}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;_t(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}(),e0=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}(),dA=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),PW=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new dA,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 dA;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}(),DW=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?ft.vertLeq(a.Org,n.Org)?ft.edgeSign(n.Dst,a.Org,n.Org)<=0:ft.edgeSign(a.Dst,n.Org,a.Org)>=0:ft.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return ft.edgeSign(a.Dst,s,a.Org)>=0;var o=ft.edgeEval(a.Dst,s,a.Org),l=ft.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&_t(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){_t(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 e0;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 gi.ODD:return(i&1)!==0;case gi.NONZERO:return i!==0;case gi.POSITIVE:return i>0;case gi.NEGATIVE:return i<0;case gi.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,u,c=!0;h=r;do _t(ft.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,u=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),c=!1,l=o,u=h;l.dirty=!0,_t(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=ft.vertL1dist(i,t),a=ft.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(ft.vertLeq(s.Org,a.Org)){if(ft.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;ft.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(ft.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(_t(!ft.vertEq(s.Dst,a.Dst)),ft.vertLeq(s.Dst,a.Dst)){if(ft.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(ft.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,u,c,d=new Zh,p,f;if(_t(!ft.vertEq(h,l)),_t(ft.edgeSign(l,t.event,n)<=0),_t(ft.edgeSign(h,t.event,o)>=0),_t(n!==t.event&&o!==t.event),_t(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(u=Math.min(n.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(ft.vertLeq(n,o)){if(ft.edgeSign(h,n,o)>0)return!1}else if(ft.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),ft.intersect(l,n,h,o,d),_t(Math.min(n.t,l.t)<=d.t),_t(d.t<=Math.max(o.t,h.t)),_t(Math.min(h.s,l.s)<=d.s),_t(d.s<=Math.max(o.s,n.s)),ft.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=ft.vertLeq(n,o)?n:o,ft.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),ft.vertEq(d,n)||ft.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!ft.vertEq(l,t.event)&&ft.edgeSign(l,t.event,d)>=0||!ft.vertEq(h,t.event)&&ft.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):(ft.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),ft.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),ft.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),ft.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}ft.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,ft.vertEq(s.Org,r)){_t(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!ft.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}_t(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(_t(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),ft.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 e0;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,ft.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=ft.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 u=t.mesh.connect(o.Dnext,i.anEdge);l=u.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);_t(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 e0,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 PW(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||(_t(i.fixUpperEdge),_t(++r===1)),_t(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,ft.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 TW(a,ft.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,_t(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||!ft.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}(),OW=function(){function e(){this.mesh=new hA,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=gi.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],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var v=0;v<3;++v)a=i.coords[v],h[v]=a,f[v]=i,l[v]=a,p[v]=i;for(i=m.next;i!==m;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],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],i=m.next;i!==m;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],d[0]=u[1]*c[2]-u[2]*c[1],d[1]=u[2]*c[0]-u[0]*c[2],d[2]=u[0]*c[1]-u[1]*c[0],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_(u)]=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(;ft.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ft.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(ft.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(ft.edgeGoesLeft(s.Lnext)||ft.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&&(ft.edgeGoesRight(r.Lprev)||ft.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 u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){a=u.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=n,++n}this.elementCount=n,i===or.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 c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(u.inside){a=u.anEdge,l=0;do{var h=a.Org;this.elements[d++]=h.n,l++,a=a.Lnext}while(a!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===or.CONNECTED_POLYGONS){a=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==u.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,u=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[u++]=a,this.elements[u++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new hA),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=gi.ODD),i===void 0&&(i=or.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_(),DW.computeInterior(this,n);var o=this.mesh;return i===or.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===or.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Go(e){var t=e.windingRule,i=t===void 0?gi.ODD:t,r=e.elementType,s=r===void 0?or.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,c=e.contours,d=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,m=e.debug,v=m===void 0?!1:m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var y=new OW;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,u,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:v?y.mesh:void 0}}}var Xee=gi.ODD,Yee=gi.NONZERO,Qee=gi.POSITIVE,Zee=gi.NEGATIVE,Kee=gi.ABS_GEQ_TWO,Jee=or.POLYGONS,$ee=or.CONNECTED_POLYGONS,ete=or.BOUNDARY_CONTOURS,v1=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*v1.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*v1.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)}},n3=v1;n3.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var IW=Br(NO()),eb={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},o3={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},l3={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},t0=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),tb=class extends ut{constructor(e,t,i=0,r=12,s=3,a=gi.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 N=P[z-1],B=P[z-0];R.push(N,B)}return R}),h=[],u=[];for(let T=0;T<o.length;T+=2)u.push([o[T],o[T+1]]);h.push(u);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 c;e.isText?c=new AC().setFromPoints(e.points.map(T=>T.position)).getSize(new $).length()*.1:h[0].length===0?c=i:c=(0,IW.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let d;try{d=Go({windingRule:a,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=eb}let p;try{p=Go({windingRule:gi.ODD,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=o3}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 m=1/0,v=-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],N=d.vertices[R+1];z<m&&(m=z),z>v&&(v=z),N<y&&(y=N),N>x&&(x=N)}this._minX=m,this._minY=y,this._width=v-m,this._height=x-y,this._buffer=new n3(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],N=d.elements[R+1],B=z+N,V={start:z,count:N,normals:[],continuous:[],concave:[]},H=z,X=B-1,G=z+1,se=this._shape.roundedCurves.length;do{let te=H-z,oe=d.vertices[X*2+0],ie=d.vertices[X*2+1],be=d.vertices[H*2+0],ue=d.vertices[H*2+1],ye=d.vertices[G*2+0],de=d.vertices[G*2+1],Be=be-oe,Ce=ue-ie,_e=Math.sqrt(Be*Be+Ce*Ce);Be/=_e,Ce/=_e;let Ze=be-ye,Qe=ue-de,Je=Math.sqrt(Ze*Ze+Qe*Qe);Ze/=Je,Qe/=Je,V.normals[te*2+0]=-Qe,V.normals[te*2+1]=Ze,V.concave[te]=Be*Qe-Ce*Ze>0;let $e=d.vertexIndices[H];if(Array.isArray($e))V.continuous[te]=!1;else{let[He,je]=this._shape.getCurveIndexFromVertexId($e-1,!0);if(je>0&&je<1)V.continuous[te]=!0;else{let ot=je===1?He+1:He-1;ot=(ot+se)%se;let gt=je===1?0:1,Q=this._shape.roundedCurves[He].getTangent(je),j=this._shape.roundedCurves[ot].getTangent(gt);V.continuous[te]=Q.dot(j)>.95}}P&&(V.normals[te*2+0]*=-1,V.normals[te*2+1]*=-1),[X,H,G]=[H,G,G+1],G>=B&&(G-=N)}while(G!==z+1);let ae=[];ae.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(z*2,B*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((te,oe)=>[oe,oe]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(z*2,B*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let oe=te/this._bevelSegments*Math.PI/2,ie=(1-Math.cos(oe))*this._bevel,be=[],ue=[],ye=[],de=[],Be=0;for(let _e=0;_e<N;_e++){let Ze=_e*2,Qe=(_e-1+N)%N*2,Je=d.vertices[V.start*2+Ze+0],$e=d.vertices[V.start*2+Ze+1],He=-V.normals[Qe+0]*ie,je=-V.normals[Qe+1]*ie,ot=-V.normals[Ze+0]*ie,gt=-V.normals[Ze+1]*ie;if(V.concave[_e]||!V.concave[_e]&&P){let Q=Math.atan2(je,He),j=Math.atan2(gt,ot);j>Q&&(j-=Math.PI*2);let ge=j-Q;if(V.continuous[_e]||P){let Ne=Q+ge/2,Te=Math.cos(Ne)*ie,Ge=Math.sin(Ne)*ie;be[2*Be+0]=Je+Te*(P?-1:1),be[2*Be+1]=$e+Ge*(P?-1:1),de[Be]=_e,Be++}else{let Ne=Math.max(1,Math.floor(r/4*Math.abs(ge)/Math.PI));for(let Te=0;Te<=Ne;Te++){let Ge=Q+ge*(Te/Ne),lt=Math.cos(Ge)*ie,Ve=Math.sin(Ge)*ie;be[2*Be+0]=Je+lt,be[2*Be+1]=$e+Ve,de[Be]=_e,Be++}}}else be[2*Be+0]=Je+He,be[2*Be+1]=$e+je,de[Be]=_e,ue[_e]=Be,Be++,be[2*Be+0]=Je,be[2*Be+1]=$e,de[Be]=_e,Be++,be[2*Be+0]=Je+ot,be[2*Be+1]=$e+gt,de[Be]=_e,ye[_e]=Be,Be++}let Ce=Go({windingRule:gi.POSITIVE,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[be],edgeCreateCallback:_e=>{let Ze=_e.Org.idx,Qe=de[Ze],Je=de[(Ze+1)%de.length];_e.idx=[Qe,Je],_e.Sym.idx=[Je,Qe]},vertexIdCallback:_e=>{let Ze=_e.Lprev.idx;return[Ze?Ze[1]:0,_e.idx?_e.idx[0]:0]}});if(!Ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!Ce.vertexCount){let _e=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(_e))*this._bevel;break}for(let _e=0;_e<Ce.vertexIndices.length;_e++){let[Ze,Qe]=Ce.vertexIndices[_e];if(Ze===Qe)continue;let Je=Qe;Qe<Ze&&(Je+=N);for(let $e=Ze;$e<Je;$e++){let He=$e%N,je=($e+1)%N;if(!V.continuous[He]||!V.continuous[je]){Ce.vertexIndices[_e]=[Ze,He],Ce.vertexIndices.splice(_e+1,0,[je,Qe]),Ce.vertices.splice((_e+1)*2,0,Ce.vertices[_e*2],Ce.vertices[_e*2+1]);break}}}ae.push({bevelI:te,angle:oe,size:ie,boundary:Ce,reverseMap:de,insetPoints:be})}let K=(te,oe,ie)=>{let be=0,ue=te.boundary.vertexIndices.length;for(;be<ue&&ie(te.boundary.vertexIndices[oe]);)oe=(oe+1)%ue,be++;return be},ne=b.length;for(let te=1;te<ae.length;te++){let oe=ae[te-1],ie=ae[te],be=oe.boundary.vertexIndices.length,ue=ie.boundary.vertexIndices.length;if(!be||!ue)break;let ye=V.concave.length,de=0,Be=t0(de,N);for(;!oe.boundary.vertexIndices.filter(Be).length||!ie.boundary.vertexIndices.filter(Be).length;)de++,Be=t0(de,N);let Ce=oe.boundary.vertexIndices.findIndex(Be),_e=ie.boundary.vertexIndices.findIndex(Be);do Ce=(Ce+1)%be;while(Be(oe.boundary.vertexIndices[Ce]));do _e=(_e+1)%ue;while(Be(ie.boundary.vertexIndices[_e]));de=(de+1)%N;let Ze=de,Qe=0,Je=this._buildBevelVert(V,oe,(Ce-1+be)%be,void 0,Qe),$e=this._buildBevelVert(V,ie,(_e-1+ue)%ue,void 0,Qe),He=Je,je=$e,ot,gt,Q=!1;do{Qe=(de||ye)/ye,Be=t0(de,N);let j=K(oe,Ce,Be),ge=K(ie,_e,Be),Ne=Q;if(Q=!1,j&&!ge){for(let Te=0;Te<j;Te++)ot=this._buildBevelVert(V,oe,(Ce+Te)%be,Te/(j-1),Qe),b.push(He.topN,ot.topP,je.topN),n===!1&&b.push(ot.bottomP,He.bottomN,je.bottomN),He=ot;Q=!0}else if(!j&&ge)for(let Te=0;Te<ge;Te++)gt=this._buildBevelVert(V,ie,(_e+Te)%ue,Te/(ge-1),Qe),b.push(je.topN,He.topP,gt.topP),n===!1&&b.push(He.bottomP,je.bottomN,gt.bottomP),je=gt;else if(j&&ge)if(ot=this._buildBevelVert(V,oe,Ce,0,Qe),gt=this._buildBevelVert(V,ie,_e,0,Qe),Ne?(b.push(He.topN,gt.topP,je.topN),b.push(He.topN,ot.topP,gt.topP),n===!1&&(b.push(gt.bottomP,He.bottomN,je.bottomN),b.push(gt.bottomP,ot.bottomP,He.bottomN))):(b.push(je.topN,He.topN,ot.topP),b.push(je.topN,ot.topP,gt.topP),n===!1&&(b.push(ot.bottomP,He.bottomN,je.bottomN),b.push(ot.bottomP,je.bottomN,gt.bottomP))),He=ot,je=gt,j===ge)for(let Te=1;Te<j;Te++)ot=this._buildBevelVert(V,oe,(Ce+Te)%be,Te/(j-1),Qe),gt=this._buildBevelVert(V,ie,(_e+Te)%ue,Te/(ge-1),Qe),b.push(He.topN,ot.topP,je.topN),b.push(je.topN,ot.topP,gt.topP),n===!1&&(b.push(ot.bottomP,He.bottomN,je.bottomN),b.push(ot.bottomP,je.bottomN,gt.bottomP)),He=ot,je=gt;else if(j>ge){let Te=j/ge,Ge=0;for(let lt=1;lt<j;lt++)ot=this._buildBevelVert(V,oe,(Ce+lt)%be,lt/(j-1),Qe),b.push(He.topN,ot.topP,je.topN),n===!1&&b.push(ot.bottomP,He.bottomN,je.bottomN),He=ot,lt>(Ge+1)*Te&&(Ge++,gt=this._buildBevelVert(V,ie,(_e+Ge)%ue,Ge/(ge-1),Qe),b.push(je.topN,ot.topP,gt.topP),n===!1&&b.push(ot.bottomP,je.bottomN,gt.bottomP),je=gt)}else{let Te=ge/j,Ge=0;for(let lt=1;lt<ge;lt++)gt=this._buildBevelVert(V,ie,(_e+lt)%ue,lt/(ge-1),Qe),b.push(je.topN,ot.topP,gt.topP),n===!1&&b.push(ot.bottomP,je.bottomN,gt.bottomP),je=gt,lt>(Ge+1)*Te&&(Ge++,ot=this._buildBevelVert(V,oe,(Ce+Ge)%be,Ge/(j-1),Qe),b.push(He.topN,ot.topP,je.topN),n===!1&&b.push(ot.bottomP,He.bottomN,je.bottomN),He=ot)}Ce=(Ce+j)%be,_e=(_e+ge)%ue,de=(de+1)%ye}while(de!==Ze)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(ae,V,b),P){let te=[];for(let oe=b.length-1;oe>=ne+2;oe-=3){let ie=b[oe-2],be=b[oe-1],ue=b[oe-0];te.push(ue,be,ie)}b.splice(ne,b.length-ne,...te)}if(P){let te=[];for(let oe=ae[ae.length-1].boundary.vertices.length-1;oe>=1;oe-=2){let ie=ae[ae.length-1].boundary.vertices[oe-1],be=ae[ae.length-1].boundary.vertices[oe-0];te.push(ie,be)}_.push(te)}if(!P){let te=ae[ae.length-1],oe;try{oe=Go({windingRule:ae.length>1?gi.POSITIVE:gi.ODD,elementType:or.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,..._]})}catch{oe=l3}if(!oe)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ie=0;ie<oe.elementCount*3;ie+=3){let be=this._buildSurfaceVert(oe,oe.elements[ie+0],J),ue=this._buildSurfaceVert(oe,oe.elements[ie+1],J),ye=this._buildSurfaceVert(oe,oe.elements[ie+2],J);b.push(be.top,ue.top,ye.top),n===!1&&b.push(ye.bottom,ue.bottom,be.bottom)}}this.vertexCache={}}this._buffer.shrink();let S=new At(Uint32Array.from(b),1),M=new At(this._buffer.positions,3),C=new At(this._buffer.normals,3),A=new At(this._buffer.uvs,2);M.needsUpdate=!0,C.needsUpdate=!0,A.needsUpdate=!0,S.needsUpdate=!0,this.setAttribute("position",M),this.setAttribute("normal",C),this.setAttribute("uv",A),this.setIndex(S)}_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,u=l*2,c={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[u+0]=n,this._buffer.uvs[u+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[u+2]=n,this._buffer.uvs[u+3]=o),this.vertexCache[r]=c,c}_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,u,c;n!==o?(h=n,l=o,c=!1,u=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,u=e.continuous[l]||c);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,v=h*2,y=t.boundary.vertices[f+0],x=t.boundary.vertices[f+1],b=(1-p)*this._bevel,_=(y-this._minX)/this._width,S=(x-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(_=s),S=1);let M=e.normals[m+0],C=e.normals[m+1],A=e.normals[v+0],T=e.normals[v+1];if(c){let B=A-M,V=T-C;M=M+B*(1-r),C=C+V*(1-r);let H=Math.sqrt(M*M+C*C);M/=H,C/=H}let P=this.forPathBevel?this._buffer.get(u?1:2):this._buffer.get(u?2:4),R=P*3,z=P*2,N={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]=M*d,this._buffer.normals[R+1]=C*d,this._buffer.normals[R+2]=p,this._buffer.uvs[z+0]=_,this._buffer.uvs[z+1]=S,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]=M*d,this._buffer.normals[R+4]=C*d,this._buffer.normals[R+5]=-p,this._buffer.uvs[z+2]=S,this._buffer.uvs[z+3]=_),u||(this.forPathBevel?(P+=1,R+=3,z+=2):(P+=2,R+=6,z+=4),N.topP=P+0,N.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]=S,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]=S,this._buffer.uvs[z+3]=_)),this.vertexCache[a]=N,N}clone(){let e=new tb(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yg(this.userData),e}},h3=class extends ut{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=gi.ODD,this.elementType=or.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:gi.ODD,elementType:or.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,m=r[f+0],v=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&v!==h&&(o=!1),l=m,h=v,!n&&!o)break}if(!n&&!o)try{a=Go({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=eb}let u=a?.vertexCount??1,c=a?.elementCount??1;if(this._positionAttribute=new At(new Float32Array(u*3),3),this._normalAttribute=new At(new Float32Array(u*3),3),this._uvAttribute=new At(new Float32Array(u*2),2),this._indexAttribute=new At(new Uint32Array(c*3),1),a){let d=1/0,p=-1/0,f=1/0,m=-1/0;for(let x=0,b=u;x<b;x++){let _=x*2,S=a.vertices[_+0],M=a.vertices[_+1];S<d&&(d=S),S>p&&(p=S),M<f&&(f=M),M>m&&(m=M)}let v=p-d,y=m-f;for(let x=0,b=u;x<b;x++){let _=x*2,S=a.vertices[_+0],M=a.vertices[_+1],C=(S-d)/v,A=(M-f)/y;this._positionAttribute.setXYZ(x,S,M,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,C,A)}for(let x=0,b=c;x<b;x++){let _=x*3,S=a.elements[_+0],M=a.elements[_+1],C=a.elements[_+2];this._indexAttribute.setX(_+0,S),this._indexAttribute.setX(_+1,M),this._indexAttribute.setX(_+2,C)}}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 h3(this._shape,this._curveSegments);return e.userData=yg(this.userData),e}},c3=class extends tb{constructor(e,t,i=0,r=12,s=3,a=gi.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 c3(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yg(this.userData),e}},ih=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:gi.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 Hi?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new Hi(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new Hi(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 h3(e.shape,s,{windingRule:n}):o=new c3(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},u3=Math.PI*2,ib=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=st.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof Hi?e.shape:new Hi,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,u=t*.5,c=i*.5,d=RW(h,u,c,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new ut,p.setAttribute("position",new et([],3))):p=ih.create({shape:h,parameters:{subdivisions:d,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function RW(e,t,i,r,s,a){if(r>=u3)return s>30||s%4===0?(LW(e,t,i,a),Math.round(s/4)):pA(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=CW({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?BW(e,n.x,n.y,h,s,t,i,a):pA(e,r,s,t,i,a)}function BW(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(fc(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=fc(c.x,c.y);d.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?d3(e,a,n,o):e.addPoint(fc(0,0)),l}function pA(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,u=Math.cos(l)*s;e.addPoint(fc(h,u))}return t<u3?a>0?d3(e,r,s,a):e.addPoint(fc(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&p3(e,r,s,a)),1}function LW(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(ff(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(ff(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(ff(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(ff(s,a-i,s+o,a-i,s-o,a-i)),r>0&&p3(e,t,i,r)}function fc(e,t){return new pc(st.generateUUID(),new $(e,t))}function ff(e,t,i,r,s,a){let n=fc(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function d3(e,t,i,r){f3(e,t,i,r).forEach(s=>e.addPoint(s))}function p3(e,t,i,r){let s=f3(e,t,i,r),a=new Hi;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function f3(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new $(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=st.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),u=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var zW=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:u,cornerSegments:c}=e.parameters,d=new m3(!1,t,i,r,s,a,n,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},i0=new nc([0,0,0],1),m3=class extends ut{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,u=1,c=1){if(super(),a===0)return;let d=e&&a===1;d&&(c=0),u>100&&(u=100),u===0&&(c=0);let p=()=>new I,f=new I,m=p(),v=p(),y=p(),x,b,_,S,M,C,A,T,P=p(),R=p(),z=p(),N=p(),B=p(),V=p(),H=p(),X=p(),G=i-2*o+.001,se=G/a,ae=Math.ceil(n*a),J=ae+1,K=G/ae,ne=-G/2,te=h+1,oe=2*Math.PI/h,ie=Math.PI/2/c,be=.01,ue=Math.min((1-u/100)*o,o-be),ye=o-ue,de=0,Be=2,Ce=c*Be+Be,_e=te*Ce/Be,Ze=_e+te*J,Qe=Math.max(0,te*(J+Ce)),[Je,$e,He]=[3,3,2].map(Fe=>Array(Qe*Fe).fill(0)),je=[],ot=s-o;function gt(Fe,ht){let Ke=Math.PI/2;C=ht*K,T=2*Math.PI*(C%se)/se+Ke,C+=ne,A=Math.sin(T)*ot,M=Math.cos(T)*ot,e?Fe.set(M,A,C):Fe.set(M,C,A)}gt(f,-1e-10),gt(m,0),P.copy(f),gt(f,1);let Q=f.distanceTo(m),j=d?0:ye+ue,ge=Q*ae+2*j,Ne=ue,Te=ge-j;for(let Fe=0;Fe<=ae;Fe++){gt(v,Fe),X.subVectors(v,P).normalize(),P.copy(v),V.copy(v).setComponent(+e+1,0).normalize(),H.crossVectors(X,V).normalize();let ht=Fe===0,Ke=Fe===ae,vt=ht?3*Math.PI/2:ie,dt=ht?Ne:Te,Wt=ht?te:Ze,ui=ht?0:Qe-te,Di=X.clone().multiplyScalar(ht?-ye:ye).add(v),ce=X.clone().multiplyScalar(ht?-1:1).normalize();for(let we=0;we<te;we++){let Ue=we*oe;if(R.addVectors(f.copy(V).multiplyScalar(o*Math.cos(Ue)),m.copy(H).multiplyScalar(o*Math.sin(Ue))),z.copy(R).normalize(),ht||Ke){d||(de=ui+we,[0,1,2].forEach(We=>{Je[de*3+We]=Di.getComponent(We),$e[de*3+We]=ce.getComponent(We)}),He[de*2]=+Ke,He[de*2+1]=we/h),m.copy(z).multiplyScalar(ue),y.addVectors(v,m);for(let We=0;We<c;We++){let pt=We*ie+vt;N.addVectors(f.copy(X).multiplyScalar(ye*Math.sin(pt)),m.copy(z).multiplyScalar(ye*Math.cos(pt))),B.copy(N).normalize(),m.addVectors(y,N),N.normalize(),de=Wt+We*te+we,[0,1,2].forEach(xi=>{Je[de*3+xi]=m.getComponent(xi),$e[de*3+xi]=B.getComponent(xi)});let $t=+ht+Math.sin(pt);He[de*2]=(dt+ye*$t)/ge,He[de*2+1]=we/h}}m.addVectors(v,R),de=_e+Fe*te+we,[0,1,2].forEach(We=>{Je[de*3+We]=m.getComponent(We),$e[de*3+We]=z.getComponent(We)}),He[de*2]=(j+Fe*Q)/ge,He[de*2+1]=we/h}}let Ge=J+2*c+Be,lt=1,[Ve,De]=[+d,Ge-1];for(let Fe=Ve;Fe<=De-1;Fe++){let ht=d&&Fe===De-1;for(let Ke=0;Ke<te-1;Ke++)x=Fe*te+Ke,b=x+1,_=(ht?Ke:x)+te,S=(ht?Ke+1:b)+te,Fe===0?je.push(b,S,_):Fe===Ge-2?je.push(x,b,_):je.push(x,b,_,b,S,_)}this.setIndex(je),this.setAttribute("position",new et(Je,3)),this.setAttribute("normal",new et($e,3)),this.setAttribute("uv",new et(He,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,u=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,a=s+1,n=(u?c:s)+i,o=(u?c+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,i0.array=r,i0.count=r.length,i0}},kW=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 g3(t*.5,a,n):new pC(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},g3=class extends Kx{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 g3(e.radius,e.corner,e.cornerSides)}},NW=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 um;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 oC(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},Za=new Le,r0=new ci,mf=new I,Qm=class extends Qr{constructor(){super(),this.uuid=st.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 Ki().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 Za.makeRotationX(e),this.applyMatrix4(Za),this}rotateY(e){return Za.makeRotationY(e),this.applyMatrix4(Za),this}rotateZ(e){return Za.makeRotationZ(e),this.applyMatrix4(Za),this}translate(e,t,i){return Za.makeTranslation(e,t,i),this.applyMatrix4(Za),this}scale(e,t,i){return Za.makeScale(e,t,i),this.applyMatrix4(Za),this}lookAt(e){return r0.lookAt(e),r0.updateMatrix(),this.applyMatrix4(r0.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 c=0;c<s.count;c++)t.vertices.push(new I().fromBufferAttribute(s,c)),n!==void 0&&t.colors.push(new yt().fromBufferAttribute(n,c));function h(c,d,p,f){let m=n===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],v=a===void 0?[]:[new I().fromBufferAttribute(a,c),new I().fromBufferAttribute(a,d),new I().fromBufferAttribute(a,p)],y=new y1(c,d,p,v,m,f);t.faces.push(y),o!==void 0&&t.faceVertexUvs[0].push([new $().fromBufferAttribute(o,c),new $().fromBufferAttribute(o,d),new $().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new $().fromBufferAttribute(l,c),new $().fromBufferAttribute(l,d),new $().fromBufferAttribute(l,p)])}let u=e.groups;if(u.length>0)for(let c=0;c<u.length;c++){let d=u[c],p=d.start,f=d.count;for(let m=p,v=p+f;m<v;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),d.materialIndex):h(m,m+1,m+2,d.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mf).negate(),this.translate(mf.x,mf.y,mf.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new Le;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 Qm;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 er),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zs),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,u=e.colors;t!==void 0&&(r=new Ki().getNormalMatrix(t));for(let c=0,d=n.length;c<d;c++){let p=n[c].clone();t!==void 0&&p.applyMatrix4(t),a.push(p)}for(let c=0,d=u.length;c<d;c++)h.push(u[c].clone());for(let c=0,d=l.length;c<d;c++){let p=l[c],f,m,v=p.vertexNormals,y=p.vertexColors,x=new y1(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,_=v.length;b<_;b++)f=v[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++)m=y[b],x.vertexColors.push(m.clone());x.materialIndex=p.materialIndex+i,o.push(x)}for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let v=p[f],y=[];for(let x=0,b=v.length;x<b;x++)y.push(v[x].clone());this.faceVertexUvs[c].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],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[u]]}let 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 u=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(u[c]===u[(c+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,u=this.faceVertexUvs.length;h<u;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],m=!0,v=!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,S=f.vertexColors.length>0,M=0;if(M=h(M,0,0),M=h(M,1,m),M=h(M,2,v),M=h(M,3,y),M=h(M,4,x),M=h(M,5,b),M=h(M,6,_),M=h(M,7,S),i.push(M),i.push(f.a,f.b,f.c),i.push(f.materialIndex),y){let C=this.faceVertexUvs[0][p];i.push(d(C[0]),d(C[1]),d(C[2]))}if(x&&i.push(u(f.normal)),b){let C=f.vertexNormals;i.push(u(C[0]),u(C[1]),u(C[2]))}if(_&&i.push(c(f.color)),S){let C=f.vertexColors;i.push(c(C[0]),c(C[1]),c(C[2]))}}function h(p,f,m){return m?p|1<<f:p&~(1<<f)}function u(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return 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 Qm().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,d=t.length;c<d;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,d=i.length;c<d;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,d=r.length;c<d;c++)this.faces.push(r[c].clone());for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let v=p[f],y=[];for(let x=0,b=v.length;x<b;x++){let _=v[x];y.push(_.clone())}this.faceVertexUvs[c].push(y)}}let s=e.morphTargets;for(let c=0,d=s.length;c<d;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let c=0,d=a.length;c<d;c++){let p={};if(a[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=a[c].vertexNormals.length;f<m;f++){let v=a[c].vertexNormals[f],y={};y.a=v.a.clone(),y.b=v.b.clone(),y.c=v.c.clone(),p.vertexNormals.push(y)}}if(a[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=a[c].faceNormals.length;f<m;f++)p.faceNormals.push(a[c].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let c=0,d=n.length;c<d;c++)this.skinWeights.push(n[c].clone());let o=e.skinIndices;for(let c=0,d=o.length;c<d;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,d=l.length;c<d;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new FW().fromGeometry(this),t=new ut,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",gf.call(new At(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",gf.call(new At(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",fA.call(new At(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",mA.call(new At(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",mA.call(new At(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 et(l.data.length*3,3);h.name=l.name,s.push(gf.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new et(e.skinIndices.length*4,4);t.setAttribute("skinIndex",gA.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new et(e.skinWeights.length*4,4);t.setAttribute("skinWeight",gA.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 ut,i=e.geometry;if(e.isPoints||e.isLine){let r=new et(i.vertices.length*3,3),s=new et(i.colors.length*3,3);if(t.setAttribute("position",gf.call(r,i.vertices)),t.setAttribute("color",fA.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new et(i.lineDistances.length,1);t.setAttribute("lineDistance",UW.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}};Qm.prototype.isGeometry=!0;var FW=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 v=0;v<o;v++)l[v]={name:n[v].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let v=0;v<u;v++)c[v]={name:h[v].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let v=0;v<t.length;v++){let y=t[v];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][v];_!==void 0?this.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new $,new $,new $))}if(a===!0){let _=r[1][v];_!==void 0?this.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new $,new $,new $))}for(let _=0;_<o;_++){let S=n[_].vertices;l[_].data.push(S[y.a],S[y.b],S[y.c])}for(let _=0;_<u;_++){let S=h[_].vertexNormals[v];c[_].data.push(S.a,S.b,S.c)}f&&this.skinIndices.push(d[y.a],d[y.b],d[y.c]),m&&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}},y1=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 yt,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 UW(e){return this.array.set(e),this}function fA(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 yt),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function mA(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 $),t[i++]=a.x,t[i++]=a.y}return this}function gf(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 gA(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 Et),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var VW=["a","b","c"];function jW(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function s0(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function a0(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 u=i[n],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function GW(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],a0(n.a,n.b,e,r,n,i),a0(n.b,n.c,e,r,n,i),a0(n.c,n.a,e,r,n,i)}function vf(e,t,i,r,s){e.push(new y1(t,i,r,void 0,void 0,s))}function Rh(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function yf(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var HW=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof ut?e=new Qm().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],u=h!==void 0&&h.length>0,c=[],d=new Map;GW(o,l,c,d);let p=[],f,m,v,y,x,b,_;for(let be of Array.from(d.keys())){for(m=d.get(be),v=new I,x=3/8,b=1/8,_=m.faces.length,_!=2&&(x=.5,b=0,_!=1),v.addVectors(m.a,m.b).multiplyScalar(x),t.set(0,0,0),a=0;a<_;a++){for(y=m.faces[a],n=0;n<3&&(f=o[jW(y,VW[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(b),v.add(t),m.newEdge=p.length,p.push(v)}let S,M,C,A,T,P,R,z=[];for(r=0,s=o.length;r<s;r++){for(P=o[r],T=c[r].edges,i=T.length,i==3?S=3/16:i>3&&(S=3/(8*i)),M=1-i*Number(S),C=S,i<=2&&(i==2?(M=3/4,C=1/8):i==1||i==0),R=P.clone().multiplyScalar(M),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(C)),R.add(t),z.push(R)}let N=z.concat(p),B=z.length,V,H,X,G=[],se=[],ae,J,K,ne,te=new $,oe=new $,ie=new $;for(r=0,s=l.length;r<s;r++)y=l[r],V=Number(s0(y.a,y.b,d).newEdge)+B,H=Number(s0(y.b,y.c,d).newEdge)+B,X=Number(s0(y.c,y.a,d).newEdge)+B,vf(G,V,H,X,y.materialIndex),vf(G,y.a,V,X,y.materialIndex),vf(G,y.b,H,V,y.materialIndex),vf(G,y.c,X,H,y.materialIndex),u&&(ae=h[r],J=ae[0],K=ae[1],ne=ae[2],te.set(Rh(J.x,K.x),Rh(J.y,K.y)),oe.set(Rh(K.x,ne.x),Rh(K.y,ne.y)),ie.set(Rh(J.x,ne.x),Rh(J.y,ne.y)),yf(se,te,oe,ie),yf(se,J,te,ie),yf(se,K,oe,te),yf(se,ne,ie,oe));e.vertices=N,e.faces=G,u&&(e.faceVertexUvs[0]=se)}},fr=new I,WW=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new ut().copy(new Fa(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(fr),r={width:fr.x,height:fr.y,depth:fr.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 ut().copy(new Fa(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(fr)):fr.set(n.width,n.height,n.depth),(t!==fr.x||i!==fr.y||r!==fr.z)&&a.scale(fr.x===0?1:t/fr.x,fr.y===0?1:i/fr.y,fr.z===0?1:r/fr.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new HW(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 _C(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(fr);let a=100/fr.x;Object.assign(s.parameters,{width:100,height:fr.y*a,depth:fr.z*a}),t(this.build(s))})}},v3=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 Hi?e.shape:new Hi,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,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let v=p*m,y=c+Math.sin(v)*h,x=d+Math.cos(v)*u;l.addPoint(l.createPoint(y,x))}l.isClosed=!0;for(let m=0,v=l.points.length;m<v;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=ih.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},qW=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 YW(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Lu(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function n0(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 XW(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var YW=class extends ut{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=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,x=new I(0,-d,0),b=new I(0,d,0),_=new $(e,-d),S=new $(f,-d),M=new $(0,b.y).sub(S),C=new $(0,b.y).sub(_),A=new $(M.y,-M.x).normalize(),T=new $(C.y,-C.x).normalize(),P=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-M.angle())/2)-1e-8;a=Math.min(a,P);let R;{let G=new I(A.x,A.y,0),se=new I(Math.cos(m)*G.x,G.y,Math.sin(m)*G.x);R=G.angleTo(se)}let z=a/Math.tan((Math.PI-M.angle())/2),N=a/Math.tan((Math.PI-R)/2),B=new I;if(!s){l.push(x.x,x.y,x.z),h.push(0,-1,0),u.push(0,0);let G=c++,se=[],ae=_.clone(),J=z/Math.cos(Math.PI/i);ae.x-=J;for(let K=0;K<i;K++){let ne=K/i*Math.PI*2+p,te=new $(Math.sin(ne),Math.cos(ne));Lu(ae,te,B),l.push(B.x,B.y,B.z),h.push(0,-1,0),u.push(0,0),se.push(c++)}for(let K=0;K<se.length;K++)o.push(se[K],G,se[(K+1)%se.length])}let V=[];{let G=new I,se=new I,ae=new I,J=new I,K=new I,ne=new I;for(let te=0;te<i;te++){let oe=te/i*Math.PI*2+p,ie=(te+.5)/i*Math.PI*2+p,be=(te+1)/i*Math.PI*2+p,ue=new $(Math.sin(oe),Math.cos(oe)),ye=new $(Math.sin(ie),Math.cos(ie)),de=new $(Math.sin(be),Math.cos(be));Lu(_,ue,se),Lu(_,de,ae),Lu(A,ye,G),n0(b,se,ae,N,N,J),l.push(J.x,J.y,J.z),n0(se,b,ae,N,z,K),l.push(K.x,K.y,K.z),n0(ae,se,b,z,N,ne),l.push(ne.x,ne.y,ne.z),h.push(G.x,G.y,G.z),h.push(G.x,G.y,G.z),h.push(G.x,G.y,G.z),u.push(0,0),u.push(0,0),u.push(0,0);let Be=c++,Ce=c++,_e=c++;if(o.push(Be,Ce,_e),a>0){{let Je=se.clone().add(ae).multiplyScalar(.5),$e=b.clone().sub(Je).normalize(),He=x.clone().sub(Je).normalize().add($e).normalize().multiplyScalar(-1),je=ne.clone().sub(K);H(Je,je,He,M.angle())}let Ze,Qe;{let Je=new I;Lu(T,de,Je);let $e=ne.clone().add(J).multiplyScalar(.5);$e=XW($e,ae,b);let He=ne.clone().sub(J);[Ze,Qe]=H($e,He,Je,R,J.y)}{let Je=Ze,$e=Je.clone().setY(0).normalize(),He=new I(0,-1,0),je=$e.clone().cross(He);X(Je,$e,He,je)}V.concat(Qe);{let Je=M.angle(),$e=Math.PI-Je,He=b.clone();He.y-=a/Math.sin(Je-Math.PI/2);let je=new I,ot=[];for(let Q=0;Q<n;Q++){let j=[],ge=Math.PI/2-$e*Q/n,Ne=Math.cos(ge),Te=Math.sin(ge),Ge=ie;for(let lt=0;lt<=Q;lt++){let Ve=Math.cos(Ge),De=Math.sin(Ge);G.x=Ne*De,G.y=Te,G.z=Ne*Ve,je.copy(He).addScaledVector(G,a),l.push(je.x,je.y,je.z),h.push(G.x,G.y,G.z),u.push(0,0),j.push(c++),Ge+=Math.PI*2/Q/i}ot.push(j)}Qe.reverse(),ot.push(Qe);let gt=ot.length-1;for(let Q=0;Q<gt;Q++){let j=ot[Q],ge=ot[Q+1],Ne=j.length-1;o.push(ge[1],j[0],ge[0]);for(let Te=1;Te<=Ne;Te++)o.push(j[Te],j[Te-1],ge[Te]),o.push(ge[Te+1],j[Te],ge[Te])}}}}}this.setIndex(o),this.setAttribute("position",new et(l,3)),this.setAttribute("normal",new et(h,3)),this.setAttribute("uv",new et(u,2));function H(G,se,ae,J,K){let ne=-J/2,te=(Math.PI-J)/2,oe=se.clone().normalize().cross(ae);G.addScaledVector(ae,-a/Math.sin(te));let ie=new I,be=new I,ue=1,ye=c,de=[];for(let Be=0;Be<=n;Be++){let Ce=ne+Be/n*J;be.set(0,0,0),be.addScaledVector(oe,Math.sin(Ce)),be.addScaledVector(ae,Math.cos(Ce));for(let _e=0;_e<=ue;_e++){let Ze=_e/ue-.5;if(ie.copy(G),ie.addScaledVector(se,Ze),ie.addScaledVector(be,a),K!=null){let Qe=Math.max(0,ie.y-K);ie.addScaledVector(se,-Qe/se.y)}l.push(ie.x,ie.y,ie.z),h.push(be.x,be.y,be.z),u.push(0,0),_e===0&&de.push(c),c++}}for(let Be=0;Be<n;Be++)for(let Ce=0;Ce<ue;Ce++){let _e=ye+Ce+(ue+1)*Be,Ze=_e+(ue+1),Qe=Ze+1,Je=_e+1;o.push(_e,Ze,Je),o.push(Ze,Qe,Je)}return[G.clone().addScaledVector(se,.5),de]}function X(G,se,ae,J){let K=Math.PI/2,ne=C.angle()-K,te=[],oe=new I,ie=new I;for(let ue=0;ue<=n;ue++){let ye=[],de=ue/n;for(let Be=0;Be<=ue;Be++){let Ce=((ue?Be/ue:0)-.5)*y,_e=Math.cos(Ce),Ze=Math.sin(Ce),Qe=Math.atan(Math.tan(ne)*_e),Je=(K+Qe)*de,$e=Math.cos(Je),He=Math.sin(Je);oe.set(0,0,0),oe.addScaledVector(se,He*_e),oe.addScaledVector(ae,$e),oe.addScaledVector(J,He*Ze),ie.copy(G).addScaledVector(oe,a),l.push(ie.x,ie.y,ie.z),h.push(oe.x,oe.y,oe.z),u.push(0,0),ye.push(c++)}te.push(ye)}let be=te.length-1;for(let ue=0;ue<be;ue++){let ye=te[ue],de=te[ue+1],Be=ye.length-1;o.push(ye[0],de[1],de[0]);for(let Ce=1;Ce<=Be;Ce++)o.push(ye[Ce-1],ye[Ce],de[Ce]),o.push(ye[Ce],de[Ce+1],de[Ce])}}}},rb=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 Hi?e.shape:new Hi,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},u={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function d(_,S,M){return S>i&&M>r?Math.min(_*i/S,_*r/M):S>i?_*i/S:M>r?_*r/M:_}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=u.x,m=c.x,v=c.y,y=u.y;t.addPoint(t.createPoint(f,v)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let x=!0;for(let _=0,S=t.points.length;_<S;_++)t.points[_].roundness=p[_],_>0&&p[_]!==p[_-1]&&(x=!1);x&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let b=ih.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},QW=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=st.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,u;return h===0?(u=new ut,u.setAttribute("position",new et([],3))):u=new oc(.5*t,s,a,n,o,l,h*st.DEG2RAD),u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},ZW=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 Jl(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},KW=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 JW(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},JW=class extends ut{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 u=[],c=Math.PI/2,d=(be=0,ue=0,ye=0)=>new I(be,ue,ye),p=d(),f=d(),[m,v,y]=[t/2,e/2,i/2],x=-v,b=+v,[_,S,M]=[d(x,-m,+y),d(x,-m,-y),d(x,+m,-y)],C=(be,ue=!1)=>Math.sin(be-Math.PI/(1+ +ue)),A=(be,ue=!1)=>Math.cos(be-Math.PI/(1+ +ue));M.y=Math.sin(r)*t-m;let T=Math.cos(r)*t-y,P=_.z-h;r<=c?(M.z=Math.min(T,P),M.z==P&&(M.y-=(T-P)/Math.tan(c-r))):S.z=Math.min(S.z-T-y,_.z-h),p.subVectors(_,S),f.subVectors(M,S);let R=Math.min(p.length(),f.length())*s/100,z=R*Math.tan(r/2),N=R/Math.cos(r/2),B=p.clone().normalize().add(f.normalize()).setLength(N).add(S);p.set(0,C(r,!0),A(r,!0)),u.push([M,p.clone()]);let V=(Math.PI-r)/a;for(let be=0;be<=a;be++){let ue=c+r+be*V;p.set(0,Math.sin(ue)*z,Math.cos(ue)*z),p.add(B),f.set(0,C(ue),A(ue)),u.push([p.clone(),f.clone()])}u.push([_,d(0,1,0)]);let H=Math.sin(V/2)*z*2,X=u.length-1,G=u[0][0].distanceTo(u[1][0]),se=u[X-1][0].distanceTo(u[X][0]),ae=G+H*a+se;u[0].push(1);for(let be=0;be<=a;be++)u[be+1].push(1-(G+be*H)/ae);u[X].push(0);let[J,K,ne]=u[0],te,oe,ie;for(let be=1;be<u.length;be++)[te,oe,ie]=u[be],n.push(x,J.y,J.z,x,te.y,te.z,b,J.y,J.z,b,J.y,J.z,x,te.y,te.z,b,te.y,te.z),o.push(0,K.y,K.z,0,oe.y,oe.z,0,K.y,K.z,0,K.y,K.z,0,oe.y,oe.z,0,oe.y,oe.z),l.push(0,ne,0,ie,1,ne,1,ne,0,ie,1,ie),[J,K,ne]=[te,oe,ie];this.setAttribute("position",new et(n,3)),this.setAttribute("normal",new et(o,3)),this.setAttribute("uv",new et(l,2))}},y3=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 Hi?e.shape:new Hi,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,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,m=n*Math.PI/360/s,v=Math.PI/2*3*-1,y=c*r/100,x=d*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let _=0;_<s;_++){let S=m*_,M=p+Math.sin(S)*c,C=f+Math.cos(S)*d;u.addPoint(u.createPoint(M,C))}}else for(let _=0;_<s;_++){let S=p+Math.cos(v)*c,M=f+Math.sin(v)*d;u.addPoint(u.createPoint(S,M)),v+=m,S=p+Math.cos(v)*y,M=f+Math.sin(v)*x,_<=s,u.addPoint(u.createPoint(S,M)),v+=m}u.isClosed=!0;for(let _=0,S=u.points.length;_<S;_++)u.points[_].roundness=a;u.roundness=a,u.update();let b=ih.create({shape:u,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},$W=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 Jl(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},e7=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),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=t7(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 t7(e,t,i,r,s,a,n,o,l,h,u){[t,i]=[i,t],n=t/2;let c=st.clamp(s/360,0,1);if(c===0){let d=new ut;return d.setAttribute("position",new et([],3)),d}return c===1&&(h=0),new m3(!0,e,t,i,r,c,a,n,o,l,h,u)}var i7=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 mC(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},r7=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 Hi?e.shape:new Hi,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,u=i*.5;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let c=ih.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function s7(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var a7=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)})}},n7=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)})}},Me=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Me.version}static addUnaryOp(e){return Me.max_unop_len=Math.max(e.length,Me.max_unop_len),Me.unary_ops[e]=1,Me}static addBinaryOp(e,t,i){return Me.max_binop_len=Math.max(e.length,Me.max_binop_len),Me.binary_ops[e]=t,i?Me.right_associative.add(e):Me.right_associative.delete(e),Me}static addIdentifierChar(e){return Me.additional_identifier_chars.add(e),Me}static addLiteral(e,t){return Me.literals[e]=t,Me}static removeUnaryOp(e){return delete Me.unary_ops[e],e.length===Me.max_unop_len&&(Me.max_unop_len=Me.getMaxKeyLen(Me.unary_ops)),Me}static removeAllUnaryOps(){return Me.unary_ops={},Me.max_unop_len=0,Me}static removeIdentifierChar(e){return Me.additional_identifier_chars.delete(e),Me}static removeBinaryOp(e){return delete Me.binary_ops[e],e.length===Me.max_binop_len&&(Me.max_binop_len=Me.getMaxKeyLen(Me.binary_ops)),Me.right_associative.delete(e),Me}static removeAllBinaryOps(){return Me.binary_ops={},Me.max_binop_len=0,Me}static removeLiteral(e){return delete Me.literals[e],Me}static removeAllLiterals(){return Me.literals={},Me}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 Me(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 Me.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!Me.binary_ops[String.fromCharCode(e)]||Me.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return Me.isIdentifierStart(e)||Me.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(Me.hooks[e]){let i={context:this,node:t};return Me.hooks.run(e,i),i.node}return t}searchHook(e){if(Me.hooks[e]){let t={context:this};return Me.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===Me.SPACE_CODE||e===Me.TAB_CODE||e===Me.LF_CODE||e===Me.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:Me.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===Me.SEMCOL_CODE||i===Me.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,Me.max_binop_len),t=e.length;for(;t>0;){if(Me.binary_ops.hasOwnProperty(e)&&(!Me.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Me.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:Me.binaryPrecedence(t),right_a:Me.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=Me.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:Me.right_associative.has(t)},l=t;let h=u=>s.right_a&&u.right_a?i>u.prec:i<=u.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:Me.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:Me.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,Me.isDecimalDigit(e)||e===Me.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===Me.SQUOTE_CODE||e===Me.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===Me.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,Me.max_unop_len),i=t.length;i>0;){if(Me.unary_ops.hasOwnProperty(t)&&(!Me.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Me.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:Me.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}Me.isIdentifierStart(e)?(r=this.gobbleIdentifier(),Me.literals.hasOwnProperty(r.name)?r={type:Me.LITERAL,value:Me.literals[r.name],raw:r.name}:r.name===Me.this_str&&(r={type:Me.THIS_EXP})):e===Me.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===Me.PERIOD_CODE||t===Me.OBRACK_CODE||t===Me.OPAREN_CODE||t===Me.QUMARK_CODE;){let i;if(t===Me.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Me.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===Me.OBRACK_CODE?(e={type:Me.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==Me.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===Me.OPAREN_CODE?e={type:Me.CALL_EXP,arguments:this.gobbleArguments(Me.CPAREN_CODE),callee:e}:(t===Me.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:Me.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(;Me.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===Me.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);Me.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++));Me.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);Me.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,Me.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===Me.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===Me.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Me.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+=`
|
|
3155
3155
|
`;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:Me.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(Me.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,Me.isIdentifierPart(e));)this.index++;return{type:Me.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===Me.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(s===Me.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===Me.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===Me.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===Me.COMPOUND)&&this.throwError("Expected comma"),t.push(a)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(Me.CPAREN_CODE);if(this.code===Me.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:Me.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Me.ARRAY_EXP,elements:this.gobbleArguments(Me.CBRACK_CODE)}}},o7=new a7;Object.assign(Me,{hooks:o7,plugins:new n7(Me),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"});Me.max_unop_len=Me.getMaxKeyLen(Me.unary_ops);Me.max_binop_len=Me.getMaxKeyLen(Me.binary_ops);var Bc=e=>new Me(e).parse(),l7=Object.getOwnPropertyNames(Me);l7.forEach(e=>{Bc[e]===void 0&&e!=="prototype"&&(Bc[e]=Me[e])});Bc.Jsep=Me;var h7="ConditionalExpression",c7={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:h7,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 :")}})}};Bc.plugins.register(c7);var u7=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],d7=["0","1","2","3","4","5","6","7","8","9","."],p7=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function f7(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}Bc.addBinaryOp("^",11,!0);function x3(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];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),u=Ws.getDisplayedValue(h);i==="number"&&Ws.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?u=parseFloat(u).toString():i==="boolean"&&Ws.isBoolean(h)?u=h?"true":"false":i==="boolean"&&Ws.isTextValue(h)&&!Array.isArray(h.textValue)&&(u='"'+u+'"'),r+=u;continue}else if(i==="string"){o.name!=='"'&&o.name!=="+"&&(r+=o.name),o.name==="+"&&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"&&!f7(o.name)&&!d7.includes(o.name)&&!u7.includes(o.name)&&!p7.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=Bc(r)}catch(n){console.error(r,n);return}let a;try{a=ei(s)}catch(n){console.error(r,s,n)}return a}function ei(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return Number(ei(e.left)===ei(e.right));case"!=":return Number(ei(e.left)!==ei(e.right));case">":return Number(ei(e.left)>ei(e.right));case">=":return Number(ei(e.left)>=ei(e.right));case"<":return Number(ei(e.left)<ei(e.right));case"<=":return Number(ei(e.left)<=ei(e.right));case"+":return ei(e.left)+ei(e.right);case"-":return ei(e.left)-ei(e.right);case"*":return ei(e.left)*ei(e.right);case"/":return ei(e.left)/ei(e.right);case"%":return ei(e.left)%ei(e.right);case"&&":return ei(e.left)&&ei(e.right);case"||":return ei(e.left)||ei(e.right);case"^":return Math.pow(ei(e.left),ei(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-ei(e.argument);case"!":return Number(!ei(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=ei(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=ei(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(ei))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var m7=new Le,g7=new Le;function v7(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=st.lerp(a.length(),o.length(),i);a.lerp(o,i).setLength(l)}),new Le().makeBasis(r[0],r[1],r[2])}var y7=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??ib.create({parameters:GT}).userData.shape;return{path:e.path??Bm.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:a,extrusion:{...HT,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new x7(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new ut,{userData:{...e,type:"PathGeometry"}})}},x7=class extends ut{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)||!s7(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 X=0;X<o;X++){let G=this.inputs.path.isClosed?(X+a)%e.length:Math.min(X+a,e.length-1);l.push(e[G].clone()),h.push(t[G].clone())}let u=(X,G,se)=>{l[X]=l[X].clone().lerp(l[G],se),h[X]=v7(h[X],h[G],se)},c=0,d=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(c=d,u(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,u(l.length-1,l.length-2,1-p)),i===0){let X=l.length-1;l[X].copy(l[0]),h[X].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:m,bevelSides:v}=this.inputs.parameters.extrusion,y=m>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:S}=this._computeShapePoints(x),M=0,C;y==="round"&&(C=new tb(this.inputs.shapeData,2*m,m,x,v,void 0,!0),M=C.getAttribute("position").count);let A=0,T=0;_.sort((X,G)=>X.start-G.start),_.forEach(X=>{X.verticesStart=A,X.verticesCount=X.continuous.reduce((G,se,ae)=>G+(ae===0||!se?2:1),0),T+=X.verticesCount,A=T});let P=T*o,R,z=0;if(this._isOpenEnded()&&y==="flat"){try{R=Go({windingRule:gi.ODD,elementType:or.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{R=l3}z=R.vertexCount}let N=P+2*z+M*2,B=P+2*z,V={positions:new Float32Array(N*3),normals:new Float32Array(N*3),uvs:new Float32Array(N*2)},H=[];if(_.forEach(X=>{this._extrudeRegion(X,S,h,l,V,H,this._isGeometryClosed()&&!this._isOpenEnded())}),R&&(this._closeEnd(R,P,H,V,h[0],l[0],!1),this._closeEnd(R,P+z,H,V,h[h.length-1],l[l.length-1],!0)),C){V.positions.set(C.getAttribute("position").array,B*3),V.normals.set(C.getAttribute("normal").array,B*3),V.uvs.set(C.getAttribute("uv").array,B*2);let X=H.length;H.push(...C.getIndex().array.map(ae=>ae+B)),B+=M,V.positions.set(C.getAttribute("position").array,B*3),V.normals.set(C.getAttribute("normal").array,B*3),V.uvs.set(C.getAttribute("uv").array,B*2);let G=H.length;H.push(...C.getIndex().array.map(ae=>ae+B)),this.setAttribute("position",new At(V.positions,3)),this.setAttribute("normal",new At(V.normals,3)),this.setAttribute("uv",new At(V.uvs,2)),this.setIndex(H);let se=m7;se.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(se,B,N),se.copy(h[0]).setPosition(l[0]).multiply(g7.makeScale(1,1,-1)),this.applyMatrix4OnRange(se,B-M,B),this.reverseIndicesOnRange(X,G)}else this.setAttribute("position",new At(V.positions,3)),this.setAttribute("normal",new At(V.normals,3)),this.setAttribute("uv",new At(V.uvs,2)),this.setIndex(H)}_extractPathPoints(){let e=$T(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 m=e[f],v;f===0?v=r?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):v=e[f-1];let y;f===i-1?y=r?e[1]:m.clone().multiplyScalar(2).sub(e[f-1]):y=e[f+1];let x=m.clone().sub(v).normalize(),b=y.clone().sub(m).normalize(),_=x.clone().add(b).normalize();n.copy(_),f===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let S=l.clone().cross(_).normalize(),M=_.clone().cross(S).normalize();l.copy(M),o.copy(S),f===0&&(s.copy(M),a.copy(_));let C=new Le().makeBasis(S,M,_);t.push(C)}let h=r?a:n,u=r?s:new I(0,1,0),c=h.clone().cross(o).normalize(),d=Math.acos(u.dot(c));if(isNaN(d))return t;let p=u.clone().cross(c);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let m=new Le().makeRotationZ(d*f/t.length);t[f].multiply(m)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:a,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new Le,h=new Le;return e.forEach((u,c)=>{let d=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(st.lerp(s,s+a,d)*st.DEG2RAD);let p=st.lerp(n,o,d);h.makeScale(p,p,p),u.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=gi.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),m=[];for(let v=f.length-1;v>=1;v-=2){let y=f[v-1],x=f[v-0];m.push(y,x)}return m}),a;try{a=Go({windingRule:t,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{a=eb}let n;try{n=Go({windingRule:gi.ODD,elementType:or.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{n=o3}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],m=p%2===0?a.vertexCount:0;a.elements.push(f+m)}for(let p=0;p<n.vertexIndices.length;p++){let f=n.vertexIndices[p],m=a.vertexCount;a.vertexIndices.push(f+m)}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,u=1/0,c=-1/0;for(let p=0,f=a.vertexCount;p<f;p++){let m=p*2,v=a.vertices[m+0],y=a.vertices[m+1];v<l&&(l=v),v>h&&(h=v),y<u&&(u=y),y>c&&(c=y)}let d=[];for(let p=a.elementCount-1;p>=0;p--){let f=p>=o,m=p*2,v=a.elements[m+0],y=a.elements[m+1],x=v+y,b={start:v,count:y,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(b);let _=v,S=x-1,M=v+1,C=i.roundedCurves.length;do{let A=_-v,T=a.vertices[S*2+0],P=a.vertices[S*2+1],R=a.vertices[_*2+0],z=a.vertices[_*2+1],N=a.vertices[M*2+0],B=a.vertices[M*2+1],V=R-T,H=z-P,X=Math.sqrt(V*V+H*H);V/=X,H/=X;let G=R-N,se=z-B,ae=Math.sqrt(G*G+se*se);G/=ae,se/=ae,b.normals[A*2+0]=-se,b.normals[A*2+1]=G;let J=a.vertexIndices[_];if(Array.isArray(J))b.continuous[A]=!1;else{let[K,ne]=i.getCurveIndexFromVertexId(J-1,!0);if(ne>0&&ne<1)b.continuous[A]=!0;else{let te=ne===1?K+1:K-1;te=(te+C)%C;let oe=ne===1?0:1,ie=i.roundedCurves[K].getTangent(ne),be=i.roundedCurves[te].getTangent(oe);b.continuous[A]=ie.dot(be)>.95}}f&&(b.normals[A*2+0]*=-1,b.normals[A*2+1]*=-1),[S,_,M]=[_,M,M+1],M>=x&&(M-=y)}while(M!==v+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,u=new I,c=new $;i.forEach((p,f)=>{let m=r[f],v=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(m),e.continuous[y])u.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),u.copy(o).sub(l),u.set(-u.y,u.x,0),e.isHole||u.negate()}if(u.applyMatrix4(p).normalize(),c.set(y===0?1:y/e.count,f/(i.length-1)),this._insertVertex(s,v,h,u,c),v++,!e.continuous[y]||y===0){if(y===0)u.set(e.normals[y*2+0],e.normals[y*2+1],0),c.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),u.copy(l).sub(o),u.set(-u.y,u.x,0),e.isHole||u.negate()}u.applyMatrix4(p).normalize(),this._insertVertex(s,v,h,u,c),v++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,m=e.verticesStart*i.length+e.verticesCount*(p+1),v=0;for(let y=0;y<e.count;y++){(!e.continuous[y]||y===0)&&v++;let x=y===e.count-1?0:v+1,b=f+v,_=f+x,S=m+x,M=m+v;e.isHole?a.push(b,S,_,b,M,S):a.push(b,_,S,b,S,M),v++}}}_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,u=new $;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,u)}let c=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=c[p+0]+t,m=c[p+(n?1:2)]+t,v=c[p+(n?2:1)]+t;i.push(f,m,v)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new Ki().getNormalMatrix(e).elements,a,n,o,l,h=this.attributes.position,u=this.attributes.normal;if(!h||!u)return;let c=h.array,d=u.array,p=h.itemSize;for(let f=t*p,m=i*p;f<m;f+=p){if(f===t)debugger;a=c[f+0],n=c[f+1],o=c[f+2],l=1/(r[3]*a+r[7]*n+r[11]*o+r[15]),c[f+0]=(r[0]*a+r[4]*n+r[8]*o+r[12])*l,c[f+1]=(r[1]*a+r[5]*n+r[9]*o+r[13])*l,c[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,u.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 b3(){let e=new ut;return e.setAttribute("position",new At(new Float32Array([]),3)),e.setIndex(new At(new Uint16Array([]),1)),e}var b7=b3().attributes,w7=12,_7=1,w3=class extends ut{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,b7),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n,text:o,textTransform:l}=e,h=Ws.getDisplayedValue(o),u=l===2?h.toUpperCase():l===3?h.toLowerCase():h,c=S7(e,t,u),{shapes:d,charWidths:p,charCoords:f}=t.generateShapes(c,e),m=(typeof i=="number"?i:1)*.5,v=(typeof r=="number"?r:1)*.5,y=d.map(_=>new Hi().fromShape(_,!0));this.vectorShapes=y;let x=y.map(_=>ih.create({shape:_,parameters:{depth:s,extrudeBevelSegments:n,extrudeBevelSize:a,windingRule:s<=0?gi.NONZERO:gi.ODD,subdivisions:this.isLowResolution&&s>0?_7:w7}})),b=x.length?Ol(x):b3();b.translate(-m,v,0),this.dispose(),this.wrappedText=c,this.charCoords=f,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([_,S])=>{this.setAttribute(_,S)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=bn(new ut,w3.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function S7(e,t,i){let r=[""],s="";for(let a of i)s+=a,a===" "||a===`
|
|
3156
3156
|
`?(r[r.length-1]+=s,s="",a===`
|
|
3157
|
-
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var _3,S3=new Promise(e=>{_3=e}),vA=!1,xf;function A7(){if(vA)return;if(xf)return xf;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@1.0.21/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});_3(n),vA=!0}return xf=e(),xf}var M7=["font"];function zd(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 u=a;for(let c of h)u=u[c];for(s in u){let c=u[s];w2(c)&&!M7.includes(s)&&(u[s]=t.getVariable(c,[r.uuid,"geometry",...h,s]),w2(u[s])&&(u[s]=1))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=Hi.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry")a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new _C().parse(a);else if(a.type==="SubdivGeometry"){let h=new ys(a,i);return h.data=e,h}else{if(a.type==="TextGeometry")return new w3(a,t);if(a.type==="UIGeometry")return rb.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}let l;try{l=_A(o)}catch(h){console.error(h)}if(!l){let h=Hi.createFromState(Rm.defaultData(),100,100);o.shape=h,l=_A(o)}return l}var E7=new Le;function x1(e,t,i,r){let s=e.position.array,a=e.normal.array,n=E7.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=a[u],l=a[u+1],h=a[u+2],a[u]=n[0]*o+n[4]*l+n[8]*h,a[u+1]=n[1]*o+n[5]*l+n[9]*h,a[u+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var bf=new er,Bh=new I,xt;S3.then(e=>{xt=e});var yA=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),xA=new Uint32Array([0,1,2,3]),bA=new Uint8Array([4]),ys=class extends ut{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=Nl.div(t,i);this.subdividedGeometry&&x1(this.subdividedGeometry.attributes,...r),this.originalGeometry&&x1(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(Bh.fromArray(r));let a=Bh.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}=ys.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Fa(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&&(ys.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new zs,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;bf.setFromBufferAttribute(t),bf.getCenter(i),e.boundingSphere.radius=i.distanceTo(bf.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),bf.getSize(Bh);let r={width:Bh.x,height:Bh.y,depth:Bh.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&&(xt.free_bvh(t),xt.free_subdivision_surface(t));try{s=ys.allocate(e,r)}catch(l){console.error(l,e),s=ys.allocate({positionWASM:yA,indexWASM:xA,verticesPerFaceWASM:bA},r)}if(xt.set_destination_refinement_level(s,0),a=ys.buildLevel(s,!0,o),e.subdivisions>0)try{xt.set_destination_refinement_level(s,e.subdivisions),n=ys.buildLevel(s,!1,o)}catch{try{xt.set_destination_refinement_level(s,e.subdivisions-1),n=ys.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:zd(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}=Eg(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let u=e.radialSegments*e.heightSegments*3*2,c=u+e.radialSegments*3;h=[u,c]}return{indices:n,verticesPerFace:o}=A3(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=yA,r=xA,s=bA);let o=i.length,l=r.length,h=s.length,u=i.length+a.length+n.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,m=xt._malloc(d),v=new Float32Array(xt.HEAPF32.buffer,m,u),y=new Uint32Array(xt.HEAPU32.buffer,m+p,c);v.set(i,0),v.set(a,i.length),v.set(n,i.length+a.length),y.set(r,0),y.set(s,r.length);let x;e?.scaleBaked?.some(_=>_!==1)&&(x=new Le().makeScale(...e.scaleBaked)),t&&(x?x.premultiply(t):x=t);let b=x?xt.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,x.elements):xt.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return xt._free(m),b}static buildLevel(e,t,i,r,s){let a=s?xt.get_mesh_data2(e,t?xt.Level.CONTROL:xt.Level.REFINED,i,s.elements):xt.get_mesh_data(e,t?xt.Level.CONTROL:xt.Level.REFINED,i),n=8,o=xt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,u=xt.HEAPU32[o[h]>>2],c=xt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=xt.HEAPU32[o[h]>>2],p=xt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=xt.HEAPU32[o[h]>>2],m=xt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let v=xt.HEAPU32[o[h]>>2],y=xt.HEAPU32.subarray(v>>2,(v>>2)+l[h]);if(h++,r===void 0){let x=new ut;if(x.setIndex(new nc(y,1)),x.setAttribute("position",new et(c,3)),x.setAttribute("normal",new et(p,3)),t){x.setAttribute("faceMap",new nc(m,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new At(b,4))}return xt.free_mesh_data(a),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,xt.free_mesh_data(a)}static freeSubdivPointer(e){xt.free_bvh(e),xt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=xt.get_wireframe_data_for_base_level(e),s=4,a=xt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=xt.HEAPU32[a[o]>>2],h=xt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let u=xt.HEAPU32[a[o]>>2],c=xt.HEAPU32.subarray(u>>2,(u>>2)+n[o]);if(t===void 0){let d=new ut;d.setAttribute("position",new et(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new At(p,3)),d.setIndex(new nc(c,1)),xt.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,xt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||xt.set_destination_refinement_level(e,t);let s=i?xt.get_topological_data2(e,r?xt.Level.CONTROL:xt.Level.REFINED,i.elements):xt.get_topological_data(e,r?xt.Level.CONTROL:xt.Level.REFINED),a=6,n=xt.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=xt.HEAPU32[n[l]>>2],u=new Float32Array(xt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=xt.HEAPU32[n[l]>>2],d=new Uint32Array(xt.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=xt.HEAPU32[n[l]>>2],f=new Uint8Array(xt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return xt.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},wA=["getX","getY","getZ"];function Eg(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[wA[d]](u)*o)},`;if(c in i)a.push(i[c]);else{for(let d=0;d<3;d++)n.push(e[wA[d]](u));i[c]=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 wf=new I,o0=new I,l0=new I,h0=new I;function A3(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 u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let c=0;if(u<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(c++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(c++);return a.push(c),{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]){wf.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),o0.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),l0.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),h0.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),o0.sub(wf).normalize(),l0.sub(wf).normalize(),h0.sub(wf).normalize();let l=o0.cross(l0).dot(h0);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:o>=r[u]&&o<r[u+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=[],u=0;for(let c=0,d=0;c<e.length;c+=3,d++)e[c+2]===0&&(l.push(d),u++),e[c+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),a.push(u,u)}return{indices:s,verticesPerFace:a}}var qn={};BO(qn,{calcBoolean:()=>O7,calcBooleanTopological:()=>D7,freeMeshSet:()=>L7,getMeshSet:()=>I7,hasOpenEdges:()=>R7,transformMeshSet:()=>B7});var M3,C7=new Promise(e=>{M3=e}),_f;function T7(){if(_f)return _f;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@1.0.21/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});M3(n)}return _f=e(),_f}var Gt,mc;C7.then(e=>Gt=e);function P7(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}=Eg(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=A3(a,n,e);o=h.length,r=[];for(let u=0,c=0;u<o;u++){r.push(h[u]);for(let d=0;d<h[u];d++)r.push(l[c++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,u=0;u<r.length;)r[u++]=3,o++,r[u++]=n[h++],r[u++]=n[h++],r[u++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function E3(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=Gt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(Gt.HEAPU32.buffer,a,t):new Float32Array(Gt.HEAPF32.buffer,a,t)).set(e,0),a}function C3(e){switch(e){case 0:return Gt.OP.UNION;case 1:return Gt.OP.INTERSECTION;case 2:return Gt.OP.A_MINUS_B;case 3:return Gt.OP.B_MINUS_A;case 4:return Gt.OP.SYMMETRIC_DIFFERENCE;case 5:return Gt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function D7(e,t){mc===void 0&&(mc=Gt.init_csg());let i=E3(e),r=Gt.csg_calc_topological(mc,i,e.length,C3(t));Gt._free(i);let s=6,a=Gt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=Gt.HEAPU32[a[o]>>2],h=new Float32Array(Gt.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let u=Gt.HEAPU32[a[o]>>2],c=new Uint32Array(Gt.HEAPU32.subarray(u>>2,(u>>2)+n[o]));o++;let d=Gt.HEAPU32[a[o]>>2],p=new Uint8Array(Gt.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return Gt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function O7(e,t,i,r){mc===void 0&&(mc=Gt.init_csg());let s=E3(e),a=Gt.csg_calc(mc,s,e.length,r,C3(t));Gt._free(s);let n=5,o=Gt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,u=Gt.HEAPU32[o[h]>>2],c=Gt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Gt.HEAPU32[o[h]>>2],p=Gt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new et(c,3)),i.setAttribute("normal",new et(p,3));let m=Gt.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new zs),i.boundingSphere.radius=-1,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Gt.free_mesh_data(a),f}function I7(e,t,i){if(Gt===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 S=0;S<y.verticesPerFace[x];S++)s[_++]=y.indices[b++]}}else({positions:r,faceIndices:s,nFaces:a}=P7(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=Gt._malloc(u),f=new Float32Array(Gt.HEAPF32.buffer,p,l),m=new Uint32Array(Gt.HEAPU32.buffer,p+c,h);f.set(r,0),m.set(s,0);let v=Gt.get_csg_mesh(p,n,p+c,o,a);return Gt._free(p),v}function R7(e){return Gt.has_open_edges(e)}function B7(e,t){Gt.transform_csg_mesh(e,t.elements)}function L7(e){Gt.free_csg_mesh(e)}var z7={ConeGeometry:tW,CubeGeometry:iW,CylinderGeometry:e3,DodecahedronGeometry:sW,EllipseGeometry:ib,HelixGeometry:zW,IcosahedronGeometry:kW,LatheGeometry:NW,NonParametricGeometry:WW,PolygonGeometry:v3,PyramidGeometry:qW,RectangleGeometry:rb,SphereGeometry:QW,PlaneGeometry:ZW,BackdropGeometry:KW,StarGeometry:y3,TextFrameGeometry:$W,TorusGeometry:e7,TorusKnotGeometry:i7,TriangleGeometry:r7,PathGeometry:y7,VectorGeometry:ih},_A=e=>z7[e.type].create(e);function Lh(e){return e!==null&&"booleanOp"in e}var T3=class extends Zx(yr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new Le}updateVisible(e){super.updateVisible(e),this.visible=!Lh(this.parent)&&this.visible,Lh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(qn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Lh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof T3&&(e.freeBooleanPointer(),Lh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Lh(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Lh(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Sf=new er;function sb(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<a&&(a=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}Sf.min.set(a,n,o),Sf.max.set(l,h,u),Sf.getCenter(r),Sf.getSize(s).multiplyScalar(.5)}var k7=new ut,N7=new Nc,Ss=class extends T3{constructor(e,t){super(k7,N7),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?sb(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},SA=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}},el=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=st.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,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}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof el&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},F7=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}},Is=new F7,yi=class extends el{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=st.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}},ks=class extends yi{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))}},Ur=class extends ks{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof $?e:new $(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)}},aa=class extends ks{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)}},Yr=class extends yt{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}},Xn=class extends ks{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Yr?e:new Yr(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)}},U7=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,AA=/[a-z_0-9]+/gi,Ye=class extends yi{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=AA.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&Is.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=Is.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||Is.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+n-1]!=="."&&(o=o.substring(0,u.index+n)+p+o.substring(u.index+c.length+n),n+=p.length-c.length),this.getIncludeByName(p)===void 0&&Is.contains(p)&&e.include(Is.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=U7.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(AA);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=""}}},V7=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,P3=class extends yi{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||P3.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=V7.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)}},fi=P3;fi.PI="PI",fi.PI2="PI2",fi.RECIPROCAL_PI="RECIPROCAL_PI",fi.RECIPROCAL_PI2="RECIPROCAL_PI2",fi.LOG2="LOG2",fi.EPSILON="EPSILON";var j7=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3157
|
+
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var _3,S3=new Promise(e=>{_3=e}),vA=!1,xf;function A7(){if(vA)return;if(xf)return xf;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@1.0.22/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});_3(n),vA=!0}return xf=e(),xf}var M7=["font"];function zd(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 u=a;for(let c of h)u=u[c];for(s in u){let c=u[s];w2(c)&&!M7.includes(s)&&(u[s]=t.getVariable(c,[r.uuid,"geometry",...h,s]),w2(u[s])&&(u[s]=1))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=Hi.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry")a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new _C().parse(a);else if(a.type==="SubdivGeometry"){let h=new ys(a,i);return h.data=e,h}else{if(a.type==="TextGeometry")return new w3(a,t);if(a.type==="UIGeometry")return rb.create({parameters:{width:a.width,height:a.height,cornerRadius:a.cornerRadius,cornerType:a.cornerType}})}let l;try{l=_A(o)}catch(h){console.error(h)}if(!l){let h=Hi.createFromState(Rm.defaultData(),100,100);o.shape=h,l=_A(o)}return l}var E7=new Le;function x1(e,t,i,r){let s=e.position.array,a=e.normal.array,n=E7.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=a[u],l=a[u+1],h=a[u+2],a[u]=n[0]*o+n[4]*l+n[8]*h,a[u+1]=n[1]*o+n[5]*l+n[9]*h,a[u+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var bf=new er,Bh=new I,xt;S3.then(e=>{xt=e});var yA=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),xA=new Uint32Array([0,1,2,3]),bA=new Uint8Array([4]),ys=class extends ut{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=Nl.div(t,i);this.subdividedGeometry&&x1(this.subdividedGeometry.attributes,...r),this.originalGeometry&&x1(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(Bh.fromArray(r));let a=Bh.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}=ys.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Fa(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&&(ys.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new zs,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;bf.setFromBufferAttribute(t),bf.getCenter(i),e.boundingSphere.radius=i.distanceTo(bf.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),bf.getSize(Bh);let r={width:Bh.x,height:Bh.y,depth:Bh.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&&(xt.free_bvh(t),xt.free_subdivision_surface(t));try{s=ys.allocate(e,r)}catch(l){console.error(l,e),s=ys.allocate({positionWASM:yA,indexWASM:xA,verticesPerFaceWASM:bA},r)}if(xt.set_destination_refinement_level(s,0),a=ys.buildLevel(s,!0,o),e.subdivisions>0)try{xt.set_destination_refinement_level(s,e.subdivisions),n=ys.buildLevel(s,!1,o)}catch{try{xt.set_destination_refinement_level(s,e.subdivisions-1),n=ys.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:zd(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}=Eg(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let u=e.radialSegments*e.heightSegments*3*2,c=u+e.radialSegments*3;h=[u,c]}return{indices:n,verticesPerFace:o}=A3(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=yA,r=xA,s=bA);let o=i.length,l=r.length,h=s.length,u=i.length+a.length+n.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,m=xt._malloc(d),v=new Float32Array(xt.HEAPF32.buffer,m,u),y=new Uint32Array(xt.HEAPU32.buffer,m+p,c);v.set(i,0),v.set(a,i.length),v.set(n,i.length+a.length),y.set(r,0),y.set(s,r.length);let x;e?.scaleBaked?.some(_=>_!==1)&&(x=new Le().makeScale(...e.scaleBaked)),t&&(x?x.premultiply(t):x=t);let b=x?xt.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,x.elements):xt.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return xt._free(m),b}static buildLevel(e,t,i,r,s){let a=s?xt.get_mesh_data2(e,t?xt.Level.CONTROL:xt.Level.REFINED,i,s.elements):xt.get_mesh_data(e,t?xt.Level.CONTROL:xt.Level.REFINED,i),n=8,o=xt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,u=xt.HEAPU32[o[h]>>2],c=xt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=xt.HEAPU32[o[h]>>2],p=xt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=xt.HEAPU32[o[h]>>2],m=xt.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let v=xt.HEAPU32[o[h]>>2],y=xt.HEAPU32.subarray(v>>2,(v>>2)+l[h]);if(h++,r===void 0){let x=new ut;if(x.setIndex(new nc(y,1)),x.setAttribute("position",new et(c,3)),x.setAttribute("normal",new et(p,3)),t){x.setAttribute("faceMap",new nc(m,1));let b=new Float32Array(p.length/3*4).fill(0);x.setAttribute("color",new At(b,4))}return xt.free_mesh_data(a),x.userData.type="SubdivGeometry",x}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,xt.free_mesh_data(a)}static freeSubdivPointer(e){xt.free_bvh(e),xt.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=xt.get_wireframe_data_for_base_level(e),s=4,a=xt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=xt.HEAPU32[a[o]>>2],h=xt.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let u=xt.HEAPU32[a[o]>>2],c=xt.HEAPU32.subarray(u>>2,(u>>2)+n[o]);if(t===void 0){let d=new ut;d.setAttribute("position",new et(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new At(p,3)),d.setIndex(new nc(c,1)),xt.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,xt.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||xt.set_destination_refinement_level(e,t);let s=i?xt.get_topological_data2(e,r?xt.Level.CONTROL:xt.Level.REFINED,i.elements):xt.get_topological_data(e,r?xt.Level.CONTROL:xt.Level.REFINED),a=6,n=xt.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=xt.HEAPU32[n[l]>>2],u=new Float32Array(xt.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=xt.HEAPU32[n[l]>>2],d=new Uint32Array(xt.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=xt.HEAPU32[n[l]>>2],f=new Uint8Array(xt.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return xt.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},wA=["getX","getY","getZ"];function Eg(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[wA[d]](u)*o)},`;if(c in i)a.push(i[c]);else{for(let d=0;d<3;d++)n.push(e[wA[d]](u));i[c]=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 wf=new I,o0=new I,l0=new I,h0=new I;function A3(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 u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let c=0;if(u<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(c++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(c++);return a.push(c),{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]){wf.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),o0.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),l0.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),h0.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),o0.sub(wf).normalize(),l0.sub(wf).normalize(),h0.sub(wf).normalize();let l=o0.cross(l0).dot(h0);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:o>=r[u]&&o<r[u+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=[],u=0;for(let c=0,d=0;c<e.length;c+=3,d++)e[c+2]===0&&(l.push(d),u++),e[c+2]===n&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),a.push(u,u)}return{indices:s,verticesPerFace:a}}var qn={};BO(qn,{calcBoolean:()=>O7,calcBooleanTopological:()=>D7,freeMeshSet:()=>L7,getMeshSet:()=>I7,hasOpenEdges:()=>R7,transformMeshSet:()=>B7});var M3,C7=new Promise(e=>{M3=e}),_f;function T7(){if(_f)return _f;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@1.0.22/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});M3(n)}return _f=e(),_f}var Gt,mc;C7.then(e=>Gt=e);function P7(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}=Eg(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=A3(a,n,e);o=h.length,r=[];for(let u=0,c=0;u<o;u++){r.push(h[u]);for(let d=0;d<h[u];d++)r.push(l[c++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,u=0;u<r.length;)r[u++]=3,o++,r[u++]=n[h++],r[u++]=n[h++],r[u++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function E3(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=Gt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(Gt.HEAPU32.buffer,a,t):new Float32Array(Gt.HEAPF32.buffer,a,t)).set(e,0),a}function C3(e){switch(e){case 0:return Gt.OP.UNION;case 1:return Gt.OP.INTERSECTION;case 2:return Gt.OP.A_MINUS_B;case 3:return Gt.OP.B_MINUS_A;case 4:return Gt.OP.SYMMETRIC_DIFFERENCE;case 5:return Gt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function D7(e,t){mc===void 0&&(mc=Gt.init_csg());let i=E3(e),r=Gt.csg_calc_topological(mc,i,e.length,C3(t));Gt._free(i);let s=6,a=Gt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=Gt.HEAPU32[a[o]>>2],h=new Float32Array(Gt.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let u=Gt.HEAPU32[a[o]>>2],c=new Uint32Array(Gt.HEAPU32.subarray(u>>2,(u>>2)+n[o]));o++;let d=Gt.HEAPU32[a[o]>>2],p=new Uint8Array(Gt.HEAPU32.subarray(d>>2,(d>>2)+n[o]));return Gt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function O7(e,t,i,r){mc===void 0&&(mc=Gt.init_csg());let s=E3(e),a=Gt.csg_calc(mc,s,e.length,r,C3(t));Gt._free(s);let n=5,o=Gt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,u=Gt.HEAPU32[o[h]>>2],c=Gt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Gt.HEAPU32[o[h]>>2],p=Gt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new et(c,3)),i.setAttribute("normal",new et(p,3));let m=Gt.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new zs),i.boundingSphere.radius=-1,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Gt.free_mesh_data(a),f}function I7(e,t,i){if(Gt===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 S=0;S<y.verticesPerFace[x];S++)s[_++]=y.indices[b++]}}else({positions:r,faceIndices:s,nFaces:a}=P7(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=Gt._malloc(u),f=new Float32Array(Gt.HEAPF32.buffer,p,l),m=new Uint32Array(Gt.HEAPU32.buffer,p+c,h);f.set(r,0),m.set(s,0);let v=Gt.get_csg_mesh(p,n,p+c,o,a);return Gt._free(p),v}function R7(e){return Gt.has_open_edges(e)}function B7(e,t){Gt.transform_csg_mesh(e,t.elements)}function L7(e){Gt.free_csg_mesh(e)}var z7={ConeGeometry:tW,CubeGeometry:iW,CylinderGeometry:e3,DodecahedronGeometry:sW,EllipseGeometry:ib,HelixGeometry:zW,IcosahedronGeometry:kW,LatheGeometry:NW,NonParametricGeometry:WW,PolygonGeometry:v3,PyramidGeometry:qW,RectangleGeometry:rb,SphereGeometry:QW,PlaneGeometry:ZW,BackdropGeometry:KW,StarGeometry:y3,TextFrameGeometry:$W,TorusGeometry:e7,TorusKnotGeometry:i7,TriangleGeometry:r7,PathGeometry:y7,VectorGeometry:ih},_A=e=>z7[e.type].create(e);function Lh(e){return e!==null&&"booleanOp"in e}var T3=class extends Zx(yr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new Le}updateVisible(e){super.updateVisible(e),this.visible=!Lh(this.parent)&&this.visible,Lh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(qn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Lh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof T3&&(e.freeBooleanPointer(),Lh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Lh(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Lh(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Sf=new er;function sb(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<a&&(a=d),p<n&&(n=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}Sf.min.set(a,n,o),Sf.max.set(l,h,u),Sf.getCenter(r),Sf.getSize(s).multiplyScalar(.5)}var k7=new ut,N7=new Nc,Ss=class extends T3{constructor(e,t){super(k7,N7),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?sb(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},SA=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}},el=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=st.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,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}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof el&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},F7=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}},Is=new F7,yi=class extends el{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=st.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}},ks=class extends yi{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))}},Ur=class extends ks{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof $?e:new $(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)}},aa=class extends ks{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)}},Yr=class extends yt{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}},Xn=class extends ks{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Yr?e:new Yr(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)}},U7=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,AA=/[a-z_0-9]+/gi,Ye=class extends yi{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=AA.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&Is.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=Is.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||Is.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+n-1]!=="."&&(o=o.substring(0,u.index+n)+p+o.substring(u.index+c.length+n),n+=p.length-c.length),this.getIncludeByName(p)===void 0&&Is.contains(p)&&e.include(Is.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=U7.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(AA);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=""}}},V7=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,P3=class extends yi{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||P3.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=V7.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)}},fi=P3;fi.PI="PI",fi.PI2="PI2",fi.RECIPROCAL_PI="RECIPROCAL_PI",fi.RECIPROCAL_PI2="RECIPROCAL_PI2",fi.LOG2="LOG2",fi.EPSILON="EPSILON";var j7=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3158
3158
|
)*?)}`,"gim"),G7=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),D3=class extends yi{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=j7.exec(e);if(t){let i=t[2],r;for(;r=G7.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},ab=class extends yi{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)}};Is.addKeyword("uv",function(){return new ab});Is.addKeyword("uv2",function(){return new ab(1)});var Kh=class extends yi{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Kh.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Na:return["Linear"];case Rt:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=Kh.Nodes[this.method],a=e.include(s);if(a===Kh.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=Kh.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Kh.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},pn=Kh;pn.Nodes={LinearToLinear:new Ye(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3159
3159
|
`)),sRGBToLinear:new Ye(["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(`
|
|
3160
3160
|
`)),LinearTosRGB:new Ye(["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(`
|
|
@@ -3391,7 +3391,7 @@ layout(location = 1) out vec4 gVelocity;
|
|
|
3391
3391
|
`}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,i,r="varying",s="V",a=""){let n=this.getVars(r),o=n[e];if(!o){let l=n.length;o={name:i||"node"+s+l+(a?"_"+a:""),type:t},n.push(o),n[e]=o}return o}getTempVar(e,t,i,r){return this.getVar(e,t,i,this.shader,"T",r)}getAttribute(e,t){if(!this.attributes[e]){let i=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(i.name+" = "+e+";"),this.attributes[e]={varying:i,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(`
|
|
3392
3392
|
`)}getVarListCode(e,t){t=t??"";let i="";for(let r=0,s=e.length;r<s;++r){let a=e[r],n=a.type,o=a.name,l=a.size,h=this.getFormatByType(n);if(h===void 0)throw new Error("Node pars "+h+" not found.");h.includes("[]")?i+=t+" "+h.substring(0,h.length-2)+" "+o+`[${l}];
|
|
3393
3393
|
`:i+=t+" "+h+" "+o+`;
|
|
3394
|
-
`}return i}getVars(e){return this.inputs.vars[e??this.shader]}getNodeData(e){let t=e instanceof el?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,i,r,s,a){if(t.includes("[]")){let n=this.inputs.arrayUniforms,o=n.list.length,l=new SA({type:t,size:i.size,name:r||"nodeUA"+o+(a?"_"+a:""),node:i,needsUpdate:s});return n.list.push(l),n[e].push(l),n[e][l.name]=l,this.uniforms[l.name]=l,l}else{let n=this.inputs.uniforms,o=n.list.length,l=new SA({type:t,name:r||"nodeU"+o+(a?"_"+a:""),node:i,needsUpdate:s});return n.list.push(l),n[e].push(l),n[e][l.name]=l,this.uniforms[l.name]=l,l}}createVertexUniform(e,t,i,r,s){return this.createUniform("vertex",e,t,i,r,s)}createFragmentUniform(e,t,i,r,s){return this.createUniform("fragment",e,t,i,r,s)}include(e,t,i){let r;if(e=typeof e=="string"?Is.get(e):e,this.context.include===!1)return e.name;e instanceof Ye?r=this.includes.functions:e instanceof fi?r=this.includes.consts:e instanceof D3&&(r=this.includes.structs);let s=r[this.shader]=r[this.shader]||[];if(e){let a=s[e.name];if(a||(a=s[e.name]={node:e,deps:[]},s.push(a),a.src=e.build(this,"source")),e instanceof Ye&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),e.includes?.length)){let n=0;do this.include(e.includes[n++],t);while(n<e.includes.length)}return i&&(a.src=i),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return J7[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let i=e[t];if(i?.isNode)return i}}resolve(...e){for(let t=0;t<arguments.length;t++){let i=e[t];if(i!==void 0){if(i.isNode)return i;if(i.isTexture)switch(i.mapping){case jl:case Gl:return new W7(i);case Vd:return new H7(new $n(i));default:return new $n(i)}else{if(i.isVector2)return new Ur(i);if(i.isVector3)return new aa(i);if(i.isVector4)return new Xn(i)}}}}format(e,t,i){switch(this.colorToVector(i+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return $7[e]||e}getFormatByType(e){return eq[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return EA[e]}getIndexByElement(e){return EA.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=Na,t===Na&&this.context.gamma&&(t=Rt),t}},Wi=class extends ks{constructor(e=0,t,i,r){super("c"),this.nodeType="Color",this.value=e instanceof Yr?e:new Yr(e||0,t,i,r)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i),o=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return o?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))}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",r,t)}},wi=class extends ks{constructor(e){super("i"),this.nodeType="Int",this.value=Math.floor(e??0)}generateReadonly(e,t,i,r,s,a){return e.format(this.value.toString(),r,t)}},xs=class extends ks{constructor(e){super("b"),this.nodeType="Bool",this.value=e??!1}generateReadonly(e,t,i,r){return e.format(this.value?"true":"false",r,t)}},vl=class extends ks{constructor(e=1,t){super("f[]"),this.nodeType="FloatArray",this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}},nb=class extends ks{},tq=class extends nb{constructor(e){super("v3"),this.image=e,this._value=new I}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}},w1=class extends nb{constructor(e,t){super("t"),this.image=e,this.wrap=t}get value(){return this.image.getTexture(this.wrap)}},R3=class extends ks{constructor(e){super("m3"),this.nodeType="Matrix3",this.value=e??new Ki}generateReadonly(e,t,i,r,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",r,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}},Sn=class extends ks{constructor(e){super("m4"),this.nodeType="Matrix4",this.value=e??new Le}generateReadonly(e,t,i,r,s,a){return e.format("mat4("+this.value.elements.join(", ")+")",r,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function CA(e,t,i){e.setUvTransform(i[0],i[1],t[0],t[1],0,0,0)}var iq=class extends R3{constructor(e,t){super(new Ki),this.repeat=e,this.offset=t,CA(this.value,e,t)}updateMatrix(){CA(this.value,this.repeat,this.offset)}},yl=class extends ks{constructor(e=1,t){super("v4[]"),this.nodeType="Vector4Array",this.size=e,this.value=Array.isArray(t)?t:t instanceof Et?new Array(e).fill(t):new Array(e).fill(new Et(0))}},TA=class extends yi{constructor(e,t,i,r){super("v3"),this.nodeType="Blend",this.a=e,this.b=t,this.alpha=i,this.mode=r}generate(e,t){if(e.isShader("fragment")){let i=[];return i.push(this.a.build(e,"c")),i.push(this.b.build(e,"c")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),e.format("spe_blend("+i.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},B3=class extends yi{constructor(e,t){super("v3"),this.nodeType="CustomColor",this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let i=e.include(B3.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let r=[];return r.push(this.color.build(e,"v3")),r.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},_1=B3;_1.Nodes=function(){return{customColor:new Ye(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
|
|
3394
|
+
`}return i}getVars(e){return this.inputs.vars[e??this.shader]}getNodeData(e){let t=e instanceof el?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,i,r,s,a){if(t.includes("[]")){let n=this.inputs.arrayUniforms,o=n.list.length,l=new SA({type:t,size:i.size,name:r||"nodeUA"+o+(a?"_"+a:""),node:i,needsUpdate:s});return n.list.push(l),n[e].push(l),n[e][l.name]=l,this.uniforms[l.name]=l,l}else{let n=this.inputs.uniforms,o=n.list.length,l=new SA({type:t,name:r||"nodeU"+o+(a?"_"+a:""),node:i,needsUpdate:s});return n.list.push(l),n[e].push(l),n[e][l.name]=l,this.uniforms[l.name]=l,l}}createVertexUniform(e,t,i,r,s){return this.createUniform("vertex",e,t,i,r,s)}createFragmentUniform(e,t,i,r,s){return this.createUniform("fragment",e,t,i,r,s)}include(e,t,i){let r;if(e=typeof e=="string"?Is.get(e):e,this.context.include===!1)return e.name;e instanceof Ye?r=this.includes.functions:e instanceof fi?r=this.includes.consts:e instanceof D3&&(r=this.includes.structs);let s=r[this.shader]=r[this.shader]||[];if(e){let a=s[e.name];if(a||(a=s[e.name]={node:e,deps:[]},s.push(a),a.src=e.build(this,"source")),e instanceof Ye&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),e.includes?.length)){let n=0;do this.include(e.includes[n++],t);while(n<e.includes.length)}return i&&(a.src=i),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return J7[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let i=e[t];if(i?.isNode)return i}}resolve(...e){for(let t=0;t<arguments.length;t++){let i=e[t];if(i!==void 0){if(i.isNode)return i;if(i.isTexture)switch(i.mapping){case jl:case Gl:return new W7(i);case Vd:return new H7(new $n(i));default:return new $n(i)}else{if(i.isVector2)return new Ur(i);if(i.isVector3)return new aa(i);if(i.isVector4)return new Xn(i)}}}}format(e,t,i){switch(this.colorToVector(i+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return $7[e]||e}getFormatByType(e){return eq[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return EA[e]}getIndexByElement(e){return EA.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=Na,t===Na&&this.context.gamma&&(t=Rt),t}},Wi=class extends ks{constructor(e=0,t,i,r){super("c"),this.nodeType="Color",this.value=e instanceof Yr?e:new Yr(e||0,t,i,r)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,i,r,s,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i),o=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return o?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))}generateReadonly(e,t,i,r,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",r,t)}},wi=class extends ks{constructor(e){super("i"),this.nodeType="Int",this.value=Math.floor(e??0)}generateReadonly(e,t,i,r,s,a){return e.format(this.value.toString(),r,t)}},xs=class extends ks{constructor(e){super("b"),this.nodeType="Bool",this.value=e??!1}generateReadonly(e,t,i,r){return e.format(this.value?"true":"false",r,t)}},vl=class extends ks{constructor(e=1,t){super("f[]"),this.nodeType="FloatArray",this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}},nb=class extends ks{},tq=class extends nb{constructor(e){super("v3"),this.image=e,this._value=new I}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}},w1=class extends nb{constructor(e,t,i=1008){super("t"),this.image=e,this.wrap=t,this.minFilter=i}get value(){return this.image.getTexture(this.wrap,this.minFilter)}},R3=class extends ks{constructor(e){super("m3"),this.nodeType="Matrix3",this.value=e??new Ki}generateReadonly(e,t,i,r,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",r,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}},Sn=class extends ks{constructor(e){super("m4"),this.nodeType="Matrix4",this.value=e??new Le}generateReadonly(e,t,i,r,s,a){return e.format("mat4("+this.value.elements.join(", ")+")",r,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};function CA(e,t,i){e.setUvTransform(i[0],i[1],t[0],t[1],0,0,0)}var iq=class extends R3{constructor(e,t){super(new Ki),this.repeat=e,this.offset=t,CA(this.value,e,t)}updateMatrix(){CA(this.value,this.repeat,this.offset)}},yl=class extends ks{constructor(e=1,t){super("v4[]"),this.nodeType="Vector4Array",this.size=e,this.value=Array.isArray(t)?t:t instanceof Et?new Array(e).fill(t):new Array(e).fill(new Et(0))}},TA=class extends yi{constructor(e,t,i,r){super("v3"),this.nodeType="Blend",this.a=e,this.b=t,this.alpha=i,this.mode=r}generate(e,t){if(e.isShader("fragment")){let i=[];return i.push(this.a.build(e,"c")),i.push(this.b.build(e,"c")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),e.format("spe_blend("+i.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},B3=class extends yi{constructor(e,t){super("v3"),this.nodeType="CustomColor",this.color=e,this.alpha=t,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){let i=e.include(B3.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let r=[];return r.push(this.color.build(e,"v3")),r.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),r.push(this.alpha.build(e,"f")),r.push(this.calpha),e.format(i+"("+r.join(",")+")",this.getType(e),t)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},_1=B3;_1.Nodes=function(){return{customColor:new Ye(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
|
|
3395
3395
|
float lalpha = alpha * mask;
|
|
3396
3396
|
calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
|
|
3397
3397
|
accumAlpha += (1.0 - accumAlpha) * lalpha;
|
|
@@ -4971,7 +4971,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
4971
4971
|
vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
|
|
4972
4972
|
displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
|
|
4973
4973
|
return displaced_position;
|
|
4974
|
-
}`,[e,t])}}();var bt={normalRenderTarget:new $n,normalRenderTargetDepth:new $n,transmissionRenderTarget:new $n,aspectRatio:new Ur,transmissionSize:new Ur(2048,2048),transmissionRenderTargetDepth:new $n,aoRenderTarget:new $n,aoEnabled:new xs,pixelRatioNode:new it(1),resolution:new Ur,penumbraSize:new vl(5,.5),frameIndex:new wi(0),transmissionLod:new wi(2)};for(let e of Object.values(bt))e.isRenderGlobal=!0;var eP={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.
|
|
4974
|
+
}`,[e,t])}}();var bt={normalRenderTarget:new $n,normalRenderTargetDepth:new $n,transmissionRenderTarget:new $n,aspectRatio:new Ur,transmissionSize:new Ur(2048,2048),transmissionRenderTargetDepth:new $n,aoRenderTarget:new $n,aoEnabled:new xs,pixelRatioNode:new it(1),resolution:new Ur,penumbraSize:new vl(5,.5),frameIndex:new wi(0),transmissionLod:new wi(2)};for(let e of Object.values(bt))e.isRenderGlobal=!0;var eP={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.22/build/ui.wasm"},hb=class extends el{constructor(){super("basic"),this.nodeType="Basic",this.color=new Wi(qs),this.shadingAlpha=new it(1),this.shadingBlend=new wi(0),this.previousModelViewMatrix=new Sn,this.previouseProjectionMatrix=new Sn}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:bt.frameIndex}),e.mergeUniform({resolution:bt.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Fc.merge([Xe.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
4975
4975
|
`));let r=["#include <beginnormal_vertex>",`
|
|
4976
4976
|
#if !defined( USE_LAYER_DISPLACE )
|
|
4977
4977
|
#include <defaultnormal_vertex>
|
|
@@ -5373,7 +5373,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
5373
5373
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${c}, ${n.result} );
|
|
5374
5374
|
}
|
|
5375
5375
|
`),o&&u.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),l?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h&&u.push(`gl_FragColor.a *= ${h.result};`),u.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=u.join(`
|
|
5376
|
-
`)}return t}},cq=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},uq=class extends cq{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},c0;function dq(e){return typeof e=="string"?e:(c0||(c0=new uq),c0.load(e))}var pq=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},fq=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},tP=class extends pq{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isCanvas=!1,this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let r=[1e3,1001,1002];for(let s of r){let a=this[s];a&&(a.image=this.img,a.needsUpdate=!0)}this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=a=>{r=a.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=dq(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let i;return this.isCanvas&&(i=new ak(this.img,void 0,e,e)),this.isVideo?i=new sk(this.img,void 0,e,e):i=new Li(this.img,void 0,e,e),this.loaded&&(i.needsUpdate=!0),this[e]=i,i}}setNeedsUpdate(e){let t=[1e3,1001,1002];for(let i of t){let r=this[i];r&&(r.needsUpdate=e)}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}},Lo=class extends tP{};function mq(e,t){var i=xq(t);return i.formatToParts?vq(i,e):yq(i,e)}var gq={year:0,month:1,day:2,hour:3,minute:4,second:5};function vq(e,t){try{for(var i=e.formatToParts(t),r=[],s=0;s<i.length;s++){var a=gq[i[s].type];a>=0&&(r[a]=parseInt(i[s].value,10))}return r}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function yq(e,t){var i=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(i);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var u0={};function xq(e){if(!u0[e]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),i=t==="06/25/2014, 00:00:00"||t==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";u0[e]=i?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return u0[e]}function iP(e,t,i,r,s,a,n){var o=new Date(0);return o.setUTCFullYear(e,t,i),o.setUTCHours(r,s,a,n),o}var PA=36e5,bq=6e4,d0={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function rP(e,t,i){var r,s;if(!e||(r=d0.timezoneZ.exec(e),r))return 0;var a;if(r=d0.timezoneHH.exec(e),r)return a=parseInt(r[1],10),DA(a)?-(a*PA):NaN;if(r=d0.timezoneHHMM.exec(e),r){a=parseInt(r[1],10);var n=parseInt(r[2],10);return DA(a,n)?(s=Math.abs(a)*PA+n*bq,a>0?-s:s):NaN}if(Sq(e)){t=new Date(t||Date.now());var o=i?t:wq(t),l=A1(o,e),h=i?l:_q(t,l,e);return-h}return NaN}function wq(e){return iP(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function A1(e,t){var i=mq(e,t),r=iP(i[0],i[1]-1,i[2],i[3]%24,i[4],i[5],0).getTime(),s=e.getTime(),a=s%1e3;return s-=a>=0?a:1e3+a,r-s}function _q(e,t,i){var r=e.getTime(),s=r-t,a=A1(new Date(s),i);if(t===a)return t;s-=a-t;var n=A1(new Date(s),i);return a===n?a:Math.max(a,n)}function DA(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var OA={};function Sq(e){if(OA[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),OA[e]=!0,!0}catch{return!1}}var Aq=Br(FO(),1),IA=Br(UO(),1),Mq=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,Eq=Mq,p0=36e5,RA=6e4,Cq=2,bs={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:Eq};function Tq(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);var i=t||{},r=i.additionalDigits==null?Cq:(0,Aq.default)(i.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var s=Pq(e),a=Dq(s.date,r),n=a.year,o=a.restDateString,l=Oq(o,n);if(isNaN(l))return new Date(NaN);if(l){var h=l.getTime(),u=0,c;if(s.time&&(u=Iq(s.time),isNaN(u)))return new Date(NaN);if(s.timeZone||i.timeZone){if(c=rP(s.timeZone||i.timeZone,new Date(h+u)),isNaN(c))return new Date(NaN)}else c=(0,IA.default)(new Date(h+u)),c=(0,IA.default)(new Date(h+u+c));return new Date(h+u+c)}else return new Date(NaN)}function Pq(e){var t={},i=bs.dateTimePattern.exec(e),r;if(i?(t.date=i[1],r=i[3]):(i=bs.datePattern.exec(e),i?(t.date=i[1],r=i[2]):(t.date=null,r=e)),r){var s=bs.timeZone.exec(r);s?(t.time=r.replace(s[1],""),t.timeZone=s[1].trim()):t.time=r}return t}function Dq(e,t){var i=bs.YYY[t],r=bs.YYYYY[t],s;if(s=bs.YYYY.exec(e)||r.exec(e),s){var a=s[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(s=bs.YY.exec(e)||i.exec(e),s){var n=s[1];return{year:parseInt(n,10)*100,restDateString:e.slice(n.length)}}return{year:null}}function Oq(e,t){if(t===null)return null;var i,r,s,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(i=bs.MM.exec(e),i)return r=new Date(0),s=parseInt(i[1],10)-1,LA(t,s)?(r.setUTCFullYear(t,s),r):new Date(NaN);if(i=bs.DDD.exec(e),i){r=new Date(0);var n=parseInt(i[1],10);return Lq(t,n)?(r.setUTCFullYear(t,0,n),r):new Date(NaN)}if(i=bs.MMDD.exec(e),i){r=new Date(0),s=parseInt(i[1],10)-1;var o=parseInt(i[2],10);return LA(t,s,o)?(r.setUTCFullYear(t,s,o),r):new Date(NaN)}if(i=bs.Www.exec(e),i)return a=parseInt(i[1],10)-1,zA(t,a)?BA(t,a):new Date(NaN);if(i=bs.WwwD.exec(e),i){a=parseInt(i[1],10)-1;var l=parseInt(i[2],10)-1;return zA(t,a,l)?BA(t,a,l):new Date(NaN)}return null}function Iq(e){var t,i,r;if(t=bs.HH.exec(e),t)return i=parseFloat(t[1].replace(",",".")),f0(i)?i%24*p0:NaN;if(t=bs.HHMM.exec(e),t)return i=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),f0(i,r)?i%24*p0+r*RA:NaN;if(t=bs.HHMMSS.exec(e),t){i=parseInt(t[1],10),r=parseInt(t[2],10);var s=parseFloat(t[3].replace(",","."));return f0(i,r,s)?i%24*p0+r*RA+s*1e3:NaN}return null}function BA(e,t,i){t=t||0,i=i||0;var r=new Date(0);r.setUTCFullYear(e,0,4);var s=r.getUTCDay()||7,a=t*7+i+1-s;return r.setUTCDate(r.getUTCDate()+a),r}var Rq=[31,28,31,30,31,30,31,31,30,31,30,31],Bq=[31,29,31,30,31,30,31,31,30,31,30,31];function sP(e){return e%400===0||e%4===0&&e%100!==0}function LA(e,t,i){if(t<0||t>11)return!1;if(i!=null){if(i<1)return!1;var r=sP(e);if(r&&i>Bq[t]||!r&&i>Rq[t])return!1}return!0}function Lq(e,t){if(t<1)return!1;var i=sP(e);return!(i&&t>366||!i&&t>365)}function zA(e,t,i){return!(t<0||t>52||i!=null&&(i<0||i>6))}function f0(e,t,i){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||i!=null&&(i<0||i>=60))}function zq(e,t,i){var r=Tq(e,i),s=rP(t,r,!0),a=new Date(r.getTime()-s),n=new Date(0);return n.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),n.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),n}function ws(e,t){return t.color(e)}function kA(e=new Date,t){let i=t.format,r=e.getSeconds(),s=e;t&&t.timeZone!==null&&(s=zq(new Date,t.timeZone));let a=s.getHours(),n=s.getMinutes(),o;t.format12h24h==="12ampm"&&(o=a>=12?"PM":"AM");let l=a;t.format12h24h!=="24"&&(l=a%12,l===0&&(l=12));let h,u;switch(i){case"HH:mm:ss":h=[l,n,r];break;case"HH:mm":h=[l,n];break;case"HH":h=[l],o=void 0;break;case"mm":h=[n],o=void 0;break;case"ss":h=[r],o=void 0;break;case"year":u=s.getFullYear();break;case"month":u=s.getMonth()+1;break;case"dayOfYear":u=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=s.getDate();break;case"secondOfDay":u=a*60*60+n*60+r;break;default:console.error("Unknown time format",i),u=0;break}return h!==void 0?{textValue:h,suffix:o}:u}function kq(e,t){switch(e.type){case"fresnel":return Uq(e,t);case"gradient":return Vq(e,t);case"depth":return jq(e,t);case"normal":return Gq(e,t);case"noise":return Hq(e,t);case"rainbow":return Wq(e,t);case"toon":return qq(e,t);case"outline":return Xq(e,t);case"transmission":return Yq(e,t);case"color":return Fq(e,t);case"pattern":return Qq(e,t)}}function Nq(e){return{type:e.type}}function ja(e,t){let{alpha:i,mode:r,isMask:s}=e,a=typeof i=="string"?(Number(t.getVariable(i))??100)/100:i;return{...Nq(e),alpha:a,mode:r,isMask:s}}function Fq(e,t){return{...ja(e,t),color:ws(e.color,t)}}function Uq(e,t){let{bias:i,scale:r,intensity:s,factor:a,color:n}=e;return{...ja(e,t),color:ws(n,t),bias:i,scale:r,intensity:s,factor:a}}function Vq(e,t){let{gradientType:i,smooth:r,colors:s,steps:a,angle:n,offset:o,morph:l}=e;return{...ja(e,t),gradientType:i,smooth:r,colors:s.map(h=>new Et(h[0],h[1],h[2],h[3])),num:s.length,steps:a,offset:new $(...o),morph:new $(...l),angle:n}}function jq(e,t){let{gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:o,direction:l,colors:h,steps:u,smooth:c}=e;return{...ja(e,t),gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:new I(...o),direction:l?new I(...l):new I(1,0,0),colors:h.map(d=>d!==void 0?new Et(d[0],d[1],d[2],d[3]):new Et(0,0,0,0)),steps:u.slice(0,h.length),smooth:c}}function Gq(e,t){let{cnormal:i}=e;return{...ja(e,t),cnormal:new I(i[0],i[1],i[2])}}function Hq(e,t){return{...ja(e,t),scale:e.scale,move:e.move,fA:new $(...e.fA),fB:new $(...e.fB),size:new I(...e.size),distortion:new $(...e.distortion),colorA:ws(e.colorA,t),colorB:ws(e.colorB,t),colorC:ws(e.colorC,t),colorD:ws(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function Wq(e,t){return{...ja(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new I(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new I(...e.offset)}}function qq(e,t){return{...ja(e,t),positioning:e.positioning,colors:e.colors.map(i=>new Et(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new I(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:ws(e.shadowColor,t),offset:new I(...e.offset)}}function Xq(e,t){return{...ja(e,t),outlineColor:ws(e.outlineColor,t),contourColor:ws(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new I(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function Yq(e,t){return{...ja(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function Qq(e,t){return{...ja(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new $(...e.offset),colorA:ws(e.colorA,t),colorB:ws(e.colorB,t),frequency:new $(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new $(...e.vertical),horizontal:new $(...e.horizontal),sides:e.sides}}var Zm=class extends Yr{},aP={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},nP={depth:["colors"]};function Zq(e,t,i){if(t==="isMask")return!0;let r=aP[e.type],s=nP[e.type];if(s!==void 0){let a=e.color;if(s.includes(t)){let n=a[t]?.value?.length;if(n!==void 0&&n!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function oP(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,a=e;if("image"in a){let n=a.image,o=t.image(n),l=r;l.image instanceof Lo||l.image.deref(),l.image=o}if("video"in a){let n=a.video,o=t.video(n),l=r;l.image instanceof Lo||l.image.deref(),l.image=o}if("wrapping"in a){let n=r;n.wrap=a.wrapping}if("repeat"in a||"offset"in a){let n="mat",o=i.uniforms[`f${i.id}_${n}`];"repeat"in a&&(o.repeat=a.repeat),"offset"in a&&(o.offset=a.offset),o.updateMatrix()}return s}function Kq(e,t,i,r){let s=!1;for(let[a,n]of Object.entries(e)){if(a==="bumpMap"||a==="roughnessMap"){s=!0;continue}if(!a||n===void 0)continue;if(hP(a,i,r,t)){a==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${a}`];if(!!o&&!(o instanceof nb))switch(s=s||Zq(i,a,n),o.constructor){case Wi:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Zm?o.value=new Yr(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case Xn:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Zm?o.value=new Yr(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Ur:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]);break}case aa:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case $n:{oP(n,t,i);break}case yl:{o.value=n.map(l=>new Et(...l));break}default:{o.value=n;break}}}return s}var Ql=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?e*100:e,i)??100)/100))??1,Vl=class{constructor(e,t,i,r,s){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let a in r)this.uniforms[`f${this.id}_${a}`]=r[a];for(let a in i)hP(a,this,i,s)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return on.createLigherLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.canvas(i.texture.image)??r.image(i.texture.image):r.video(i.texture.video),a=new w1(s,i.texture.wrapping),n=new tq(s),o=new iq(i.texture.repeat,i.texture.offset),l=new it(i.crop?1:0),h=new wi(i.projection??0),u=new wi(["x","y","z"].indexOf(i.axis)??0),c=new wi(i.side??0),d=new Ur(i.size?new $(i.size[0],i.size[1]):new $(100,100)),p=new it(i.blending??0),f=new it(Ql(i.alpha,r)),m=new wi(i.mode??0),v=new xs(i.isMask??!1),y=new ob(a,n,l,h,u,c,d,p,o,f,m,v),x=new Ci(y.calpha,"f");return new ji(e,t,i,{texture:a,textureSize:n,crop:l,projection:h,axis:u,side:c,size:d,blending:p,mat:o,alpha:f,mode:m,isMask:v},y,m,x,v,r)}else if(i.type==="matcap"){let s=r.image(i.texture.image),a=new w1(s,i.texture.wrapping),n=new it(Ql(i.alpha,r)),o=new wi(i.mode??0),l=new xs(i.isMask??!1),h=new V3(a,n,o,l),u=new Ci(h.calpha,"f");return new ji(e,t,i,{texture:a,alpha:n,mode:o,isMask:l},h,o,u,l,r)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new aa(new I(...i.offset)),a=new it(i.scale??10),n=new it(i.intensity??8),o=new it(i.movement??1),l=new wi(i.noiseType??0),h=new wi(i.voronoiStyle??0),u=new it(i.smoothness??.5),c=new it(i.seed??0),d=new it(i.highCut??1),p=new it(i.lowCut??0),f=new wi(i.quality??1),m=new $3(n,o,s,h,u,c,d,p,f,a,l);return new lP(e,t,i,{offset:s,scale:a,intensity:n,movement:o,noiseType:l,voronoiStyle:h,smoothness:u,seed:c,highCut:d,lowCut:p,quality:f},m,r)}else throw new Error;else return eX(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):Kq(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?oP(r.props,i.shared,this):!0;return!1}dispose(){if(Jq(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Lo||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},ji=class extends Vl{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,l),this.params=r,this.color=s,this.mode=a,this.alpha=n,this.isMask=o}},lP=class extends Vl{constructor(e,t,i,r,s,a){super(e,t,i,r,a),this.position=s}},on=class extends Vl{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.node=r}static createLigherLayer(e,t,i,r){let s,a=new it(Ql(i.alpha,r)),n=new wi(i.mode),o=new it(i.bumpMapIntensity),l=new it(Ql(i.alphaOverride,r)),h;if(!i.visible)s=new hb,h={};else if(i.category==="lambert"){s=new nq;let u=new Wi(r.color(i.emissive)??0),c=new xs(i.occlusion??!0);h={emissive:u,occlusion:c},s.emissive=u,s.occlusion=c}else if(i.category==="toon"){s=new hq;let u=new it(i.shininess??30),c=new Wi(r.color(i.specular)??1118481);h={shininess:u,specular:c},s.shininess=u,s.specular=c}else if(i.category==="physical"){s=new lq;let u=new it(i.roughness??.3),c=new it(i.metalness??0),d=new it(i.reflectivity??.5),p=new xs(i.occlusion??!0);h={roughness:u,metalness:c,reflectivity:d,occlusion:p},s.roughness=u,s.metalness=c,s.reflectivity=d,s.occlusion=p}else{s=new oq;let u=new it(i.shininess??30),c=new Wi(i.specular!==void 0?r.color(i.specular)??1118481:1118481),d=new xs(i.occlusion??!0);h={shininess:u,specular:c,occlusion:d},s.shininess=u,s.specular=c,s.occlusion=d}return s.alpha=new it(1),s.shadingAlpha=a,s.shadingBlend=n,s.bumpMapIntensity=o,s.alphaOverride=l,h.alpha=s.shadingAlpha,h.mode=s.shadingBlend,h.bumpMapIntensity=s.bumpMapIntensity,h.alphaOverride=s.alphaOverride,new on(e,t,i,s,h,r)}get category(){return this.node.category}};function Jq(e){let t=e instanceof Vl?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function ea(e){return{alpha:new it(e.alpha??1),mode:new wi(e.mode??0),isMask:new xs(e.isMask??!1)}}function $q(e,t,i,r,s){switch(e.type){case"color":{let a=new Wi(r.color??qs),n=ea(r),o=new _1(a,n.alpha),l=new Ci(o.calpha,"f");return new ji(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}case"fresnel":{let a=new Wi(r.color??16777215),n=new it(r.bias??.1),o=new it(r.scale??1),l=new it(r.intensity??2),h=new it(r.factor??1),u=ea(r),c=new rq(a,n,o,l,h,u.alpha,u.mode,u.isMask),d=new Ci(c.calpha,"f");return new ji(t,i,e,{color:a,bias:n,scale:o,intensity:l,factor:h,...u},c,u.mode,d,u.isMask,s)}case"rainbow":{let a=new it(r.filmThickness??30),n=new it(r.movement??0),o=new aa(r.wavelengths??new I(0,0,0)),l=new it(r.noiseStrength??0),h=new it(r.noiseScale??1),u=new aa(r.offset??new I(0,0,0)),c=ea(r),d=new X3(a,n,o,l,h,u,c.alpha,c.isMask),p=new Ci(d.calpha,"f");return new ji(t,i,e,{filmThickness:a,movement:n,wavelengths:o,noiseStrength:l,noiseScale:h,offset:u,...c},d,c.mode,p,c.isMask,s)}case"transmission":{let a=new it(r.thickness??10),n=new it(r.ior??1.5),o=new it(r.roughness??.5),l=bt.transmissionSize,h=bt.transmissionRenderTarget,u=bt.transmissionRenderTargetDepth,c=window.innerWidth,d=window.innerHeight,p=c>=d?new Ur(d/c,1):new Ur(1,c/d),f=ea(r),m=new K3(a,n,o,l,h,u,p,f.alpha),v=new Ci(m.calpha,"f");return new ji(t,i,e,{thickness:a,ior:n,roughness:o,aspectRatio:p,...f},m,f.mode,v,f.isMask,s)}case"toon":{let a=new wi(r.positioning??0),n;r.colors?n=new yl(r.colors.length,r.colors):(n=new yl(10,new Et(0,0,0,1)),n.value[1]=new Et(1,1,1,1));let o;r.steps?o=new vl(r.steps.length,r.steps):(o=new vl(10,1),o.value[0]=0);let l=new aa(r.source??new I(0,0,0)),h=new xs(r.isWorldSpace??!0),u=new it(r.noiseStrength??0),c=new it(r.noiseScale??1),d=new Xn(r.shadowColor),p=new aa(r.offset??new I(0,0,0)),f=ea(r),m=new Q3(a,n,o,l,h,u,c,d,p,f.alpha),v=new Ci(m.calpha,"f");return new ji(t,i,e,{positioning:a,colors:n,steps:o,source:l,isWorldSpace:h,noiseStrength:u,noiseScale:c,shadowColor:d,offset:p,...f},m,f.mode,v,f.isMask,s)}case"outline":{let a=new Wi(r.outlineColor??16777215),n=new Wi(r.contourColor??16777215),o=new it(r.outlineWidth??.1),l=new it(r.contourWidth??.1),h=new it(r.outlineThreshold??.1),u=new it(r.contourThreshold??.1),c=new it(r.outlineSmoothing??.1),d=new it(r.contourFrequency??.1),p=new aa(r.contourDirection??new I(0,1,0)),f=new xs(r.positionalLines??!1),m=new xs(r.compensation??!0),v=bt.normalRenderTarget,y=bt.normalRenderTargetDepth,x=bt.pixelRatioNode,b=bt.resolution,_=ea(r),S=new H3(a,n,o,l,h,u,c,d,p,f,m,b,v,y,x,_.alpha),M=new Ci(S.calpha,"f");return new ji(t,i,e,{outlineColor:a,contourColor:n,outlineWidth:o,contourWidth:l,outlineThreshold:h,contourThreshold:u,outlineSmoothing:c,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,..._},S,_.mode,M,_.isMask,s)}case"depth":{let a=new wi(r.gradientType??0),n=new xs(r.smooth??!1),o=new it(r.near??50),l=new it(r.far??200),h=new it(r.isVector??1),u=new it(r.isWorldSpace??0),c=new aa(r.origin??new I),d=new aa(r.direction??new I),p;r.colors?p=new yl(r.colors.length,r.colors):(p=new yl(2,new Et(0,0,0,1)),p.value[1]=new Et(1,1,1,1));let f;r.steps?f=new vl(r.steps.length,r.steps):(f=new vl(2,1),f.value[0]=0);let m=ea(r),v=new k3(a,n,o,l,h,u,c,d,p,f,m.alpha,m.isMask),y=new Ci(v.calpha,"f");return new ji(t,i,e,{gradientType:a,smooth:n,near:o,far:l,isVector:h,isWorldSpace:u,origin:c,direction:d,colors:p,steps:f,...m},v,m.mode,y,m.isMask,s)}case"noise":{let a=new it(r.scale??1),n=new aa(r.size??new I(100,100,100)),o=new it(r.move??1),l=new Ur(r.fA??new $(1.7,9.2)),h=new Ur(r.fB??new $(8.3,2.8)),u=new Ur(r.distortion??new $(1,1)),c=new Xn(r.colorA),d=new Xn(r.colorB),p=new Xn(r.colorC),f=new Xn(r.colorD),m=new wi(r.noiseType??0),v=new wi(r.voronoiStyle??0),y=new it(r.highCut??1),x=new it(r.lowCut??0),b=new it(r.smoothness??.5),_=new it(r.seed??.5),S=new wi(r.quality??1),M=ea(r),C=new j3(a,n,o,l,h,u,c,d,p,f,M.alpha,m,M.isMask,v,y,x,b,_,S),A=new Ci(C.calpha,"f");return new ji(t,i,e,{scale:a,size:n,move:o,fA:l,fB:h,distortion:u,colorA:c,colorB:d,colorC:p,colorD:f,noiseType:m,...M,voronoiStyle:v,highCut:y,lowCut:x,smoothness:b,seed:_,quality:S},C,M.mode,A,M.isMask,s)}case"normal":{let a=new aa(r.cnormal??new I(1,1,1)),n=ea(r),o=new z3(a,n.alpha),l=new Ci(o.calpha,"f");return new ji(t,i,e,{cnormal:a,...n},o,n.mode,l,n.isMask,s)}case"gradient":{let a=new wi(r.gradientType??0),n=new xs(r.smooth??!1),o;r.colors?o=new yl(r.colors.length,r.colors):(o=new yl(10,new Et(0,0,0,1)),o.value[1]=new Et(1,1,1,1));let l;r.steps?l=new vl(r.steps.length,r.steps):(l=new vl(10,1),l.value[0]=0);let h=new Ur(r.offset??new $(0,0)),u=new Ur(r.morph??new $(0,0)),c=new it(r.angle??0),d=ea(r),p=new F3(a,n,o,l,h,u,c,d.alpha,d.isMask),f=new Ci(p.calpha,"f");return new ji(t,i,e,{gradientType:a,smooth:n,colors:o,steps:l,offset:h,morph:u,angle:c,...d},p,d.mode,f,d.isMask,s)}case"pattern":{let a=new wi(r.style??0),n=new wi(r.projection??0),o=new wi(["x","y","z"].indexOf(r.axis)??0),l=new it(r.blending??0),h=new Ur(r.offset??new $(0,0)),u=new Xn(r.colorA),c=new Xn(r.colorB),d=new Ur(r.frequency??new $(10,10)),p=new it(r.size??.5),f=new it(r.variation??0),m=new it(r.smoothness??.5),v=new it(r.zigzag??0),y=new it(r.rotation??0),x=new Ur(r.vertical??new $(0,1)),b=new Ur(r.horizontal??new $(0,1)),_=new wi(r.sides??6),S=ea(r),M=new W3(a,n,o,l,h,u,c,d,p,f,m,v,y,x,b,_,S.alpha,S.isMask),C=new Ci(M.calpha,"f");return new ji(t,i,e,{style:a,projection:n,axis:o,blending:l,offset:h,colorA:u,colorB:c,frequency:d,size:p,variation:f,smoothness:m,zigzag:v,rotation:y,vertical:x,horizontal:b,sides:_,...S},M,S.mode,C,S.isMask,s)}default:{let a=new Wi(1,0,0,1),n=ea(r),o=new _1(a,n.alpha),l=new Ci(o.calpha,"f");return new ji(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}}}function eX(e,t,i,r){let s=kq(i,r);return $q(i,e,t,s,r)}function hP(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let s=t.uniforms[`f${t.id}_intensity`];return s?(s.value=i.intensity*(i.visible?1:0),s):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let s=t.uniforms[`f${t.id}_alpha`];if(!s)return;if(s.value=Ql(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let a=t.uniforms[`f${t.id}_compensation`];a&&(a.value=i.compensation&&i.visible)}return s}}function sc(e,t){let i=0,r=e.layers.find(s=>s.data.type==="light");if(r){let s=r.data,a=Number(t.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?a/100:s.alphaOverride)<1)return!0}for(let s of e.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let a=s.data.visible?s.data.alpha:0;if(typeof a=="string"&&(a=Math.max(0,Math.min(1,Number(t.getVariable(a)??100)/100))),a===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let n of s.data.colors)if(n[3]<1){a=n[3];break}}else if(a===1&&s.data.type==="noise"){let n=t.color(s.data.colorA).a,o=t.color(s.data.colorB).a,l=t.color(s.data.colorC).a,h=t.color(s.data.colorD).a,u=Math.min(n,Math.min(o,Math.min(l,h)));u<1&&(a=u)}i+=(1-i)*a}}return i<1}var Jo=class extends ni{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.cacheKey="",this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},tX=class extends Jo{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i){return this.root.getFlavor(e,t,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},cb=class extends Jo{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,i){let r=i?6:(e?3:0)+t;if(r===0)return this;this.flavors===void 0&&(this.flavors=[]),r-=1;let s=this.flavors[r];return s===void 0&&(s=new tX(e,t,i,this),this.flavors[r]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t,i=!1){(this.data!==e||i)&&this.reset0(e,t)}reset0(e,t){this.data=e;let i=e.layers??ss.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>Vl.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=sc(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.transparent=sc(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],s=e[2];if(r&&s){let a=this.layers.find(n=>n.uuid===r);a?.hasValue(s)&&(s==="alpha"?(this.transparent=sc(this.data,i.shared),a.setValue(s,Math.max(0,Math.min(Number(t)/100,1)))):a.setValue(s,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(t=>t instanceof on),this.lightLayer===void 0&&(this.lightLayer=new on(0,"",{...Tr.defaultData("light","phong"),visible:!1},new hb,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(s=>s instanceof on);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;s<this.layers.length;++s){let a=this.layers[s];a instanceof ji&&a.color instanceof ob&&(a.uuid===i&&(e.node.bumpMap=a.color),a.uuid===r&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,i){if(t!==void 0?this.data=t:t=this.data,this.transparent=sc(t,i.shared),e.path[0]==="layers"){this.data=t;let r=i.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let a=Vl.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,a),i.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let a=this.layers.findIndex(o=>o.uuid===e.id),n=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,n),i.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(i.shared)}else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(n=>n.uuid===s);if(a){let n=t.layers.data(s),o;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?o={...e.props,alpha:Ql(e.props.alpha,r,["material",this.uuid,"layer",s,"alpha"])}:o={...e.props,alphaOverride:Ql(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},n,i)){let l=Vl.create(this.layerIdGen++,s,n,r);this.layers.splice(this.layers.findIndex(h=>h.uuid===s),1,l),this.onUpdate(i.shared)}}}}else this.reset(t,i)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ji?t.color.mask=void 0:t instanceof on&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ji&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof on?r.node.mask=new Ps(t.color,t.alpha,Ps.MUL):r instanceof ji&&(r.isMask.value||(r.color.mask=new Ps(t.color,t.alpha,Ps.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof ji),t=this.layers.findIndex(i=>i instanceof on);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof ji){if(s.isMask.value)continue;i=new TA(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Ci("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof on);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof ji){if(r.isMask.value)continue;e=new TA(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof lP);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Ps(t,e[i].position,Ps.ADD),t=new Ps(t,new it(.5).setReadonly(!0),Ps.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,a)=>Math.min(Math.max(r,s),a);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let i=(aP[t.type]??[]).map(o=>t[o]),r=(nP[t.type]??[]).map(o=>t[o]?.length??0),s=[...i,...r],a="isMask"in t&&t.isMask,n=`"${t.type}-${t.visible}-${a}"`;s.length?e+=`[${n}, "${s.join('","')}"],`:e+=n}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new I3;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ji){let t=e.params.texture;if(t instanceof w1&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Jo.prototype,{properties:{get:function(){return this.fragment.properties}}});var M1=class extends cb{constructor(e,t,i){super(e,t,!1),this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},iX=Br(VO()),NA=new Map;function rX(e){if(typeof e=="string")return e;let t=NA.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},NA.set(e,t)),t.url}var ed=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:rX(e),format:"wav"},this.sound=new iX.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},sX=class{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new cm,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath?.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,f,m,v){let y=p.x,x=f.x,b=m.x,_=v.x,S=p.y,M=f.y,C=m.y,A=v.y,T=(_-b)*(S-C)-(A-C)*(y-b),P=(x-y)*(S-C)-(M-S)*(y-b),R=(A-C)*(x-y)-(_-b)*(M-S),z=T/R,N=P/R;if(R===0&&T!==0||z<=0||z>=1||N<0||N>1)return null;if(T===0&&R===0){for(let B=0;B<2;B++)if(r(B===0?m:v,p,f),t.loc===e.ORIGIN){let V=B===0?m:v;return{x:V.x,y:V.y,t:t.t}}else if(t.loc===e.BETWEEN){let V=+(y+t.t*(x-y)).toPrecision(10),H=+(S+t.t*(M-S)).toPrecision(10);return{x:V,y:H,t:t.t}}return null}else{for(let H=0;H<2;H++)if(r(H===0?m:v,p,f),t.loc===e.ORIGIN){let X=H===0?m:v;return{x:X.x,y:X.y,t:t.t}}let B=+(y+z*(x-y)).toPrecision(10),V=+(S+z*(M-S)).toPrecision(10);return{x:B,y:V,t:z}}}function r(p,f,m){let v=m.x-f.x,y=m.y-f.y,x=p.x-f.x,b=p.y-f.y,_=v*b-x*y;if(p.x===f.x&&p.y===f.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===m.x&&p.y===m.y){t.loc=e.DESTINATION,t.t=1;return}if(_<-Number.EPSILON){t.loc=e.LEFT;return}if(_>Number.EPSILON){t.loc=e.RIGHT;return}if(v*x<0||y*b<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+y*y)<Math.sqrt(x*x+b*b)){t.loc=e.BEYOND;return}let S;v!==0?S=x/v:S=b/y,t.loc=e.BETWEEN,t.t=S}function s(p,f){let m=[],v=[];for(let y=1;y<p.length;y++){let x=p[y-1],b=p[y];for(let _=1;_<f.length;_++){let S=f[_-1],M=f[_],C=i(x,b,S,M);C!==null&&m.find(A=>A.t<=C.t+Number.EPSILON&&A.t>=C.t-Number.EPSILON)===void 0&&(m.push(C),v.push(new $(C.x,C.y)))}}return v}function a(p,f,m){let v=new $;f.getCenter(v);let y=[];return m.forEach(x=>{x.boundingBox.containsPoint(v)&&s(p,x.points).forEach(b=>{y.push({identifier:x.identifier,isCW:x.isCW,point:b})})}),y.sort((x,b)=>x.point.x-b.point.x),y}function n(p,f,m,v,y){(y==null||y==="")&&(y="nonzero");let x=new $;p.boundingBox.getCenter(x);let b=[new $(m,x.y),new $(v,x.y)],_=a(b,p.boundingBox,f);_.sort((P,R)=>P.point.x-R.point.x);let S=[],M=[];_.forEach(P=>{P.identifier===p.identifier?S.push(P):M.push(P)});let C=S[0].point.x,A=[],T=0;for(;T<M.length&&M[T].point.x<C;)A.length>0&&A[A.length-1]===M[T].identifier?A.pop():A.push(M[T].identifier),T++;if(A.push(p.identifier),y==="evenodd"){let P=A.length%2===0,R=A[A.length-2];return{identifier:p.identifier,isHole:P,for:R}}else if(y==="nonzero"){let P=!0,R=null,z=null;for(let N=0;N<A.length;N++){let B=A[N];f[B]&&(P?(z=f[B].isCW,P=!1,R=B):z!==f[B].isCW&&(z=f[B].isCW,P=!0))}return{identifier:p.identifier,isHole:P,for:R}}else console.warn('fill-rule: "'+y+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,u=[];this.subPaths.forEach(p=>{let f=p.getPoints(),m=-999999999,v=999999999,y=-999999999,x=999999999;for(let b=0;b<f.length;b++){let _=f[b];_.y>m&&(m=_.y),_.y<v&&(v=_.y),_.x>y&&(y=_.x),_.x<x&&(x=_.x)}h<=y&&(h=y+1),l>=x&&(l=x-1),f.length&&u.push({curves:p.curves,points:f,isCW:dC.isClockWise(f),identifier:o++,boundingBox:new AC(new $(x,v),new $(y,m))})});let c=u.map(p=>n(p,u,l,h,this.userData?.style.fillRule)),d=[];return u.forEach(p=>{let f=c[p.identifier];if(f&&!f.isHole){let m=new um;m.curves=p.curves,c.filter(v=>v?.isHole&&v.for===p.identifier).forEach(v=>{if(v){let y=u[v.identifier],x=new cm;x.curves=y.curves,m.holes.push(x)}}),d.push(m)}}),d}},cP=!1,uP,FA=new Promise(e=>{uP=e}),UA=!1,Af;function aX(){if(cP=!0,UA)return;if(Af)return Af;async function e(){let t=await import("./opentype.js");uP(t),UA=!0}return Af=e(),Af}var nX=class{async load(e,t,i=()=>{}){let{load:r}=await FA;r(e,(s,a)=>{s||!a?i(s??"Something went wrong"):t(a)})}async parse(e){let{parse:t,Bidi:i}=await FA;try{let r=t(e),s=new i,a=n=>r.charToGlyphIndex(n.char);return s.registerModifier("glyphIndex",null,a),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function oX(e){return await(await fetch(e)).arrayBuffer()}var lX=new nX;async function VA(e){let t,i,r=!1;if(e.url?(t=await oX(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t)if(cP){let s=await lX.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}else return{font:void 0,url:i,intercepted:r,arr:t,bidi:null}}function hX(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var cX=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=VA(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=VA(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,a=[],n=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,u=String.fromCharCode(i[l].unicode),c=s[n];if(hX(h,c)||o)a.push({char:u,index:h,replacements:[c.state.glyphIndex],replacementChars:[c.char]}),n++;else{let d=c.char,p="",f=[c.state.glyphIndex],m=[],v=!1;for(;!v;)n++,p=t.charAt(n),d+=p,f.push(e.charToGlyphIndex(p)),m=e.stringToGlyphs(d),m.length===1&&m[0].index===h&&(v=!0),n>t.length&&(v=!0);a.push({char:u,index:h,replacements:f,replacementChars:Array.from(d)}),n++}}return a}generateShapes(e,t){if(!this._isLoaded)return;let i=this.font,r=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,a=e.map(y=>this.getTextWidth(y,t)),n=t.width,o=this.getCharWidth(`
|
|
5376
|
+
`)}return t}},cq=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;)this.dispose(t.src,t.data),this.cache.delete(t.src),t=t.next,t.prev=this.head,this.head.next=t;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){return this.cache.get(e)?.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}},uq=class extends cq{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},c0;function dq(e){return typeof e=="string"?e:(c0||(c0=new uq),c0.load(e))}var pq=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},fq=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},tP=class extends pq{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isCanvas=!1,this._cache={[1e3]:{},[1001]:{},[1002]:{}},this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let s of Object.values(r))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(s=>{i.onloadend=a=>{r=a.target?.result,s(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=dq(e),this.img.onload=t}getTexture(e,t=1008){let i=this._cache[e][t];if(i)return i;{let r;return this.isCanvas&&(r=new ak(this.img,void 0,e,e,void 0,t)),this.isVideo?r=new sk(this.img,void 0,e,e):r=new Li(this.img,void 0,e,e,void 0,t),this.loaded&&(r.needsUpdate=!0),this._cache[e][t]=r,r}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let i of Object.values(t))i&&(i.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))r?.dispose(),this._cache[e][i]=void 0}dispose(){super.dispose(),this.disposeTextures()}},Lo=class extends tP{};function mq(e,t){var i=xq(t);return i.formatToParts?vq(i,e):yq(i,e)}var gq={year:0,month:1,day:2,hour:3,minute:4,second:5};function vq(e,t){try{for(var i=e.formatToParts(t),r=[],s=0;s<i.length;s++){var a=gq[i[s].type];a>=0&&(r[a]=parseInt(i[s].value,10))}return r}catch(n){if(n instanceof RangeError)return[NaN];throw n}}function yq(e,t){var i=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(i);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var u0={};function xq(e){if(!u0[e]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),i=t==="06/25/2014, 00:00:00"||t==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";u0[e]=i?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return u0[e]}function iP(e,t,i,r,s,a,n){var o=new Date(0);return o.setUTCFullYear(e,t,i),o.setUTCHours(r,s,a,n),o}var PA=36e5,bq=6e4,d0={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function rP(e,t,i){var r,s;if(!e||(r=d0.timezoneZ.exec(e),r))return 0;var a;if(r=d0.timezoneHH.exec(e),r)return a=parseInt(r[1],10),DA(a)?-(a*PA):NaN;if(r=d0.timezoneHHMM.exec(e),r){a=parseInt(r[1],10);var n=parseInt(r[2],10);return DA(a,n)?(s=Math.abs(a)*PA+n*bq,a>0?-s:s):NaN}if(Sq(e)){t=new Date(t||Date.now());var o=i?t:wq(t),l=A1(o,e),h=i?l:_q(t,l,e);return-h}return NaN}function wq(e){return iP(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function A1(e,t){var i=mq(e,t),r=iP(i[0],i[1]-1,i[2],i[3]%24,i[4],i[5],0).getTime(),s=e.getTime(),a=s%1e3;return s-=a>=0?a:1e3+a,r-s}function _q(e,t,i){var r=e.getTime(),s=r-t,a=A1(new Date(s),i);if(t===a)return t;s-=a-t;var n=A1(new Date(s),i);return a===n?a:Math.max(a,n)}function DA(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var OA={};function Sq(e){if(OA[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),OA[e]=!0,!0}catch{return!1}}var Aq=Br(FO(),1),IA=Br(UO(),1),Mq=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,Eq=Mq,p0=36e5,RA=6e4,Cq=2,bs={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:Eq};function Tq(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);var i=t||{},r=i.additionalDigits==null?Cq:(0,Aq.default)(i.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var s=Pq(e),a=Dq(s.date,r),n=a.year,o=a.restDateString,l=Oq(o,n);if(isNaN(l))return new Date(NaN);if(l){var h=l.getTime(),u=0,c;if(s.time&&(u=Iq(s.time),isNaN(u)))return new Date(NaN);if(s.timeZone||i.timeZone){if(c=rP(s.timeZone||i.timeZone,new Date(h+u)),isNaN(c))return new Date(NaN)}else c=(0,IA.default)(new Date(h+u)),c=(0,IA.default)(new Date(h+u+c));return new Date(h+u+c)}else return new Date(NaN)}function Pq(e){var t={},i=bs.dateTimePattern.exec(e),r;if(i?(t.date=i[1],r=i[3]):(i=bs.datePattern.exec(e),i?(t.date=i[1],r=i[2]):(t.date=null,r=e)),r){var s=bs.timeZone.exec(r);s?(t.time=r.replace(s[1],""),t.timeZone=s[1].trim()):t.time=r}return t}function Dq(e,t){var i=bs.YYY[t],r=bs.YYYYY[t],s;if(s=bs.YYYY.exec(e)||r.exec(e),s){var a=s[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(s=bs.YY.exec(e)||i.exec(e),s){var n=s[1];return{year:parseInt(n,10)*100,restDateString:e.slice(n.length)}}return{year:null}}function Oq(e,t){if(t===null)return null;var i,r,s,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(i=bs.MM.exec(e),i)return r=new Date(0),s=parseInt(i[1],10)-1,LA(t,s)?(r.setUTCFullYear(t,s),r):new Date(NaN);if(i=bs.DDD.exec(e),i){r=new Date(0);var n=parseInt(i[1],10);return Lq(t,n)?(r.setUTCFullYear(t,0,n),r):new Date(NaN)}if(i=bs.MMDD.exec(e),i){r=new Date(0),s=parseInt(i[1],10)-1;var o=parseInt(i[2],10);return LA(t,s,o)?(r.setUTCFullYear(t,s,o),r):new Date(NaN)}if(i=bs.Www.exec(e),i)return a=parseInt(i[1],10)-1,zA(t,a)?BA(t,a):new Date(NaN);if(i=bs.WwwD.exec(e),i){a=parseInt(i[1],10)-1;var l=parseInt(i[2],10)-1;return zA(t,a,l)?BA(t,a,l):new Date(NaN)}return null}function Iq(e){var t,i,r;if(t=bs.HH.exec(e),t)return i=parseFloat(t[1].replace(",",".")),f0(i)?i%24*p0:NaN;if(t=bs.HHMM.exec(e),t)return i=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),f0(i,r)?i%24*p0+r*RA:NaN;if(t=bs.HHMMSS.exec(e),t){i=parseInt(t[1],10),r=parseInt(t[2],10);var s=parseFloat(t[3].replace(",","."));return f0(i,r,s)?i%24*p0+r*RA+s*1e3:NaN}return null}function BA(e,t,i){t=t||0,i=i||0;var r=new Date(0);r.setUTCFullYear(e,0,4);var s=r.getUTCDay()||7,a=t*7+i+1-s;return r.setUTCDate(r.getUTCDate()+a),r}var Rq=[31,28,31,30,31,30,31,31,30,31,30,31],Bq=[31,29,31,30,31,30,31,31,30,31,30,31];function sP(e){return e%400===0||e%4===0&&e%100!==0}function LA(e,t,i){if(t<0||t>11)return!1;if(i!=null){if(i<1)return!1;var r=sP(e);if(r&&i>Bq[t]||!r&&i>Rq[t])return!1}return!0}function Lq(e,t){if(t<1)return!1;var i=sP(e);return!(i&&t>366||!i&&t>365)}function zA(e,t,i){return!(t<0||t>52||i!=null&&(i<0||i>6))}function f0(e,t,i){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||i!=null&&(i<0||i>=60))}function zq(e,t,i){var r=Tq(e,i),s=rP(t,r,!0),a=new Date(r.getTime()-s),n=new Date(0);return n.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),n.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),n}function ws(e,t){return t.color(e)}function kA(e=new Date,t){let i=t.format,r=e.getSeconds(),s=e;t&&t.timeZone!==null&&(s=zq(new Date,t.timeZone));let a=s.getHours(),n=s.getMinutes(),o;t.format12h24h==="12ampm"&&(o=a>=12?"PM":"AM");let l=a;t.format12h24h!=="24"&&(l=a%12,l===0&&(l=12));let h,u;switch(i){case"HH:mm:ss":h=[l,n,r];break;case"HH:mm":h=[l,n];break;case"HH":h=[l],o=void 0;break;case"mm":h=[n],o=void 0;break;case"ss":h=[r],o=void 0;break;case"year":u=s.getFullYear();break;case"month":u=s.getMonth()+1;break;case"dayOfYear":u=Math.floor((s.getTime()-new Date(s.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=s.getDate();break;case"secondOfDay":u=a*60*60+n*60+r;break;default:console.error("Unknown time format",i),u=0;break}return h!==void 0?{textValue:h,suffix:o}:u}function kq(e,t){switch(e.type){case"fresnel":return Uq(e,t);case"gradient":return Vq(e,t);case"depth":return jq(e,t);case"normal":return Gq(e,t);case"noise":return Hq(e,t);case"rainbow":return Wq(e,t);case"toon":return qq(e,t);case"outline":return Xq(e,t);case"transmission":return Yq(e,t);case"color":return Fq(e,t);case"pattern":return Qq(e,t)}}function Nq(e){return{type:e.type}}function ja(e,t){let{alpha:i,mode:r,isMask:s}=e,a=typeof i=="string"?(Number(t.getVariable(i))??100)/100:i;return{...Nq(e),alpha:a,mode:r,isMask:s}}function Fq(e,t){return{...ja(e,t),color:ws(e.color,t)}}function Uq(e,t){let{bias:i,scale:r,intensity:s,factor:a,color:n}=e;return{...ja(e,t),color:ws(n,t),bias:i,scale:r,intensity:s,factor:a}}function Vq(e,t){let{gradientType:i,smooth:r,colors:s,steps:a,angle:n,offset:o,morph:l}=e;return{...ja(e,t),gradientType:i,smooth:r,colors:s.map(h=>new Et(h[0],h[1],h[2],h[3])),num:s.length,steps:a,offset:new $(...o),morph:new $(...l),angle:n}}function jq(e,t){let{gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:o,direction:l,colors:h,steps:u,smooth:c}=e;return{...ja(e,t),gradientType:i,near:r,far:s,isVector:a,isWorldSpace:n,origin:new I(...o),direction:l?new I(...l):new I(1,0,0),colors:h.map(d=>d!==void 0?new Et(d[0],d[1],d[2],d[3]):new Et(0,0,0,0)),steps:u.slice(0,h.length),smooth:c}}function Gq(e,t){let{cnormal:i}=e;return{...ja(e,t),cnormal:new I(i[0],i[1],i[2])}}function Hq(e,t){return{...ja(e,t),scale:e.scale,move:e.move,fA:new $(...e.fA),fB:new $(...e.fB),size:new I(...e.size),distortion:new $(...e.distortion),colorA:ws(e.colorA,t),colorB:ws(e.colorB,t),colorC:ws(e.colorC,t),colorD:ws(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function Wq(e,t){return{...ja(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new I(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new I(...e.offset)}}function qq(e,t){return{...ja(e,t),positioning:e.positioning,colors:e.colors.map(i=>new Et(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new I(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:ws(e.shadowColor,t),offset:new I(...e.offset)}}function Xq(e,t){return{...ja(e,t),outlineColor:ws(e.outlineColor,t),contourColor:ws(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new I(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function Yq(e,t){return{...ja(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function Qq(e,t){return{...ja(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new $(...e.offset),colorA:ws(e.colorA,t),colorB:ws(e.colorB,t),frequency:new $(...e.frequency),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new $(...e.vertical),horizontal:new $(...e.horizontal),sides:e.sides}}var Zm=class extends Yr{},aP={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},nP={depth:["colors"]};function Zq(e,t,i){if(t==="isMask")return!0;let r=aP[e.type],s=nP[e.type];if(s!==void 0){let a=e.color;if(s.includes(t)){let n=a[t]?.value?.length;if(n!==void 0&&n!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function oP(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let s=!1,a=e;if("image"in a){let n=a.image,o=t.image(n),l=r;l.image instanceof Lo||l.image.deref(),l.image=o}if("video"in a){let n=a.video,o=t.video(n),l=r;l.image instanceof Lo||l.image.deref(),l.image=o}if("wrapping"in a){let n=r;n.wrap=a.wrapping}if("minFilter"in a){let n=r;n.minFilter=a.minFilter}if("repeat"in a||"offset"in a){let n="mat",o=i.uniforms[`f${i.id}_${n}`];"repeat"in a&&(o.repeat=a.repeat),"offset"in a&&(o.offset=a.offset),o.updateMatrix()}return s}function Kq(e,t,i,r){let s=!1;for(let[a,n]of Object.entries(e)){if(a==="bumpMap"||a==="roughnessMap"){s=!0;continue}if(!a||n===void 0)continue;if(hP(a,i,r,t)){a==="visible"&&i.type==="light"&&(s=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${a}`];if(!!o&&!(o instanceof nb))switch(s=s||Zq(i,a,n),o.constructor){case Wi:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Zm?o.value=new Yr(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case Xn:if(typeof n=="string"){let l=t.getColor(n);l&&(o.value=l);break}else{let l=n;o.value instanceof Zm?o.value=new Yr(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Ur:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]);break}case aa:{let l=n;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case $n:{oP(n,t,i);break}case yl:{o.value=n.map(l=>new Et(...l));break}default:{o.value=n;break}}}return s}var Ql=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?e*100:e,i)??100)/100))??1,Vl=class{constructor(e,t,i,r,s){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let a in r)this.uniforms[`f${this.id}_${a}`]=r[a];for(let a in i)hP(a,this,i,s)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return on.createLigherLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let s=i.type==="texture"?r.canvas(i.texture.image)??r.image(i.texture.image):r.video(i.texture.video),a=new w1(s,i.texture.wrapping,i.texture.minFilter??1008),n=new tq(s),o=new iq(i.texture.repeat,i.texture.offset),l=new it(i.crop?1:0),h=new wi(i.projection??0),u=new wi(["x","y","z"].indexOf(i.axis)??0),c=new wi(i.side??0),d=new Ur(i.size?new $(i.size[0],i.size[1]):new $(100,100)),p=new it(i.blending??0),f=new it(Ql(i.alpha,r)),m=new wi(i.mode??0),v=new xs(i.isMask??!1),y=new ob(a,n,l,h,u,c,d,p,o,f,m,v),x=new Ci(y.calpha,"f");return new ji(e,t,i,{texture:a,textureSize:n,crop:l,projection:h,axis:u,side:c,size:d,blending:p,mat:o,alpha:f,mode:m,isMask:v},y,m,x,v,r)}else if(i.type==="matcap"){let s=r.image(i.texture.image),a=new w1(s,i.texture.wrapping,i.texture.minFilter??1008),n=new it(Ql(i.alpha,r)),o=new wi(i.mode??0),l=new xs(i.isMask??!1),h=new V3(a,n,o,l),u=new Ci(h.calpha,"f");return new ji(e,t,i,{texture:a,alpha:n,mode:o,isMask:l},h,o,u,l,r)}else if(i.type==="displace")if(i.displacementType==="noise"){let s=new aa(new I(...i.offset)),a=new it(i.scale??10),n=new it(i.intensity??8),o=new it(i.movement??1),l=new wi(i.noiseType??0),h=new wi(i.voronoiStyle??0),u=new it(i.smoothness??.5),c=new it(i.seed??0),d=new it(i.highCut??1),p=new it(i.lowCut??0),f=new wi(i.quality??1),m=new $3(n,o,s,h,u,c,d,p,f,a,l);return new lP(e,t,i,{offset:s,scale:a,intensity:n,movement:o,noiseType:l,voronoiStyle:h,smoothness:u,seed:c,highCut:d,lowCut:p,quality:f},m,r)}else throw new Error;else return eX(e,t,i,r)}updateByOp(e,t,i){let r=e;if(r.path[0]===void 0){if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):Kq(r.props,i.shared,this,t)}else if(r.path[0]==="texture")return"texture"in t||"video"in t?oP(r.props,i.shared,this):!0;return!1}dispose(){if(Jq(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof Lo||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},ji=class extends Vl{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,l),this.params=r,this.color=s,this.mode=a,this.alpha=n,this.isMask=o}},lP=class extends Vl{constructor(e,t,i,r,s,a){super(e,t,i,r,a),this.position=s}},on=class extends Vl{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.node=r}static createLigherLayer(e,t,i,r){let s,a=new it(Ql(i.alpha,r)),n=new wi(i.mode),o=new it(i.bumpMapIntensity),l=new it(Ql(i.alphaOverride,r)),h;if(!i.visible)s=new hb,h={};else if(i.category==="lambert"){s=new nq;let u=new Wi(r.color(i.emissive)??0),c=new xs(i.occlusion??!0);h={emissive:u,occlusion:c},s.emissive=u,s.occlusion=c}else if(i.category==="toon"){s=new hq;let u=new it(i.shininess??30),c=new Wi(r.color(i.specular)??1118481);h={shininess:u,specular:c},s.shininess=u,s.specular=c}else if(i.category==="physical"){s=new lq;let u=new it(i.roughness??.3),c=new it(i.metalness??0),d=new it(i.reflectivity??.5),p=new xs(i.occlusion??!0);h={roughness:u,metalness:c,reflectivity:d,occlusion:p},s.roughness=u,s.metalness=c,s.reflectivity=d,s.occlusion=p}else{s=new oq;let u=new it(i.shininess??30),c=new Wi(i.specular!==void 0?r.color(i.specular)??1118481:1118481),d=new xs(i.occlusion??!0);h={shininess:u,specular:c,occlusion:d},s.shininess=u,s.specular=c,s.occlusion=d}return s.alpha=new it(1),s.shadingAlpha=a,s.shadingBlend=n,s.bumpMapIntensity=o,s.alphaOverride=l,h.alpha=s.shadingAlpha,h.mode=s.shadingBlend,h.bumpMapIntensity=s.bumpMapIntensity,h.alphaOverride=s.alphaOverride,new on(e,t,i,s,h,r)}get category(){return this.node.category}};function Jq(e){let t=e instanceof Vl?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function ea(e){return{alpha:new it(e.alpha??1),mode:new wi(e.mode??0),isMask:new xs(e.isMask??!1)}}function $q(e,t,i,r,s){switch(e.type){case"color":{let a=new Wi(r.color??qs),n=ea(r),o=new _1(a,n.alpha),l=new Ci(o.calpha,"f");return new ji(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}case"fresnel":{let a=new Wi(r.color??16777215),n=new it(r.bias??.1),o=new it(r.scale??1),l=new it(r.intensity??2),h=new it(r.factor??1),u=ea(r),c=new rq(a,n,o,l,h,u.alpha,u.mode,u.isMask),d=new Ci(c.calpha,"f");return new ji(t,i,e,{color:a,bias:n,scale:o,intensity:l,factor:h,...u},c,u.mode,d,u.isMask,s)}case"rainbow":{let a=new it(r.filmThickness??30),n=new it(r.movement??0),o=new aa(r.wavelengths??new I(0,0,0)),l=new it(r.noiseStrength??0),h=new it(r.noiseScale??1),u=new aa(r.offset??new I(0,0,0)),c=ea(r),d=new X3(a,n,o,l,h,u,c.alpha,c.isMask),p=new Ci(d.calpha,"f");return new ji(t,i,e,{filmThickness:a,movement:n,wavelengths:o,noiseStrength:l,noiseScale:h,offset:u,...c},d,c.mode,p,c.isMask,s)}case"transmission":{let a=new it(r.thickness??10),n=new it(r.ior??1.5),o=new it(r.roughness??.5),l=bt.transmissionSize,h=bt.transmissionRenderTarget,u=bt.transmissionRenderTargetDepth,c=window.innerWidth,d=window.innerHeight,p=c>=d?new Ur(d/c,1):new Ur(1,c/d),f=ea(r),m=new K3(a,n,o,l,h,u,p,f.alpha),v=new Ci(m.calpha,"f");return new ji(t,i,e,{thickness:a,ior:n,roughness:o,aspectRatio:p,...f},m,f.mode,v,f.isMask,s)}case"toon":{let a=new wi(r.positioning??0),n;r.colors?n=new yl(r.colors.length,r.colors):(n=new yl(10,new Et(0,0,0,1)),n.value[1]=new Et(1,1,1,1));let o;r.steps?o=new vl(r.steps.length,r.steps):(o=new vl(10,1),o.value[0]=0);let l=new aa(r.source??new I(0,0,0)),h=new xs(r.isWorldSpace??!0),u=new it(r.noiseStrength??0),c=new it(r.noiseScale??1),d=new Xn(r.shadowColor),p=new aa(r.offset??new I(0,0,0)),f=ea(r),m=new Q3(a,n,o,l,h,u,c,d,p,f.alpha),v=new Ci(m.calpha,"f");return new ji(t,i,e,{positioning:a,colors:n,steps:o,source:l,isWorldSpace:h,noiseStrength:u,noiseScale:c,shadowColor:d,offset:p,...f},m,f.mode,v,f.isMask,s)}case"outline":{let a=new Wi(r.outlineColor??16777215),n=new Wi(r.contourColor??16777215),o=new it(r.outlineWidth??.1),l=new it(r.contourWidth??.1),h=new it(r.outlineThreshold??.1),u=new it(r.contourThreshold??.1),c=new it(r.outlineSmoothing??.1),d=new it(r.contourFrequency??.1),p=new aa(r.contourDirection??new I(0,1,0)),f=new xs(r.positionalLines??!1),m=new xs(r.compensation??!0),v=bt.normalRenderTarget,y=bt.normalRenderTargetDepth,x=bt.pixelRatioNode,b=bt.resolution,_=ea(r),S=new H3(a,n,o,l,h,u,c,d,p,f,m,b,v,y,x,_.alpha),M=new Ci(S.calpha,"f");return new ji(t,i,e,{outlineColor:a,contourColor:n,outlineWidth:o,contourWidth:l,outlineThreshold:h,contourThreshold:u,outlineSmoothing:c,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,..._},S,_.mode,M,_.isMask,s)}case"depth":{let a=new wi(r.gradientType??0),n=new xs(r.smooth??!1),o=new it(r.near??50),l=new it(r.far??200),h=new it(r.isVector??1),u=new it(r.isWorldSpace??0),c=new aa(r.origin??new I),d=new aa(r.direction??new I),p;r.colors?p=new yl(r.colors.length,r.colors):(p=new yl(2,new Et(0,0,0,1)),p.value[1]=new Et(1,1,1,1));let f;r.steps?f=new vl(r.steps.length,r.steps):(f=new vl(2,1),f.value[0]=0);let m=ea(r),v=new k3(a,n,o,l,h,u,c,d,p,f,m.alpha,m.isMask),y=new Ci(v.calpha,"f");return new ji(t,i,e,{gradientType:a,smooth:n,near:o,far:l,isVector:h,isWorldSpace:u,origin:c,direction:d,colors:p,steps:f,...m},v,m.mode,y,m.isMask,s)}case"noise":{let a=new it(r.scale??1),n=new aa(r.size??new I(100,100,100)),o=new it(r.move??1),l=new Ur(r.fA??new $(1.7,9.2)),h=new Ur(r.fB??new $(8.3,2.8)),u=new Ur(r.distortion??new $(1,1)),c=new Xn(r.colorA),d=new Xn(r.colorB),p=new Xn(r.colorC),f=new Xn(r.colorD),m=new wi(r.noiseType??0),v=new wi(r.voronoiStyle??0),y=new it(r.highCut??1),x=new it(r.lowCut??0),b=new it(r.smoothness??.5),_=new it(r.seed??.5),S=new wi(r.quality??1),M=ea(r),C=new j3(a,n,o,l,h,u,c,d,p,f,M.alpha,m,M.isMask,v,y,x,b,_,S),A=new Ci(C.calpha,"f");return new ji(t,i,e,{scale:a,size:n,move:o,fA:l,fB:h,distortion:u,colorA:c,colorB:d,colorC:p,colorD:f,noiseType:m,...M,voronoiStyle:v,highCut:y,lowCut:x,smoothness:b,seed:_,quality:S},C,M.mode,A,M.isMask,s)}case"normal":{let a=new aa(r.cnormal??new I(1,1,1)),n=ea(r),o=new z3(a,n.alpha),l=new Ci(o.calpha,"f");return new ji(t,i,e,{cnormal:a,...n},o,n.mode,l,n.isMask,s)}case"gradient":{let a=new wi(r.gradientType??0),n=new xs(r.smooth??!1),o;r.colors?o=new yl(r.colors.length,r.colors):(o=new yl(10,new Et(0,0,0,1)),o.value[1]=new Et(1,1,1,1));let l;r.steps?l=new vl(r.steps.length,r.steps):(l=new vl(10,1),l.value[0]=0);let h=new Ur(r.offset??new $(0,0)),u=new Ur(r.morph??new $(0,0)),c=new it(r.angle??0),d=ea(r),p=new F3(a,n,o,l,h,u,c,d.alpha,d.isMask),f=new Ci(p.calpha,"f");return new ji(t,i,e,{gradientType:a,smooth:n,colors:o,steps:l,offset:h,morph:u,angle:c,...d},p,d.mode,f,d.isMask,s)}case"pattern":{let a=new wi(r.style??0),n=new wi(r.projection??0),o=new wi(["x","y","z"].indexOf(r.axis)??0),l=new it(r.blending??0),h=new Ur(r.offset??new $(0,0)),u=new Xn(r.colorA),c=new Xn(r.colorB),d=new Ur(r.frequency??new $(10,10)),p=new it(r.size??.5),f=new it(r.variation??0),m=new it(r.smoothness??.5),v=new it(r.zigzag??0),y=new it(r.rotation??0),x=new Ur(r.vertical??new $(0,1)),b=new Ur(r.horizontal??new $(0,1)),_=new wi(r.sides??6),S=ea(r),M=new W3(a,n,o,l,h,u,c,d,p,f,m,v,y,x,b,_,S.alpha,S.isMask),C=new Ci(M.calpha,"f");return new ji(t,i,e,{style:a,projection:n,axis:o,blending:l,offset:h,colorA:u,colorB:c,frequency:d,size:p,variation:f,smoothness:m,zigzag:v,rotation:y,vertical:x,horizontal:b,sides:_,...S},M,S.mode,C,S.isMask,s)}default:{let a=new Wi(1,0,0,1),n=ea(r),o=new _1(a,n.alpha),l=new Ci(o.calpha,"f");return new ji(t,i,e,{color:a,...n},o,n.mode,l,n.isMask,s)}}}function eX(e,t,i,r){let s=kq(i,r);return $q(i,e,t,s,r)}function hP(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let s=t.uniforms[`f${t.id}_intensity`];return s?(s.value=i.intensity*(i.visible?1:0),s):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let s=t.uniforms[`f${t.id}_alpha`];if(!s)return;if(s.value=Ql(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let a=t.uniforms[`f${t.id}_compensation`];a&&(a.value=i.compensation&&i.visible)}return s}}function sc(e,t){let i=0,r=e.layers.find(s=>s.data.type==="light");if(r){let s=r.data,a=Number(t.getVariable(s.alphaOverride));if((typeof s.alphaOverride=="string"?a/100:s.alphaOverride)<1)return!0}for(let s of e.layers){if(s.data.type!=="displace"&&s.data.isMask)return!0;if(s.data.type!=="displace"&&"alpha"in s.data&&s.data.type!=="light"&&s.data.type!=="fresnel"&&s.data.type!=="texture"&&s.data.type!=="matcap"&&s.data.type!=="rainbow"&&s.data.type!=="outline"&&s.data.type!=="pattern"){let a=s.data.visible?s.data.alpha:0;if(typeof a=="string"&&(a=Math.max(0,Math.min(1,Number(t.getVariable(a)??100)/100))),a===1&&s.data.type==="depth"||s.data.type==="gradient"){for(let n of s.data.colors)if(n[3]<1){a=n[3];break}}else if(a===1&&s.data.type==="noise"){let n=t.color(s.data.colorA).a,o=t.color(s.data.colorB).a,l=t.color(s.data.colorC).a,h=t.color(s.data.colorD).a,u=Math.min(n,Math.min(o,Math.min(l,h)));u<1&&(a=u)}i+=(1-i)*a}}return i<1}var Jo=class extends ni{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.cacheKey="",this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},tX=class extends Jo{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i){return this.root.getFlavor(e,t,i)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},cb=class extends Jo{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.reset0(e,t)}get nodeMaterial(){return this}getFlavor(e,t,i){let r=i?6:(e?3:0)+t;if(r===0)return this;this.flavors===void 0&&(this.flavors=[]),r-=1;let s=this.flavors[r];return s===void 0&&(s=new tX(e,t,i,this),this.flavors[r]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,t,i=!1){(this.data!==e||i)&&this.reset0(e,t)}reset0(e,t){this.data=e;let i=e.layers??ss.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>Vl.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=sc(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.transparent=sc(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],s=e[2];if(r&&s){let a=this.layers.find(n=>n.uuid===r);a?.hasValue(s)&&(s==="alpha"?(this.transparent=sc(this.data,i.shared),a.setValue(s,Math.max(0,Math.min(Number(t)/100,1)))):a.setValue(s,t))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(t=>t instanceof on),this.lightLayer===void 0&&(this.lightLayer=new on(0,"",{...Tr.defaultData("light","phong"),visible:!1},new hb,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(s=>s instanceof on);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let s=0;s<this.layers.length;++s){let a=this.layers[s];a instanceof ji&&a.color instanceof ob&&(a.uuid===i&&(e.node.bumpMap=a.color),a.uuid===r&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,i){if(t!==void 0?this.data=t:t=this.data,this.transparent=sc(t,i.shared),e.path[0]==="layers"){this.data=t;let r=i.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let a=Vl.create(this.layerIdGen++,e.id,e.data,i.shared);this.layers.splice(e.localIndex,0,a),i.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),i.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let a=this.layers.findIndex(o=>o.uuid===e.id),n=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,n),i.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(i.shared)}else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(n=>n.uuid===s);if(a){let n=t.layers.data(s),o;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?o={...e.props,alpha:Ql(e.props.alpha,r,["material",this.uuid,"layer",s,"alpha"])}:o={...e.props,alphaOverride:Ql(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},n,i)){let l=Vl.create(this.layerIdGen++,s,n,r);this.layers.splice(this.layers.findIndex(h=>h.uuid===s),1,l),this.onUpdate(i.shared)}}}}else this.reset(t,i)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ji?t.color.mask=void 0:t instanceof on&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ji&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof on?r.node.mask=new Ps(t.color,t.alpha,Ps.MUL):r instanceof ji&&(r.isMask.value||(r.color.mask=new Ps(t.color,t.alpha,Ps.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof ji),t=this.layers.findIndex(i=>i instanceof on);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let s=this.layers[r];if(s instanceof ji){if(s.isMask.value)continue;i=new TA(i,s.color,s.alpha,s.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Ci("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof on);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof ji){if(r.isMask.value)continue;e=new TA(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof lP);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Ps(t,e[i].position,Ps.ADD),t=new Ps(t,new it(.5).setReadonly(!0),Ps.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,s,a)=>Math.min(Math.max(r,s),a);for(let r of this.layers)if(r.type==="displace"){let s=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=s}}computeCacheKey(){let e="[";for(let{data:t}of this.data.layers)if(t.type==="light")e+=`"${t.visible?t.category.toUpperCase():"Basic"}"`;else{let i=(aP[t.type]??[]).map(o=>t[o]),r=(nP[t.type]??[]).map(o=>t[o]?.length??0),s=[...i,...r],a="isMask"in t&&t.isMask,n=`"${t.type}-${t.visible}-${a}"`;s.length?e+=`[${n}, "${s.join('","')}"],`:e+=n}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new I3;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ji){let t=e.params.texture;if(t instanceof w1&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Jo.prototype,{properties:{get:function(){return this.fragment.properties}}});var M1=class extends cb{constructor(e,t,i){super(e,t,!1),this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},iX=Br(VO()),NA=new Map;function rX(e){if(typeof e=="string")return e;let t=NA.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},NA.set(e,t)),t.url}var ed=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let s;typeof e=="string"?s={src:e}:s={src:rX(e),format:"wav"},this.sound=new iX.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},sX=class{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new cm,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath?.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath?.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(p,f,m,v){let y=p.x,x=f.x,b=m.x,_=v.x,S=p.y,M=f.y,C=m.y,A=v.y,T=(_-b)*(S-C)-(A-C)*(y-b),P=(x-y)*(S-C)-(M-S)*(y-b),R=(A-C)*(x-y)-(_-b)*(M-S),z=T/R,N=P/R;if(R===0&&T!==0||z<=0||z>=1||N<0||N>1)return null;if(T===0&&R===0){for(let B=0;B<2;B++)if(r(B===0?m:v,p,f),t.loc===e.ORIGIN){let V=B===0?m:v;return{x:V.x,y:V.y,t:t.t}}else if(t.loc===e.BETWEEN){let V=+(y+t.t*(x-y)).toPrecision(10),H=+(S+t.t*(M-S)).toPrecision(10);return{x:V,y:H,t:t.t}}return null}else{for(let H=0;H<2;H++)if(r(H===0?m:v,p,f),t.loc===e.ORIGIN){let X=H===0?m:v;return{x:X.x,y:X.y,t:t.t}}let B=+(y+z*(x-y)).toPrecision(10),V=+(S+z*(M-S)).toPrecision(10);return{x:B,y:V,t:z}}}function r(p,f,m){let v=m.x-f.x,y=m.y-f.y,x=p.x-f.x,b=p.y-f.y,_=v*b-x*y;if(p.x===f.x&&p.y===f.y){t.loc=e.ORIGIN,t.t=0;return}if(p.x===m.x&&p.y===m.y){t.loc=e.DESTINATION,t.t=1;return}if(_<-Number.EPSILON){t.loc=e.LEFT;return}if(_>Number.EPSILON){t.loc=e.RIGHT;return}if(v*x<0||y*b<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+y*y)<Math.sqrt(x*x+b*b)){t.loc=e.BEYOND;return}let S;v!==0?S=x/v:S=b/y,t.loc=e.BETWEEN,t.t=S}function s(p,f){let m=[],v=[];for(let y=1;y<p.length;y++){let x=p[y-1],b=p[y];for(let _=1;_<f.length;_++){let S=f[_-1],M=f[_],C=i(x,b,S,M);C!==null&&m.find(A=>A.t<=C.t+Number.EPSILON&&A.t>=C.t-Number.EPSILON)===void 0&&(m.push(C),v.push(new $(C.x,C.y)))}}return v}function a(p,f,m){let v=new $;f.getCenter(v);let y=[];return m.forEach(x=>{x.boundingBox.containsPoint(v)&&s(p,x.points).forEach(b=>{y.push({identifier:x.identifier,isCW:x.isCW,point:b})})}),y.sort((x,b)=>x.point.x-b.point.x),y}function n(p,f,m,v,y){(y==null||y==="")&&(y="nonzero");let x=new $;p.boundingBox.getCenter(x);let b=[new $(m,x.y),new $(v,x.y)],_=a(b,p.boundingBox,f);_.sort((P,R)=>P.point.x-R.point.x);let S=[],M=[];_.forEach(P=>{P.identifier===p.identifier?S.push(P):M.push(P)});let C=S[0].point.x,A=[],T=0;for(;T<M.length&&M[T].point.x<C;)A.length>0&&A[A.length-1]===M[T].identifier?A.pop():A.push(M[T].identifier),T++;if(A.push(p.identifier),y==="evenodd"){let P=A.length%2===0,R=A[A.length-2];return{identifier:p.identifier,isHole:P,for:R}}else if(y==="nonzero"){let P=!0,R=null,z=null;for(let N=0;N<A.length;N++){let B=A[N];f[B]&&(P?(z=f[B].isCW,P=!1,R=B):z!==f[B].isCW&&(z=f[B].isCW,P=!0))}return{identifier:p.identifier,isHole:P,for:R}}else console.warn('fill-rule: "'+y+'" is currently not implemented.')}let o=0,l=999999999,h=-999999999,u=[];this.subPaths.forEach(p=>{let f=p.getPoints(),m=-999999999,v=999999999,y=-999999999,x=999999999;for(let b=0;b<f.length;b++){let _=f[b];_.y>m&&(m=_.y),_.y<v&&(v=_.y),_.x>y&&(y=_.x),_.x<x&&(x=_.x)}h<=y&&(h=y+1),l>=x&&(l=x-1),f.length&&u.push({curves:p.curves,points:f,isCW:dC.isClockWise(f),identifier:o++,boundingBox:new AC(new $(x,v),new $(y,m))})});let c=u.map(p=>n(p,u,l,h,this.userData?.style.fillRule)),d=[];return u.forEach(p=>{let f=c[p.identifier];if(f&&!f.isHole){let m=new um;m.curves=p.curves,c.filter(v=>v?.isHole&&v.for===p.identifier).forEach(v=>{if(v){let y=u[v.identifier],x=new cm;x.curves=y.curves,m.holes.push(x)}}),d.push(m)}}),d}},cP=!1,uP,FA=new Promise(e=>{uP=e}),UA=!1,Af;function aX(){if(cP=!0,UA)return;if(Af)return Af;async function e(){let t=await import("./opentype.js");uP(t),UA=!0}return Af=e(),Af}var nX=class{async load(e,t,i=()=>{}){let{load:r}=await FA;r(e,(s,a)=>{s||!a?i(s??"Something went wrong"):t(a)})}async parse(e){let{parse:t,Bidi:i}=await FA;try{let r=t(e),s=new i,a=n=>r.charToGlyphIndex(n.char);return s.registerModifier("glyphIndex",null,a),s.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:s}}catch(r){console.error(r)}}};async function oX(e){return await(await fetch(e)).arrayBuffer()}var lX=new nX;async function VA(e){let t,i,r=!1;if(e.url?(t=await oX(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t)if(cP){let s=await lX.parse(t);if(s)return{font:s.font,url:i,intercepted:r,arr:t,bidi:s.bidi}}else return{font:void 0,url:i,intercepted:r,arr:t,bidi:null}}function hX(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var cX=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=VA(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=VA(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let s=r.tokenizer.tokens,a=[],n=0,o=i.length===s.length;for(let l=0;l<i.length;l++){let h=i[l].index,u=String.fromCharCode(i[l].unicode),c=s[n];if(hX(h,c)||o)a.push({char:u,index:h,replacements:[c.state.glyphIndex],replacementChars:[c.char]}),n++;else{let d=c.char,p="",f=[c.state.glyphIndex],m=[],v=!1;for(;!v;)n++,p=t.charAt(n),d+=p,f.push(e.charToGlyphIndex(p)),m=e.stringToGlyphs(d),m.length===1&&m[0].index===h&&(v=!0),n>t.length&&(v=!0);a.push({char:u,index:h,replacements:f,replacementChars:Array.from(d)}),n++}}return a}generateShapes(e,t){if(!this._isLoaded)return;let i=this.font,r=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,a=e.map(y=>this.getTextWidth(y,t)),n=t.width,o=this.getCharWidth(`
|
|
5377
5377
|
`,t),l=t.horizontalAlign===1?o:0,h=this.computeSpaceWidthForLine(e,0,t),u=this.getLineInitialOffsetX(a[0],n,t.horizontalAlign,e[0],o),c=this.getLineInitialOffsetY(s,e.length,t.height,r,t.verticalAlign),d=[],p=e.map(y=>[]),f=e.map(y=>[]),m;for(let y=0;y<e.length;y++){let x=e[y],b={features:{liga:!0}},_=[];try{_=i.stringToGlyphs(x,b)}catch(M){console.warn(M)}u=this.getLineInitialOffsetX(a[y],n,t.horizontalAlign,x,o);let S=[];try{S=this.reverseLigaturesTable(i,x,_)}catch(M){console.warn(M)}h=this.computeSpaceWidthForLine(e,y,t);for(let M=0;M<_.length;M++){let C=_[M],A=C.index===0?`
|
|
5378
5378
|
`:C.unicode?String.fromCharCode(C.unicode):void 0,T=S[M],P=0,R=0;M===0&&t.horizontalAlign===2&&C.leftSideBearing!==void 0&&(R=-C.leftSideBearing*r),m&&(P=i.getKerningValue(C,m)*r),u+=R+P;let z=0;if(A===`
|
|
5379
5379
|
`)z=l;else if(A===" ")z=h;else{let N=this.createPath(C,r,u,c,t);N&&(z=N.offsetX-(P+R),d.push(N.path))}if(T.replacements.length===1)f[y].push([u,c]),p[y].push(z);else{let N=T.replacements.map(X=>(i.glyphs.get(X).advanceWidth??0)*r),B=N.reduce((X,G)=>X+=G,0),V=N.map(X=>X/B),H=u;for(let X=0;X<V.length;X++){let G=z*V[X];f[y].push([H,c]),p[y].push(G),H+=G}}u+=z,m=C}c-=s}let v=[];for(let y=0,x=d.length;y<x;y++)v.push(...d[y].toShapes());return{shapes:v,charWidths:p,lineWidths:a,charCoords:f}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(e,t,i,r,s){return(i===3||i===2)&&r.indexOf(`
|
|
@@ -7348,7 +7348,7 @@ end_header
|
|
|
7348
7348
|
gVelocity = vec4(0.0); // so it is ignored by TAA
|
|
7349
7349
|
}`,r={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new $},viewport:{type:"v2",value:new $},basisViewport:{type:"v2",value:new $},debugColor:{type:"v3",value:new yt},covariancesTextureSize:{type:"v2",value:new $(1024,1024)},centersColorsTextureSize:{type:"v2",value:new $(1024,1024)},orthoZoom:{type:"f",value:-1}};return new ni({uniforms:r,vertexShader:t,fragmentShader:i,transparent:!0,alphaTest:1,blending:Bl,depthTest:!0,depthWrite:!1,side:Rs})}static buildGeomtery(e){let t=new ut;t.setIndex([0,1,2,0,2,3]);let i=new Float32Array(4*3),r=new At(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 wC().copy(t),a=new Uint32Array(e),n=new vd(a,1,!1);return n.setUsage(jI),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 $(4096,1024);for(;t.x*t.y*2<e*6;)t.y*=2;let i=new $(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 u=0;u<this.covariances.length;u++)s[u]=y5.toHalfFloat(this.covariances[u]);r=new ca(s,t.x,t.y,rm,Hl)}else s=new Float32Array(t.x*t.y*2),s.set(this.covariances),r=new ca(s,t.x,t.y,rm,lr);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 u=0;u<e;u++){let c=u*4,d=u*3,p=u*4;a[p]=iK(this.colors[c],this.colors[c+1],this.colors[c+2],this.colors[c+3]),a[p+1]=B0(this.centers[d]),a[p+2]=B0(this.centers[d+1]),a[p+3]=B0(this.centers[d+2])}let n=new ca(a,i.x,i.y,NE,to);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 u=0;u<this.meshMatrixWorlds.length;u++)l.set(this.meshMatrixWorlds[u].elements,u*16);let h=new ca(l,o,1,Pr,lr);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&&(Nf.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Nf),this.material.uniforms.basisViewport.value.set(2/Nf.x,2/Nf.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())}},rK=class{constructor(e={}){gs(this,"updateSplatMeshUniforms",function(){let t=new $;return function(){this.splatMesh!==null&&this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}()),gs(this,"updateView",function(){let t=new Le,i=[],r=new I(0,0,-1),s=new I(0,0,-1),a=new I,n=new I;return function(o=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),h=this.cropsChanged();if(!o){s.set(0,0,-1).applyQuaternion(this.camera.quaternion);let c=!1,d=!1;if(s.dot(r)<=.95&&(c=!0),n.copy(this.camera.position).sub(a).length()>=1&&(d=!0),!c&&!d&&!l&&!h)return}a.copy(this.camera.position),r.copy(s),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),i[0]=this.camera.position.x,i[1]=this.camera.position.y,i[2]=this.camera.position.z;let u={sort:{view:t.elements,cameraPosition:i,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...h?{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.renderer=e.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let e=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=e?this:null}loadSplat(e={}){this.activePage=this.scene.activePage,e.position&&(e.position=new I().fromArray(e.position)),e.orientation&&(e.orientation=new Mt().fromArray(e.orientation)),e.halfPrecisionCovariances=!!e.halfPrecisionCovariances;let t=[];if(this.splatEntries=t,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let n=a.visible;a.traverseAncestors(o=>{n&&(n=o.visible)}),n&&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 j1(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 Mt,s=!1,a=1,n,o){this.splatMesh=Jf.buildMesh(e,t,s,a,n,o),this.splatMesh.position.copy(i),this.splatMesh.quaternion.copy(r),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=t}setupSortWorker(e){this.sortWorker=tK(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.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}},G1=new Nc;G1.wireframe=!0;var zM=new I,Sb=class extends so{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.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new WZ,this.invisibleObjects=new yc("jflkdsafjasdifjaslk",{...Jy.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1,this.errorPage=new jr("fdasfa",{...Rc.defaultData,name:""},{shared:t,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=VZ(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=UZ(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 jr&&(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)=>hT(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===Qc)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 jr&&t.uiScene){let i=t.uiScene.find(e);if(i)return i}}findScene2DfromObject2D(e){for(let t of this.children)if(t instanceof jr&&t.uiScene&&t.uiScene.find(e))return t.uiScene}find2DInUIObjects(e){let t;return this.traverseEntity(i=>{t===void 0&&i instanceof ts&&(t=i.uiCanvas.find(e))}),t}traverse2D(e){for(let t of this.children)t instanceof jr&&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(),Oa(r)&&ro(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");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),ro(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Oa(i)&&(i.freeBooleanPointer(),r instanceof Zl&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof bb&&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()),Oa(i)&&(i.invalidateUpstreamBooleanData(),ro(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Zl&&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 jr&&(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{FZ(s,t,i,{scene:this,shared:r}),s instanceof rs&&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 ts||n instanceof jr)&&(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 as&&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){Yt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Yt.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=Ed(l.data,h=>{let u=h.events.data(n.id),c=l.goUp(a);if(c){let d=[...lT(c.identity),e].join("-"),p=this.entityIdentityToEntity[d];if(p){let f=p.uuid,m=Wr.zoom(u,t);m[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)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof xc&&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=Ed(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of Um.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 xc&&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),wb(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof xc&&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)Yt.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(Yt.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(Oa(a)||T1(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),U1(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;Yt.is(s)&&(s.visible||a?.object.data.visible)&&((Oa(s)||T1(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),U1(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)Yt.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Yt.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Yt.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof rs&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s);let a=i.invalidateDownstreamBooleanData();ro(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Ld.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Yt.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=_b(e,t,n);return 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 rs&&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 rs&&h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),c=h.boneInverses.map(p=>new Le().fromArray(p)),d=new ux(u,c);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 er;return i.setFromPoints(t),i.getCenter(zM),zM}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 Ss)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof Jo&&e(t.material[i]);else t.material instanceof Jo&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof as&&r.setViewplaneSize(e,t,i)})}initializeSplatViewer(e){this.splatViewer=new rK({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}},$f=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},sK=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return nK(Math.atan2(r,i))},aK=(e,t,i)=>{let r={x:0,y:0};return i=H1(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},H1=e=>e*(Math.PI/180),nK=e=>e*(180/Math.PI),oK=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,L0=new Map,kM=e=>{L0.has(e)&&clearTimeout(L0.get(e)),L0.set(e,setTimeout(e,100))},ig=(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)},NM=(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)},RP=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),FM=()=>{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}},W1=(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")},Ab=(e,t,i)=>{let r=BP(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},lK=(e,t)=>{let i=BP(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},BP=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},z0=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},hK=(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},q1=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},cK=(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"&&(LP="ontouchstart"in window,zP=!!window.PointerEvent,kP=!!window.MSPointerEvent);var LP,zP,kP,Uu={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"}},ac,Nd={};zP?ac=Uu.pointer:kP?ac=Uu.MSPointer:LP?(ac=Uu.touch,Nd=Uu.mouse):ac=Uu.mouse;function rh(){}rh.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};rh.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};rh.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)})};rh.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=hK(t.options,e))};rh.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.')},ig(e,ac[t],i._domHandlers_[t]),Nd[t]&&ig(e,Nd[t],i._domHandlers_[t]),i};rh.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},NM(e,ac[t],i._domHandlers_[t]),Nd[t]&&NM(e,Nd[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var Mb=rh;function _r(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=_r.id,_r.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}_r.prototype=new Mb;_r.constructor=_r;_r.id=0;_r.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)};_r.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=lK("borderRadius","50%"),i=Ab("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)"},z0(r.el,i),this.options.shape==="circle"&&z0(r.back,t),z0(r.front,t),this.applyStyles(r),this};_r.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};_r.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};_r.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};_r.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};_r.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};_r.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};_r.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=Ab("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)};_r.prototype.restCallback=function(){var e=this,t={};t.front=Ab("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};_r.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};_r.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 uK=_r;function tr(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=tr.id,tr.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}tr.prototype=new Mb;tr.constructor=tr;tr.id=0;tr.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}};tr.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};tr.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)}};tr.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 uK(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||(W1(h.ui.el,s),W1(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};tr.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};tr.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)};tr.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)};tr.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=RP(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 q1(e,s),t.manager.bindDocument(),!1};tr.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(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),a>0&&t.pressureFn(e,u,u.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=$f(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};tr.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)};tr.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(!oK(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=$f(l,s.position),u=sK(l,s.position),c=H1(u),d=h/o,p={distance:h,position:l},f,m;if(s.options.shape==="circle"?(f=Math.min(h,o),m=aK(s.position,f,u)):(m=cK(l,s.position,o),f=$f(m,s.position)),i.follow){if(h>o){let b=l.x-m.x,_=l.y-m.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=$f(l,s.position)}}else l=m,h=f;var v=l.x-s.position.x,y=l.y-s.position.y;s.frontPosition={x:v,y},i.dataOnly||W1(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:c,degree:u},vector:{x:v/o,y:-y/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};x=s.computeDirection(x),x.angle={radian:H1(180-u),degree:180-u},s.trigger("move",x),t.trigger("move "+s.id+":move",x)};tr.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))};tr.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()};tr.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 dK=tr;function Rr(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=FM(),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;ig(window,"resize",function(){kM(i)});var r=function(){t.scroll=FM()};return ig(window,"scroll",function(){kM(r)}),t.collections}Rr.prototype=new Mb;Rr.constructor=Rr;Rr.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}};Rr.prototype.create=function(e){return this.createCollection(e)};Rr.prototype.createCollection=function(e){var t=this,i=new dK(t,e);return t.bindCollection(i),t.collections.push(i),i};Rr.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)};Rr.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};Rr.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Rr.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]};Rr.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};Rr.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};Rr.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};Rr.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};Rr.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=RP(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),q1(i.collections,a.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return q1(t,n),!1};Rr.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};Rr.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 pK=Rr,UM=new pK,fK={create:function(e){return UM.create(e)},factory:UM},NP=new Map,ud=new Map,Il=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 ed({src:l,volume:a,delay:n,loop:o}),ud.has(i.uuid)?ud.get(i.uuid).push(this):ud.set(i.uuid,[this]),NP.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()}},X1=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=NP.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=ud.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=[...ud.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}},FP=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new Il(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new X1(t);else throw new Error("Missing property")}dispatchBasic(){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Il?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Il?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof Il&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},UP=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.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze():this.unFreeze()}start(e=0){if(e){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},this.delay);return}this.particleSystem.start()}stop(){this.particleSystem.stop(),this.clearDelay()}freeze(){this.particleSystem.froze(),this.clearDelay()}unFreeze(){this.particleSystem.unFroze(),this.clearDelay()}reset(){this.particleSystem.reset(),this.clearDelay()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(zi(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();break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop();break;case"reset":this.reset();break;default:break}}dispatchConditional(){if(zi(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.particleSystem.start();break;case"stop":this.particleSystem.stop();break;case"reset":this.particleSystem.reset();break;default:break}}dispatchGameControl(e){if(zi(this.shared,this.condition)===!1||!this.particleSystem)return!1;e==="start"?this.particleSystem.start():this.particleSystem.stop()}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}},mK="text/plain",gK="us-ascii",VM=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),vK=(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(u=>{let[c,d=""]=u.split("=").map(p=>p.trim());return c==="charset"&&(d=d.toLowerCase(),d===gK)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==mK)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${a?`#${a}`:""}`};function yK(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 vK(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 u=h[0],c=h.index,d=r.pathname.slice(n,c);o+=d.replace(/\/{2,}/g,"/"),o+=u,n=c+u.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];VM(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()])VM(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 xK=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:yK(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){if(zi(this.shared,this.condition)===!1)return!1;kx?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.controlsManager.orbitControls?.onPointerUp(wt[0]),GG())}},VP=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(zi(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(zi(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))}},jP=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(zi(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),zb(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}},GP={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},Eb={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},bK=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],rg={CSS:{},springs:{}};function La(e,t,i){return Math.min(Math.max(e,t),i)}function dd(e,t){return e.indexOf(t)>-1}function k0(e,t){return e.apply(null,t)}var St={arr:function(e){return Array.isArray(e)},obj:function(e){return dd(Object.prototype.toString.call(e),"Object")},pth:function(e){return St.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||St.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 St.hex(e)||St.rgb(e)||St.hsl(e)},key:function(e){return!GP.hasOwnProperty(e)&&!Eb.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function HP(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function WP(e,t){var i=HP(e),r=La(St.und(i[0])?1:i[0],.1,100),s=La(St.und(i[1])?100:i[1],.1,100),a=La(St.und(i[2])?10:i[2],.1,100),n=La(St.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,u=1,c=l<1?(l*o+-n)/h:-n+o;function d(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(u*Math.cos(h*m)+c*Math.sin(h*m)):m=(u+c*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=rg.springs[e];if(f)return f;for(var m=1/6,v=0,y=0;;)if(v+=m,d(v)===1){if(y++,y>=16)break}else y=0;var x=v*m*1e3;return rg.springs[e]=x,x}return t?d:p}function wK(e){return e===void 0&&(e=10),function(t){return Math.ceil(La(t,1e-6,1)*e)*(1/e)}}var _K=function(){var e=11,t=1/(e-1);function i(u,c){return 1-3*c+3*u}function r(u,c){return 3*c-6*u}function s(u){return 3*u}function a(u,c,d){return((i(c,d)*u+r(c,d))*u+s(c))*u}function n(u,c,d){return 3*i(c,d)*u*u+2*r(c,d)*u+s(c)}function o(u,c,d,p,f){var m,v,y=0;do v=c+(d-c)/2,m=a(v,p,f)-u,m>0?d=v:c=v;while(Math.abs(m)>1e-7&&++y<10);return v}function l(u,c,d,p){for(var f=0;f<4;++f){var m=n(c,d,p);if(m===0)return c;var v=a(c,d,p)-u;c-=v/m}return c}function h(u,c,d,p){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var f=new Float32Array(e);if(u!==c||d!==p)for(var m=0;m<e;++m)f[m]=a(m*t,u,d);function v(y){for(var x=0,b=1,_=e-1;b!==_&&f[b]<=y;++b)x+=t;--b;var S=(y-f[b])/(f[b+1]-f[b]),M=x+S*t,C=n(M,u,d);return C>=.001?l(y,M,u,d):C===0?M:o(y,x,x+t,u,d)}return function(y){return u===c&&d===p||y===0||y===1?y:a(v(y),c,p)}}return h}(),qP=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=La(r,1,10),n=La(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 Cb(e,t){if(St.fnc(e))return e;var i=e.split("(")[0],r=qP[i],s=HP(e);switch(i){case"spring":return WP(e,t);case"cubicBezier":return k0(_K,s);case"steps":return k0(wK,s);default:return k0(r,s)}}function XP(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Pg(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 Dg(e){return e.reduce(function(t,i){return t.concat(St.arr(i)?Dg(i):i)},[])}function jM(e){return St.arr(e)?e:(St.str(e)&&(e=XP(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function Tb(e,t){return e.some(function(i){return i===t})}function Pb(e){var t={};for(var i in e)t[i]=e[i];return t}function Y1(e,t){var i=Pb(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Og(e,t){var i=Pb(e);for(var r in t)i[r]=St.und(e[r])?t[r]:e[r];return i}function SK(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function AK(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,u){return l+l+h+h+u+u}),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 MK(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 u=s<.5?s*(1+r):s+r-s*r,c=2*s-u;o=n(c,u,i+1/3),l=n(c,u,i),h=n(c,u,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+a+")"}function EK(e){if(St.rgb(e))return SK(e);if(St.hex(e))return AK(e);if(St.hsl(e))return MK(e)}function oo(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 CK(e){if(dd(e,"translate")||e==="perspective")return"px";if(dd(e,"rotate")||dd(e,"skew"))return"deg"}function Q1(e,t){return St.fnc(e)?e(t.target,t.id,t.total):e}function mn(e,t){return e.getAttribute(t)}function Db(e,t,i){var r=oo(t);if(Tb([i,"deg","rad","turn"],r))return t;var s=rg.CSS[t+i];if(!St.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 rg.CSS[t+i]=h,h}function YP(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?Db(e,s,i):s}}function Ob(e,t){if(St.dom(e)&&!St.inp(e)&&(mn(e,t)||St.svg(e)&&e[t]))return"attribute";if(St.dom(e)&&Tb(bK,t))return"transform";if(St.dom(e)&&t!=="transform"&&YP(e,t))return"css";if(e[t]!=null)return"object"}function QP(e){if(St.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 TK(e,t,i,r){var s=dd(t,"scale")?1:0+CK(t),a=QP(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?Db(e,a,r):a}function Ib(e,t,i,r){switch(Ob(e,t)){case"transform":return TK(e,t,r,i);case"css":return YP(e,t,i);case"attribute":return mn(e,t);default:return e[t]||0}}function Rb(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=oo(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 ZP(e,t){if(St.col(e))return EK(e);if(/\s/g.test(e))return e;var i=oo(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Bb(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function PK(e){return Math.PI*2*mn(e,"r")}function DK(e){return mn(e,"width")*2+mn(e,"height")*2}function OK(e){return Bb({x:mn(e,"x1"),y:mn(e,"y1")},{x:mn(e,"x2"),y:mn(e,"y2")})}function KP(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var a=t.getItem(s);s>0&&(i+=Bb(r,a)),r=a}return i}function IK(e){var t=e.points;return KP(e)+Bb(t.getItem(t.numberOfItems-1),t.getItem(0))}function JP(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return PK(e);case"rect":return DK(e);case"line":return OK(e);case"polyline":return KP(e);case"polygon":return IK(e)}}function RK(e){var t=JP(e);return e.setAttribute("stroke-dasharray",t),t}function BK(e){for(var t=e.parentNode;St.svg(t)&&St.svg(t.parentNode);)t=t.parentNode;return t}function $P(e,t){var i=t||{},r=i.el||BK(e),s=r.getBoundingClientRect(),a=mn(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 LK(e,t){var i=St.str(e)?XP(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:$P(i),totalLength:JP(i)*(r/100)}}}function zK(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=$P(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 GM(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=ZP(St.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:St.str(e)||t?r.split(i):[]}}function eD(e){var t=e?Dg(St.arr(e)?e.map(jM):jM(e)):[];return Pg(t,function(i,r,s){return s.indexOf(i)===r})}function tD(e){var t=eD(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:QP(i)}}})}function kK(e,t){var i=Pb(t);if(/^spring/.test(i.easing)&&(i.duration=WP(i.easing)),St.arr(e)){var r=e.length,s=r===2&&!St.obj(e[0]);s?e={value:e}:St.fnc(t.duration)||(i.duration=t.duration/r)}var a=St.arr(e)?e:[e];return a.map(function(n,o){var l=St.obj(n)&&!St.pth(n)?n:{value:n};return St.und(l.delay)&&(l.delay=o?0:t.delay),St.und(l.endDelay)&&(l.endDelay=o===a.length-1?t.endDelay:0),l}).map(function(n){return Og(n,i)})}function NK(e){for(var t=Pg(Dg(e.map(function(a){return Object.keys(a)})),function(a){return St.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)St.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 FK(e,t){var i=[],r=t.keyframes;r&&(t=Og(NK(r),t));for(var s in t)St.key(s)&&i.push({name:s,tweens:kK(t[s],e)});return i}function UK(e,t){var i={};for(var r in e){var s=Q1(e[r],t);St.arr(s)&&(s=s.map(function(a){return Q1(a,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function VK(e,t){var i;return e.tweens.map(function(r){var s=UK(r,t),a=s.value,n=St.arr(a)?a[1]:a,o=oo(n),l=Ib(t.target,e.name,o,t),h=i?i.to.original:l,u=St.arr(a)?a[0]:h,c=oo(u)||oo(l),d=o||c;return St.und(n)&&(n=h),s.from=GM(u,d),s.to=GM(Rb(n,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=Cb(s.easing,s.duration),s.isPath=St.pth(a),s.isColor=St.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var iD={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 rD(e,t){var i=tD(e);i.forEach(function(r){for(var s in t){var a=Q1(t[s],r),n=r.target,o=oo(a),l=Ib(n,s,o,r),h=o||oo(l),u=Rb(ZP(a,h),l),c=Ob(n,s);iD[c](n,s,u,r.transforms,!0)}})}function jK(e,t){var i=Ob(e.target,t.name);if(i){var r=VK(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 GK(e,t){return Pg(Dg(e.map(function(i){return t.map(function(r){return jK(i,r)})})),function(i){return!St.und(i)})}function sD(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 HM=0;function HK(e){var t=Y1(GP,e),i=Y1(Eb,e),r=FK(i,e),s=tD(e.targets),a=GK(s,r),n=sD(a,i),o=HM;return HM++,Og(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=[],WM=[],em,WK=function(){function e(){em=requestAnimationFrame(t)}function t(i){var r=pa.length;if(r){for(var s=0;s<r;){var a=pa[s];a.paused?(pa.splice(s,1),r-=1):(a.tick(i),s++)}e()}else em=cancelAnimationFrame(em)}return e}();function qK(e){document.hidden?(pa.forEach(function(t){return t.pause(e.timeStamp)}),WM=pa.slice(0),$i.running=pa=[]):WM.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",qK);function $i(e){e===void 0&&(e={});var t=0,i=0,r=0,s,a,n=0,o=null;function l(C){var A=window.Promise&&new Promise(function(T){return o=T});return C.finished=A,A}var h=HK(e),u=l(h);function c(){var C=h.direction;C!=="alternate"&&(h.direction=C!=="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(C){return C.reversed=!1})}function p(C){return h.reversed?h.duration-C:C}function f(){t=0,i=p(h.currentTime)*(1/$i.speed)}function m(C,A,T=!1){A&&(h.reversed?A.seek(A.duration*A.loop-(C-A.timelineOffset-A.pingPongDelayCorrection),T):A.seek(C-A.timelineOffset-A.startOnceDelay-A.pingPongDelayCorrection,T))}function v(C,A=!1){if(h.reversed)for(var T=n;T--;)m(C,a[T],A);else for(var P=0;P<n;P++)m(C,a[P],A)}function y(C){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"?C=h.duration-h.delay+h.endDelay-C:C=h.duration+h.delay-h.endDelay-C):S(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?C=h.duration-h.delay+h.endDelay-C:C=h.duration+h.delay-h.endDelay-C);A<P;){var R=T[A],z=R.animatable,N=R.tweens,B=N.length-1,V=N[B];B&&(V=Pg(N,function(de){return C<de.end})[0]||V);let ye;h.parent?.reversed&&h.direction==="alternate"?ye=La(C-V.start-V.endDelay,0,V.duration)/V.duration:ye=La(C-V.start-V.delay,0,V.duration)/V.duration;for(var H=isNaN(ye)?1:V.easing(ye),X=V.to.strings,G=V.round,se=[],ae=V.to.numbers.length,J=void 0,K=0;K<ae;K++){var ne=void 0;let de,Be;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(de=V.to.numbers[K],Be=V.from.numbers[K]||0):(Be=V.to.numbers[K],de=V.from.numbers[K]||0):S(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(de=V.to.numbers[K],Be=V.from.numbers[K]||0):(Be=V.to.numbers[K],de=V.from.numbers[K]||0),V.isPath?ne=zK(V.value,H*Be):ne=de+H*(Be-de),G&&(V.isColor&&K>2||(ne=Math.round(ne*G)/G)),se.push(ne)}var te=X.length;if(!te)J=se[0];else{J=X[0];for(var oe=0;oe<te;oe++){var ie=X[oe],be=X[oe+1],ue=se[oe];isNaN(ue)||(be?J+=ue+be:J+=ue+" ")}}iD[R.type](z.target,R.property,J,z.transforms),R.currentValue=J,A++}}function x(C){h[C]&&!h.passThrough&&h[C](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 S(C,A,T,P,R){return _[C<<4|A<<3|T<<2|P<<1|R]}function M(C,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(C);if(h.progress=La(z/T*100,0,100),A||(h.reversePlayback=z<h.currentTime),n&&v(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=La(z,0,T+h.pingPongDelayCorrection),h.began&&x("update"),C>=T)if(b(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,x("loopComplete"),x("complete"),!h.passThrough&&"Promise"in window&&(o(),u=l(h)));else{n?t+=h.duration/$i.speed:t+=h.duration;for(let N of a)N.setStartTime(0),N.remaining=N.loop;x("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():n&&d()}}return h.reset=function(){var C=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=C==="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(C){t=C},h.set=function(C,A){return rD(C,A),h},h.tick=function(C){r=C,t||(t=r),M((r+(i-t))*$i.speed)},h.seek=function(C,A=!1){M(C-t,A)},h.pause=function(C){h.paused=!0,n&&(s=C??performance.now())},h.play=function(C){!h.paused||(h.completed&&h.reset(),h.paused=!1,pa.push(h),n&&s!==void 0&&(t+=(C??performance.now())-s),em||WK())},h.reverse=function(){c(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function qM(e,t){for(var i=t.length;i--;)Tb(e,t[i].animatable.target)&&t.splice(i,1)}function XK(e){for(var t=eD(e),i=pa.length;i--;){var r=pa[i],s=r.animations,a=r.children;qM(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;qM(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}}function YK(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?Cb(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",u=St.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=oo(u?e[1]:e)||0,f=t.start||0+(u?c:0),m=[],v=0;return function(y,x,b){if(o&&(n=0),l&&(n=(b-1)/2),h&&(n=b-1),!m.length){for(var _=0;_<b;_++){if(!s)m.push(Math.abs(n-_));else{var S=l?(s[0]-1)/2:n%s[0],M=l?(s[1]-1)/2:Math.floor(n/s[0]),C=_%s[0],A=Math.floor(_/s[0]),T=S-C,P=M-A,R=Math.sqrt(T*T+P*P);a==="x"&&(R=-T),a==="y"&&(R=-P),m.push(R)}v=Math.max.apply(Math,m)}r&&(m=m.map(function(N){return r(N/v)*v})),i==="reverse"&&(m=m.map(function(N){return a?N<0?N*-1:-N:Math.abs(v-N)}))}var z=u?(d-c)/v:c;return f+z*(Math.round(m[x]*100)/100)+p}}function QK(e){e===void 0&&(e={});var t=$i(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=Og(i,Y1(Eb,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=St.und(r)?h:Rb(r,h),n(t);var u=$i(l);n(u),a.push(u),u.parent=t;var c=sD(a,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}$i.version="3.2.0";$i.speed=1;$i.running=pa;$i.remove=XK;$i.get=Ib;$i.set=rD;$i.convertPx=Db;$i.path=LK;$i.setDashoffset=RK;$i.stagger=YK;$i.timeline=QK;$i.easing=Cb;$i.penner=qP;$i.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var aD=$i,XM=new I,YM=new I,QM=new Mt;function ZK(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 u=1-r;return i.w=u*e.w+r*t.w,i.x=u*e.x+r*t.x,i.y=u*e.y+r*t.y,i.z=u*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 Vr(e,t,i,r,s,a){let n=i[e]?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:u=>{let c=st.lerp(l,h,u);a?t[e]=Math.trunc(c):t[e]=c},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function Lb(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(c=>typeof c=="string"?Number(s.getVariable(c)??0):c),u=[...o].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c);if(!(h.length!==u.length||nT(h,u)))return{update:c=>{h.forEach((d,p)=>{let f=st.lerp(d,u[p],c);t[e][p]=a?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],u)}}}function sg(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function ZM(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?sg(new I,a,s):o.clone(),h=sg(new I,n,s);if(!l.equals(h))return{update:u=>{o.lerpVectors(l,h,u)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function KM(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function Z1(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 $),h=o instanceof $?o:new $().fromArray(o),u=a?KM(new $,a,s):h.clone(),c=KM(new $,n,s);if(!u.equals(c))return{update:d=>{h.lerpVectors(u,c,d),l&&(t[e]=h.toArray())},start:()=>{h.copy(u),l&&(t[e]=h.toArray())},end:()=>{h.copy(c),l&&(t[e]=h.toArray())}}}function KK(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 Le().fromArray(s):n.clone(),l=new I,h=new Mt,u=new I;o.decompose(l,h,u);let c=new Le().fromArray(a),d=new I,p=new Mt,f=new I;if(c.decompose(d,p,f),!o.equals(c))return{update:m=>{QM.slerpQuaternions(h,p,m),XM.lerpVectors(l,d,m),YM.lerpVectors(u,f,m),n.compose(XM,QM,YM)},start:()=>{n.compose(l,h,u)},end:()=>{n.compose(d,p,f)}}}function JK(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 yt().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new yt().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let u=o.clone();return t[e]=u,{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Ff(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 Yr(o.r,o.g,o.b,o.a),h=a?typeof a=="string"?s.getColor(a).clone():new Yr(a.r,a.g,a.b,a.a):l.clone(),u=typeof n=="string"?s.getColor(n).clone():new Yr(n.r,n.g,n.b,n.a);if(!h.equals(u))return{update:c=>{l.lerpColors(h,u,c);let d=st.lerp(h.a,u.a,c);l.a=d,t[e]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(h)},end:()=>{l.copy(u)}}}function tl(e,t,i,r,s){if(typeof t[e]=="number")return Vr(e,t,i??{},r,s);if(Array.isArray(t[e]))return Lb(e,t,i??{},r,s)}function $K(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=st.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=Vr("targetOffset",e,t,i,r);o&&s.push(o)}return s}function eJ(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(Nl.isEqual(s,a))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[st.lerp(s[0],a[0],o),st.lerp(s[1],a[1],o),st.lerp(s[2],a[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData()}}),n}function tJ(e,t,i,r){if(!i.extrusion)return;let s=e.extrusion,a=t.extrusion??{},n=i.extrusion,o=[];return WT.forEach(l=>{let h=tl(l,s,a,n,r);h&&o.push(h)}),o}function iJ(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 kd){let l=eJ(e,n,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,ao(a,M2)),M2.forEach(h=>{let u=tl(h,l,n,o,r);u&&s.push(u)}),e instanceof bb){Object.assign(l,{extrusion:{...a.extrusion}});let h=tJ(l,n,o,r);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return s}function rJ(e,t,i,r){let s=[];if(i.intensity!==void 0){let a=Vr("intensity",e,t,i,r);a&&s.push(a)}if(i.color!==void 0){let a=JK("color",e,t,i,r);a&&s.push(a)}return s}function sJ(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]??{},u=n[l];typeof h=="string"||typeof u=="string"||s.push(...JM(o,h,u,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(...JM(e.material,a,n,r))}return s}function JM(e,t,i,r){let s=[],a=sc(i,r)||!!t.layers&&sc(t,r);s.push(pJ(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(u=>!jT.some(c=>u.includes(c)));for(let u of h)try{let c=n.getValue(u),d;if(u==="colors")d=uJ(n,o,l,u);else if(Array.isArray(c))u==="steps"&&(d=cJ(n,o,l,u));else if(typeof c=="number")d=aJ(n,o,l,u,r);else{if(typeof c=="boolean")continue;c instanceof $?d=nJ(n,o,l,u):c instanceof I?d=oJ(n,o,l,u,r):c instanceof Yr?d=hJ(n,o,l,u,r):c instanceof yt?d=lJ(n,o,l,u,r):"isTexture"in c&&(d=dJ(n,o,l,u))}d&&(Array.isArray(d)?s.push(...d):s.push(d))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return s}function aJ(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,st.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function nJ(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),a=t?new $().fromArray(t[r]):s.clone(),n=new $().fromArray(i[r]);if(!a.equals(n))return{update:o=>{s.lerpVectors(a,n,o)},start:()=>{s.copy(a)},end:()=>{s.copy(n)}}}function oJ(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?sg(new I,n,s):a.clone(),h=sg(new I,o,s);if(!l.equals(h))return{update:u=>{a.lerpVectors(l,h,u)},start:()=>{a.copy(l)},end:()=>{a.copy(h)}}}function lJ(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 yt().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new yt().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function hJ(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 yt().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new Yr(n.r,n.g,n.b,n.a);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function cJ(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];for(let l=0;l<a.length;++l){let h=n[l],u=o[l];h!==u&&s.push({update:c=>{a[l]=st.lerp(h,u,c)},start:()=>{a[l]=h},end:()=>{a[l]=u}})}return s.length?s:void 0}function uJ(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]],u=[...o[l]];Dm.isEqual(h,u)||s.push({update:c=>{a[l].fromArray(Dm.lerp(h,u,c))},start:()=>{a[l].fromArray(h)},end:()=>{a[l].fromArray(u)}})}return s.length?s:void 0}function dJ(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let a=t?t[r]:s,n=i[r],o=[...a.repeat],l=[...a.offset],h=[...n.repeat],u=[...n.offset];if(!No.isEqual(o,h)||!No.isEqual(l,u))return{update:c=>{s.repeat=No.lerp(o,h,c),s.offset=No.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}function pJ(e,t){return{update:()=>{e.transparent=t}}}var N0=new I,$M=new vr;function fJ(e,t,i,r,s){let a=[],n,o,l,h,u,c,d;if(e instanceof xr?(n=Z1("position",e,t,i,s),n&&a.push(n),l=Vr("rotation",e,t,i,s),l&&a.push(l)):(d={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=Vr("slide",d,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),u&&a.push(u),c=Vr("offset",d,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),c&&a.push(c),!u&&!c&&(n=ZM("position",e,t,i,s),n&&a.push(n),o=ZM("scale",e,t,i,s),o&&a.push(o),l=mJ(e,t,i,r,s),l&&a.push(l),h=KK("hiddenMatrix",e,t,i),h&&a.push(h))),n||o||l||h||u||c){let p=e instanceof xr?()=>{e.updateWorldMatrix(!0)}:()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Oa(e)&&ro(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,d))};a.push({update:p,start:p,end:p})}return a}function mJ(e,t,i,r,s){let a=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(s.getVariable(u)??0):u)*st.DEG2RAD):void 0,n=i.rotation?.map(u=>(typeof u=="string"?Number(s.getVariable(u)??0):u)*st.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=N0.subVectors(l,o);if(r&&h.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Mt().setFromEuler($M.setFromVector3(o)),c=new Mt().setFromEuler($M.setFromVector3(l));return{update:d=>{ZK(u,c,e.quaternion,d)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:u=>{N0.lerpVectors(o,l,u),e.rotation.setFromVector3(N0)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function gJ(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;zT.forEach(p=>{let f;p==="count"?f=Vr("count",a.parameters,n,o,r,!0):f=tl(p,a.parameters,n??{},o,r),f&&s.push(f)});let l=vJ(a,n,o,r);l?.length&&s.push(...l);let h=yJ(a,n,o,r);h?.length&&s.push(...h);let u=xJ(a,n,o,r);u?.length&&s.push(...u);let c=bJ(a,n,o,r);c?.length&&s.push(...c);let d=wJ(a,n,o,r);return d?.length&&s.push(...d),s.length&&s.push({update:()=>{a.update()}}),s}function vJ(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 kT.forEach(l=>{let h=tl(l,n,s??{},a,r);h&&o.push(h)}),o}function yJ(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 NT.forEach(l=>{let h=tl(l,o,s??{},a,r);h&&n.push(h)}),n}function xJ(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 FT.forEach(l=>{let h;l==="count"?h=Lb(l,o,s??{},a,r,!0):h=tl(l,o,s??{},a,r),h&&n.push(h)}),n}function bJ(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 UT.forEach(l=>{let h;l==="count"?h=Vr(l,o,s??{},a,r,!0):h=tl(l,o,s??{},a,r),h&&n.push(h)}),n}function wJ(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 VT.forEach(l=>{let h=tl(l,o,s??{},a,r);h&&n.push(h)}),n}function _J(e,t){return{update:()=>{e instanceof Gr&&(e.fill.enabled=t)}}}function SJ(e,t){return{update:()=>{e instanceof Gr&&(e.stroke.enabled=t)}}}function AJ(e,t){return{update:()=>{e instanceof Gr&&(e.dropShadow.enabled=t)}}}function MJ(e,t){return{update:()=>{e instanceof Gr&&(e.innerShadow.enabled=t)}}}function EJ(e,t){return{update:()=>{e instanceof Gr&&(e.backgroundBlur.enabled=t)}}}function CJ(e,t){return{update:()=>{e instanceof Gr&&(e.layerBlur.enabled=t)}}}function TJ(e,t,i,r,s){let a=[],n,o,l,h,u,c,d,p,f,m,v,y,x,b,_;if("width"in e&&(n=Vr("width",e,t,i,s),n&&a.push(n)),"height"in e&&(o=Vr("height",e,t,i,s),o&&a.push(o)),e instanceof Gr||e instanceof yn){let S={...t.fill},M={...i.fill};S.enabled!==void 0&&S.enabled!==M.enabled&&(a.push(_J(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}})),l=Ff("color",e.fill,S,M,s),l&&a.push(l)}if(e instanceof Gr){let S={...t.stroke},M={...i.stroke};(S.enabled||M.enabled)&&(a.push(SJ(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}})),h=Ff("color",e.stroke,S,M,s),h&&a.push(h),u=Vr("thickness",e.stroke,S,M,s),u&&a.push(u)}if(e instanceof Gr){let S={...t.dropShadow},M={...i.dropShadow};(S.enabled||M.enabled)&&(a.push(AJ(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}})),c=Ff("color",e.dropShadow,S,M,s),c&&a.push(c),d=Vr("blurRadius",e.dropShadow,S,M,s),d&&a.push(d),f=Vr("spread",e.dropShadow,S,M,s),f&&a.push(f),p=Z1("offset",e.dropShadow,S,M,s),p&&a.push(p)}if(e instanceof Gr){let S={...t.innerShadow},M={...i.innerShadow};(S.enabled||M.enabled)&&(a.push(MJ(e,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),M.enabled||Object.assign(M,{enabled:!0,color:{...M.color,a:0}})),m=Ff("color",e.innerShadow,S,M,s),m&&a.push(m),v=Vr("blurRadius",e.innerShadow,S,M,s),v&&a.push(v),x=Vr("spread",e.innerShadow,S,M,s),x&&a.push(x),y=Z1("offset",e.innerShadow,S,M,s),y&&a.push(y)}if(e instanceof Gr||e instanceof yn){let S={...t.backgroundBlur},M={...i.backgroundBlur};(S.enabled||M.enabled)&&(a.push(EJ(e,!0)),S.enabled||Object.assign(S,{enabled:!0,radius:0}),M.enabled||Object.assign(M,{enabled:!0,radius:0})),b=Vr("radius",e.backgroundBlur,S,M,s),b&&a.push(b)}if(e instanceof Gr){let S={...t.layerBlur},M={...i.layerBlur};(S.enabled||M.enabled)&&(a.push(CJ(e,!0)),S.enabled||Object.assign(S,{enabled:!0,radius:0}),M.enabled||Object.assign(M,{enabled:!0,radius:0})),_=Vr("radius",e.layerBlur,S,M,s),_&&a.push(_)}if(e instanceof yn||e instanceof $d){let S=Lb("cornerRadius",e,t,i,s);S&&a.push(S)}return a}function eE(e,t,i,r,s){let a=[];return e.data.visible&&a.push(...fJ(e,t,i,s,r)),e instanceof xr?a.push(...TJ(e,t,i,s,r)):(e.data.visible&&a.push(...gJ(e,t,i,r)),Oa(e)?(e instanceof rs&&e.data.visible&&a.push(...iJ(e,t,i,r)),e.data.visible&&a.push(...sJ(e,t,i,r))):UX(e)?e.data.visible&&a.push(...rJ(e,t,i,r)):FX(e)&&a.push(...$K(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 tE=new I;function zb(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]=Dl.patch(n,l)}rE(e.scene,a,null,t,n.events.find(o=>o.data.type==="Follow"||o.data.type==="LookAt")!==void 0),iE(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(tE,!0),a.rigidBody?.setAngvel(tE,!0)),!Yt.is(a))return;let n=a.uuid,o=a.data;if(delete a.states,a.uuid===Qc)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 u={...h.data};e.data.globalPhysics.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0&&delete u.position,h.data.rotation!==void 0&&delete u.rotation,h.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),a.states||(a.states={}),a.states[h.id]=Cl.patch(o,u)}rE(e.scene,a,null,t,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0),iE(e),a instanceof ts&&a.frame&&(a.frame.traverse(h=>s(h)),a.uiCanvas?.applySize())}),e.frame&&(e.frame.traverse(a=>s(a)),e.uiCanvas?.applySize())}function iE(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 rE(e,t,i,r,s=!1){if(t instanceof rs&&t.removeInteractionGeometry(r),t instanceof xr?t.changeSelectedState(i,{shared:r},s):t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof rs&&t.updateGeometryGroupsIfNeeded(),t instanceof as&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),!(t instanceof xr)){if(t.cloner)for(let a of t.cloner.children)a.playModeVisible=void 0;t.updateVisible(e)}}function nD(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
|
|
7350
7350
|
${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
|
|
7351
|
-
)`}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=Oo.linear;break;case 1:i=Oo.ease;break;case 2:i=Oo.easeIn;break;case 3:i=Oo.easeOut;break;case 4:i=Oo.easeInOut;break;default:i=Oo.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function K1(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 PJ={type:"beginState"},DJ={type:"completeState",isfromEntity:!1},sE=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 xr||this.object.traverseEntity(o=>{o!==this.object&&o instanceof as&&o.dispatchEvent(PJ)})},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 xr||this.object.traverseEntity(o=>{o!==this.object&&o instanceof as&&o.dispatchEvent(DJ)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=eE(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=tm(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=tm(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=tm(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,...K1(r),...nD(r),change:this.onChange},this.callback=eE(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}},oD=class extends Qr{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=tm(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=K1(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=aD.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?.playing===!0)?(h=void 0,this.object instanceof as&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new sE(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(u.params,{startOnceDelay:0}),this.tweens[n]=u,this.timeline.add(u.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?.playing===!0)?(h=void 0,this.object instanceof as&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new sE(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(u.params,{startOnceDelay:0}),this.tweens[n-1]=u,this.timeline.add(u.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(zi(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=K1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}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 xr?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(zi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function tm(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 OJ={type:"beginState"},aE={type:"completeState",isfromEntity:!1},nE={type:"requestRender"},lD=class extends Qr{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new I,this.posEnd=new I,this.qStart=new Mt,this.qEnd=new Mt,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=aD({targets:i,t:1,...nD(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.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(OJ));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(nE),i.t===1&&r.dispatchEvent(aE)}})}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(zi(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(zi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(aE),this.page.activeCamera.dispatchEvent(nE))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},hD=class extends Qr{constructor(e,t,i,r,s){super(),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];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(zi(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=st.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(zi(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()}},cD=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(zi(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))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),zb(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},uD=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=zi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=x3(this.data.expression,this.shared,Ws.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},dD=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(zi(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)}};function zi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=x3(t.expression,e,"boolean");return t.negate?!i:!!i}function As(e,t,i,r,s,a){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:u})=>{try{u.type==="Audio"&&!(a instanceof xr)?Cs[e.type].includes("Audio")&&n.Audio.push(new FP(h,u,a,r,l)):u.type==="Video"&&!(a instanceof xr)?Cs[e.type].includes("Video")&&n.Video.push(new fD(h,u,a,r,l)):u.type==="Particles"?Cs[e.type].includes("Particles")&&n.Particles.push(new UP(u,i,r,l)):u.type==="Link"?Cs[e.type].includes("Link")&&n.Link.push(new xK(u,s.controlsManager,r,l)):u.type==="Create"?Cs[e.type].includes("Create")&&n.Create.push(new mD(u,i,s.controlsManager,r,l)):u.type==="Destroy"?Cs[e.type].includes("Destroy")&&n.Destroy.push(new VP(u,i,s.controlsManager,r,l)):u.type==="Reset"?Cs[e.type].includes("Reset")&&n.Reset.push(new jP(u,i,r,s,l)):u.type==="Transition"?Cs[e.type].includes("Transition")&&n.Transition.push(new oD(u,i,r,l)):u.type==="SwitchCamera"?Cs[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new lD(u,i,r,l)):u.type==="SceneTransition"?Cs[e.type].includes("SceneTransition")&&n.SceneTransition.push(new cD(u,i,s,r,l)):u.type==="Animation"?Cs[e.type].includes("Animation")&&n.Animation.push(new hD(u,i,s.animationControls,r,l)):u.type==="SetVariable"?Cs[e.type].includes("SetVariable")&&n.SetVariable.push(new uD(u,i,r,l)):u.type==="DynamicVariablePlay"?Cs[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new dD(u,i,r,l)):u.type==="Conditional"&&Cs[e.type].includes("Conditional")&&(u.ifActions.forEach(o({expression:u.condition,negate:!1})),u.elseActions.forEach(o({expression:u.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Ir(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof FP||i instanceof fD||i instanceof UP||i instanceof hD||i instanceof oD||i instanceof mD||i instanceof VP||i instanceof lD||i instanceof cD||i instanceof jP||i instanceof uD||i instanceof dD)&&i.dispose()})})}function IJ(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 pD=new Map,pd=new Map,wc=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=IJ(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,kx&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),pd.has(i.uuid)?pd.get(i.uuid).push(this):pd.set(i.uuid,[this]),pD.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())}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)}},J1=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=pD.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=pd.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=[...pd.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}},fD=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new wc(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new J1(t);else throw new Error("Missing property")}dispatchBasic(){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof wc?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof wc?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},oE=(()=>{let e,t,i,r;function s(o){!e&&!lE()&&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,u=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,d=0;for(;d<c;){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&&u[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(u[p.userData.actionId]>p.userData.quantity&&u[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)),c--,r())}e=d>0?requestAnimationFrame(a):void 0,i=d>0?o:void 0}function n(){lE()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function lE(){return!!document&&document.hidden}var hE=new Mt,RJ=new I,BJ=new I,mD=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=st.generateUUID(),this.dispatch=()=>{if(zi(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(zi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=OG(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 is(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.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),oE(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Ba)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 is)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Ba)return;n instanceof is?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(RJ,hE,BJ),l.applyQuaternion(hE),this.data.velocity.some(u=>u!==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(u=>u!==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");oE(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=[]}},gD=200,F0=.02,U0=.3,LJ=65,xte=new I,cE=new I,uE=new I,zJ=new I,fs=new I,Ts=new I,Co=new I,V0=new Le,dE=new Le,kJ=new Le,bte=new Le,Ea=new Mt,Fn=new Mt,en=new vr(0,0,0,"YXZ"),NJ=new I(1,0,0),Ca=new I(0,1,0),FJ=new I(0,0,1),pE=new I(1,1,1),wte=new zs,UJ=1,VJ=.025,jJ=16e-6,fE=12,GJ=20,Er=new da,ra=new er,HJ={type:"requestRender"},WJ={type:"updateMatrix"},mE=Math.PI/6,$1=class extends Qr{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 Le,this.target0=new I,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=gD,this.euler0=new vr(0,0,0,"YXZ"),this.position0Cam=new I,this.quat0Cam=new Mt,this.scale0Cam=new I,this.hiddenMatrix0Cam=new Le,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new da(new I(0,-40,0),new I(0,40,0)),matrix:new Le,position:new I,rotation:new Mt},this.euler=new vr(0,0,0,"YXZ"),this.eulerDelta=new I,this.lastPosition=new I,this.lastCameraQuaternion=new Mt,this.lastCameraPosition=new I,this.PI_2=Math.PI/2,this.prevMouse=new $,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 Le,this.nonColliderPosOffset=new Le,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 Le,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 Mt,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 Mt,this.objXZQuatInv=new Mt,this.objXZRotMat=new Le,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new I,this.pushedVelocity=new I,this.groundYRotation=0,this.objectRealQuat=new Mt,this.colliderWorldQuat=new Mt,this.groundNormal=new I,this.groundTilt=new Mt,this.groundTiltInv=new Mt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new I,this.quaternion=new Mt,this.scale=new I,this.initialAction=!0,this.onPointerDown=f=>{f.target!==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"&&!Hs&&(!QS||ZS>=15.5)&&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 m=f.clientX-this.prevMouse.x,v=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(QS&&ZS<15.5&&!Hs?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-v*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=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-v*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?$1.isLocked=!0:$1.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 m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let v=2;v<4;v++){let y=f.axes[v];m===0?v===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,v===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(),u=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,u,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),m=new I().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,y;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,y=m.projectOnVector(f)):m.y/f.y>0?y=f.multiplyScalar(m.y/f.y):y=f.multiplyScalar(m.length()),this.targetToCamera0.copy(y).negate(),v=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(v,this.position);let x=new vr().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 as&&(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)*UJ,this.speedOrbit=(i.speedRotate??100)*VJ,this.mouseOrbitSensitivity=(i.speedRotate??100)*jJ,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[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??Oc.defaultData.gravity)*fE,this.usePhysics=this.gloabalPhysics.usePhysics??Oc.defaultData.usePhysics,this.jumpPower=i.jumpPower*GJ,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??Vm.defaultDataThirdPerson.orientWith,this.slopeThresh=LJ*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*F0/this.pixelsPerMeter,this.stepThresh=i.collider.height*U0/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*F0/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*U0/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*F0/this.pixelsPerMeter,this.stepThresh=i.collider.height*U0/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new I().fromArray(i.collider.position),d=new Mt().setFromEuler(new vr().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(c,d,pE),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.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new mt;f.push({fi:0,data:{...Tr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Tr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new cb({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new yr(e3.create({parameters:{width:p,height:p/10,hollow:.7}}),m),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 vr().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 as?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={},Um.list.forEach(i=>{this.actions[i]=As({...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"),Ir(this.actions.idle),Ir(this.actions.move),Ir(this.actions.run),Ir(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 fs.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=Ts.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*fE),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 u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h&&u.userData.isFollowingObj!==this.object.uuid){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(fs,Fn,Ts),this.groundVelocity.subVectors(fs,u.prevT),this.object.getWorldPosition(Ts).add(this.collider.position).sub(fs),this.groundYRotation=en.setFromQuaternion(Fn).y-u.prevR.y,Co.copy(Ts).applyAxisAngle(Ca,this.groundYRotation),this.groundVelocity.add(Co.sub(Ts)).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=fs.subVectors(this.path[1],this.position),h=Ts.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=zJ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ts.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")if(this.orientWith==="camera"&&this.path.length<=1){let o=fs;this.camera.getWorldDirection(o);let l=Co.copy(Ca).multiplyScalar(o.dot(Ca));o.sub(l);let h=Ts.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(en.setFromVector3(this.rot),this.moveMode==="walk"&&(en.x=0),n.applyEuler(en),a&&(Fn.setFromUnitVectors(Ca,this.groundNormal),n.applyQuaternion(Fn)),i){let o=en.set(0,this.vrEulerYOffset*mE,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=Ts;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=Co.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),fs.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=Yt.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==c){let d;l instanceof is&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),c.dispatchEvent(tx));this.lastHitObj=c}if(u!==null){this.pushedVelocity.copy(h),o.copy(u.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(Ca,this.euler.y-this.euler0.y);let o=Ts.copy(this.objectToCamXZ).normalize(),l=Co.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(fs.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=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=st.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(en.copy(t),en.y=0):(en.copy(this.euler),en.y=0),this.nonColliderRotOffset.makeRotationFromEuler(en)),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*mE),Ea.setFromAxisAngle(NJ,this.rot.x),Fn.setFromAxisAngle(Ca,this.rot.y),Fn.multiply(Ea),Ea.setFromAxisAngle(FJ,this.rot.z),Fn.multiply(Ea),this.quaternion.copy(Fn),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Ts.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new I;for(let u=0;u<5;u++){let c=o.length(),d=Co.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,c,!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&&u===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 S of p.cloner.children)if(S.rigidBody===b){_=S;break}}x.dispatch(_),p.dispatchEvent(tx)}}}let f=cE.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=uE.copy(d).multiplyScalar(l.toi).dot(f),v=l.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(v=l.toi*(m-this.offset)/m,h.addScaledVector(d,v)),o.copy(d).multiplyScalar(c-v),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=Co.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{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(fs.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Ea.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);V0.lookAt(l,o,Ca).setPosition(l),V0.decompose(this.targetPos,this.targetQuat,fs),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=st.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=st.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(WJ),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(HJ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ea.setFromAxisAngle(Ca,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?st.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=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=fs.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Fn.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Ca.angleTo(e)*180/Math.PI<15||Ca.angleTo(e)*180/Math.PI>85?Ea.identity():Ea.setFromUnitVectors(Ca,e),this.groundTilt.slerp(Ea,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=uE.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=V0.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(fs,Ea,Ts).compose(fs,Ea,pE);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;ra.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=dE.copy(a).invert(),o=kJ.copy(dE).multiply(i);Er.copy(this.collider.segment),Er.start.applyMatrix4(o),Er.end.applyMatrix4(o);let l=cE.copy(this.position).applyMatrix4(n);ra.expandByPoint(Er.start),ra.expandByPoint(Er.end),ra.min.addScalar(-this.collider.radius),ra.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Er.end)},intersectsBounds:h=>h.intersectsBox(ra),intersectsTriangle:h=>{let u=fs,c=Ts,d=h.closestPointToSegment(Er,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,f=c.sub(u).normalize(),m=Co.copy(l);m.addScaledVector(f,p);let v=m.applyMatrix4(a).sub(this.position);t.add(v),Er.start.addScaledVector(f,p),Er.end.addScaledVector(f,p)}}})}),ra.makeEmpty(),Er.copy(this.collider.segment),Er.start.applyMatrix4(i),Er.end.applyMatrix4(i),ra.expandByPoint(Er.start),ra.expandByPoint(Er.end),ra.min.addScalar(-this.collider.radius),ra.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(Er.end)},intersectsBounds:s=>s.intersectsBox(ra),intersectsTriangle:s=>{let a=fs,n=Ts,o=s.closestPointToSegment(Er,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),Er.start.addScaledVector(h,l),Er.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)}},vD=$1;vD.isLocked=!1;var qJ=Br(IE());function Zn(e,t){let i=new ut;if(!e.getAttribute("position"))return i.setAttribute("position",new et([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=Eg(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new et(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var XJ=new Le,YJ=new Le,tn=[[0,0,0],[0,0,0],[0,0,0]];function yD(e){let t=e.elements;tn[0][0]=t[0],tn[0][1]=t[4],tn[0][2]=t[8],tn[1][0]=t[1],tn[1][1]=t[5],tn[1][2]=t[9],tn[2][0]=t[2],tn[2][1]=t[6],tn[2][2]=t[10];let{u:i,v:r}=(0,qJ.SVD)(tn),s=XJ.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=YJ.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 QJ=class extends SC{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}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 $o({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 ut;return a.setFromPoints([t,s]),new hm(a,e)}},xD=e=>e instanceof yc||e instanceof xc;function ZJ(e,t){return e.distance-t.distance}function bD(e,t,i){if(!(!Qn(t)||!t.visible)){Oa(t)&&t.raycast(e,i);for(let r of t.children)bD(e,r,i)}}function im(e,t,i,r=!1){if(!r&&!i.some(a=>ag(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>bD(e,a,s)),s.sort(ZJ),s}function ex(e){let t=[];if(e.length){let i=e[0].object;Qn(i)&&t.push(i);let r=i.parent;for(;r;)xD(r)&&t.push(r),r=r.parent}return t}function Kn(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 ag(e,t){if(Oa(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(xD(t))return wD(e,t)}function wD(e,t){if(!(!Qn(t)||!t.visible)){if(Oa(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=wD(e,i);if(r)return r}}}function KJ(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 JJ(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var $J=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 QJ,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=KJ(t,i,this._domRect),this.pointerScreen=JJ(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},Ga=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},kb=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],_D=e=>kb.find(([t,i])=>i===e)?.[0],ep=e=>kb.find(([t])=>t===e)?.[1],e$=(e,t)=>{let i=_D(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},t$=class extends Ga{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[_D(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of kb)if(i.data.events.some(a=>a.data.type===s&&!a.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let a={id:i.uuid,name:i.name},n=e$(s,a),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},i$=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=As(t,t.actions,r,s,a,i)}disconnect(){Ir(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.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):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)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{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())}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())}},r$=class extends Ga{constructor(e,t,i){super(e),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=n=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(n);let{raycaster:o,page:l}=this.eventContext,h=im(o,l,[],!0);this.sceneInterects=h,h.length&&(this.eventContext.sharedAssets.raycastProperty={x:h[0].point.x,y:h[0].point.y,z:h[0].point.z,objX:h[0].object.matrixWorld.elements[12],objY:h[0].object.matrixWorld.elements[13],objZ:h[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{(o.data.type==="MouseDown"||o.data.type==="MousePress")&&(this.onCanvasRaycast(n),o.dispatch())})},this.onCanvasMouseUp=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{o.data.type==="MouseUp"?(this.onCanvasRaycast(n),o.dispatch()):o.data.type==="MousePress"&&o.dispatchRelease()})},this.onMouseDown=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||(this.handleKeyEvent(n,"KeyDown"),this.handleKeyEventHeld(n,"KeyDown",!0)),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp"),this.handleKeyEventHeld(n,"KeyUp",!0)},this.onKeyPressDown=n=>{this.heldKeysPress[n.key]?this.handleKeyEventHeld(n,"KeyPress"):(this.handleKeyEvent(n,"KeyPress"),this.handleKeyEventHeld(n,"KeyPress",!0)),this.heldKeysPress[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this.releaseHeldKeyPress=n=>{delete this.heldKeysPress[n.key]},this._onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=ep(n);h&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress"?(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(u=>{u.dispatchUserEvent(l)})):(h==="KeyDown"||h==="KeyUp"||h==="KeyPress")&&(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(u=>{u.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext,a=(n,o)=>{if(!n.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let h of l){let u=this.eventsPerObjects[h];n.data.events.filter(({data:c})=>c.type===h&&c.disabled!==!0).forEach(({id:c,data:d})=>{try{let p=new i$(c,d,n,r,s,t);p.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(p):u[n.uuid]?u[n.uuid].some(f=>f.id===p.id)||u[n.uuid].push(p):u[n.uuid]=[p]}catch{}}),u[n.uuid]?.length&&this.objectsPerTypes[h].push(n instanceof xr&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress")?o:n)}};r.traverseEntity(n=>{(n instanceof ts||n instanceof jr)&&n.frame?.traverse(o=>{a(o,n)}),a(n)})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.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 xr));if(!(!a.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&Kn(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=im(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];ex(o).forEach(h=>{h instanceof ts&&Kn(h,l,Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=ag(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof ts&&Kn(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 xr)),s=[];if(i.length){if(!e){let{stopRaycast:a,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=Kn(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),u=>{s.push(u)})),a&&!h){let u=im(n,o,r);s=ex(u),u.forEach(c=>{c.object instanceof ts&&Kn(c.object,[c?.uv?.x??0,c?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{s.push(d)})})}else r.forEach(u=>{let c=ag(n,u);c&&(s.push(u),u instanceof ts&&Kn(u,[c?.uv?.x??0,c?.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)})})}},s$=new I,a$=new I,SD=class{constructor(e,t,i,r,s){this.actionsIn=As(e,e.inActions,i,r,s,t),this.actionsOut=As(e,e.outActions,i,r,s,t)}disconnect(){Ir(this.actionsIn),Ir(this.actionsOut)}},n$=class extends SD{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=s$.setFromMatrixPosition(this.objects[0].matrixWorld),u=a$.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(u)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let d=c==="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())}};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 u=r.find(h);if(!u)throw new Error("Missing property");this.objects.push(u)}}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)})}},o$=class extends SD{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(u=>u.dispatchConditional()),this.actionsOut.Particles.forEach(u=>u.dispatchConditional()),this.actionsOut.Video.forEach(u=>u.dispatchConditional()),this.actionsOut.Link.forEach(u=>u.dispatch()),this.actionsOut.Create.forEach(u=>u.dispatch()),this.actionsOut.Destroy.forEach(u=>u.dispatch()),this.actionsOut.Reset.forEach(u=>u.dispatch()),this.actionsIn.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(u=>u.play()),this.actionsOut.Animation.forEach(u=>u.play()),this.actionsIn.SwitchCamera.forEach(u=>u.pause()),this.actionsOut.SwitchCamera.forEach(u=>u.play()),this.actionsOut.SceneTransition.forEach(u=>u.dispatch()),this.actionsOut.SetVariable.forEach(u=>u.checkConditions()),this.actionsOut.SetVariable.forEach(u=>u.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(u=>u.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(u=>u.dispatchConditional()),this.actionsIn.Particles.forEach(u=>u.dispatchConditional()),this.actionsIn.Video.forEach(u=>u.dispatchConditional()),this.actionsIn.Link.forEach(u=>u.dispatch()),this.actionsIn.Create.forEach(u=>u.dispatch()),this.actionsIn.Destroy.forEach(u=>u.dispatch()),this.actionsIn.Reset.forEach(u=>u.dispatch()),this.actionsOut.Transition.forEach(u=>u.pause()),this.actionsOut.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(u=>u.play()),this.actionsIn.Animation.forEach(u=>u.play()),this.actionsOut.SwitchCamera.forEach(u=>u.pause()),this.actionsIn.SwitchCamera.forEach(u=>u.play()),this.actionsIn.SceneTransition.forEach(u=>u.dispatch()),this.actionsIn.SetVariable.forEach(u=>u.checkConditions()),this.actionsIn.SetVariable.forEach(u=>u.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(u=>u.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(){El(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),El(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),El(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),El(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},l$=class extends Ga{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new n$(a,n,s,i,r,t):n.condition.type==="State"&&(o=new o$(a,n,s,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Vu=new I,To=new I,pl=new I,gE=new Gs,h$=.01,ri=new I,gr=new I,vE=new I,Rl=new Mt,j0=new vr,c$=new Le,G0=new Ki,Uh=new I,rn=new I,Vh=.2;function H0(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 u$=function(){let e=new Le;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"&&H0(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?H0(s.position,t.limits):t.reference==="local"&&(Rl.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Rl),H0(s.position,t.limits),Rl.invert(),s.position.applyQuaternion(Rl),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(ri,s.quaternion,gr),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Ss&&ro(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),d$=class{constructor(e,t,i,r,s,a){this.object=e,this.data=t,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=As(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=As(t,t.dragDropActions.drop,i,r,s,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&n.push(u)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new I().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new I().setFromMatrixPosition(o.matrixWorld),pointStart:new I,pointEnd:new I,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new I().copy(o.position),quat0:new Mt().copy(o.quaternion),snapped:!1,orientationMatrix:new Le,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Ir(this.actionsDrag),Ir(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()})}},p$=class extends Ga{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(wt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:u,pointStart:c}of o.dragItems){if(h===n[0].object||h===n[0].object.object||Yt.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(ri,Rl,gr),j0.setFromQuaternion(Rl),d.prevR===void 0?(d.prevR=j0.clone(),d.prevT=ri.clone()):(d.prevR.copy(j0),d.prevT.copy(ri)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(wt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(wt.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||Yt.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof yc)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===h.object.uuid||a.scene.find(u).isAncestorOf(h.object.uuid))))[0]),l){let h=vE.copy(l.face.normal).applyMatrix3(G0.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){ri.copy(h).applyMatrix3(G0.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;ri.x>Vh?gr.x=-u.recursiveBBox.min.x:ri.x<-Vh&&(gr.x=-u.recursiveBBox.max.x),ri.y>Vh?gr.y=-u.recursiveBBox.min.y:ri.y<-Vh&&(gr.y=-u.recursiveBBox.max.y),ri.z>Vh?gr.z=-u.recursiveBBox.min.z:ri.z<-Vh&&(gr.z=-u.recursiveBBox.max.z),gr.applyMatrix3(G0.invert())}else gr.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(gr)}this.activeEvent.data.autoOrient&&(ri.set(0,1,0).cross(h),ri.length()<1e-4&&ri.set(-1,0,0).cross(h),gr.crossVectors(vE,ri),o.orientationMatrix.makeBasis(ri,gr,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=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||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(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(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new d$(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(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(To),To.negate();let n=Rl.identity();switch(r==="parent"?c$.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(ri,n,gr):r==="local"&&e.matrixWorld.decompose(ri,n,gr),i){case"x":ri.set(1,0,0).applyQuaternion(n),Uh.copy(To).cross(ri),rn.copy(ri).cross(Uh);break;case"y":ri.set(0,1,0).applyQuaternion(n),Uh.copy(To).cross(ri),rn.copy(ri).cross(Uh);break;case"z":ri.set(0,0,1).applyQuaternion(n),Uh.copy(To).cross(ri),rn.copy(ri).cross(Uh);break;case"xy":rn.set(0,0,1).applyQuaternion(n);break;case"yz":rn.set(1,0,0).applyQuaternion(n);break;case"xz":rn.set(0,1,0).applyQuaternion(n);break;case"adaptive":To.angleTo(gr.set(0,1,0))>Math.PI/6?(ri.crossVectors(gr.set(0,1,0),To),rn.crossVectors(ri,gr)):rn.set(0,1,0);break;default:rn.copy(To);break}pl.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:pl;if(gE.setFromNormalAndCoplanarPoint(rn,o),!!a.ray.intersectPlane(gE,t)&&(i==="x"||i==="y"||i==="z")){let l=gr.subVectors(t,o).dot(ri);t.copy(o).addScaledVector(ri,l)}}updateDragItem(e,t=!1){pl.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Vu.subVectors(e.fromPosition,pl).divideScalar(e.currentDampingFactor):e.reset==="original"?(Vu.subVectors(e.obj.userData.worldPosition0,pl).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Vu.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(pl).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Vu.length()<h$:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&u$(e,Vu.add(pl),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},jh=new I,W0=new I,Un=new I,Vn=new I,yE=new Gs,f$=.01,m$={type:"requestRender"},g$=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}(),xE=function(){let e=new Le;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 Ss&&ro(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),v$=class{constructor(e,t,i,r,s){this.data=e,this.object=t,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={...Iy.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.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=As(e,e.actions,i,r,s,t)}},y$=class extends Ga{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(wt.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new v$(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&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,Ir(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(Un),e.isReset)Vn.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Vn);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(W0),W0.negate(),jh.copy(W0)):i==="xy"?jh.set(0,0,1):i==="xz"?jh.set(0,1,0):i==="yz"&&jh.set(1,0,0),yE.setFromNormalAndCoplanarPoint(jh,Un),!o.ray.intersectPlane(yE,Vn))return}if(!e.isReset){if(Vn.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)Vn.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&&(Vn.x=Un.x),e.data.enabledTranslation[1]===!1&&(Vn.y=Un.y),e.data.enabledTranslation[2]===!1&&(Vn.z=Un.z);let a=g$(Un,Vn,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=jh.subVectors(a,Un).divideScalar(e.currentDampingFactor);Un.add(n),t&&xE(e.object,Un),e.paused=n.length()<f$}else xE(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(m$)}},ju=new I,Uf=new I,Gu=new Le,Gh=new Mt,Po=new Mt,Hu=new I,Wu=new I,fl=new I,jn=new I,q0=new Gs,x$=1e-6,b$={type:"requestRender"},w$={type:"changeRotation"},bE=function(){let e=new Le;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(yD(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Ss&&ro(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),_$=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new Mt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Ry.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},S$=class extends Ga{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(wt.length>1)){this._lastMouseEvent=i,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.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let a=ep(r);a&&a==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new _$(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let a=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,a]),n.addEventListener("requestRender",a)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&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:u,target:c}=e;if(u.getWorldPosition(Hu),!e.isReset)if(e.target)e.target.getWorldPosition(Wu);else{if(s==="custom"?(l().getWorldDirection(Uf),Uf.negate(),q0.setFromNormalAndCoplanarPoint(Uf,Hu)):(s==="xy"?ju.set(0,0,1):s==="xz"?ju.set(0,1,0):s==="yz"&&ju.set(1,0,0),q0.setFromNormalAndCoplanarPoint(ju,Hu)),!h.ray.intersectPlane(q0,Wu))return;r>0&&(s==="custom"||s===void 0)&&Wu.addScaledVector(Uf,r)}if(e.isReset||(c?t==="target"?fl.copy(c.up).applyMatrix4(Gu.extractRotation(c.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(jn.set(0,0,1),n[2]===!1&&jn.set(0,1,0)):i==="y"?(jn.set(1,0,0),n[0]===!1&&jn.set(0,0,1)):(jn.set(0,1,0),n[1]===!1&&jn.set(1,0,0)),fl.copy(jn).applyQuaternion(e.worldQuaternion0).normalize()):fl.set(0,1,0):s==="custom"?fl.set(0,1,0):fl.copy(ju)),e.isReset)Po.copy(e.worldQuaternion0);else if(Hu.distanceTo(Wu)>a&&o&&c)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)Po.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;A$(Gu,Wu,Hu,fl,i,jn),Po.setFromRotationMatrix(Gu),Gh.setFromUnitVectors(jn.applyQuaternion(Po),fl),n.some(d=>d===!1)&&t!=="target"&&Po.premultiply(Gh).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),Gh.setFromRotationMatrix(yD(u.matrixWorld)),Gh.slerp(Po,1/e.currentDampingFactor),bE(u,Gu.makeRotationFromQuaternion(Gh)),e.paused=8*(1-Gh.dot(Po))<x$):(bE(u,Gu.makeRotationFromQuaternion(Po)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(b$),u.dispatchEvent(w$)}},sa=new I,mr=new I,Qi=new I;function A$(e,t,i,r,s,a){let n=e.elements;Qi.subVectors(t,i),Qi.lengthSq()===0&&(Qi.z=1),Qi.normalize(),mr.crossVectors(r,Qi),mr.lengthSq()===0&&(Math.abs(r.z)===1?Qi.x+=1e-4:Qi.z+=1e-4,Qi.normalize(),mr.crossVectors(r,Qi)),mr.normalize(),sa.crossVectors(Qi,mr),s==="x"?a.z===1?[mr,sa,Qi]=[Qi,mr,sa]:(mr.negate(),[mr,Qi]=[Qi,mr]):s==="y"?a.x===1?[mr,sa,Qi]=[sa,Qi,mr]:(mr.negate(),[sa,Qi]=[Qi,sa]):a.x===1&&(mr.negate(),[mr,sa]=[sa,mr]),n[0]=mr.x,n[4]=sa.x,n[8]=Qi.x,n[1]=mr.y,n[5]=sa.y,n[9]=Qi.y,n[2]=mr.z,n[6]=sa.z,n[10]=Qi.z}var M$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=As(t,t.actions,r,s,a,i)}disconnect(){Ir(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.dispatch()),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()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,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())}},E$=class extends Ga{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=a=>{wt.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseHoverEvent())},this.onMouseUp=a=>{wt.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=a=>{wt.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:a,target:n,reverse:o})=>{if(!a||!n)return;let l=ep(a);l&&l==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(h=>h.dispatchUserEvent(o)))};let{page:i,sharedAssets:r}=this.eventContext,s=(a,n)=>{if(!(!a.visible||!a.data?.events.length)){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="MouseHover")try{let h=new M$(o,l,a,i,r,t);this.eventsPerObjects[a.uuid]?this.eventsPerObjects[a.uuid].push(h):this.eventsPerObjects[a.uuid]=[h]}catch{}this.eventsPerObjects[a.uuid]?.length&&this.objects.push(a instanceof xr?n:a)}};i.traverseEntity(a=>{(a instanceof ts||a instanceof jr)&&a.frame?.traverse(n=>{s(n,a)}),s(a)})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(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=Kn(s,[a.x,a.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=im(r,s,this.objects);t=ex(o),o.forEach(l=>{l.object instanceof ts&&Kn(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=ag(r,o);l&&(t.push(o),o instanceof ts&&Kn(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}},C$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=As(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){Ir(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())}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())}},T$=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=As(t,t.actions,r,s,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,a=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=a-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Ir(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())}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())}},P$=class extends Ga{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([o,l])=>{l.forEach(h=>h.handleResize())})},this.onScroll=o=>{if(!this.isInview)return;let l={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([h,u])=>{h.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:l}),u.forEach(c=>c.dispatch(l))})},this.onWheel=o=>{!this.isInview||o.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:o.deltaY}),h.forEach(u=>u.dispatch(o.deltaY))})},this.onUserEvent=({eventName:o,target:l,reverse:h})=>{if(!o||!l)return;let u=ep(o);u&&u==="Scroll"&&(l.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(l)?.forEach(c=>{c.dispatchUserEvent(h)}))};let{page:i,sharedAssets:r,domElement:s,isExport:a}=this.eventContext,n=o=>{if(o.data?.events.length){for(let{id:l,data:h}of o.data.events)if(!h.disabled&&h.type==="Scroll")if(h.trigger==="load"||!a){let u=new C$(l,h,o,i,r,t);this.wheelEventsPerObject.has(o)?this.wheelEventsPerObject.get(o)?.push(u):this.wheelEventsPerObject.set(o,[u])}else{let u=new T$(l,h,o,i,r,s,t);this.scrollEventsPerObject.has(o)?this.scrollEventsPerObject.get(o)?.push(u):this.scrollEventsPerObject.set(o,[u])}}};i.traverseEntity(o=>{(o instanceof ts||o instanceof jr)&&o.frame?.traverse(l=>{n(l)}),n(o)}),this.intersectionObserver=new IntersectionObserver(o=>{let l=o[0];l&&(this.isInview=l.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,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)})}},D$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=As(t,t.actions,r,s,a,i)}disconnect(){Ir(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.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 Il?t.interaction.audioPlayer.play():t.interaction instanceof X1&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof wc?t.interaction.play(i==="autoplay"):t.interaction instanceof J1&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}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.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Il?t.interaction.audioPlayer.play():t.interaction instanceof X1&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof wc?t.interaction.play():t.interaction instanceof J1&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},O$=class extends Ga{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;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(n=>{n.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 Il&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof wc&&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.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=ep(i);a&&a==="Start"&&(r instanceof xr||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 D$(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)&&(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 ts||r instanceof jr)&&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()}},I$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=As(t,t.actions,r,s,a,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Ir(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{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()}))}},R$=class extends Ga{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.events=[],this.onFrame=a=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:d,property:p,prevValue:f}=this.propertiesToWatch[c],m=this.eventContext.scene.find(d),v=Ly.propertyPaths[p];if(v[0]==="width"||v[0]==="height"||v[0]==="depth")m=m.geometry.userData.parameters[v[0]];else for(let y=0;y<v.length;y++)m=m[v[y]];f===null?this.propertiesToWatch[c].prevValue=m instanceof I?m.clone():m:(m instanceof I?!m.equals(f):f!==m)&&(l.push({objId:d,property:p}),m instanceof I?this.propertiesToWatch[c].prevValue.copy(m):this.propertiesToWatch[c].prevValue=m)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:d,prevValue:p}=this.variablesToWatch[c],f=this.shared.getVariable(d);f!==p&&(o.push(d),this.variablesToWatch[c].prevValue=f)}for(let c=0;c<this.dynamicVars.length;c++){let{id:d,expectedTime:p,last:f,data:m,timerSeconds:v,startValue:y}=this.dynamicVars[c],x=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?x=1:m.dynamicVariableType==="counter"?x=m.updateInterval:m.dynamicVariableType==="random"&&(x=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+x;continue}if(!((this.shared.getDynamicVariablePlayState(d)==="Stopped"||this.shared.getDynamicVariablePlayState(d)==="Restarted")&&(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+x,m.dynamicVariableType==="counter"&&this.shared.getVariable(d)!==y&&(this.shared.updateVariable(d,y),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==y&&(this.dynamicVars[c].timerSeconds=y,this.shared.updateVariable(d,la.getFormattedTimerTime(y,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(d)==="Restarted"&&this.shared.setDynamicVariablePlayState(d,"Playing"),this.shared.getDynamicVariablePlayState(d)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(d)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-a,0)),this.dynamicVars[c].last=a-(x-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=a+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(a>=p)if(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime+=x,m.dynamicVariableType==="random"){let b=m.min+Math.random()*(m.max-m.min),_=m.decimals;b=Math.round(b*Math.pow(10,_))/Math.pow(10,_),this.shared.updateVariable(d,b),o.push(d),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let b=this.shared.getVariable(d),_=this.shared.getDynamicVariableToggleIsForward(d)??!0,S=this.shared.getVariable(d)+m.increment*(_?1:-1);m.hasEnd&&(S=m.increment>0?st.clamp(S,y,m.endValue):st.clamp(S,m.endValue,y),S===y&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?S===m.endValue&&(S=y):(S===y||S===m.endValue)&&this.shared.setDynamicVariablePlayState(d,"Paused")),S!==b&&(o.push(d),this.shared.updateVariable(d,S),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(d,kA(n,m)),o.push(d),this.eventManager.requestRender();else{let b=Ws.isTextValue(m.endValue)?wE(m.endValue.textValue):m.endValue,_=this.shared.getDynamicVariableToggleIsForward(d)??!0,S=v+(a-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(_?1:-1);S=Math.max(S,0),m.hasEnd&&(S=m.dynamicVariableType==="stopwatch"?st.clamp(S,y,b):st.clamp(S,b,y),S===y&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?Math.abs(S-b)<(m.format==="number3decimal"?1e-4:.1)&&(S=y):(Math.abs(S-y)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(S-b)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(d,"Paused")),S!==v&&(o.push(d),this.dynamicVars[c].timerSeconds=S,this.shared.updateVariable(d,la.getFormattedTimerTime(S,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(c=>{c.data.variableId==="mouseProperty"&&(c.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let u=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,u=!0),this.events.forEach(c=>{(o.includes(c.data.variableId)||l.find(d=>d.objId===c.data.objectId&&d.property===c.data.property)||c.data.variableId==="mouseProperty"&&h||c.data.variableId==="raycastProperty"&&u)&&(c.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(a=>{a.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new B$(a.uuid,n.data,a,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(Ws.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(a,kA(new Date,n)),n.dynamicVariableType==="counter"&&(o=Ws.isTextValue(n.value)?wE(n.value.textValue):n.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){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.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())}},B$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=As(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())}dispose(){Ir(this.actions)}};function wE(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var L$="https://unpkg.com/@splinetool/runtime@1.0.21/build/",z$="https://unpkg.com/@splinetool/navmesh-wasm@1.0.21/build/",k$=`
|
|
7351
|
+
)`}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=Oo.linear;break;case 1:i=Oo.ease;break;case 2:i=Oo.easeIn;break;case 3:i=Oo.easeOut;break;case 4:i=Oo.easeInOut;break;default:i=Oo.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:Math.max(e.duration,1e-4),easing:t}}function K1(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 PJ={type:"beginState"},DJ={type:"completeState",isfromEntity:!1},sE=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 xr||this.object.traverseEntity(o=>{o!==this.object&&o instanceof as&&o.dispatchEvent(PJ)})},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 xr||this.object.traverseEntity(o=>{o!==this.object&&o instanceof as&&o.dispatchEvent(DJ)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=eE(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=tm(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=tm(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=tm(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,...K1(r),...nD(r),change:this.onChange},this.callback=eE(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}},oD=class extends Qr{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=tm(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=K1(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=aD.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?.playing===!0)?(h=void 0,this.object instanceof as&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new sE(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(u.params,{startOnceDelay:0}),this.tweens[n]=u,this.timeline.add(u.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?.playing===!0)?(h=void 0,this.object instanceof as&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new sE(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(u.params,{startOnceDelay:0}),this.tweens[n-1]=u,this.timeline.add(u.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(zi(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=K1(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}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 xr?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(zi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function tm(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 OJ={type:"beginState"},aE={type:"completeState",isfromEntity:!1},nE={type:"requestRender"},lD=class extends Qr{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new I,this.posEnd=new I,this.qStart=new Mt,this.qEnd=new Mt,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=aD({targets:i,t:1,...nD(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.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(OJ));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(nE),i.t===1&&r.dispatchEvent(aE)}})}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(zi(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(zi(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(aE),this.page.activeCamera.dispatchEvent(nE))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},hD=class extends Qr{constructor(e,t,i,r,s){super(),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];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(zi(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=st.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(zi(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()}},cD=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(zi(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))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),zb(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},uD=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=zi(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=x3(this.data.expression,this.shared,Ws.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},dD=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(zi(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)}};function zi(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=x3(t.expression,e,"boolean");return t.negate?!i:!!i}function As(e,t,i,r,s,a){let n={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:u})=>{try{u.type==="Audio"&&!(a instanceof xr)?Cs[e.type].includes("Audio")&&n.Audio.push(new FP(h,u,a,r,l)):u.type==="Video"&&!(a instanceof xr)?Cs[e.type].includes("Video")&&n.Video.push(new fD(h,u,a,r,l)):u.type==="Particles"?Cs[e.type].includes("Particles")&&n.Particles.push(new UP(u,i,r,l)):u.type==="Link"?Cs[e.type].includes("Link")&&n.Link.push(new xK(u,s.controlsManager,r,l)):u.type==="Create"?Cs[e.type].includes("Create")&&n.Create.push(new mD(u,i,s.controlsManager,r,l)):u.type==="Destroy"?Cs[e.type].includes("Destroy")&&n.Destroy.push(new VP(u,i,s.controlsManager,r,l)):u.type==="Reset"?Cs[e.type].includes("Reset")&&n.Reset.push(new jP(u,i,r,s,l)):u.type==="Transition"?Cs[e.type].includes("Transition")&&n.Transition.push(new oD(u,i,r,l)):u.type==="SwitchCamera"?Cs[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new lD(u,i,r,l)):u.type==="SceneTransition"?Cs[e.type].includes("SceneTransition")&&n.SceneTransition.push(new cD(u,i,s,r,l)):u.type==="Animation"?Cs[e.type].includes("Animation")&&n.Animation.push(new hD(u,i,s.animationControls,r,l)):u.type==="SetVariable"?Cs[e.type].includes("SetVariable")&&n.SetVariable.push(new uD(u,i,r,l)):u.type==="DynamicVariablePlay"?Cs[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new dD(u,i,r,l)):u.type==="Conditional"&&Cs[e.type].includes("Conditional")&&(u.ifActions.forEach(o({expression:u.condition,negate:!1})),u.elseActions.forEach(o({expression:u.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Ir(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof FP||i instanceof fD||i instanceof UP||i instanceof hD||i instanceof oD||i instanceof mD||i instanceof VP||i instanceof lD||i instanceof cD||i instanceof jP||i instanceof uD||i instanceof dD)&&i.dispose()})})}function IJ(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 pD=new Map,pd=new Map,wc=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=IJ(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,kx&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),pd.has(i.uuid)?pd.get(i.uuid).push(this):pd.set(i.uuid,[this]),pD.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())}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)}},J1=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=pD.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=pd.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=[...pd.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}},fD=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new wc(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new J1(t);else throw new Error("Missing property")}dispatchBasic(){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof wc?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(zi(this.shared,this.condition)===!1)return!1;this.interaction instanceof wc?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},oE=(()=>{let e,t,i,r;function s(o){!e&&!lE()&&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,u=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,d=0;for(;d<c;){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&&u[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(u[p.userData.actionId]>p.userData.quantity&&u[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)),c--,r())}e=d>0?requestAnimationFrame(a):void 0,i=d>0?o:void 0}function n(){lE()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function lE(){return!!document&&document.hidden}var hE=new Mt,RJ=new I,BJ=new I,mD=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=st.generateUUID(),this.dispatch=()=>{if(zi(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(zi(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=OG(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 is(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.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),oE(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof Ba)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 is)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof Ba)return;n instanceof is?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(RJ,hE,BJ),l.applyQuaternion(hE),this.data.velocity.some(u=>u!==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(u=>u!==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");oE(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=[]}},gD=200,F0=.02,U0=.3,LJ=65,xte=new I,cE=new I,uE=new I,zJ=new I,fs=new I,Ts=new I,Co=new I,V0=new Le,dE=new Le,kJ=new Le,bte=new Le,Ea=new Mt,Fn=new Mt,en=new vr(0,0,0,"YXZ"),NJ=new I(1,0,0),Ca=new I(0,1,0),FJ=new I(0,0,1),pE=new I(1,1,1),wte=new zs,UJ=1,VJ=.025,jJ=16e-6,fE=12,GJ=20,Er=new da,ra=new er,HJ={type:"requestRender"},WJ={type:"updateMatrix"},mE=Math.PI/6,$1=class extends Qr{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 Le,this.target0=new I,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=gD,this.euler0=new vr(0,0,0,"YXZ"),this.position0Cam=new I,this.quat0Cam=new Mt,this.scale0Cam=new I,this.hiddenMatrix0Cam=new Le,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new da(new I(0,-40,0),new I(0,40,0)),matrix:new Le,position:new I,rotation:new Mt},this.euler=new vr(0,0,0,"YXZ"),this.eulerDelta=new I,this.lastPosition=new I,this.lastCameraQuaternion=new Mt,this.lastCameraPosition=new I,this.PI_2=Math.PI/2,this.prevMouse=new $,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 Le,this.nonColliderPosOffset=new Le,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 Le,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 Mt,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 Mt,this.objXZQuatInv=new Mt,this.objXZRotMat=new Le,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new I,this.pushedVelocity=new I,this.groundYRotation=0,this.objectRealQuat=new Mt,this.colliderWorldQuat=new Mt,this.groundNormal=new I,this.groundTilt=new Mt,this.groundTiltInv=new Mt,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new I,this.quaternion=new Mt,this.scale=new I,this.initialAction=!0,this.onPointerDown=f=>{f.target!==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"&&!Hs&&(!QS||ZS>=15.5)&&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 m=f.clientX-this.prevMouse.x,v=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(QS&&ZS<15.5&&!Hs?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-v*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=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-v*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?$1.isLocked=!0:$1.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 m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let v=2;v<4;v++){let y=f.axes[v];m===0?v===2?this.movementState.movePosX=y:this.movementState.movePosZ=y:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,v===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(),u=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,u,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),m=new I().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,y;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,y=m.projectOnVector(f)):m.y/f.y>0?y=f.multiplyScalar(m.y/f.y):y=f.multiplyScalar(m.length()),this.targetToCamera0.copy(y).negate(),v=this.camera.position.clone().add(y),this.objectToTarget0.subVectors(v,this.position);let x=new vr().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 as&&(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)*UJ,this.speedOrbit=(i.speedRotate??100)*VJ,this.mouseOrbitSensitivity=(i.speedRotate??100)*jJ,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[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??Oc.defaultData.gravity)*fE,this.usePhysics=this.gloabalPhysics.usePhysics??Oc.defaultData.usePhysics,this.jumpPower=i.jumpPower*GJ,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??Vm.defaultDataThirdPerson.orientWith,this.slopeThresh=LJ*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*F0/this.pixelsPerMeter,this.stepThresh=i.collider.height*U0/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*F0/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*U0/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*F0/this.pixelsPerMeter,this.stepThresh=i.collider.height*U0/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new I().fromArray(i.collider.position),d=new Mt().setFromEuler(new vr().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(c,d,pE),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.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new mt;f.push({fi:0,data:{...Tr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...Tr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new cb({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new yr(e3.create({parameters:{width:p,height:p/10,hollow:.7}}),m),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 vr().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 as?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={},Um.list.forEach(i=>{this.actions[i]=As({...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"),Ir(this.actions.idle),Ir(this.actions.move),Ir(this.actions.run),Ir(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 fs.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=Ts.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*fE),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 u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h&&u.userData.isFollowingObj!==this.object.uuid){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(fs,Fn,Ts),this.groundVelocity.subVectors(fs,u.prevT),this.object.getWorldPosition(Ts).add(this.collider.position).sub(fs),this.groundYRotation=en.setFromQuaternion(Fn).y-u.prevR.y,Co.copy(Ts).applyAxisAngle(Ca,this.groundYRotation),this.groundVelocity.add(Co.sub(Ts)).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=fs.subVectors(this.path[1],this.position),h=Ts.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=zJ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Ts.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")if(this.orientWith==="camera"&&this.path.length<=1){let o=fs;this.camera.getWorldDirection(o);let l=Co.copy(Ca).multiplyScalar(o.dot(Ca));o.sub(l);let h=Ts.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(en.setFromVector3(this.rot),this.moveMode==="walk"&&(en.x=0),n.applyEuler(en),a&&(Fn.setFromUnitVectors(Ca,this.groundNormal),n.applyQuaternion(Fn)),i){let o=en.set(0,this.vrEulerYOffset*mE,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=Ts;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=Co.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),fs.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=Yt.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==c){let d;l instanceof is&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),c.dispatchEvent(tx));this.lastHitObj=c}if(u!==null){this.pushedVelocity.copy(h),o.copy(u.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(Ca,this.euler.y-this.euler0.y);let o=Ts.copy(this.objectToCamXZ).normalize(),l=Co.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(fs.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=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=st.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(en.copy(t),en.y=0):(en.copy(this.euler),en.y=0),this.nonColliderRotOffset.makeRotationFromEuler(en)),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*mE),Ea.setFromAxisAngle(NJ,this.rot.x),Fn.setFromAxisAngle(Ca,this.rot.y),Fn.multiply(Ea),Ea.setFromAxisAngle(FJ,this.rot.z),Fn.multiply(Ea),this.quaternion.copy(Fn),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Ts.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new I;for(let u=0;u<5;u++){let c=o.length(),d=Co.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,c,!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&&u===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 S of p.cloner.children)if(S.rigidBody===b){_=S;break}}x.dispatch(_),p.dispatchEvent(tx)}}}let f=cE.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=uE.copy(d).multiplyScalar(l.toi).dot(f),v=l.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(v=l.toi*(m-this.offset)/m,h.addScaledVector(d,v)),o.copy(d).multiplyScalar(c-v),Math.acos(-f.y)>this.slopeThresh){let y=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),x=Co.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{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(fs.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Ea.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);V0.lookAt(l,o,Ca).setPosition(l),V0.decompose(this.targetPos,this.targetQuat,fs),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=st.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=st.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(WJ),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(HJ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Ea.setFromAxisAngle(Ca,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?st.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=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=fs.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=Fn.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Ca.angleTo(e)*180/Math.PI<15||Ca.angleTo(e)*180/Math.PI>85?Ea.identity():Ea.setFromUnitVectors(Ca,e),this.groundTilt.slerp(Ea,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=uE.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=V0.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(fs,Ea,Ts).compose(fs,Ea,pE);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;ra.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=dE.copy(a).invert(),o=kJ.copy(dE).multiply(i);Er.copy(this.collider.segment),Er.start.applyMatrix4(o),Er.end.applyMatrix4(o);let l=cE.copy(this.position).applyMatrix4(n);ra.expandByPoint(Er.start),ra.expandByPoint(Er.end),ra.min.addScalar(-this.collider.radius),ra.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Er.end)},intersectsBounds:h=>h.intersectsBox(ra),intersectsTriangle:h=>{let u=fs,c=Ts,d=h.closestPointToSegment(Er,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,f=c.sub(u).normalize(),m=Co.copy(l);m.addScaledVector(f,p);let v=m.applyMatrix4(a).sub(this.position);t.add(v),Er.start.addScaledVector(f,p),Er.end.addScaledVector(f,p)}}})}),ra.makeEmpty(),Er.copy(this.collider.segment),Er.start.applyMatrix4(i),Er.end.applyMatrix4(i),ra.expandByPoint(Er.start),ra.expandByPoint(Er.end),ra.min.addScalar(-this.collider.radius),ra.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(Er.end)},intersectsBounds:s=>s.intersectsBox(ra),intersectsTriangle:s=>{let a=fs,n=Ts,o=s.closestPointToSegment(Er,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),Er.start.addScaledVector(h,l),Er.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)}},vD=$1;vD.isLocked=!1;var qJ=Br(IE());function Zn(e,t){let i=new ut;if(!e.getAttribute("position"))return i.setAttribute("position",new et([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=Eg(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new et(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var XJ=new Le,YJ=new Le,tn=[[0,0,0],[0,0,0],[0,0,0]];function yD(e){let t=e.elements;tn[0][0]=t[0],tn[0][1]=t[4],tn[0][2]=t[8],tn[1][0]=t[1],tn[1][1]=t[5],tn[1][2]=t[9],tn[2][0]=t[2],tn[2][1]=t[6],tn[2][2]=t[10];let{u:i,v:r}=(0,qJ.SVD)(tn),s=XJ.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=YJ.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 QJ=class extends SC{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}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 $o({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 ut;return a.setFromPoints([t,s]),new hm(a,e)}},xD=e=>e instanceof yc||e instanceof xc;function ZJ(e,t){return e.distance-t.distance}function bD(e,t,i){if(!(!Qn(t)||!t.visible)){Oa(t)&&t.raycast(e,i);for(let r of t.children)bD(e,r,i)}}function im(e,t,i,r=!1){if(!r&&!i.some(a=>ag(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>bD(e,a,s)),s.sort(ZJ),s}function ex(e){let t=[];if(e.length){let i=e[0].object;Qn(i)&&t.push(i);let r=i.parent;for(;r;)xD(r)&&t.push(r),r=r.parent}return t}function Kn(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 ag(e,t){if(Oa(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(xD(t))return wD(e,t)}function wD(e,t){if(!(!Qn(t)||!t.visible)){if(Oa(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=wD(e,i);if(r)return r}}}function KJ(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 JJ(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width,y:1-(t-(i.top+window.scrollY))/i.height}}var $J=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 QJ,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=KJ(t,i,this._domRect),this.pointerScreen=JJ(t,i,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}},Ga=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},kb=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],_D=e=>kb.find(([t,i])=>i===e)?.[0],ep=e=>kb.find(([t])=>t===e)?.[1],e$=(e,t)=>{let i=_D(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},t$=class extends Ga{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[_D(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of kb)if(i.data.events.some(a=>a.data.type===s&&!a.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let a={id:i.uuid,name:i.name},n=e$(s,a),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},i$=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=As(t,t.actions,r,s,a,i)}disconnect(){Ir(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.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):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)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{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())}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())}},r$=class extends Ga{constructor(e,t,i){super(e),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=n=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(n);let{raycaster:o,page:l}=this.eventContext,h=im(o,l,[],!0);this.sceneInterects=h,h.length&&(this.eventContext.sharedAssets.raycastProperty={x:h[0].point.x,y:h[0].point.y,z:h[0].point.z,objX:h[0].object.matrixWorld.elements[12],objY:h[0].object.matrixWorld.elements[13],objZ:h[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{(o.data.type==="MouseDown"||o.data.type==="MousePress")&&(this.onCanvasRaycast(n),o.dispatch())})},this.onCanvasMouseUp=n=>{(n.target===this.eventContext.domElement||n.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(o=>{o.data.type==="MouseUp"?(this.onCanvasRaycast(n),o.dispatch()):o.data.type==="MousePress"&&o.dispatchRelease()})},this.onMouseDown=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{wt.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||(this.handleKeyEvent(n,"KeyDown"),this.handleKeyEventHeld(n,"KeyDown",!0)),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp"),this.handleKeyEventHeld(n,"KeyUp",!0)},this.onKeyPressDown=n=>{this.heldKeysPress[n.key]?this.handleKeyEventHeld(n,"KeyPress"):(this.handleKeyEvent(n,"KeyPress"),this.handleKeyEventHeld(n,"KeyPress",!0)),this.heldKeysPress[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this.releaseHeldKeyPress=n=>{delete this.heldKeysPress[n.key]},this._onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=ep(n);h&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress"?(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(u=>{u.dispatchUserEvent(l)})):(h==="KeyDown"||h==="KeyUp"||h==="KeyPress")&&(o.dispatchEvent({type:"beginEvent",eventName:h}),this.eventsPerObjects[h]?.[o.uuid]?.forEach(u=>{u.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext,a=(n,o)=>{if(!n.data?.events.length)return;let l=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let h of l){let u=this.eventsPerObjects[h];n.data.events.filter(({data:c})=>c.type===h&&c.disabled!==!0).forEach(({id:c,data:d})=>{try{let p=new i$(c,d,n,r,s,t);p.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(p):u[n.uuid]?u[n.uuid].some(f=>f.id===p.id)||u[n.uuid].push(p):u[n.uuid]=[p]}catch{}}),u[n.uuid]?.length&&this.objectsPerTypes[h].push(n instanceof xr&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress")?o:n)}};r.traverseEntity(n=>{(n instanceof ts||n instanceof jr)&&n.frame?.traverse(o=>{a(o,n)}),a(n)})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.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 xr));if(!(!a.length&&!this.useForRaycastProperty)&&!(r.uiCanvas&&Kn(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=im(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];ex(o).forEach(h=>{h instanceof ts&&Kn(h,l,Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}t||n.forEach(o=>{let l=ag(i,o);l&&(this.handleObjectMouseEventDispatch(o,e),o instanceof ts&&Kn(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 xr)),s=[];if(i.length){if(!e){let{stopRaycast:a,raycaster:n,page:o,pointerScreen:l}=this.eventContext,h=!1;if(o.uiCanvas&&(h=Kn(o,[l.x,l.y],Object.keys(this.eventsPerObjects[t]),u=>{s.push(u)})),a&&!h){let u=im(n,o,r);s=ex(u),u.forEach(c=>{c.object instanceof ts&&Kn(c.object,[c?.uv?.x??0,c?.uv?.y??0],Object.keys(this.eventsPerObjects[t]),d=>{s.push(d)})})}else r.forEach(u=>{let c=ag(n,u);c&&(s.push(u),u instanceof ts&&Kn(u,[c?.uv?.x??0,c?.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)})})}},s$=new I,a$=new I,SD=class{constructor(e,t,i,r,s){this.actionsIn=As(e,e.inActions,i,r,s,t),this.actionsOut=As(e,e.outActions,i,r,s,t)}disconnect(){Ir(this.actionsIn),Ir(this.actionsOut)}},n$=class extends SD{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=s$.setFromMatrixPosition(this.objects[0].matrixWorld),u=a$.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(u)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let d=c==="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())}};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 u=r.find(h);if(!u)throw new Error("Missing property");this.objects.push(u)}}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)})}},o$=class extends SD{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(u=>u.dispatchConditional()),this.actionsOut.Particles.forEach(u=>u.dispatchConditional()),this.actionsOut.Video.forEach(u=>u.dispatchConditional()),this.actionsOut.Link.forEach(u=>u.dispatch()),this.actionsOut.Create.forEach(u=>u.dispatch()),this.actionsOut.Destroy.forEach(u=>u.dispatch()),this.actionsOut.Reset.forEach(u=>u.dispatch()),this.actionsIn.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(u=>u.play()),this.actionsOut.Animation.forEach(u=>u.play()),this.actionsIn.SwitchCamera.forEach(u=>u.pause()),this.actionsOut.SwitchCamera.forEach(u=>u.play()),this.actionsOut.SceneTransition.forEach(u=>u.dispatch()),this.actionsOut.SetVariable.forEach(u=>u.checkConditions()),this.actionsOut.SetVariable.forEach(u=>u.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(u=>u.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(u=>u.dispatchConditional()),this.actionsIn.Particles.forEach(u=>u.dispatchConditional()),this.actionsIn.Video.forEach(u=>u.dispatchConditional()),this.actionsIn.Link.forEach(u=>u.dispatch()),this.actionsIn.Create.forEach(u=>u.dispatch()),this.actionsIn.Destroy.forEach(u=>u.dispatch()),this.actionsIn.Reset.forEach(u=>u.dispatch()),this.actionsOut.Transition.forEach(u=>u.pause()),this.actionsOut.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(u=>u.play()),this.actionsIn.Animation.forEach(u=>u.play()),this.actionsOut.SwitchCamera.forEach(u=>u.pause()),this.actionsIn.SwitchCamera.forEach(u=>u.play()),this.actionsIn.SceneTransition.forEach(u=>u.dispatch()),this.actionsIn.SetVariable.forEach(u=>u.checkConditions()),this.actionsIn.SetVariable.forEach(u=>u.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(u=>u.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(){El(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),El(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),El(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),El(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},l$=class extends Ga{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new n$(a,n,s,i,r,t):n.condition.type==="State"&&(o=new o$(a,n,s,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Vu=new I,To=new I,pl=new I,gE=new Gs,h$=.01,ri=new I,gr=new I,vE=new I,Rl=new Mt,j0=new vr,c$=new Le,G0=new Ki,Uh=new I,rn=new I,Vh=.2;function H0(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 u$=function(){let e=new Le;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"&&H0(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?H0(s.position,t.limits):t.reference==="local"&&(Rl.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Rl),H0(s.position,t.limits),Rl.invert(),s.position.applyQuaternion(Rl),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(ri,s.quaternion,gr),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof Ss&&ro(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),d$=class{constructor(e,t,i,r,s,a){this.object=e,this.data=t,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=As(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=As(t,t.dragDropActions.drop,i,r,s,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&n.push(u)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),a[l.uuid]&&a[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new I().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new I().setFromMatrixPosition(o.matrixWorld),pointStart:new I,pointEnd:new I,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new I().copy(o.position),quat0:new Mt().copy(o.quaternion),snapped:!1,orientationMatrix:new Le,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Ir(this.actionsDrag),Ir(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()})}},p$=class extends Ga{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(wt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:u,pointStart:c}of o.dragItems){if(h===n[0].object||h===n[0].object.object||Yt.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(ri,Rl,gr),j0.setFromQuaternion(Rl),d.prevR===void 0?(d.prevR=j0.clone(),d.prevT=ri.clone()):(d.prevR.copy(j0),d.prevT.copy(ri)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(wt.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(wt.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||Yt.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof yc)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===h.object.uuid||a.scene.find(u).isAncestorOf(h.object.uuid))))[0]),l){let h=vE.copy(l.face.normal).applyMatrix3(G0.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){ri.copy(h).applyMatrix3(G0.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;ri.x>Vh?gr.x=-u.recursiveBBox.min.x:ri.x<-Vh&&(gr.x=-u.recursiveBBox.max.x),ri.y>Vh?gr.y=-u.recursiveBBox.min.y:ri.y<-Vh&&(gr.y=-u.recursiveBBox.max.y),ri.z>Vh?gr.z=-u.recursiveBBox.min.z:ri.z<-Vh&&(gr.z=-u.recursiveBBox.max.z),gr.applyMatrix3(G0.invert())}else gr.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(gr)}this.activeEvent.data.autoOrient&&(ri.set(0,1,0).cross(h),ri.length()<1e-4&&ri.set(-1,0,0).cross(h),gr.crossVectors(vE,ri),o.orientationMatrix.makeBasis(ri,gr,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=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||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(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(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new d$(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(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(To),To.negate();let n=Rl.identity();switch(r==="parent"?c$.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(ri,n,gr):r==="local"&&e.matrixWorld.decompose(ri,n,gr),i){case"x":ri.set(1,0,0).applyQuaternion(n),Uh.copy(To).cross(ri),rn.copy(ri).cross(Uh);break;case"y":ri.set(0,1,0).applyQuaternion(n),Uh.copy(To).cross(ri),rn.copy(ri).cross(Uh);break;case"z":ri.set(0,0,1).applyQuaternion(n),Uh.copy(To).cross(ri),rn.copy(ri).cross(Uh);break;case"xy":rn.set(0,0,1).applyQuaternion(n);break;case"yz":rn.set(1,0,0).applyQuaternion(n);break;case"xz":rn.set(0,1,0).applyQuaternion(n);break;case"adaptive":To.angleTo(gr.set(0,1,0))>Math.PI/6?(ri.crossVectors(gr.set(0,1,0),To),rn.crossVectors(ri,gr)):rn.set(0,1,0);break;default:rn.copy(To);break}pl.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:pl;if(gE.setFromNormalAndCoplanarPoint(rn,o),!!a.ray.intersectPlane(gE,t)&&(i==="x"||i==="y"||i==="z")){let l=gr.subVectors(t,o).dot(ri);t.copy(o).addScaledVector(ri,l)}}updateDragItem(e,t=!1){pl.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Vu.subVectors(e.fromPosition,pl).divideScalar(e.currentDampingFactor):e.reset==="original"?(Vu.subVectors(e.obj.userData.worldPosition0,pl).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Vu.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(pl).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Vu.length()<h$:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&u$(e,Vu.add(pl),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},jh=new I,W0=new I,Un=new I,Vn=new I,yE=new Gs,f$=.01,m$={type:"requestRender"},g$=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}(),xE=function(){let e=new Le;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 Ss&&ro(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),v$=class{constructor(e,t,i,r,s){this.data=e,this.object=t,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={...Iy.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.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=As(e,e.actions,i,r,s,t)}},y$=class extends Ga{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(wt.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new v$(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&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,Ir(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(Un),e.isReset)Vn.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Vn);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(W0),W0.negate(),jh.copy(W0)):i==="xy"?jh.set(0,0,1):i==="xz"?jh.set(0,1,0):i==="yz"&&jh.set(1,0,0),yE.setFromNormalAndCoplanarPoint(jh,Un),!o.ray.intersectPlane(yE,Vn))return}if(!e.isReset){if(Vn.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)Vn.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&&(Vn.x=Un.x),e.data.enabledTranslation[1]===!1&&(Vn.y=Un.y),e.data.enabledTranslation[2]===!1&&(Vn.z=Un.z);let a=g$(Un,Vn,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=jh.subVectors(a,Un).divideScalar(e.currentDampingFactor);Un.add(n),t&&xE(e.object,Un),e.paused=n.length()<f$}else xE(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(m$)}},ju=new I,Uf=new I,Gu=new Le,Gh=new Mt,Po=new Mt,Hu=new I,Wu=new I,fl=new I,jn=new I,q0=new Gs,x$=1e-6,b$={type:"requestRender"},w$={type:"changeRotation"},bE=function(){let e=new Le;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(yD(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof Ss&&ro(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),_$=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new Mt,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Ry.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},S$=class extends Ga{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(wt.length>1)){this._lastMouseEvent=i,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.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let a=ep(r);a&&a==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new _$(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let a=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,a]),n.addEventListener("requestRender",a)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Hs&&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:u,target:c}=e;if(u.getWorldPosition(Hu),!e.isReset)if(e.target)e.target.getWorldPosition(Wu);else{if(s==="custom"?(l().getWorldDirection(Uf),Uf.negate(),q0.setFromNormalAndCoplanarPoint(Uf,Hu)):(s==="xy"?ju.set(0,0,1):s==="xz"?ju.set(0,1,0):s==="yz"&&ju.set(1,0,0),q0.setFromNormalAndCoplanarPoint(ju,Hu)),!h.ray.intersectPlane(q0,Wu))return;r>0&&(s==="custom"||s===void 0)&&Wu.addScaledVector(Uf,r)}if(e.isReset||(c?t==="target"?fl.copy(c.up).applyMatrix4(Gu.extractRotation(c.matrixWorld)).normalize():n.some(d=>d===!1)?(i==="x"?(jn.set(0,0,1),n[2]===!1&&jn.set(0,1,0)):i==="y"?(jn.set(1,0,0),n[0]===!1&&jn.set(0,0,1)):(jn.set(0,1,0),n[1]===!1&&jn.set(1,0,0)),fl.copy(jn).applyQuaternion(e.worldQuaternion0).normalize()):fl.set(0,1,0):s==="custom"?fl.set(0,1,0):fl.copy(ju)),e.isReset)Po.copy(e.worldQuaternion0);else if(Hu.distanceTo(Wu)>a&&o&&c)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)Po.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;A$(Gu,Wu,Hu,fl,i,jn),Po.setFromRotationMatrix(Gu),Gh.setFromUnitVectors(jn.applyQuaternion(Po),fl),n.some(d=>d===!1)&&t!=="target"&&Po.premultiply(Gh).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),Gh.setFromRotationMatrix(yD(u.matrixWorld)),Gh.slerp(Po,1/e.currentDampingFactor),bE(u,Gu.makeRotationFromQuaternion(Gh)),e.paused=8*(1-Gh.dot(Po))<x$):(bE(u,Gu.makeRotationFromQuaternion(Po)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(b$),u.dispatchEvent(w$)}},sa=new I,mr=new I,Qi=new I;function A$(e,t,i,r,s,a){let n=e.elements;Qi.subVectors(t,i),Qi.lengthSq()===0&&(Qi.z=1),Qi.normalize(),mr.crossVectors(r,Qi),mr.lengthSq()===0&&(Math.abs(r.z)===1?Qi.x+=1e-4:Qi.z+=1e-4,Qi.normalize(),mr.crossVectors(r,Qi)),mr.normalize(),sa.crossVectors(Qi,mr),s==="x"?a.z===1?[mr,sa,Qi]=[Qi,mr,sa]:(mr.negate(),[mr,Qi]=[Qi,mr]):s==="y"?a.x===1?[mr,sa,Qi]=[sa,Qi,mr]:(mr.negate(),[sa,Qi]=[Qi,sa]):a.x===1&&(mr.negate(),[mr,sa]=[sa,mr]),n[0]=mr.x,n[4]=sa.x,n[8]=Qi.x,n[1]=mr.y,n[5]=sa.y,n[9]=Qi.y,n[2]=mr.z,n[6]=sa.z,n[10]=Qi.z}var M$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=As(t,t.actions,r,s,a,i)}disconnect(){Ir(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.dispatch()),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()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,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())}},E$=class extends Ga{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this.objects2D=[],this._prevObjects=[],this.onMouseDown=a=>{wt.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseHoverEvent())},this.onMouseUp=a=>{wt.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=a=>{wt.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:a,target:n,reverse:o})=>{if(!a||!n)return;let l=ep(a);l&&l==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(h=>h.dispatchUserEvent(o)))};let{page:i,sharedAssets:r}=this.eventContext,s=(a,n)=>{if(!(!a.visible||!a.data?.events.length)){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="MouseHover")try{let h=new M$(o,l,a,i,r,t);this.eventsPerObjects[a.uuid]?this.eventsPerObjects[a.uuid].push(h):this.eventsPerObjects[a.uuid]=[h]}catch{}this.eventsPerObjects[a.uuid]?.length&&this.objects.push(a instanceof xr?n:a)}};i.traverseEntity(a=>{(a instanceof ts||a instanceof jr)&&a.frame?.traverse(n=>{s(n,a)}),s(a)})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Hs&&(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=Kn(s,[a.x,a.y],Object.keys(this.eventsPerObjects),o=>{t.push(o)})),i&&!n){let o=im(r,s,this.objects);t=ex(o),o.forEach(l=>{l.object instanceof ts&&Kn(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=ag(r,o);l&&(t.push(o),o instanceof ts&&Kn(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}},C$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=As(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){Ir(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())}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())}},T$=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=As(t,t.actions,r,s,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,a=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=a-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Ir(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())}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())}},P$=class extends Ga{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([o,l])=>{l.forEach(h=>h.handleResize())})},this.onScroll=o=>{if(!this.isInview)return;let l={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([h,u])=>{h.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:l}),u.forEach(c=>c.dispatch(l))})},this.onWheel=o=>{!this.isInview||o.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:o.deltaY}),h.forEach(u=>u.dispatch(o.deltaY))})},this.onUserEvent=({eventName:o,target:l,reverse:h})=>{if(!o||!l)return;let u=ep(o);u&&u==="Scroll"&&(l.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(l)?.forEach(c=>{c.dispatchUserEvent(h)}))};let{page:i,sharedAssets:r,domElement:s,isExport:a}=this.eventContext,n=o=>{if(o.data?.events.length){for(let{id:l,data:h}of o.data.events)if(!h.disabled&&h.type==="Scroll")if(h.trigger==="load"||!a){let u=new C$(l,h,o,i,r,t);this.wheelEventsPerObject.has(o)?this.wheelEventsPerObject.get(o)?.push(u):this.wheelEventsPerObject.set(o,[u])}else{let u=new T$(l,h,o,i,r,s,t);this.scrollEventsPerObject.has(o)?this.scrollEventsPerObject.get(o)?.push(u):this.scrollEventsPerObject.set(o,[u])}}};i.traverseEntity(o=>{(o instanceof ts||o instanceof jr)&&o.frame?.traverse(l=>{n(l)}),n(o)}),this.intersectionObserver=new IntersectionObserver(o=>{let l=o[0];l&&(this.isInview=l.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,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)})}},D$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=As(t,t.actions,r,s,a,i)}disconnect(){Ir(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.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 Il?t.interaction.audioPlayer.play():t.interaction instanceof X1&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof wc?t.interaction.play(i==="autoplay"):t.interaction instanceof J1&&t.interaction.dispatch())}),this.actions.Particles.forEach(t=>{(t.data.triggerAfter??"any")===e&&t.dispatchBasic()})}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.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Il?t.interaction.audioPlayer.play():t.interaction instanceof X1&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof wc?t.interaction.play():t.interaction instanceof J1&&t.interaction.dispatch()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()})}},O$=class extends Ga{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;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(n=>{n.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 Il&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof wc&&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.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=ep(i);a&&a==="Start"&&(r instanceof xr||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 D$(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)&&(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 ts||r instanceof jr)&&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()}},I$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=As(t,t.actions,r,s,a,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Ir(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{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()}))}},R$=class extends Ga{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.events=[],this.onFrame=a=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:d,property:p,prevValue:f}=this.propertiesToWatch[c],m=this.eventContext.scene.find(d),v=Ly.propertyPaths[p];if(v[0]==="width"||v[0]==="height"||v[0]==="depth")m=m.geometry.userData.parameters[v[0]];else for(let y=0;y<v.length;y++)m=m[v[y]];f===null?this.propertiesToWatch[c].prevValue=m instanceof I?m.clone():m:(m instanceof I?!m.equals(f):f!==m)&&(l.push({objId:d,property:p}),m instanceof I?this.propertiesToWatch[c].prevValue.copy(m):this.propertiesToWatch[c].prevValue=m)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:d,prevValue:p}=this.variablesToWatch[c],f=this.shared.getVariable(d);f!==p&&(o.push(d),this.variablesToWatch[c].prevValue=f)}for(let c=0;c<this.dynamicVars.length;c++){let{id:d,expectedTime:p,last:f,data:m,timerSeconds:v,startValue:y}=this.dynamicVars[c],x=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?x=1:m.dynamicVariableType==="counter"?x=m.updateInterval:m.dynamicVariableType==="random"&&(x=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+x;continue}if(!((this.shared.getDynamicVariablePlayState(d)==="Stopped"||this.shared.getDynamicVariablePlayState(d)==="Restarted")&&(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+x,m.dynamicVariableType==="counter"&&this.shared.getVariable(d)!==y&&(this.shared.updateVariable(d,y),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==y&&(this.dynamicVars[c].timerSeconds=y,this.shared.updateVariable(d,la.getFormattedTimerTime(y,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(d)==="Restarted"&&this.shared.setDynamicVariablePlayState(d,"Playing"),this.shared.getDynamicVariablePlayState(d)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(d)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-a,0)),this.dynamicVars[c].last=a-(x-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=a+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(a>=p)if(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime+=x,m.dynamicVariableType==="random"){let b=m.min+Math.random()*(m.max-m.min),_=m.decimals;b=Math.round(b*Math.pow(10,_))/Math.pow(10,_),this.shared.updateVariable(d,b),o.push(d),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let b=this.shared.getVariable(d),_=this.shared.getDynamicVariableToggleIsForward(d)??!0,S=this.shared.getVariable(d)+m.increment*(_?1:-1);m.hasEnd&&(S=m.increment>0?st.clamp(S,y,m.endValue):st.clamp(S,m.endValue,y),S===y&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?S===m.endValue&&(S=y):(S===y||S===m.endValue)&&this.shared.setDynamicVariablePlayState(d,"Paused")),S!==b&&(o.push(d),this.shared.updateVariable(d,S),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(d,kA(n,m)),o.push(d),this.eventManager.requestRender();else{let b=Ws.isTextValue(m.endValue)?wE(m.endValue.textValue):m.endValue,_=this.shared.getDynamicVariableToggleIsForward(d)??!0,S=v+(a-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(_?1:-1);S=Math.max(S,0),m.hasEnd&&(S=m.dynamicVariableType==="stopwatch"?st.clamp(S,y,b):st.clamp(S,b,y),S===y&&this.shared.setDynamicVariableToggleIsForward(d,void 0),m.repeat?Math.abs(S-b)<(m.format==="number3decimal"?1e-4:.1)&&(S=y):(Math.abs(S-y)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(S-b)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(d,"Paused")),S!==v&&(o.push(d),this.dynamicVars[c].timerSeconds=S,this.shared.updateVariable(d,la.getFormattedTimerTime(S,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(c=>{c.data.variableId==="mouseProperty"&&(c.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let u=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,u=!0),this.events.forEach(c=>{(o.includes(c.data.variableId)||l.find(d=>d.objId===c.data.objectId&&d.property===c.data.property)||c.data.variableId==="mouseProperty"&&h||c.data.variableId==="raycastProperty"&&u)&&(c.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(a=>{a.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new B$(a.uuid,n.data,a,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(Ws.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(a,kA(new Date,n)),n.dynamicVariableType==="counter"&&(o=Ws.isTextValue(n.value)?wE(n.value.textValue):n.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){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.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())}},B$=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=As(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())}dispose(){Ir(this.actions)}};function wE(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var L$="https://unpkg.com/@splinetool/runtime@1.0.22/build/",z$="https://unpkg.com/@splinetool/navmesh-wasm@1.0.22/build/",k$=`
|
|
7352
7352
|
(async function() {
|
|
7353
7353
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
7354
7354
|
import('${L$}' + 'navmesh.js'),
|
|
@@ -7414,7 +7414,7 @@ onmessage = function(messageEvent) {
|
|
|
7414
7414
|
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7415
7415
|
</svg>
|
|
7416
7416
|
`),A.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),A.addEventListener("touchend",P=>P.preventDefault()),this.joysticks[p]=[void 0,f];return}let M={zone:f,mode:"static",position:b,size:m};y==="hide"&&(M.restOpacity=0);let C=fK.create(M);C.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()}),C.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]=[C,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(d=>d.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Kt.World(new Kt.Vector3(0,this.gravity,0)),this.events=new Kt.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(n=>{let o;if(n instanceof Ba)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 is)o=n.object;else{if(n instanceof F1||n instanceof P1)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 v of l.events)v.data.disabled!==!0&&v.data.type==="GameControl"&&(h=v.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;n.updateMatrixWorldSVD();let u=ng(l),c=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let v of l.events)if(v.data.disabled!==!0){if(v.data.type==="Collision"){c=!0;let y=new I$(v.id,v.data,o,this.page,this.sharedAssets,this.eventManager);y.disabled=!0,this.collisionEvents.push(y),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(x=>x.id!==v.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(y):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[y]}else if(v.data.type==="Follow"){f=!0;let y=v.data.target;n.traverseVisible(x=>{x.userData.isFollowingObj=y})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(n.matrixWorldFusedFalse=n.matrixWorld.clone());let m=n.geometry;if(h!==void 0){let v=Kt.RigidBodyDesc.kinematicPositionBased();(n.hasNonUniformScale?n.matrixWorldRigid:n.matrixWorld).decompose(sr,Ta,Do),n.position0=sr.clone().divideScalar(this.pixelsPerMeter),n.rotation0=Ta.clone(),sr.divideScalar(this.pixelsPerMeter),v.setTranslation(sr.x,sr.y,sr.z).setRotation(Ta);let y=this.sharedGameControlGlobals.rapierWorld.createRigidBody(v);n.rigidBody=y;let x;h.collider.type==="sphere"?x=Kt.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?x=Kt.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):x=Kt.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(Kt.CoefficientCombineRule.Average).setRestitutionCombineRule(Kt.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),sr.fromArray(h.collider.position).multiply(Do.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(sr);let _=new Mt().setFromEuler(new vr().setFromVector3(new I().fromArray(h.collider.rotation)));b.setRotationWrtParent(_),b.setActiveEvents(Kt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||u||f||d||p||c?(this.addRigidBody(n,o,{hasFollow:f,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(m&&e.push(Zn(m,n.matrixWorld)),l.physics.fusedBody&&n.traverseObject((v,y)=>{if(y===0)return;let x;if(v instanceof Ba)if(v.objectForSample){if(v.objectForSample.dataPatched.physics.fusedBody)return;x=v.object}else return v.object.dataPatched.physics.fusedBody===!0&&v.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(v instanceof is)x=v.object;else if(x=v,x.dataPatched.cloner?.hideBase)return!0;let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let _=v.geometry;_?.getAttribute("position")!==void 0&&e.push(Zn(_,v.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=Ol(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=Kt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),a=Kt.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(Kt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Kt.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 CE(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new Le().compose(Pa.fromArray(t.data.position),qh.setFromEuler(TE.fromArray(t.data.rotation)),J0);if(t.data.triggerZone==="box"){let s=new er;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&&(r=!this.orbitControls.update()),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}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(sr,Ta,Do),Z0.setFromQuaternion(Ta);let t=e;t.prevR===void 0?(t.prevR=Z0.clone(),t.prevT=sr.clone()):(t.prevR.copy(Z0),t.prevT.copy(sr)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(sr.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(Ta))}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(tx)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=PE.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 CE(n.id,n.data,s,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=Kt.ColliderDesc.cuboid(...n.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=Kt.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(Kt.ActiveEvents.COLLISION_EVENTS),Pa.fromArray(n.data.position),qh.setFromEuler(TE.fromArray(n.data.rotation)),Gf.compose(Pa,qh,J0).premultiply(s.matrixWorld),i?(Gf.decompose(Pa,qh,K0),l.setActiveCollisionTypes(Kt.ActiveCollisionTypes.KINEMATIC_FIXED|Kt.ActiveCollisionTypes.DYNAMIC_FIXED)):(Gf.premultiply(r).decompose(Pa,qh,K0),e.rigidBody.bodyType()===Kt.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===Kt.RigidBodyType.Fixed?l.setActiveCollisionTypes(Kt.ActiveCollisionTypes.KINEMATIC_FIXED|Kt.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(Kt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Kt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),Pa.divideScalar(this.pixelsPerMeter),l.setTranslation(Pa.x,Pa.y,Pa.z),l.setRotation(qh),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(Yt.is(o)?o:o.object)===!1)continue;let l=PE.copy(s.matrixWorld).decompose(Pa,DE,K0).compose(Pa,DE,J0).multiply(r),h=Gf.copy(o.matrixWorld).invert().multiply(l);i instanceof er?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):($0.radius=i,$0.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere($0)),e?a.currentIntersectedObjects.indexOf(o)===-1&&(a.currentIntersectedObjects.push(o),a.dispatch(),s.dispatchEvent($$)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(u=>u!==o)}}}};function iee(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,a=this._loopCount,n=r===rx;if(e===0)return a===-1?s:n&&(a&1)===1?t-(s-i):s;if(r===FE){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 OE=!1,ree=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=dy.parse(JSON.parse(a[2]));s.animations[n]=l;let h=this.mixer.clipAction(l,s);OE===!1&&(Object.getPrototypeOf(h)._updateTime=iee,OE=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new c5(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=UE}),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=rx)),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%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??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(this.maxFrames?e/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},ey=new WeakMap,see=class extends Wd{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 py(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(ey.has(e)){let o=ey.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)}),ey.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new ut;e.index&&t.setIndex(new At(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 At(a,n))}return t}_loadLibrary(e,t){let i=new py(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=aee.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
7417
|
-
`);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 aee(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,d,p,h),m=f.attributes.map(v=>v.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(n,o,l,h){let u=h.attributeIDs,c=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 m={index:null,attributes:[]};for(let v in u){let y=self[c[v]],x,b;if(h.useUniqueIDs)b=u[v],x=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,n[u[v]]),b===-1)continue;x=o.GetAttribute(d,b)}m.attributes.push(s(n,o,d,v,y,x))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,d)),n.destroy(d),m}function r(n,o,l){let h=l.num_faces()*3,u=h*4,c=n._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(n.HEAPF32.buffer,c,h).slice();return n._free(c),{array:d,itemSize:1}}function s(n,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,f=p*u.BYTES_PER_ELEMENT,m=a(n,u),v=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,m,f,v);let y=new u(n.HEAPF32.buffer,v,p).slice();return n._free(v),{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 Wo;function nee(){return Wo||(Wo=new see,Wo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wo.decoderPending}async function oee(e){if(Wo){let t={attributeIDs:Wo.defaultAttributeIDs,attributeTypes:Wo.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Wo.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 lee(e,t){let[i,r]=_T(Dy.deserialize(new Uint8Array(e)));YT(i);let s=[];i.scene.objects.traverse((a,n)=>{n.type==="Mesh"&&n.geometry.type==="NonParametricGeometry"&&n.geometry.data.draco!==void 0&&s.push(n)}),s.length&&await nee();for(let a of s){let n=await oee(Ji(a.geometry.data.draco));if(n){n.index&&(a.geometry.data.index={array:n.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};n.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),a.geometry.data.attributes=o,a.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var hee=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=As(i,t.actions,s,a,n,r)}disconnect(){Ir(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())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},cee=class extends Ga{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=By.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}of s.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:n,id:o})=>{try{let l=new hee(o,n,a,s,e,t,this.eventManager);this.breakpoints.push(l)}catch{}})};e.traverseEntity(s=>{(s instanceof ts||s instanceof jr)&&s.frame?.traverse(a=>{r(a)}),r(s)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},uee=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=>{(a.touches.length>1||this.preventTouchScroll)&&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(){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 t$(this.eventContext),DynamicVariable:new R$(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new l$(this.eventContext,this),Start:new O$(this.eventContext,this),Basic:new r$(this.eventContext,this,this.needsRaycast),MouseHover:new E$(this.eventContext,this),Scroll:new P$(this.eventContext,this),Follow:new y$(this.eventContext,this),DragDrop:new p$(this.eventContext,this),LookAt:new S$(this.eventContext),Resize:new cee(this.eventContext,this)};let{page:e,domElement:t}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(i=>{i.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(i=>i.connect()),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){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:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),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.disabled)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.actions.forEach(t)}})}},dee=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new $().copy(i),this._editorSize=new $().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=pee(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 pee(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var fee=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new ub(e.shared,t),this.scene=new Sb(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 jr&&!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 rs&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},mee=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 gee(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 fd(e){return e instanceof kd?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function vee(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Ss)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Ss&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!ss.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!ss.isMergable(l.material))return;a=ss.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][fd(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][fd(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][fd(r)].push(l)}),i}function yee(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 xee(e,t){let i=vee(t,e),r=yee(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(v=>{v instanceof Ss&&(n[o++]=v.geometry.clone(),l[h++]=v)}),h<2)continue;for(let v=0;v<h;v++)l[v].updateWorldMatrix(!0,!1),n[v].applyMatrix4(l[v].matrixWorld),l[v].matrixWorld.determinant()<0&&gee(n[v]);let m=Ol(n.slice(0,o),!1);if(m){let v;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),v=new yr(m,l[0].material);break}default:{v=new yr(m,l[0].material);break}}v.castShadow=l[0].castShadow,v.receiveShadow=l[0].receiveShadow,t.add(v);let y=x=>{c=0;for(let b of x)b.children&&y(b.children),b instanceof Ss&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][fd(b)]&&i[b.material.uuid][fd(b)].length>1||(u[c++]=b));for(let b=0;b<c;b++)t.attach(u[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 bee=Br(YO(),1),wee=new $;function _ee(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Nb=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){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=r=>{if(this.time=r,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)),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(s=>{s.type==="ParticleSystem"&&(s.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 s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,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=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=wee.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),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 r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="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=zx(this._resize,10),this._onScroll=r=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new mee({x:10,y:10})),HG(e)}async load(e,t,i){_ee(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 lee(e);this._data=r,r.version&&(0,bee.default)(r.version,"1.0.21")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([rM(r)&&T7(),yX(r)&&A7(),Td.physicsEnabled(r.scene.objects)&&QG(),KA(r)&&aX(),bM(r)&&sZ(),H$(r)&&XG()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new fee(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();xee(r,s.scene);let l=performance.now();console.log("Merged geometries in ",l-o," ms")}rM(r)&&this._scene.traverse(o=>{ro(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof Ba&&o.pendingMediaLoad&&o.update()})}),this._scene?.traverse(o=>{o.type==="ParticleSystem"&&(o.wakeUp(),o.data.autoPlay?o.start():o.stop())});let a=Object.keys(r.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(a).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),KA(r)&&eee(r)&&await Promise.all(a),bM(r)){let o=[];this._scene.traverseEntity(l=>{l instanceof ts&&o.push(l)}),await Promise.all(o.map(l=>l.uiCanvas.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),zb(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new ZQ({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let n=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.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=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new dee(this._renderer,this._camera,new $(this._viewportWidth,this._viewportHeight),new $(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let o=new $J(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new tee(o),this._animationControls=new ree(this._scene,this._requestRenderAutoMode),this._eventManager=new uee(r.scene.publish,this._controls,this._animationControls,o,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),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"&&Ws.isTextValue(e)?Ws.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}}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!==Qc&&!this._scene.isInvisibleObjects(t)&&!(t instanceof jr)){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 MD&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},a=new Yr(t,i,r,s);try{a.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(a),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{vS.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(),WG(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(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(s=>{s instanceof jr&&(t=s.name)});let i={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 jr||e instanceof Sb?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=vS(i,(s,a)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=a),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}setUIWasmUrl(e){eP.skiaWasmUrl=e}};var Ig=window,Rg=Ig.ShadowRoot&&(Ig.ShadyCSS===void 0||Ig.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Fb=Symbol(),ED=new WeakMap,tp=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Fb)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(Rg&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=ED.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ED.set(i,t))}return t}toString(){return this.cssText}},CD=e=>new tp(typeof e=="string"?e:e+"",void 0,Fb),Ub=(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 tp(i,e,Fb)},Vb=(e,t)=>{Rg?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Ig.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Bg=Rg?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return CD(i)})(e):e;var jb,Lg=window,TD=Lg.trustedTypes,See=TD?TD.emptyScript:"",PD=Lg.reactiveElementPolyfillSupport,Hb={toAttribute(e,t){switch(t){case Boolean:e=e?See: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}},DD=(e,t)=>t!==e&&(t==t||e==e),Gb={attribute:!0,type:String,converter:Hb,reflect:!1,hasChanged:DD},po=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=Gb){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)||Gb}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(Bg(s))}else t!==void 0&&i.push(Bg(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 Vb(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=Gb){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:Hb).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:Hb;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||DD)(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){}};po.finalized=!0,po.elementProperties=new Map,po.elementStyles=[],po.shadowRootOptions={mode:"open"},PD?.({ReactiveElement:po}),((jb=Lg.reactiveElementVersions)!==null&&jb!==void 0?jb:Lg.reactiveElementVersions=[]).push("1.6.0");var Wb,zg=window,tu=zg.trustedTypes,OD=tu?tu.createPolicy("lit-html",{createHTML:e=>e}):void 0,il=`lit$${(Math.random()+"").slice(9)}$`,ND="?"+il,Aee=`<${ND}>`,iu=document,rp=(e="")=>iu.createComment(e),sp=e=>e===null||typeof e!="object"&&typeof e!="function",FD=Array.isArray,Mee=e=>FD(e)||typeof e?.[Symbol.iterator]=="function",ip=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ID=/-->/g,RD=/>/g,sh=RegExp(`>|[
|
|
7417
|
+
`);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 aee(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,d,p,h),m=f.attributes.map(v=>v.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(n,o,l,h){let u=h.attributeIDs,c=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 m={index:null,attributes:[]};for(let v in u){let y=self[c[v]],x,b;if(h.useUniqueIDs)b=u[v],x=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,n[u[v]]),b===-1)continue;x=o.GetAttribute(d,b)}m.attributes.push(s(n,o,d,v,y,x))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,d)),n.destroy(d),m}function r(n,o,l){let h=l.num_faces()*3,u=h*4,c=n._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(n.HEAPF32.buffer,c,h).slice();return n._free(c),{array:d,itemSize:1}}function s(n,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,f=p*u.BYTES_PER_ELEMENT,m=a(n,u),v=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,m,f,v);let y=new u(n.HEAPF32.buffer,v,p).slice();return n._free(v),{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 Wo;function nee(){return Wo||(Wo=new see,Wo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wo.decoderPending}async function oee(e){if(Wo){let t={attributeIDs:Wo.defaultAttributeIDs,attributeTypes:Wo.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Wo.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 lee(e,t){let[i,r]=_T(Dy.deserialize(new Uint8Array(e)));YT(i);let s=[];i.scene.objects.traverse((a,n)=>{n.type==="Mesh"&&n.geometry.type==="NonParametricGeometry"&&n.geometry.data.draco!==void 0&&s.push(n)}),s.length&&await nee();for(let a of s){let n=await oee(Ji(a.geometry.data.draco));if(n){n.index&&(a.geometry.data.index={array:n.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};n.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),a.geometry.data.attributes=o,a.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var hee=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=As(i,t.actions,s,a,n,r)}disconnect(){Ir(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())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},cee=class extends Ga{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=By.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}of s.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:n,id:o})=>{try{let l=new hee(o,n,a,s,e,t,this.eventManager);this.breakpoints.push(l)}catch{}})};e.traverseEntity(s=>{(s instanceof ts||s instanceof jr)&&s.frame?.traverse(a=>{r(a)}),r(s)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},uee=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=>{(a.touches.length>1||this.preventTouchScroll)&&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(){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 t$(this.eventContext),DynamicVariable:new R$(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new l$(this.eventContext,this),Start:new O$(this.eventContext,this),Basic:new r$(this.eventContext,this,this.needsRaycast),MouseHover:new E$(this.eventContext,this),Scroll:new P$(this.eventContext,this),Follow:new y$(this.eventContext,this),DragDrop:new p$(this.eventContext,this),LookAt:new S$(this.eventContext),Resize:new cee(this.eventContext,this)};let{page:e,domElement:t}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(i=>{i.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(i=>i.connect()),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){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:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),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.disabled)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.actions.forEach(t)}})}},dee=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new $().copy(i),this._editorSize=new $().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=pee(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 pee(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var fee=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new ub(e.shared,t),this.scene=new Sb(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 jr&&!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 rs&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},mee=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 gee(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 fd(e){return e instanceof kd?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function vee(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof Ss)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof Ss&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!ss.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!ss.isMergable(l.material))return;a=ss.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][fd(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][fd(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][fd(r)].push(l)}),i}function yee(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 xee(e,t){let i=vee(t,e),r=yee(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(v=>{v instanceof Ss&&(n[o++]=v.geometry.clone(),l[h++]=v)}),h<2)continue;for(let v=0;v<h;v++)l[v].updateWorldMatrix(!0,!1),n[v].applyMatrix4(l[v].matrixWorld),l[v].matrixWorld.determinant()<0&&gee(n[v]);let m=Ol(n.slice(0,o),!1);if(m){let v;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),v=new yr(m,l[0].material);break}default:{v=new yr(m,l[0].material);break}}v.castShadow=l[0].castShadow,v.receiveShadow=l[0].receiveShadow,t.add(v);let y=x=>{c=0;for(let b of x)b.children&&y(b.children),b instanceof Ss&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][fd(b)]&&i[b.material.uuid][fd(b)].length>1||(u[c++]=b));for(let b=0;b<c;b++)t.attach(u[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 bee=Br(YO(),1),wee=new $;function _ee(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var Nb=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){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=r=>{if(this.time=r,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)),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(s=>{s.type==="ParticleSystem"&&(s.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 s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,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=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=wee.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),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 r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="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=zx(this._resize,10),this._onScroll=r=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())},this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new mee({x:10,y:10})),HG(e)}async load(e,t,i){_ee(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 lee(e);this._data=r,r.version&&(0,bee.default)(r.version,"1.0.22")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([rM(r)&&T7(),yX(r)&&A7(),Td.physicsEnabled(r.scene.objects)&&QG(),KA(r)&&aX(),bM(r)&&sZ(),H$(r)&&XG()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new fee(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();xee(r,s.scene);let l=performance.now();console.log("Merged geometries in ",l-o," ms")}rM(r)&&this._scene.traverse(o=>{ro(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof Ba&&o.pendingMediaLoad&&o.update()})}),this._scene?.traverse(o=>{o.type==="ParticleSystem"&&(o.wakeUp(),o.data.autoPlay?o.start():o.stop())});let a=Object.keys(r.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);if(Promise.all(a).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),KA(r)&&eee(r)&&await Promise.all(a),bM(r)){let o=[];this._scene.traverseEntity(l=>{l instanceof ts&&o.push(l)}),await Promise.all(o.map(l=>l.uiCanvas.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),zb(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new ZQ({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),this._scene.initializeSplatViewer(this._renderer),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let n=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.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=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new dee(this._renderer,this._camera,new $(this._viewportWidth,this._viewportHeight),new $(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let o=new $J(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new tee(o),this._animationControls=new ree(this._scene,this._requestRenderAutoMode),this._eventManager=new uee(r.scene.publish,this._controls,this._animationControls,o,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),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"&&Ws.isTextValue(e)?Ws.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}}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!==Qc&&!this._scene.isInvisibleObjects(t)&&!(t instanceof jr)){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 MD&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},a=new Yr(t,i,r,s);try{a.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(a),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{vS.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(),WG(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(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(s=>{s instanceof jr&&(t=s.name)});let i={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 jr||e instanceof Sb?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=vS(i,(s,a)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=a),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}setUIWasmUrl(e){eP.skiaWasmUrl=e}};var Ig=window,Rg=Ig.ShadowRoot&&(Ig.ShadyCSS===void 0||Ig.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Fb=Symbol(),ED=new WeakMap,tp=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Fb)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(Rg&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=ED.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ED.set(i,t))}return t}toString(){return this.cssText}},CD=e=>new tp(typeof e=="string"?e:e+"",void 0,Fb),Ub=(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 tp(i,e,Fb)},Vb=(e,t)=>{Rg?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Ig.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Bg=Rg?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return CD(i)})(e):e;var jb,Lg=window,TD=Lg.trustedTypes,See=TD?TD.emptyScript:"",PD=Lg.reactiveElementPolyfillSupport,Hb={toAttribute(e,t){switch(t){case Boolean:e=e?See: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}},DD=(e,t)=>t!==e&&(t==t||e==e),Gb={attribute:!0,type:String,converter:Hb,reflect:!1,hasChanged:DD},po=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=Gb){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)||Gb}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(Bg(s))}else t!==void 0&&i.push(Bg(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 Vb(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=Gb){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:Hb).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:Hb;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||DD)(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){}};po.finalized=!0,po.elementProperties=new Map,po.elementStyles=[],po.shadowRootOptions={mode:"open"},PD?.({ReactiveElement:po}),((jb=Lg.reactiveElementVersions)!==null&&jb!==void 0?jb:Lg.reactiveElementVersions=[]).push("1.6.0");var Wb,zg=window,tu=zg.trustedTypes,OD=tu?tu.createPolicy("lit-html",{createHTML:e=>e}):void 0,il=`lit$${(Math.random()+"").slice(9)}$`,ND="?"+il,Aee=`<${ND}>`,iu=document,rp=(e="")=>iu.createComment(e),sp=e=>e===null||typeof e!="object"&&typeof e!="function",FD=Array.isArray,Mee=e=>FD(e)||typeof e?.[Symbol.iterator]=="function",ip=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ID=/-->/g,RD=/>/g,sh=RegExp(`>|[
|
|
7418
7418
|
\f\r](?:([^\\s"'>=/]+)([
|
|
7419
7419
|
\f\r]*=[
|
|
7420
7420
|
\f\r]*(?:[^
|