@splinetool/runtime 1.0.88 → 1.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.cjs CHANGED
@@ -3797,10 +3797,10 @@ void main() {
3797
3797
 
3798
3798
  }
3799
3799
 
3800
- }`,iw=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,r){if(this.texture===null){let n=new Zt,s=t.properties.get(n);s.__webglTexture=e.texture,(e.depthNear!=r.depthNear||e.depthFar!=r.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}render(t,e){if(this.texture!==null){if(this.mesh===null){let r=e.cameras[0].viewport,n=new ot({extensions:{fragDepth:!0},vertexShader:c4,fragmentShader:u4,uniforms:{depthColor:{value:this.texture},depthWidth:{value:r.z},depthHeight:{value:r.w}}});this.mesh=new tr(new sn(20,20),n)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},nw=class extends gr{constructor(t,e){super();let r=this,n=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,p=null,g=new iw,y=e.getContextAttributes(),m=null,v=null,x=[],b=[],S=new U,w=null,E=new ri;E.layers.enable(1),E.viewport=new Ze;let A=new ri;A.layers.enable(2),A.viewport=new Ze;let P=[E,A],M=new rw;M.layers.enable(1),M.layers.enable(2);let C=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let K=x[j];return K===void 0&&(K=new cp,x[j]=K),K.getTargetRaySpace()},this.getControllerGrip=function(j){let K=x[j];return K===void 0&&(K=new cp,x[j]=K),K.getGripSpace()},this.getHand=function(j){let K=x[j];return K===void 0&&(K=new cp,x[j]=K),K.getHandSpace()};function L(j){let K=b.indexOf(j.inputSource);if(K===-1)return;let ee=x[K];ee!==void 0&&(ee.update(j.inputSource,j.frame,c||o),ee.dispatchEvent({type:j.type,data:j.inputSource}))}function D(){n.removeEventListener("select",L),n.removeEventListener("selectstart",L),n.removeEventListener("selectend",L),n.removeEventListener("squeeze",L),n.removeEventListener("squeezestart",L),n.removeEventListener("squeezeend",L),n.removeEventListener("end",D),n.removeEventListener("inputsourceschange",B);for(let j=0;j<x.length;j++){let K=b[j];K!==null&&(b[j]=null,x[j].disconnect(K))}C=null,O=null,g.reset(),t.setRenderTarget(m),f=null,d=null,h=null,n=null,v=null,le.stop(),r.isPresenting=!1,t.setPixelRatio(w),t.setSize(S.width,S.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){a=j,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(j){if(n=j,n!==null){if(m=t.getRenderTarget(),n.addEventListener("select",L),n.addEventListener("selectstart",L),n.addEventListener("selectend",L),n.addEventListener("squeeze",L),n.addEventListener("squeezestart",L),n.addEventListener("squeezeend",L),n.addEventListener("end",D),n.addEventListener("inputsourceschange",B),y.xrCompatible!==!0&&await e.makeXRCompatible(),w=t.getPixelRatio(),t.getSize(S),n.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let K={antialias:n.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,K),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),v=new yt(f.framebufferWidth,f.framebufferHeight,{format:Yr,type:Dr,colorSpace:t.outputColorSpace,stencilBuffer:y.stencil})}else{let K=null,ee=null,re=null;y.depth&&(re=y.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,K=y.stencil?tl:pc,ee=y.stencil?na:is);let te={colorFormat:e.RGBA8,depthFormat:re,scaleFactor:s};h=new XRWebGLBinding(n,e),d=h.createProjectionLayer(te),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),v=new yt(d.textureWidth,d.textureHeight,{format:Yr,type:Dr,depthTexture:new qn(d.textureWidth,d.textureHeight,ee,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:y.stencil,colorSpace:t.outputColorSpace,samples:y.antialias?4:0});let $=t.properties.get(v);$.__ignoreDepthValues=d.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await n.requestReferenceSpace(a),le.setContext(n),le.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};function B(j){for(let K=0;K<j.removed.length;K++){let ee=j.removed[K],re=b.indexOf(ee);re>=0&&(b[re]=null,x[re].disconnect(ee))}for(let K=0;K<j.added.length;K++){let ee=j.added[K],re=b.indexOf(ee);if(re===-1){for(let $=0;$<x.length;$++)if($>=b.length){b.push(ee),re=$;break}else if(b[$]===null){b[$]=ee,re=$;break}if(re===-1)break}let te=x[re];te&&te.connect(ee)}}let k=new T,F=new T;function H(j,K,ee){k.setFromMatrixPosition(K.matrixWorld),F.setFromMatrixPosition(ee.matrixWorld);let re=k.distanceTo(F),te=K.projectionMatrix.elements,$=ee.projectionMatrix.elements,se=te[14]/(te[10]-1),Se=te[14]/(te[10]+1),W=(te[9]+1)/te[5],Ae=(te[9]-1)/te[5],xe=(te[8]-1)/te[0],be=($[8]+1)/$[0],Ee=se*xe,De=se*be,Pe=re/(-xe+be),Re=Pe*-xe;K.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Re),j.translateZ(Pe),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert();let ze=se+Pe,_=Se+Pe,I=Ee-Re,ie=De+(re-Re),de=W*Se/_*ze,ve=Ae*Se/_*ze;j.projectionMatrix.makePerspective(I,ie,de,ve,ze,_),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}function G(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(n===null)return;g.texture!==null&&(j.near=g.depthNear,j.far=g.depthFar),M.near=A.near=E.near=j.near,M.far=A.far=E.far=j.far,(C!==M.near||O!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),C=M.near,O=M.far,E.near=C,E.far=O,A.near=C,A.far=O,E.updateProjectionMatrix(),A.updateProjectionMatrix(),j.updateProjectionMatrix());let K=j.parent,ee=M.cameras;G(M,K);for(let re=0;re<ee.length;re++)G(ee[re],K);ee.length===2?H(M,E,A):M.projectionMatrix.copy(E.projectionMatrix),X(j,M,K)};function X(j,K,ee){ee===null?j.matrix.copy(K.matrixWorld):(j.matrix.copy(ee.matrixWorld),j.matrix.invert(),j.matrix.multiply(K.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(K.projectionMatrix),j.projectionMatrixInverse.copy(K.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Lu*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(j){l=j,d!==null&&(d.fixedFoveation=j),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=j)},this.hasDepthSensing=function(){return g.texture!==null};let Y=null;function Z(j,K){if(u=K.getViewerPose(c||o),p=K,u!==null){let ee=u.views;f!==null&&(t.setRenderTargetFramebuffer(v,f.framebuffer),t.setRenderTarget(v));let re=!1;ee.length!==M.cameras.length&&(M.cameras.length=0,re=!0);for(let $=0;$<ee.length;$++){let se=ee[$],Se=null;if(f!==null)Se=f.getViewport(se);else{let Ae=h.getViewSubImage(d,se);Se=Ae.viewport,$===0&&(t.setRenderTargetTextures(v,Ae.colorTexture,d.ignoreDepthValues?void 0:Ae.depthStencilTexture),t.setRenderTarget(v))}let W=P[$];W===void 0&&(W=new ri,W.layers.enable($),W.viewport=new Ze,P[$]=W),W.matrix.fromArray(se.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(se.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(Se.x,Se.y,Se.width,Se.height),$===0&&(M.matrix.copy(W.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),re===!0&&M.cameras.push(W)}let te=n.enabledFeatures;if(te&&te.includes("depth-sensing")){let $=h.getDepthInformation(ee[0]);$&&$.isValid&&$.texture&&g.init(t,$,n.renderState)}}for(let ee=0;ee<x.length;ee++){let re=b[ee],te=x[ee];re!==null&&te!==void 0&&te.update(re,K,c||o)}g.render(t,M),Y&&Y(j,K),K.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:K}),p=null}let le=new d_;le.setAnimationLoop(Z),this.setAnimationLoop=function(j){Y=j},this.dispose=function(){}}},uc=new Ht,h4=new ue;function d4(i,t){function e(y,m){y.matrixAutoUpdate===!0&&y.updateMatrix(),m.value.copy(y.matrix)}function r(y,m){m.color.getRGB(y.fogColor.value,h_(i)),m.isFog?(y.fogNear.value=m.near,y.fogFar.value=m.far):m.isFogExp2&&(y.fogDensity.value=m.density)}function n(y,m,v,x,b){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(y,m):m.isMeshToonMaterial?(s(y,m),h(y,m)):m.isMeshPhongMaterial?(s(y,m),u(y,m)):m.isMeshStandardMaterial?(s(y,m),d(y,m),m.isMeshPhysicalMaterial&&f(y,m,b)):m.isMeshMatcapMaterial?(s(y,m),p(y,m)):m.isMeshDepthMaterial?s(y,m):m.isMeshDistanceMaterial?(s(y,m),g(y,m)):m.isMeshNormalMaterial?s(y,m):m.isLineBasicMaterial?(o(y,m),m.isLineDashedMaterial&&a(y,m)):m.isPointsMaterial?l(y,m,v,x):m.isSpriteMaterial?c(y,m):m.isShadowMaterial?(y.color.value.copy(m.color),y.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(y,m){y.opacity.value=m.opacity,m.color&&y.diffuse.value.copy(m.color),m.emissive&&y.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(y.map.value=m.map,e(m.map,y.mapTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,e(m.alphaMap,y.alphaMapTransform)),m.bumpMap&&(y.bumpMap.value=m.bumpMap,e(m.bumpMap,y.bumpMapTransform),y.bumpScale.value=m.bumpScale,m.side===ni&&(y.bumpScale.value*=-1)),m.normalMap&&(y.normalMap.value=m.normalMap,e(m.normalMap,y.normalMapTransform),y.normalScale.value.copy(m.normalScale),m.side===ni&&y.normalScale.value.negate()),m.displacementMap&&(y.displacementMap.value=m.displacementMap,e(m.displacementMap,y.displacementMapTransform),y.displacementScale.value=m.displacementScale,y.displacementBias.value=m.displacementBias),m.emissiveMap&&(y.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,y.emissiveMapTransform)),m.specularMap&&(y.specularMap.value=m.specularMap,e(m.specularMap,y.specularMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest);let v=t.get(m),x=v.envMap,b=v.envMapRotation;if(x&&(y.envMap.value=x,uc.copy(b),uc.x*=-1,uc.y*=-1,uc.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(uc.y*=-1,uc.z*=-1),y.envMapRotation.value.setFromMatrix4(h4.makeRotationFromEuler(uc)),y.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=m.reflectivity,y.ior.value=m.ior,y.refractionRatio.value=m.refractionRatio),m.lightMap){y.lightMap.value=m.lightMap;let S=i._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=m.lightMapIntensity*S,e(m.lightMap,y.lightMapTransform)}m.aoMap&&(y.aoMap.value=m.aoMap,y.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,y.aoMapTransform))}function o(y,m){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,m.map&&(y.map.value=m.map,e(m.map,y.mapTransform))}function a(y,m){y.dashSize.value=m.dashSize,y.totalSize.value=m.dashSize+m.gapSize,y.scale.value=m.scale}function l(y,m,v,x){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,y.size.value=m.size*v,y.scale.value=x*.5,m.map&&(y.map.value=m.map,e(m.map,y.uvTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,e(m.alphaMap,y.alphaMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest)}function c(y,m){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,y.rotation.value=m.rotation,m.map&&(y.map.value=m.map,e(m.map,y.mapTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,e(m.alphaMap,y.alphaMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest)}function u(y,m){y.specular.value.copy(m.specular),y.shininess.value=Math.max(m.shininess,1e-4)}function h(y,m){m.gradientMap&&(y.gradientMap.value=m.gradientMap)}function d(y,m){y.metalness.value=m.metalness,m.metalnessMap&&(y.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,y.metalnessMapTransform)),y.roughness.value=m.roughness,m.roughnessMap&&(y.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,y.roughnessMapTransform)),t.get(m).envMap&&(y.envMapIntensity.value=m.envMapIntensity)}function f(y,m,v){y.ior.value=m.ior,m.sheen>0&&(y.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),y.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(y.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,y.sheenColorMapTransform)),m.sheenRoughnessMap&&(y.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,y.sheenRoughnessMapTransform))),m.clearcoat>0&&(y.clearcoat.value=m.clearcoat,y.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(y.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,y.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(y.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===ni&&y.clearcoatNormalScale.value.negate())),m.iridescence>0&&(y.iridescence.value=m.iridescence,y.iridescenceIOR.value=m.iridescenceIOR,y.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(y.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,y.iridescenceMapTransform)),m.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),m.transmission>0&&(y.transmission.value=m.transmission,y.transmissionSamplerMap.value=v.texture,y.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(y.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,y.transmissionMapTransform)),y.thickness.value=m.thickness,m.thicknessMap&&(y.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=m.attenuationDistance,y.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(y.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(y.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=m.specularIntensity,y.specularColor.value.copy(m.specularColor),m.specularColorMap&&(y.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,y.specularColorMapTransform)),m.specularIntensityMap&&(y.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,y.specularIntensityMapTransform))}function p(y,m){m.matcap&&(y.matcap.value=m.matcap)}function g(y,m){let v=t.get(m).light;y.referencePosition.value.setFromMatrixPosition(v.matrixWorld),y.nearDistance.value=v.shadow.camera.near,y.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:n}}function f4(i,t,e,r){let n={},s={},o=[],a=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(v,x){let b=x.program;r.uniformBlockBinding(v,b)}function c(v,x){let b=n[v.id];b===void 0&&(p(v),b=u(v),n[v.id]=b,v.addEventListener("dispose",y));let S=x.program;r.updateUBOMapping(v,S);let w=t.render.frame;s[v.id]!==w&&(d(v),s[v.id]=w)}function u(v){let x=h();v.__bindingPointIndex=x;let b=i.createBuffer(),S=v.__size,w=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,S,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,b),b}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=n[v.id],b=v.uniforms,S=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let w=0,E=b.length;w<E;w++){let A=Array.isArray(b[w])?b[w]:[b[w]];for(let P=0,M=A.length;P<M;P++){let C=A[P];if(f(C,w,P,S)===!0){let O=C.__offset,L=Array.isArray(C.value)?C.value:[C.value],D=0;for(let B=0;B<L.length;B++){let k=L[B],F=g(k);typeof k=="number"||typeof k=="boolean"?(C.__data[0]=k,i.bufferSubData(i.UNIFORM_BUFFER,O+D,C.__data)):k.isMatrix3?(C.__data[0]=k.elements[0],C.__data[1]=k.elements[1],C.__data[2]=k.elements[2],C.__data[3]=0,C.__data[4]=k.elements[3],C.__data[5]=k.elements[4],C.__data[6]=k.elements[5],C.__data[7]=0,C.__data[8]=k.elements[6],C.__data[9]=k.elements[7],C.__data[10]=k.elements[8],C.__data[11]=0):(k.toArray(C.__data,D),D+=F.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,O,C.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(v,x,b,S){let w=v.value,E=x+"_"+b;if(S[E]===void 0)return typeof w=="number"||typeof w=="boolean"?S[E]=w:S[E]=w.clone(),!0;{let A=S[E];if(typeof w=="number"||typeof w=="boolean"){if(A!==w)return S[E]=w,!0}else if(A.equals(w)===!1)return A.copy(w),!0}return!1}function p(v){let x=v.uniforms,b=0,S=16;for(let E=0,A=x.length;E<A;E++){let P=Array.isArray(x[E])?x[E]:[x[E]];for(let M=0,C=P.length;M<C;M++){let O=P[M],L=Array.isArray(O.value)?O.value:[O.value];for(let D=0,B=L.length;D<B;D++){let k=L[D],F=g(k),H=b%S;H!==0&&S-H<F.boundary&&(b+=S-H),O.__data=new Float32Array(F.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=b,b+=F.storage}}}let w=b%S;return w>0&&(b+=S-w),v.__size=b,v.__cache={},this}function g(v){let x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function y(v){let x=v.target;x.removeEventListener("dispose",y);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function m(){for(let v in n)i.deleteBuffer(n[v]);o=[],n={},s={}}return{bind:l,update:c,dispose:m}}var gp=class{constructor(t={}){let{canvas:e=mU(),context:r=null,depth:n=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=t;this.isWebGLRenderer=!0;let d;r!==null?d=r.getContextAttributes().alpha:d=o;let f=new Uint32Array(4),p=new Int32Array(4),g=null,y=null,m=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ot,this._useLegacyLights=!1,this.toneMapping=Ja,this.toneMappingExposure=1;let x=this,b=!1,S=0,w=0,E=null,A=-1,P=null,M=new Ze,C=new Ze,O=null,L=new ke(0),D=0,B=e.width,k=e.height,F=1,H=null,G=null,X=new Ze(0,0,B,k),Y=new Ze(0,0,B,k),Z=!1,le=new pp,j=!1,K=!1,ee=null,re=new ue,te=new U,$=new T,se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Se(){return E===null?F:1}let W=r;function Ae(z,ne){for(let me=0;me<z.length;me++){let ge=z[me],ae=e.getContext(ge,ne);if(ae!==null)return ae}return null}try{let z={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${la}`),e.addEventListener("webglcontextlost",vr,!1),e.addEventListener("webglcontextrestored",J,!1),e.addEventListener("webglcontextcreationerror",Ge,!1),W===null){let ne=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&ne.shift(),W=Ae(ne,z),W===null)throw Ae(ne)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&W instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(z){throw console.error("THREE.WebGLRenderer: "+z.message),z}let xe,be,Ee,De,Pe,Re,ze,_,I,ie,de,ve,fe,et,Ue,Oe,Be,xt,Te,mt,gt,ct,tt,rt;function Pt(){xe=new Pk(W),be=new Ak(W,xe,t),xe.init(be),ct=new a4(W,xe,be),Ee=new s4(W,xe,be),De=new Ik(W),Pe=new XG,Re=new o4(W,xe,Ee,Pe,be,ct,De),ze=new Tk(x),_=new _k(x),I=new UU(W,be),tt=new Sk(W,xe,I,be),ie=new Dk(W,I,De,tt),de=new Bk(W,ie,I,De),Te=new Nk(W,be,Re),Oe=new Ek(Pe),ve=new qG(x,ze,_,xe,be,tt,Oe),fe=new d4(x,Pe),et=new KG,Ue=new t4(xe,be),xt=new bk(x,ze,_,Ee,de,d,l),Be=new n4(x,de,be),rt=new f4(W,De,be,Ee),mt=new wk(W,xe,De,be),gt=new Ok(W,xe,De,be),De.programs=ve.programs,x.capabilities=be,x.extensions=xe,x.properties=Pe,x.renderLists=et,x.shadowMap=Be,x.state=Ee,x.info=De}Pt();let Ke=new nw(x,W);this.xr=Ke,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let z=xe.get("WEBGL_lose_context");z&&z.loseContext()},this.forceContextRestore=function(){let z=xe.get("WEBGL_lose_context");z&&z.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(z){z!==void 0&&(F=z,this.setSize(B,k,!1))},this.getSize=function(z){return z.set(B,k)},this.setSize=function(z,ne,me=!0){if(Ke.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=z,k=ne,e.width=Math.floor(z*F),e.height=Math.floor(ne*F),me===!0&&(e.style.width=z+"px",e.style.height=ne+"px"),this.setViewport(0,0,z,ne)},this.getDrawingBufferSize=function(z){return z.set(B*F,k*F).floor()},this.setDrawingBufferSize=function(z,ne,me){B=z,k=ne,F=me,e.width=Math.floor(z*me),e.height=Math.floor(ne*me),this.setViewport(0,0,z,ne)},this.getCurrentViewport=function(z){return z.copy(M)},this.getViewport=function(z){return z.copy(X)},this.setViewport=function(z,ne,me,ge){z.isVector4?X.set(z.x,z.y,z.z,z.w):X.set(z,ne,me,ge),Ee.viewport(M.copy(X).multiplyScalar(F).round())},this.getScissor=function(z){return z.copy(Y)},this.setScissor=function(z,ne,me,ge){z.isVector4?Y.set(z.x,z.y,z.z,z.w):Y.set(z,ne,me,ge),Ee.scissor(C.copy(Y).multiplyScalar(F).round())},this.getScissorTest=function(){return Z},this.setScissorTest=function(z){Ee.setScissorTest(Z=z)},this.setOpaqueSort=function(z){H=z},this.setTransparentSort=function(z){G=z},this.getClearColor=function(z){return z.copy(xt.getClearColor())},this.setClearColor=function(){xt.setClearColor.apply(xt,arguments)},this.getClearAlpha=function(){return xt.getClearAlpha()},this.setClearAlpha=function(){xt.setClearAlpha.apply(xt,arguments)},this.clear=function(z=!0,ne=!0,me=!0){let ge=0;if(z){let ae=!1;if(E!==null){let Xe=E.texture.format;ae=Xe===Uy||Xe===i_||Xe===r_}if(ae){let Xe=E.texture.type,Je=Xe===Dr||Xe===is||Xe===Aw||Xe===na||Xe===$C||Xe===e_,pt=xt.getClearColor(),We=xt.getClearAlpha(),Dt=pt.r,Tt=pt.g,_t=pt.b;Je?(f[0]=Dt,f[1]=Tt,f[2]=_t,f[3]=We,W.clearBufferuiv(W.COLOR,0,f)):(p[0]=Dt,p[1]=Tt,p[2]=_t,p[3]=We,W.clearBufferiv(W.COLOR,0,p))}else ge|=W.COLOR_BUFFER_BIT}ne&&(ge|=W.DEPTH_BUFFER_BIT),me&&(ge|=W.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W.clear(ge)},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(){e.removeEventListener("webglcontextlost",vr,!1),e.removeEventListener("webglcontextrestored",J,!1),e.removeEventListener("webglcontextcreationerror",Ge,!1),et.dispose(),Ue.dispose(),Pe.dispose(),ze.dispose(),_.dispose(),de.dispose(),tt.dispose(),rt.dispose(),ve.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",dn),Ke.removeEventListener("sessionend",br),ee&&(ee.dispose(),ee=null),Li.stop()};function vr(z){z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function J(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let z=De.autoReset,ne=Be.enabled,me=Be.autoUpdate,ge=Be.needsUpdate,ae=Be.type;Pt(),De.autoReset=z,Be.enabled=ne,Be.autoUpdate=me,Be.needsUpdate=ge,Be.type=ae}function Ge(z){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",z.statusMessage)}function ce(z){let ne=z.target;ne.removeEventListener("dispose",ce),Fe(ne)}function Fe(z){He(z),Pe.remove(z)}function He(z){let ne=Pe.get(z).programs;ne!==void 0&&(ne.forEach(function(me){ve.releaseProgram(me)}),z.isShaderMaterial&&ve.releaseShaderCache(z))}this.renderBufferDirect=function(z,ne,me,ge,ae,Xe){ne===null&&(ne=se);let Je=ae.isMesh&&ae.matrixWorld.determinant()<0,pt=Jb(z,ne,me,ge,ae);Ee.setMaterial(ge,Je);let We=me.index,Dt=1;if(ge.wireframe===!0){if(We=ie.getWireframeAttribute(me),We===void 0)return;Dt=2}let Tt=me.drawRange,_t=me.attributes.position,Fr=Tt.start*Dt,Yi=(Tt.start+Tt.count)*Dt;Xe!==null&&(Fr=Math.max(Fr,Xe.start*Dt),Yi=Math.min(Yi,(Xe.start+Xe.count)*Dt)),We!==null?(Fr=Math.max(Fr,0),Yi=Math.min(Yi,We.count)):_t!=null&&(Fr=Math.max(Fr,0),Yi=Math.min(Yi,_t.count));let Pr=Yi-Fr;if(Pr<0||Pr===1/0)return;tt.setup(ae,ge,pt,me,We);let St,Rr=mt;if(We!==null&&(St=I.get(We),Rr=gt,Rr.setIndex(St)),ae.isMesh)ge.wireframe===!0?(Ee.setLineWidth(ge.wireframeLinewidth*Se()),Rr.setMode(W.LINES)):Rr.setMode(W.TRIANGLES);else if(ae.isLine){let Mt=ge.linewidth;Mt===void 0&&(Mt=1),Ee.setLineWidth(Mt*Se()),ae.isLineSegments?Rr.setMode(W.LINES):ae.isLineLoop?Rr.setMode(W.LINE_LOOP):Rr.setMode(W.LINE_STRIP)}else ae.isPoints?Rr.setMode(W.POINTS):ae.isSprite&&Rr.setMode(W.TRIANGLES);if(ae.isBatchedMesh)Rr.renderMultiDraw(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount);else if(ae.isInstancedMesh)Rr.renderInstances(Fr,Pr,ae.count);else if(me.isInstancedBufferGeometry){let Mt=me._maxInstanceCount!==void 0?me._maxInstanceCount:1/0,cu=Math.min(me.instanceCount,Mt);Rr.renderInstances(Fr,Pr,cu)}else Rr.render(Fr,Pr)};function Ct(z,ne,me){z.transparent===!0&&z.side===Bi&&z.forceSinglePass===!1?(z.side=ni,z.needsUpdate=!0,au(z,ne,me),z.side=Hn,z.needsUpdate=!0,au(z,ne,me),z.side=Bi):au(z,ne,me)}this.compile=function(z,ne,me=null){me===null&&(me=z),y=Ue.get(me),y.init(),v.push(y),me.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ne.layers)&&(y.pushLight(ae),ae.castShadow&&y.pushShadow(ae))}),z!==me&&z.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ne.layers)&&(y.pushLight(ae),ae.castShadow&&y.pushShadow(ae))}),y.setupLights(x._useLegacyLights);let ge=new Set;return z.traverse(function(ae){let Xe=ae.material;if(Xe)if(Array.isArray(Xe))for(let Je=0;Je<Xe.length;Je++){let pt=Xe[Je];Ct(pt,me,ae),ge.add(pt)}else Ct(Xe,me,ae),ge.add(Xe)}),v.pop(),y=null,ge},this.compileAsync=function(z,ne,me=null){let ge=this.compile(z,ne,me);return new Promise(ae=>{function Xe(){if(ge.forEach(function(Je){Pe.get(Je).currentProgram.isReady()&&ge.delete(Je)}),ge.size===0){ae(z);return}setTimeout(Xe,10)}xe.get("KHR_parallel_shader_compile")!==null?Xe():setTimeout(Xe,10)})};let xr=null;function bi(z){xr&&xr(z)}function dn(){Li.stop()}function br(){Li.start()}let Li=new d_;Li.setAnimationLoop(bi),typeof self<"u"&&Li.setContext(self),this.setAnimationLoop=function(z){xr=z,Ke.setAnimationLoop(z),z===null?Li.stop():Li.start()},Ke.addEventListener("sessionstart",dn),Ke.addEventListener("sessionend",br),this.render=function(z,ne){if(ne!==void 0&&ne.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),ne.parent===null&&ne.matrixWorldAutoUpdate===!0&&ne.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(ne),ne=Ke.getCamera()),z.isScene===!0&&z.onBeforeRender(x,z,ne,E),y=Ue.get(z,v.length),y.init(),v.push(y),re.multiplyMatrices(ne.projectionMatrix,ne.matrixWorldInverse),le.setFromProjectionMatrix(re),K=this.localClippingEnabled,j=Oe.init(this.clippingPlanes,K),g=et.get(z,m.length),g.init(),m.push(g),ts(z,ne,0,x.sortObjects),g.finish(),x.sortObjects===!0&&g.sort(H,G),this.info.render.frame++,j===!0&&Oe.beginShadows();let me=y.state.shadowsArray;if(Be.render(me,z,ne),j===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1)&&xt.render(g,z),y.setupLights(x._useLegacyLights),ne.isArrayCamera){let ge=ne.cameras;for(let ae=0,Xe=ge.length;ae<Xe;ae++){let Je=ge[ae];Eg(g,z,Je,Je.viewport)}}else Eg(g,z,ne);E!==null&&(Re.updateMultisampleRenderTarget(E),Re.updateRenderTargetMipmap(E)),z.isScene===!0&&z.onAfterRender(x,z,ne),tt.resetDefaultState(),A=-1,P=null,v.pop(),v.length>0?y=v[v.length-1]:y=null,m.pop(),m.length>0?g=m[m.length-1]:g=null};function ts(z,ne,me,ge){if(z.visible===!1)return;if(z.layers.test(ne.layers)){if(z.isGroup)me=z.renderOrder;else if(z.isLOD)z.autoUpdate===!0&&z.update(ne);else if(z.isLight)y.pushLight(z),z.castShadow&&y.pushShadow(z);else if(z.isSprite){if(!z.frustumCulled||le.intersectsSprite(z)){ge&&$.setFromMatrixPosition(z.matrixWorld).applyMatrix4(re);let Je=de.update(z),pt=z.material;pt.visible&&g.push(z,Je,pt,me,$.z,null)}}else if((z.isMesh||z.isLine||z.isPoints)&&(!z.frustumCulled||le.intersectsObject(z))){let Je=de.update(z),pt=z.material;if(ge&&(z.boundingSphere!==void 0?(z.boundingSphere===null&&z.computeBoundingSphere(),$.copy(z.boundingSphere.center)):(Je.boundingSphere===null&&Je.computeBoundingSphere(),$.copy(Je.boundingSphere.center)),$.applyMatrix4(z.matrixWorld).applyMatrix4(re)),Array.isArray(pt)){let We=Je.groups;for(let Dt=0,Tt=We.length;Dt<Tt;Dt++){let _t=We[Dt],Fr=pt[_t.materialIndex];Fr&&Fr.visible&&g.push(z,Je,Fr,me,$.z,_t)}}else pt.visible&&g.push(z,Je,pt,me,$.z,null)}}let Xe=z.children;for(let Je=0,pt=Xe.length;Je<pt;Je++)ts(Xe[Je],ne,me,ge)}function Eg(z,ne,me,ge){let ae=z.opaque,Xe=z.transmissive,Je=z.transparent;y.setupLightsView(me),j===!0&&Oe.setGlobalState(x.clippingPlanes,me),Xe.length>0&&Zb(ae,Xe,ne,me),ge&&Ee.viewport(M.copy(ge)),ae.length>0&&Ga(ae,ne,me),Xe.length>0&&Ga(Xe,ne,me),Je.length>0&&Ga(Je,ne,me),Ee.buffers.depth.setTest(!0),Ee.buffers.depth.setMask(!0),Ee.buffers.color.setMask(!0),Ee.setPolygonOffset(!1)}function Zb(z,ne,me,ge){if((me.isScene===!0?me.overrideMaterial:null)!==null)return;let Xe=be.isWebGL2;ee===null&&(ee=new yt(1,1,{generateMipmaps:!0,type:xe.has("EXT_color_buffer_half_float")?sa:Dr,minFilter:ra,samples:Xe?4:0})),x.getDrawingBufferSize(te),Xe?ee.setSize(te.x,te.y):ee.setSize(dy(te.x),dy(te.y));let Je=x.getRenderTarget();x.setRenderTarget(ee),x.getClearColor(L),D=x.getClearAlpha(),D<1&&x.setClearColor(16777215,.5),x.clear();let pt=x.toneMapping;x.toneMapping=Ja,Ga(z,me,ge),Re.updateMultisampleRenderTarget(ee),Re.updateRenderTargetMipmap(ee);let We=!1;for(let Dt=0,Tt=ne.length;Dt<Tt;Dt++){let _t=ne[Dt],Fr=_t.object,Yi=_t.geometry,Pr=_t.material,St=_t.group;if(Pr.side===Bi&&Fr.layers.test(ge.layers)){let Rr=Pr.side;Pr.side=ni,Pr.needsUpdate=!0,Tg(Fr,me,ge,Yi,Pr,St),Pr.side=Rr,Pr.needsUpdate=!0,We=!0}}We===!0&&(Re.updateMultisampleRenderTarget(ee),Re.updateRenderTargetMipmap(ee)),x.setRenderTarget(Je),x.setClearColor(L,D),x.toneMapping=pt}function Ga(z,ne,me){let ge=ne.isScene===!0?ne.overrideMaterial:null;for(let ae=0,Xe=z.length;ae<Xe;ae++){let Je=z[ae],pt=Je.object,We=Je.geometry,Dt=ge===null?Je.material:ge,Tt=Je.group;pt.layers.test(me.layers)&&Tg(pt,ne,me,We,Dt,Tt)}}function Tg(z,ne,me,ge,ae,Xe){z.onBeforeRender(x,ne,me,ge,ae,Xe),z.modelViewMatrix.multiplyMatrices(me.matrixWorldInverse,z.matrixWorld),z.normalMatrix.getNormalMatrix(z.modelViewMatrix),ae.onBeforeRender(x,ne,me,ge,z,Xe),ae.transparent===!0&&ae.side===Bi&&ae.forceSinglePass===!1?(ae.side=ni,ae.needsUpdate=!0,x.renderBufferDirect(me,ne,ge,ae,z,Xe),ae.side=Hn,ae.needsUpdate=!0,x.renderBufferDirect(me,ne,ge,ae,z,Xe),ae.side=Bi):x.renderBufferDirect(me,ne,ge,ae,z,Xe),z.onAfterRender(x,ne,me,ge,ae,Xe)}function au(z,ne,me){ne.isScene!==!0&&(ne=se);let ge=Pe.get(z),ae=y.state.lights,Xe=y.state.shadowsArray,Je=ae.state.version,pt=ve.getParameters(z,ae.state,Xe,ne,me),We=ve.getProgramCacheKey(pt),Dt=ge.programs;ge.environment=z.isMeshStandardMaterial?ne.environment:null,ge.fog=ne.fog,ge.envMap=(z.isMeshStandardMaterial?_:ze).get(z.envMap||ge.environment),ge.envMapRotation=ge.environment!==null&&z.envMap===null?ne.environmentRotation:z.envMapRotation,Dt===void 0&&(z.addEventListener("dispose",ce),Dt=new Map,ge.programs=Dt);let Tt=Dt.get(We);if(Tt!==void 0){if(ge.currentProgram===Tt&&ge.lightsStateVersion===Je)return Mg(z,pt),Tt}else pt.uniforms=ve.getUniforms(z),z.onBuild(me,pt,x),z.onBeforeCompile(pt,x),Tt=ve.acquireProgram(pt,We),Dt.set(We,Tt),ge.uniforms=pt.uniforms;let _t=ge.uniforms;return(!z.isShaderMaterial&&!z.isRawShaderMaterial||z.clipping===!0)&&(_t.clippingPlanes=Oe.uniform),Mg(z,pt),ge.needsLights=$b(z),ge.lightsStateVersion=Je,ge.needsLights&&(_t.ambientLightColor.value=ae.state.ambient,_t.lightProbe.value=ae.state.probe,_t.directionalLights.value=ae.state.directional,_t.directionalLightShadows.value=ae.state.directionalShadow,_t.spotLights.value=ae.state.spot,_t.spotLightShadows.value=ae.state.spotShadow,_t.rectAreaLights.value=ae.state.rectArea,_t.ltc_1.value=ae.state.rectAreaLTC1,_t.ltc_2.value=ae.state.rectAreaLTC2,_t.pointLights.value=ae.state.point,_t.pointLightShadows.value=ae.state.pointShadow,_t.hemisphereLights.value=ae.state.hemi,_t.directionalShadowMap.value=ae.state.directionalShadowMap,_t.directionalShadowMatrix.value=ae.state.directionalShadowMatrix,_t.spotShadowMap.value=ae.state.spotShadowMap,_t.spotLightMatrix.value=ae.state.spotLightMatrix,_t.spotLightMap.value=ae.state.spotLightMap,_t.pointShadowMap.value=ae.state.pointShadowMap,_t.pointShadowMatrix.value=ae.state.pointShadowMatrix),ge.currentProgram=Tt,ge.uniformsList=null,Tt}function lu(z){if(z.uniformsList===null){let ne=z.currentProgram.getUniforms();z.uniformsList=Ru.seqWithValue(ne.seq,z.uniforms)}return z.uniformsList}function Mg(z,ne){let me=Pe.get(z);me.outputColorSpace=ne.outputColorSpace,me.batching=ne.batching,me.instancing=ne.instancing,me.instancingColor=ne.instancingColor,me.instancingMorph=ne.instancingMorph,me.skinning=ne.skinning,me.morphTargets=ne.morphTargets,me.morphNormals=ne.morphNormals,me.morphColors=ne.morphColors,me.morphTargetsCount=ne.morphTargetsCount,me.numClippingPlanes=ne.numClippingPlanes,me.numIntersection=ne.numClipIntersection,me.vertexAlphas=ne.vertexAlphas,me.vertexTangents=ne.vertexTangents,me.toneMapping=ne.toneMapping}function Jb(z,ne,me,ge,ae){ne.isScene!==!0&&(ne=se),Re.resetTextureUnits();let Xe=ne.fog,Je=ge.isMeshStandardMaterial?ne.environment:null,pt=E===null?x.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:an,We=(ge.isMeshStandardMaterial?_:ze).get(ge.envMap||Je),Dt=ge.vertexColors===!0&&!!me.attributes.color&&me.attributes.color.itemSize===4,Tt=!!me.attributes.tangent&&(!!ge.normalMap||ge.anisotropy>0),_t=!!me.morphAttributes.position,Fr=!!me.morphAttributes.normal,Yi=!!me.morphAttributes.color,Pr=Ja;ge.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Pr=x.toneMapping);let St=me.morphAttributes.position||me.morphAttributes.normal||me.morphAttributes.color,Rr=St!==void 0?St.length:0,Mt=Pe.get(ge),cu=y.state.lights;if(j===!0&&(K===!0||z!==P)){let tn=z===P&&ge.id===A;Oe.setState(ge,z,tn)}let $t=!1;ge.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==cu.state.version||Mt.outputColorSpace!==pt||ae.isBatchedMesh&&Mt.batching===!1||!ae.isBatchedMesh&&Mt.batching===!0||ae.isInstancedMesh&&Mt.instancing===!1||!ae.isInstancedMesh&&Mt.instancing===!0||ae.isSkinnedMesh&&Mt.skinning===!1||!ae.isSkinnedMesh&&Mt.skinning===!0||ae.isInstancedMesh&&Mt.instancingColor===!0&&ae.instanceColor===null||ae.isInstancedMesh&&Mt.instancingColor===!1&&ae.instanceColor!==null||ae.isInstancedMesh&&Mt.instancingMorph===!0&&ae.morphTexture===null||ae.isInstancedMesh&&Mt.instancingMorph===!1&&ae.morphTexture!==null||Mt.envMap!==We||ge.fog===!0&&Mt.fog!==Xe||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==Oe.numPlanes||Mt.numIntersection!==Oe.numIntersection)||Mt.vertexAlphas!==Dt||Mt.vertexTangents!==Tt||Mt.morphTargets!==_t||Mt.morphNormals!==Fr||Mt.morphColors!==Yi||Mt.toneMapping!==Pr||be.isWebGL2===!0&&Mt.morphTargetsCount!==Rr)&&($t=!0):($t=!0,Mt.__version=ge.version);let R=Mt.currentProgram;$t===!0&&(R=au(ge,ne,ae));let N=!1,q=!1,V=!1,Q=R.getUniforms(),Ce=Mt.uniforms;if(Ee.useProgram(R.program)&&(N=!0,q=!0,V=!0),ge.id!==A&&(A=ge.id,q=!0),N||P!==z){Q.setValue(W,"projectionMatrix",z.projectionMatrix),Q.setValue(W,"viewMatrix",z.matrixWorldInverse);let tn=Q.map.cameraPosition;tn!==void 0&&tn.setValue(W,$.setFromMatrixPosition(z.matrixWorld)),be.logarithmicDepthBuffer&&Q.setValue(W,"logDepthBufFC",2/(Math.log(z.far+1)/Math.LN2)),(ge.isMeshPhongMaterial||ge.isMeshToonMaterial||ge.isMeshLambertMaterial||ge.isMeshBasicMaterial||ge.isMeshStandardMaterial||ge.isShaderMaterial)&&Q.setValue(W,"isOrthographic",z.isOrthographicCamera===!0),P!==z&&(P=z,q=!0,V=!0)}if(ae.isSkinnedMesh){Q.setOptional(W,ae,"bindMatrix"),Q.setOptional(W,ae,"bindMatrixInverse");let tn=ae.skeleton;tn&&(be.floatVertexTextures?(tn.boneTexture===null&&tn.computeBoneTexture(),Q.setValue(W,"boneTexture",tn.boneTexture,Re)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ae.isBatchedMesh&&(Q.setOptional(W,ae,"batchingTexture"),Q.setValue(W,"batchingTexture",ae._matricesTexture,Re));let oo=me.morphAttributes;if((oo.position!==void 0||oo.normal!==void 0||oo.color!==void 0&&be.isWebGL2===!0)&&Te.update(ae,me,R),(q||Mt.receiveShadow!==ae.receiveShadow)&&(Mt.receiveShadow=ae.receiveShadow,Q.setValue(W,"receiveShadow",ae.receiveShadow)),ge.isMeshGouraudMaterial&&ge.envMap!==null&&(Ce.envMap.value=We,Ce.flipEnvMap.value=We.isCubeTexture&&We.isRenderTargetTexture===!1?-1:1),q&&(Q.setValue(W,"toneMappingExposure",x.toneMappingExposure),Mt.needsLights&&Qf(Ce,V),Xe&&ge.fog===!0&&fe.refreshFogUniforms(Ce,Xe),fe.refreshMaterialUniforms(Ce,ge,F,k,ee),Ru.upload(W,lu(Mt),Ce,Re)),ge.isShaderMaterial&&ge.uniformsNeedUpdate===!0&&(Ru.upload(W,lu(Mt),Ce,Re),ge.uniformsNeedUpdate=!1),ge.isSpriteMaterial&&Q.setValue(W,"center",ae.center),Q.setValue(W,"modelViewMatrix",ae.modelViewMatrix),Q.setValue(W,"normalMatrix",ae.normalMatrix),Q.setValue(W,"modelMatrix",ae.matrixWorld),ae.previousModelViewMatrix&&Q.setValue(W,"previousModelViewMatrix",ae.previousModelViewMatrix),z.previousProjectionMatrix&&Q.setValue(W,"previousProjectionMatrix",z.previousProjectionMatrix),ge.isShaderMaterial||ge.isRawShaderMaterial){let tn=ge.uniformsGroups;for(let Ha=0,Zf=tn.length;Ha<Zf;Ha++)if(be.isWebGL2){let nc=tn[Ha];rt.update(nc,R),rt.bind(nc,R)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return R}function Qf(z,ne){z.ambientLightColor.needsUpdate=ne,z.lightProbe.needsUpdate=ne,z.directionalLights.needsUpdate=ne,z.directionalLightShadows.needsUpdate=ne,z.pointLights.needsUpdate=ne,z.pointLightShadows.needsUpdate=ne,z.spotLights.needsUpdate=ne,z.spotLightShadows.needsUpdate=ne,z.rectAreaLights.needsUpdate=ne,z.hemisphereLights.needsUpdate=ne}function $b(z){return z.isMeshLambertMaterial||z.isMeshToonMaterial||z.isMeshPhongMaterial||z.isMeshStandardMaterial||z.isShadowMaterial||z.isShaderMaterial&&z.lights===!0}this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(z,ne,me){Pe.get(z.texture).__webglTexture=ne,Pe.get(z.depthTexture).__webglTexture=me;let ge=Pe.get(z);ge.__hasExternalTextures=!0,ge.__autoAllocateDepthBuffer=me===void 0,ge.__autoAllocateDepthBuffer||xe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ge.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(z,ne){let me=Pe.get(z);me.__webglFramebuffer=ne,me.__useDefaultFramebuffer=ne===void 0},this.setRenderTarget=function(z,ne=0,me=0){E=z,S=ne,w=me;let ge=!0,ae=null,Xe=!1,Je=!1;if(z){let We=Pe.get(z);We.__useDefaultFramebuffer!==void 0?(Ee.bindFramebuffer(W.FRAMEBUFFER,null),ge=!1):We.__webglFramebuffer===void 0?Re.setupRenderTarget(z):We.__hasExternalTextures&&Re.rebindTextures(z,Pe.get(z.texture).__webglTexture,Pe.get(z.depthTexture).__webglTexture);let Dt=z.texture;(Dt.isData3DTexture||Dt.isDataArrayTexture||Dt.isCompressedArrayTexture)&&(Je=!0);let Tt=Pe.get(z).__webglFramebuffer;z.isWebGLCubeRenderTarget?(Array.isArray(Tt[ne])?ae=Tt[ne][me]:ae=Tt[ne],Xe=!0):be.isWebGL2&&z.samples>0&&Re.useMultisampledRTT(z)===!1?ae=Pe.get(z).__webglMultisampledFramebuffer:Array.isArray(Tt)?ae=Tt[me]:ae=Tt,M.copy(z.viewport),C.copy(z.scissor),O=z.scissorTest}else M.copy(X).multiplyScalar(F).floor(),C.copy(Y).multiplyScalar(F).floor(),O=Z;if(Ee.bindFramebuffer(W.FRAMEBUFFER,ae)&&be.drawBuffers&&ge&&Ee.drawBuffers(z,ae),Ee.viewport(M),Ee.scissor(C),Ee.setScissorTest(O),Xe){let We=Pe.get(z.texture);W.framebufferTexture2D(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,W.TEXTURE_CUBE_MAP_POSITIVE_X+ne,We.__webglTexture,me)}else if(Je){let We=Pe.get(z.texture),Dt=ne||0;W.framebufferTextureLayer(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,We.__webglTexture,me||0,Dt)}A=-1},this.readRenderTargetPixels=function(z,ne,me,ge,ae,Xe,Je){if(!(z&&z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=Pe.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&Je!==void 0&&(pt=pt[Je]),pt){Ee.bindFramebuffer(W.FRAMEBUFFER,pt);try{let We=z.texture,Dt=We.format,Tt=We.type;if(Dt!==Yr&&ct.convert(Dt)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let _t=Tt===sa&&(xe.has("EXT_color_buffer_half_float")||be.isWebGL2&&xe.has("EXT_color_buffer_float"));if(Tt!==Dr&&ct.convert(Tt)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Tt===ar&&(be.isWebGL2||xe.has("OES_texture_float")||xe.has("WEBGL_color_buffer_float")))&&!_t){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ne>=0&&ne<=z.width-ge&&me>=0&&me<=z.height-ae&&W.readPixels(ne,me,ge,ae,ct.convert(Dt),ct.convert(Tt),Xe)}finally{let We=E!==null?Pe.get(E).__webglFramebuffer:null;Ee.bindFramebuffer(W.FRAMEBUFFER,We)}}},this.copyFramebufferToTexture=function(z,ne,me=0){let ge=Math.pow(2,-me),ae=Math.floor(ne.image.width*ge),Xe=Math.floor(ne.image.height*ge);Re.setTexture2D(ne,0),W.copyTexSubImage2D(W.TEXTURE_2D,me,0,0,z.x,z.y,ae,Xe),Ee.unbindTexture()},this.copyTextureToTexture=function(z,ne,me,ge=0){let ae=ne.image.width,Xe=ne.image.height,Je=ct.convert(me.format),pt=ct.convert(me.type);Re.setTexture2D(me,0),W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,me.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,me.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,me.unpackAlignment),ne.isDataTexture?W.texSubImage2D(W.TEXTURE_2D,ge,z.x,z.y,ae,Xe,Je,pt,ne.image.data):ne.isCompressedTexture?W.compressedTexSubImage2D(W.TEXTURE_2D,ge,z.x,z.y,ne.mipmaps[0].width,ne.mipmaps[0].height,Je,ne.mipmaps[0].data):W.texSubImage2D(W.TEXTURE_2D,ge,z.x,z.y,Je,pt,ne.image),ge===0&&me.generateMipmaps&&W.generateMipmap(W.TEXTURE_2D),Ee.unbindTexture()},this.copyTextureToTexture3D=function(z,ne,me,ge,ae=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Xe=Math.round(z.max.x-z.min.x),Je=Math.round(z.max.y-z.min.y),pt=z.max.z-z.min.z+1,We=ct.convert(ge.format),Dt=ct.convert(ge.type),Tt;if(ge.isData3DTexture)Re.setTexture3D(ge,0),Tt=W.TEXTURE_3D;else if(ge.isDataArrayTexture||ge.isCompressedArrayTexture)Re.setTexture2DArray(ge,0),Tt=W.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,ge.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ge.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,ge.unpackAlignment);let _t=W.getParameter(W.UNPACK_ROW_LENGTH),Fr=W.getParameter(W.UNPACK_IMAGE_HEIGHT),Yi=W.getParameter(W.UNPACK_SKIP_PIXELS),Pr=W.getParameter(W.UNPACK_SKIP_ROWS),St=W.getParameter(W.UNPACK_SKIP_IMAGES),Rr=me.isCompressedTexture?me.mipmaps[ae]:me.image;W.pixelStorei(W.UNPACK_ROW_LENGTH,Rr.width),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Rr.height),W.pixelStorei(W.UNPACK_SKIP_PIXELS,z.min.x),W.pixelStorei(W.UNPACK_SKIP_ROWS,z.min.y),W.pixelStorei(W.UNPACK_SKIP_IMAGES,z.min.z),me.isDataTexture||me.isData3DTexture?W.texSubImage3D(Tt,ae,ne.x,ne.y,ne.z,Xe,Je,pt,We,Dt,Rr.data):ge.isCompressedArrayTexture?W.compressedTexSubImage3D(Tt,ae,ne.x,ne.y,ne.z,Xe,Je,pt,We,Rr.data):W.texSubImage3D(Tt,ae,ne.x,ne.y,ne.z,Xe,Je,pt,We,Dt,Rr),W.pixelStorei(W.UNPACK_ROW_LENGTH,_t),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Fr),W.pixelStorei(W.UNPACK_SKIP_PIXELS,Yi),W.pixelStorei(W.UNPACK_SKIP_ROWS,Pr),W.pixelStorei(W.UNPACK_SKIP_IMAGES,St),ae===0&&ge.generateMipmaps&&W.generateMipmap(Tt),Ee.unbindTexture()},this.initTexture=function(z){z.isCubeTexture?Re.setTextureCube(z,0):z.isData3DTexture?Re.setTexture3D(z,0):z.isDataArrayTexture||z.isCompressedArrayTexture?Re.setTexture2DArray(z,0):Re.setTexture2D(z,0),Ee.unbindTexture()},this.resetState=function(){S=0,w=0,E=null,Ee.reset(),tt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ia}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===_w?"display-p3":"srgb",e.unpackColorSpace=or.workingColorSpace===Vy?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},sw=class extends gp{};sw.prototype.isWebGL1Renderer=!0;var Uu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new ke(t),this.near=e,this.far=r}clone(){return new Uu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Ai=class extends Rt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ht,this.environmentRotation=new Ht,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),e.object.environmentRotation=this.environmentRotation.toArray(),e}},xy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=HS,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=ss()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return l_("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[r+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ss()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ss()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},fn=new T,gc=class{constructor(t,e,r,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.applyMatrix4(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.applyNormalMatrix(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.transformDirection(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}getComponent(t,e){let r=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(r=Os(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=mr(r,this.array)),this.data.array[t*this.data.stride+this.offset+e]=r,this}setX(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Os(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Os(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Os(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Os(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=mr(e,this.array),r=mr(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=mr(e,this.array),r=mr(r,this.array),n=mr(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this}setXYZW(t,e,r,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=mr(e,this.array),r=mr(r,this.array),n=mr(n,this.array),s=mr(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new Ye(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new gc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var yp=class extends Rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},si=class extends Zt{constructor(t=null,e=1,r=1,n,s,o,a,l,c=Vt,u=Vt,h,d){super(null,o,a,l,c,u,n,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},TC=new ue,p4=new ue,rl=class{constructor(t=[],e=[]){this.uuid=ss(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,n=this.bones.length;r<n;r++)this.boneInverses.push(new ue)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ue;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,n=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:p4;TC.multiplyMatrices(a,e[s]),TC.toArray(r,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new rl(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new si(e,t,t,Yr,ar);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,n=t.bones.length;r<n;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new yp),this.bones.push(o),this.boneInverses.push(new ue().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let n=0,s=e.length;n<s;n++){let o=e[n];t.bones.push(o.uuid);let a=r[n];t.boneInverses.push(a.toArray())}return t}},co=class extends Ye{constructor(t,e,r,n=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},Mu=new ue,MC=new ue,Kg=[],CC=new zt,m4=new ue,np=new tr,sp=new Or,by=class extends tr{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new co(new Float32Array(r*16),16),this.instanceColor=null,this.morphTexture=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<r;n++)this.setMatrixAt(n,m4)}computeBoundingBox(){let t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new zt),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<e;r++)this.getMatrixAt(r,Mu),CC.copy(t.boundingBox).applyMatrix4(Mu),this.boundingBox.union(CC)}computeBoundingSphere(){let t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Or),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<e;r++)this.getMatrixAt(r,Mu),sp.copy(t.boundingSphere).applyMatrix4(Mu),this.boundingSphere.union(sp)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){let r=e.morphTargetInfluences,n=this.morphTexture.source.data.data,s=r.length+1,o=t*s+1;for(let a=0;a<r.length;a++)r[a]=n[o+a]}raycast(t,e){let r=this.matrixWorld,n=this.count;if(np.geometry=this.geometry,np.material=this.material,np.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),sp.copy(this.boundingSphere),sp.applyMatrix4(r),t.ray.intersectsSphere(sp)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Mu),MC.multiplyMatrices(r,Mu),np.matrixWorld=MC,np.raycast(t,Kg);for(let o=0,a=Kg.length;o<a;o++){let l=Kg[o];l.instanceId=s,l.object=this,e.push(l)}Kg.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new co(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){let r=e.morphTargetInfluences,n=r.length+1;this.morphTexture===null&&(this.morphTexture=new si(new Float32Array(n*this.count),n,this.count,t_,ar));let s=this.morphTexture.source.data.data,o=0;for(let c=0;c<r.length;c++)o+=r[c];let a=this.geometry.morphTargetsRelative?1:1-o,l=n*t;s[l]=a,s.set(r,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}};var os=class extends mc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ke(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},_C=new T,PC=new T,DC=new ue,IS=new Rs,Qg=new Or,yc=class extends Rt{constructor(t=new Ne,e=new os){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let n=1,s=e.count;n<s;n++)_C.fromBufferAttribute(e,n-1),PC.fromBufferAttribute(e,n),r[n]=r[n-1],r[n]+=_C.distanceTo(PC);t.setAttribute("lineDistance",new Ie(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Qg.copy(r.boundingSphere),Qg.applyMatrix4(n),Qg.radius+=s,t.ray.intersectsSphere(Qg)===!1)return;DC.copy(n).invert(),IS.copy(t.ray).applyMatrix4(DC);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new T,u=new T,h=new T,d=new T,f=this.isLineSegments?2:1,p=r.index,y=r.attributes.position;if(p!==null){let m=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=m,b=v-1;x<b;x+=f){let S=p.getX(x),w=p.getX(x+1);if(c.fromBufferAttribute(y,S),u.fromBufferAttribute(y,w),IS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,o.start),v=Math.min(y.count,o.start+o.count);for(let x=m,b=v-1;x<b;x+=f){if(c.fromBufferAttribute(y,x),u.fromBufferAttribute(y,x+1),IS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let w=t.ray.origin.distanceTo(d);w<t.near||w>t.far||e.push({distance:w,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},OC=new T,IC=new T,il=class extends yc{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let n=0,s=e.count;n<s;n+=2)OC.fromBufferAttribute(e,n),IC.fromBufferAttribute(e,n+1),r[n]=n===0?0:r[n-1],r[n+1]=r[n]+OC.distanceTo(IC);t.setAttribute("lineDistance",new Ie(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Sy=class extends Zt{constructor(t,e,r,n,s,o,a,l,c){super(t,e,r,n,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:it,this.magFilter=s!==void 0?s:it,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var wy=class extends Zt{constructor(t,e,r,n,s,o,a,l,c){super(t,e,r,n,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},as=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(n),e.push(s),n=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),n=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=r[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,r[n]===o)return n/(s-1);let u=r[n],d=r[n+1]-u,f=(o-u)/d;return(n+f)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=e||(o.isVector2?new U:new T);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new T,n=[],s=[],o=[],a=new T,l=new ue;for(let f=0;f<=t;f++){let p=f/t;n[f]=this.getTangentAt(p,new T)}s[0]=new T,o[0]=new T;let c=Number.MAX_VALUE,u=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);u<=c&&(c=u,r.set(1,0,0)),h<=c&&(c=h,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(n[0],r).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(ti(n[f-1].dot(n[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(n[f],s[f])}if(e===!0){let f=Math.acos(ti(s[0].dot(s[t]),-1,1));f/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(n[p],f*p)),o[p].crossVectors(n[p],s[p])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},vc=class extends as{constructor(t=0,e=0,r=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new U){let r=e,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(o?s=0:s=n),this.aClockwise===!0&&!o&&(s===n?s=-n:s=s-n);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},ow=class extends vc{constructor(t,e,r,n,s,o){super(t,e,r,r,n,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Ow(){let i=0,t=0,e=0,r=0;function n(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){n(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,f*=u,n(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+r*a}}}var Zg=new T,RS=new Ow,LS=new Ow,NS=new Ow,aw=class extends as{constructor(t=[],e=!1,r="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=n}getPoint(t,e=new T){let r=e,n=this.points,s=n.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%s]:(Zg.subVectors(n[0],n[1]).add(n[0]),c=Zg);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2<s?u=n[(a+2)%s]:(Zg.subVectors(n[s-1],n[s-2]).add(n[s-1]),u=Zg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(c.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(u),f);g<1e-4&&(g=1),p<1e-4&&(p=g),y<1e-4&&(y=g),RS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,p,g,y),LS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,p,g,y),NS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,p,g,y)}else this.curveType==="catmullrom"&&(RS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),LS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),NS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(RS.calc(l),LS.calc(l),NS.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new T().fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function RC(i,t,e,r,n){let s=(r-t)*.5,o=(n-e)*.5,a=i*i,l=i*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*i+e}function g4(i,t){let e=1-i;return e*e*t}function y4(i,t){return 2*(1-i)*i*t}function v4(i,t){return i*i*t}function up(i,t,e,r){return g4(i,t)+y4(i,e)+v4(i,r)}function x4(i,t){let e=1-i;return e*e*e*t}function b4(i,t){let e=1-i;return 3*e*e*i*t}function S4(i,t){return 3*(1-i)*i*i*t}function w4(i,t){return i*i*i*t}function hp(i,t,e,r,n){return x4(i,t)+b4(i,e)+S4(i,r)+w4(i,n)}var on=class extends as{constructor(t=new U,e=new U,r=new U,n=new U){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new U){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(hp(t,n.x,s.x,o.x,a.x),hp(t,n.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},xc=class extends as{constructor(t=new T,e=new T,r=new T,n=new T){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new T){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(hp(t,n.x,s.x,o.x,a.x),hp(t,n.y,s.y,o.y,a.y),hp(t,n.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},mn=class extends as{constructor(t=new U,e=new U){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new U){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new U){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},vp=class extends as{constructor(t=new T,e=new T){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new T){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new T){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Xn=class extends as{constructor(t=new U,e=new U,r=new U){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new U){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(up(t,n.x,s.x,o.x),up(t,n.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},lw=class extends as{constructor(t=new T,e=new T,r=new T){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new T){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(up(t,n.x,s.x,o.x),up(t,n.y,s.y,o.y),up(t,n.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Vu=class extends as{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new U){let r=e,n=this.points,s=(n.length-1)*t,o=Math.floor(s),a=s-o,l=n[o===0?o:o-1],c=n[o],u=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return r.set(RC(a,l.x,c.x,u.x,h.x),RC(a,l.y,c.y,u.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new U().fromArray(n))}return this}},LC=Object.freeze({__proto__:null,ArcCurve:ow,CatmullRomCurve3:aw,CubicBezierCurve:on,CubicBezierCurve3:xc,EllipseCurve:vc,LineCurve:mn,LineCurve3:vp,QuadraticBezierCurve:Xn,QuadraticBezierCurve3:lw,SplineCurve:Vu}),xp=class extends as{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new LC[r](e,t))}return this}getPoint(t,e){let r=t*this.getLength(),n=this.getCurveLengths(),s=0;for(;s<n.length;){if(n[s]>=r){let o=n[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let r=0,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let n=0,s=this.curves;n<s.length;n++){let o=s[n],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];r&&r.equals(u)||(e.push(u),r=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(new LC[n.type]().fromJSON(n))}return this}},bc=class extends xp{constructor(t){super(),this.type="Path",this.currentPoint=new U,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new mn(this.currentPoint.clone(),new U(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,n){let s=new Xn(this.currentPoint.clone(),new U(t,e),new U(r,n));return this.curves.push(s),this.currentPoint.set(r,n),this}bezierCurveTo(t,e,r,n,s,o){let a=new on(this.currentPoint.clone(),new U(t,e),new U(r,n),new U(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new Vu(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,n,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,n,s,o),this}absarc(t,e,r,n,s,o){return this.absellipse(t,e,r,r,n,s,o),this}ellipse(t,e,r,n,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+c,e+u,r,n,s,o,a,l),this}absellipse(t,e,r,n,s,o,a,l){let c=new vc(t,e,r,n,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},zu=class extends Ne{constructor(t=[new U(0,-.5),new U(.5,0),new U(0,.5)],e=12,r=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},e=Math.floor(e),n=ti(n,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new T,d=new U,f=new T,p=new T,g=new T,y=0,m=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:y=t[v+1].x-t[v].x,m=t[v+1].y-t[v].y,f.x=m*1,f.y=-y,f.z=m*0,g.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(g.x,g.y,g.z);break;default:y=t[v+1].x-t[v].x,m=t[v+1].y-t[v].y,f.x=m*1,f.y=-y,f.z=m*0,p.copy(f),f.x+=g.x,f.y+=g.y,f.z+=g.z,f.normalize(),l.push(f.x,f.y,f.z),g.copy(p)}for(let v=0;v<=e;v++){let x=r+v*u*n,b=Math.sin(x),S=Math.cos(x);for(let w=0;w<=t.length-1;w++){h.x=t[w].x*b,h.y=t[w].y,h.z=t[w].x*S,o.push(h.x,h.y,h.z),d.x=v/e,d.y=w/(t.length-1),a.push(d.x,d.y);let E=l[3*w+0]*b,A=l[3*w+1],P=l[3*w+0]*S;c.push(E,A,P)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,S=b,w=b+t.length,E=b+t.length+1,A=b+1;s.push(S,w,A),s.push(E,A,w)}this.setIndex(s),this.setAttribute("position",new Ie(o,3)),this.setAttribute("uv",new Ie(a,2)),this.setAttribute("normal",new Ie(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zu(t.points,t.segments,t.phiStart,t.phiLength)}};var Sc=class extends Ne{constructor(t=1,e=1,r=1,n=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;n=Math.floor(n),s=Math.floor(s);let u=[],h=[],d=[],f=[],p=0,g=[],y=r/2,m=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Ie(h,3)),this.setAttribute("normal",new Ie(d,3)),this.setAttribute("uv",new Ie(f,2));function v(){let b=new T,S=new T,w=0,E=(e-t)/r;for(let A=0;A<=s;A++){let P=[],M=A/s,C=M*(e-t)+t;for(let O=0;O<=n;O++){let L=O/n,D=L*l+a,B=Math.sin(D),k=Math.cos(D);S.x=C*B,S.y=-M*r+y,S.z=C*k,h.push(S.x,S.y,S.z),b.set(B,E,k).normalize(),d.push(b.x,b.y,b.z),f.push(L,1-M),P.push(p++)}g.push(P)}for(let A=0;A<n;A++)for(let P=0;P<s;P++){let M=g[P][A],C=g[P+1][A],O=g[P+1][A+1],L=g[P][A+1];u.push(M,C,L),u.push(C,O,L),w+=6}c.addGroup(m,w,0),m+=w}function x(b){let S=p,w=new U,E=new T,A=0,P=b===!0?t:e,M=b===!0?1:-1;for(let O=1;O<=n;O++)h.push(0,y*M,0),d.push(0,M,0),f.push(.5,.5),p++;let C=p;for(let O=0;O<=n;O++){let D=O/n*l+a,B=Math.cos(D),k=Math.sin(D);E.x=P*k,E.y=y*M,E.z=P*B,h.push(E.x,E.y,E.z),d.push(0,M,0),w.x=B*.5+.5,w.y=k*.5*M+.5,f.push(w.x,w.y),p++}for(let O=0;O<n;O++){let L=S+O,D=C+O;b===!0?u.push(D,D+1,L):u.push(D+1,D,L),A+=3}c.addGroup(m,A,b===!0?1:2),m+=A}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Sc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},nl=class extends Sc{constructor(t=1,e=1,r=32,n=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,n,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new nl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ku=class extends Ne{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};let s=[],o=[];a(n),c(r),u(),this.setAttribute("position",new Ie(s,3)),this.setAttribute("normal",new Ie(s.slice(),3)),this.setAttribute("uv",new Ie(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new T,b=new T,S=new T;for(let w=0;w<e.length;w+=3)f(e[w+0],x),f(e[w+1],b),f(e[w+2],S),l(x,b,S,v)}function l(v,x,b,S){let w=S+1,E=[];for(let A=0;A<=w;A++){E[A]=[];let P=v.clone().lerp(b,A/w),M=x.clone().lerp(b,A/w),C=w-A;for(let O=0;O<=C;O++)O===0&&A===w?E[A][O]=P:E[A][O]=P.clone().lerp(M,O/C)}for(let A=0;A<w;A++)for(let P=0;P<2*(w-A)-1;P++){let M=Math.floor(P/2);P%2===0?(d(E[A][M+1]),d(E[A+1][M]),d(E[A][M])):(d(E[A][M+1]),d(E[A+1][M+1]),d(E[A+1][M]))}}function c(v){let x=new T;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(v),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function u(){let v=new T;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let b=y(v)/2/Math.PI+.5,S=m(v)/Math.PI+.5;o.push(b,1-S)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],S=o[v+4],w=Math.max(x,b,S),E=Math.min(x,b,S);w>.9&&E<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let b=v*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function p(){let v=new T,x=new T,b=new T,S=new T,w=new U,E=new U,A=new U;for(let P=0,M=0;P<s.length;P+=9,M+=6){v.set(s[P+0],s[P+1],s[P+2]),x.set(s[P+3],s[P+4],s[P+5]),b.set(s[P+6],s[P+7],s[P+8]),w.set(o[M+0],o[M+1]),E.set(o[M+2],o[M+3]),A.set(o[M+4],o[M+5]),S.copy(v).add(x).add(b).divideScalar(3);let C=y(S);g(w,M+0,v,C),g(E,M+2,x,C),g(A,M+4,b,C)}}function g(v,x,b,S){S<0&&v.x===1&&(o[x]=v.x-1),b.x===0&&b.z===0&&(o[x]=S/2/Math.PI+.5)}function y(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ku(t.vertices,t.indices,t.radius,t.details)}},Gu=class extends ku{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=1/r,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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Gu(t.radius,t.detail)}};var oa=class extends bc{constructor(t){super(t),this.uuid=ss(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,n=this.holes.length;r<n;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(new bc().fromJSON(n))}return this}},A4={triangulate:function(i,t,e=2){let r=t&&t.length,n=r?t[0]*e:i.length,s=v_(i,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,f;if(r&&(s=_4(i,t,s,e)),i.length>80*e){a=c=i[0],l=u=i[1];for(let p=e;p<n;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return bp(s,o,e,a,l,f,0),o}};function v_(i,t,e,r,n){let s,o;if(n===V4(i,t,e,r)>0)for(s=t;s<e;s+=r)o=NC(s,i[s],i[s+1],o);else for(s=e-r;s>=t;s-=r)o=NC(s,i[s],i[s+1],o);return o&&ky(o,o.next)&&(wp(o),o=o.next),o}function wc(i,t){if(!i)return i;t||(t=i);let e=i,r;do if(r=!1,!e.steiner&&(ky(e,e.next)||Gr(e.prev,e,e.next)===0)){if(wp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function bp(i,t,e,r,n,s,o){if(!i)return;!o&&s&&R4(i,r,n,s);let a=i,l,c;for(;i.prev!==i.next;){if(l=i.prev,c=i.next,s?T4(i,r,n,s):E4(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(c.i/e|0),wp(i),i=c.next,a=c.next;continue}if(i=c,i===a){o?o===1?(i=M4(wc(i),t,e),bp(i,t,e,r,n,s,2)):o===2&&C4(i,t,e,r,n,s):bp(wc(i),t,e,r,n,s,1);break}}}function E4(i){let t=i.prev,e=i,r=i.next;if(Gr(t,e,r)>=0)return!1;let n=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,u=n<s?n<o?n:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Ou(n,a,s,l,o,c,p.x,p.y)&&Gr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function T4(i,t,e,r){let n=i.prev,s=i,o=i.next;if(Gr(n,s,o)>=0)return!1;let a=n.x,l=s.x,c=o.x,u=n.y,h=s.y,d=o.y,f=a<l?a<c?a:c:l<c?l:c,p=u<h?u<d?u:d:h<d?h:d,g=a>l?a>c?a:c:l>c?l:c,y=u>h?u>d?u:d:h>d?h:d,m=cw(f,p,t,e,r),v=cw(g,y,t,e,r),x=i.prevZ,b=i.nextZ;for(;x&&x.z>=m&&b&&b.z<=v;){if(x.x>=f&&x.x<=g&&x.y>=p&&x.y<=y&&x!==n&&x!==o&&Ou(a,u,l,h,c,d,x.x,x.y)&&Gr(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Ou(a,u,l,h,c,d,b.x,b.y)&&Gr(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=m;){if(x.x>=f&&x.x<=g&&x.y>=p&&x.y<=y&&x!==n&&x!==o&&Ou(a,u,l,h,c,d,x.x,x.y)&&Gr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Ou(a,u,l,h,c,d,b.x,b.y)&&Gr(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function M4(i,t,e){let r=i;do{let n=r.prev,s=r.next.next;!ky(n,s)&&x_(n,r,r.next,s)&&Sp(n,s)&&Sp(s,n)&&(t.push(n.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),wp(r),wp(r.next),r=i=s),r=r.next}while(r!==i);return wc(r)}function C4(i,t,e,r,n,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&B4(o,a)){let l=b_(o,a);o=wc(o,o.next),l=wc(l,l.next),bp(o,t,e,r,n,s,0),bp(l,t,e,r,n,s,0);return}a=a.next}o=o.next}while(o!==i)}function _4(i,t,e,r){let n=[],s,o,a,l,c;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:i.length,c=v_(i,a,l,r,!1),c===c.next&&(c.steiner=!0),n.push(N4(c));for(n.sort(P4),s=0;s<n.length;s++)e=D4(n[s],e);return e}function P4(i,t){return i.x-t.x}function D4(i,t){let e=O4(i,t);if(!e)return t;let r=b_(e,i);return wc(r,r.next),wc(e,e.next)}function O4(i,t){let e=t,r=-1/0,n,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,n=e.x<e.next.x?e:e.next,d===s))return n}e=e.next}while(e!==t);if(!n)return null;let a=n,l=n.x,c=n.y,u=1/0,h;e=n;do s>=e.x&&e.x>=l&&s!==e.x&&Ou(o<c?s:r,o,l,c,o<c?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),Sp(e,i)&&(h<u||h===u&&(e.x>n.x||e.x===n.x&&I4(n,e)))&&(n=e,u=h)),e=e.next;while(e!==a);return n}function I4(i,t){return Gr(i.prev,i,t.prev)<0&&Gr(t.next,i,i.next)<0}function R4(i,t,e,r){let n=i;do n.z===0&&(n.z=cw(n.x,n.y,t,e,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,L4(n)}function L4(i){let t,e,r,n,s,o,a,l,c=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<c&&(a++,r=r.nextZ,!!r);t++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(n=e,e=e.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:i=n,n.prevZ=s,s=n;e=r}s.nextZ=null,c*=2}while(o>1);return i}function cw(i,t,e,r,n){return i=(i-e)*n|0,t=(t-r)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function N4(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Ou(i,t,e,r,n,s,o,a){return(n-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(r-a)}function B4(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!F4(i,t)&&(Sp(i,t)&&Sp(t,i)&&U4(i,t)&&(Gr(i.prev,i,t.prev)||Gr(i,t.prev,t))||ky(i,t)&&Gr(i.prev,i,i.next)>0&&Gr(t.prev,t,t.next)>0)}function Gr(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ky(i,t){return i.x===t.x&&i.y===t.y}function x_(i,t,e,r){let n=$g(Gr(i,t,e)),s=$g(Gr(i,t,r)),o=$g(Gr(e,r,i)),a=$g(Gr(e,r,t));return!!(n!==s&&o!==a||n===0&&Jg(i,e,t)||s===0&&Jg(i,r,t)||o===0&&Jg(e,i,r)||a===0&&Jg(e,t,r))}function Jg(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function $g(i){return i>0?1:i<0?-1:0}function F4(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&x_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Sp(i,t){return Gr(i.prev,i,i.next)<0?Gr(i,t,i.next)>=0&&Gr(i,i.prev,t)>=0:Gr(i,t,i.prev)<0||Gr(i,i.next,t)<0}function U4(i,t){let e=i,r=!1,n=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function b_(i,t){let e=new uw(i.i,i.x,i.y),r=new uw(t.i,t.x,t.y),n=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function NC(i,t,e,r){let n=new uw(i,t,e);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function wp(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function uw(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function V4(i,t,e,r){let n=0;for(let s=t,o=e-r;s<e;s+=r)n+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return n}var Hu=class{static area(t){let e=t.length,r=0;for(let n=e-1,s=0;s<e;n=s++)r+=t[n].x*t[s].y-t[s].x*t[n].y;return r*.5}static isClockWise(t){return Hu.area(t)<0}static triangulateShape(t,e){let r=[],n=[],s=[];BC(t),FC(r,t);let o=t.length;e.forEach(BC);for(let l=0;l<e.length;l++)n.push(o),o+=e[l].length,FC(r,e[l]);let a=A4.triangulate(r,n);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function BC(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function FC(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var ju=class extends ku{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=[-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],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(n,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ju(t.radius,t.detail)}};var Ls=class extends Ne{constructor(t=1,e=32,r=16,n=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new T,d=new T,f=[],p=[],g=[],y=[];for(let m=0;m<=r;m++){let v=[],x=m/r,b=0;m===0&&o===0?b=.5/e:m===r&&l===Math.PI&&(b=-.5/e);for(let S=0;S<=e;S++){let w=S/e;h.x=-t*Math.cos(n+w*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(n+w*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),g.push(d.x,d.y,d.z),y.push(w+b,1-x),v.push(c++)}u.push(v)}for(let m=0;m<r;m++)for(let v=0;v<e;v++){let x=u[m][v+1],b=u[m][v],S=u[m+1][v],w=u[m+1][v+1];(m!==0||o>0)&&f.push(x,b,w),(m!==r-1||l<Math.PI)&&f.push(b,S,w)}this.setIndex(f),this.setAttribute("position",new Ie(p,3)),this.setAttribute("normal",new Ie(g,3)),this.setAttribute("uv",new Ie(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ls(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Wu=class extends Ne{constructor(t=1,e=.4,r=12,n=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:n,arc:s},r=Math.floor(r),n=Math.floor(n);let o=[],a=[],l=[],c=[],u=new T,h=new T,d=new T;for(let f=0;f<=r;f++)for(let p=0;p<=n;p++){let g=p/n*s,y=f/r*Math.PI*2;h.x=(t+e*Math.cos(y))*Math.cos(g),h.y=(t+e*Math.cos(y))*Math.sin(g),h.z=e*Math.sin(y),a.push(h.x,h.y,h.z),u.x=t*Math.cos(g),u.y=t*Math.sin(g),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(p/n),c.push(f/r)}for(let f=1;f<=r;f++)for(let p=1;p<=n;p++){let g=(n+1)*f+p-1,y=(n+1)*(f-1)+p-1,m=(n+1)*(f-1)+p,v=(n+1)*f+p;o.push(g,y,v),o.push(y,m,v)}this.setIndex(o),this.setAttribute("position",new Ie(a,3)),this.setAttribute("normal",new Ie(l,3)),this.setAttribute("uv",new Ie(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wu(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},qu=class extends Ne{constructor(t=1,e=.4,r=64,n=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o},r=Math.floor(r),n=Math.floor(n);let a=[],l=[],c=[],u=[],h=new T,d=new T,f=new T,p=new T,g=new T,y=new T,m=new T;for(let x=0;x<=r;++x){let b=x/r*s*Math.PI*2;v(b,s,o,t,f),v(b+.01,s,o,t,p),y.subVectors(p,f),m.addVectors(p,f),g.crossVectors(y,m),m.crossVectors(g,y),g.normalize(),m.normalize();for(let S=0;S<=n;++S){let w=S/n*Math.PI*2,E=-e*Math.cos(w),A=e*Math.sin(w);h.x=f.x+(E*m.x+A*g.x),h.y=f.y+(E*m.y+A*g.y),h.z=f.z+(E*m.z+A*g.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(x/r),u.push(S/n)}}for(let x=1;x<=r;x++)for(let b=1;b<=n;b++){let S=(n+1)*(x-1)+(b-1),w=(n+1)*x+(b-1),E=(n+1)*x+b,A=(n+1)*(x-1)+b;a.push(S,w,A),a.push(w,E,A)}this.setIndex(a),this.setAttribute("position",new Ie(l,3)),this.setAttribute("normal",new Ie(c,3)),this.setAttribute("uv",new Ie(u,2));function v(x,b,S,w,E){let A=Math.cos(x),P=Math.sin(x),M=S/b*x,C=Math.cos(M);E.x=w*(2+C)*.5*A,E.y=w*(2+C)*P*.5,E.z=w*Math.sin(M)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function ey(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function z4(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function k4(i){function t(n,s){return i[n]-i[s]}let e=i.length,r=new Array(e);for(let n=0;n!==e;++n)r[n]=n;return r.sort(t),r}function UC(i,t,e){let r=i.length,n=new i.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)n[o++]=i[a+l]}return n}function S_(i,t,e,r){let n=1,s=i[0];for(;s!==void 0&&s[r]===void 0;)s=i[n++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[n++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=i[n++];while(s!==void 0)}var Xu=class{constructor(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,n=e[r],s=e[r-1];e:{t:{let o;r:{i:if(!(t<n)){for(let a=r+2;;){if(n===void 0){if(t<s)break i;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=n,n=e[++r],t<n)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(n=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(n=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,n)}return this.interpolate_(r,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=t*n;for(let o=0;o!==n;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},hw=class extends Xu{constructor(t,e,r,n){super(t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Cu,endingEnd:Cu}}intervalChanged_(t,e,r){let n=this.parameterPositions,s=t-2,o=t+1,a=n[s],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case _u:s=t,a=2*e-r;break;case ay:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case _u:o=t,l=2*r-e;break;case ay:o=1,l=r+n[1]-n[0];break;default:o=t-1,l=e}let c=(r-e)*.5,u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-r),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(r-e)/(n-e),g=p*p,y=g*p,m=-d*y+2*d*g-d*p,v=(1+d)*y+(-1.5-2*d)*g+(-.5+d)*p+1,x=(-1-f)*y+(1.5+f)*g+.5*p,b=f*y-f*g;for(let S=0;S!==a;++S)s[S]=m*o[u+S]+v*o[c+S]+x*o[l+S]+b*o[h+S];return s}},Ay=class extends Xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=(r-e)/(n-e),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}},dw=class extends Xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t){return this.copySampleValue_(t-1)}},ls=class{constructor(t,e,r,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ey(e,this.TimeBufferType),this.values=ey(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:ey(t.times,Array),values:ey(t.values,Array)};let n=t.getInterpolation();n!==t.DefaultInterpolation&&(r.interpolation=n)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new dw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ay(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new hw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case sy:e=this.InterpolantFactoryMethodDiscrete;break;case oy:e=this.InterpolantFactoryMethodLinear;break;case aS:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return sy;case this.InterpolantFactoryMethodLinear:return oy;case this.InterpolantFactoryMethodSmooth:return aS}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]*=t}return this}trim(t,e){let r=this.times,n=r.length,s=0,o=n-1;for(;s!==n&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=r.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,n=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(n!==void 0&&z4(n))for(let a=0,l=n.length;a!==l;++a){let c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),r=this.getValueSize(),n=this.getInterpolation()===aS,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=t[a],u=t[a+1];if(c!==u&&(a!==1||c!==t[0]))if(n)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let p=0;p!==r;++p){let g=e[h+p];if(g!==e[d+p]||g!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*r)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};ls.prototype.TimeBufferType=Float32Array;ls.prototype.ValueBufferType=Float32Array;ls.prototype.DefaultInterpolation=oy;var sl=class extends ls{};sl.prototype.ValueTypeName="bool";sl.prototype.ValueBufferType=Array;sl.prototype.DefaultInterpolation=sy;sl.prototype.InterpolantFactoryMethodLinear=void 0;sl.prototype.InterpolantFactoryMethodSmooth=void 0;var Ey=class extends ls{};Ey.prototype.ValueTypeName="color";var Yu=class extends ls{};Yu.prototype.ValueTypeName="number";var fw=class extends Xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(n-e),c=t*a;for(let u=c+a;c!==u;c+=4)Qe.slerpFlat(s,0,o,c-a,o,c,l);return s}},Ac=class extends ls{InterpolantFactoryMethodLinear(t){return new fw(this.times,this.values,this.getValueSize(),t)}};Ac.prototype.ValueTypeName="quaternion";Ac.prototype.DefaultInterpolation=oy;Ac.prototype.InterpolantFactoryMethodSmooth=void 0;var ol=class extends ls{};ol.prototype.ValueTypeName="string";ol.prototype.ValueBufferType=Array;ol.prototype.DefaultInterpolation=sy;ol.prototype.InterpolantFactoryMethodLinear=void 0;ol.prototype.InterpolantFactoryMethodSmooth=void 0;var Ku=class extends ls{};Ku.prototype.ValueTypeName="vector";var Qu=class{constructor(t,e=-1,r,n=Mw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=ss(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,n=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(H4(r[o]).scale(n));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(ls.toJSON(r[s]));return n}static CreateFromMorphTargetSequence(t,e,r,n){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=k4(l);l=UC(l,1,u),c=UC(c,1,u),!n&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Yu(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let n=t;r=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<r.length;n++)if(r[n].name===e)return r[n];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let c=t[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],d=n[h];d||(n[h]=d=[]),d.push(c)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,g){if(f.length!==0){let y=[],m=[];S_(f,y,m,p),y.length!==0&&g.push(new h(d,y,m))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let h=0;h<c.length;h++){let d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let g=0;g<d[p].morphTargets.length;g++)f[d[p].morphTargets[g]]=-1;for(let g in f){let y=[],m=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];y.push(x.time),m.push(x.morphTarget===g?1:0)}n.push(new Yu(".morphTargetInfluence["+g+"]",y,m))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(Ku,f+".position",d,"pos",n),r(Ac,f+".quaternion",d,"rot",n),r(Ku,f+".scale",d,"scl",n)}}return n.length===0?null:new this(s,l,n,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,n=t.length;r!==n;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function G4(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Yu;case"vector":case"vector2":case"vector3":case"vector4":return Ku;case"color":return Ey;case"quaternion":return Ac;case"bool":case"boolean":return sl;case"string":return ol}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function H4(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=G4(i.type);if(i.times===void 0){let e=[],r=[];S_(i.keys,e,r,"value"),i.times=e,i.values=r}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var Ty={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Ap=class{constructor(t,e,r){let n=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(u){a++,s===!1&&n.onStart!==void 0&&n.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,n.onProgress!==void 0&&n.onProgress(u,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(u){n.onError!==void 0&&n.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){let f=c[h],p=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},j4=new Ap,aa=class{constructor(t){this.manager=t!==void 0?t:j4,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(n,s){r.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};aa.DEFAULT_MATERIAL_NAME="__DEFAULT";var $o={},pw=class extends Error{constructor(t,e){super(t),this.response=e}},Zu=class extends aa{constructor(t){super(t)}load(t,e,r,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=Ty.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if($o[t]!==void 0){$o[t].push({onLoad:e,onProgress:r,onError:n});return}$o[t]=[],$o[t].push({onLoad:e,onProgress:r,onError:n});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=$o[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,g=0,y=new ReadableStream({start(m){v();function v(){h.read().then(({done:x,value:b})=>{if(x)m.close();else{g+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:p,loaded:g,total:f});for(let w=0,E=u.length;w<E;w++){let A=u[w];A.onProgress&&A.onProgress(S)}m.enqueue(b),v()}})}}});return new Response(y)}else throw new pw(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{Ty.add(t,c);let u=$o[t];delete $o[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=$o[t];if(u===void 0)throw this.manager.itemError(t),c;delete $o[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var mw=class extends aa{constructor(t){super(t)}load(t,e,r,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=this,o=Ty.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=dp("img");function l(){u(),Ty.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(h){u(),n&&n(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}};var My=class extends aa{constructor(t){super(t)}load(t,e,r,n){let s=new Zt,o=new mw(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,n),s}},al=class extends Rt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ke(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Cy=class extends al{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ke(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},BS=new ue,VC=new T,zC=new T,Ep=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pp,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;VC.setFromMatrixPosition(t.matrixWorld),e.position.copy(VC),zC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(zC),e.updateMatrixWorld(),BS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(BS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(BS)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},gw=class extends Ep{constructor(){super(new ri(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Lu*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},_y=class extends al{constructor(t,e,r=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.distance=r,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new gw}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},kC=new ue,op=new T,FS=new T,yw=class extends Ep{constructor(){super(new ri(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new U(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new T(1,0,0),new T(-1,0,0),new T(0,0,1),new T(0,0,-1),new T(0,1,0),new T(0,-1,0)],this._cubeUps=[new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,0,1),new T(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,n=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),op.setFromMatrixPosition(t.matrixWorld),r.position.copy(op),FS.copy(r.position),FS.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(FS),r.updateMatrixWorld(),n.makeTranslation(-op.x,-op.y,-op.z),kC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kC)}},Py=class extends al{constructor(t,e,r=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=n,this.shadow=new yw}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},vw=class extends Ep{constructor(){super(new Fu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Dy=class extends al{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.shadow=new vw}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Tp=class extends Ne{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Ju=class extends aa{constructor(t){super(t)}load(t,e,r,n){let s=this,o=new Zu(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),s.manager.itemError(t)}},r,n)}parse(t){let e={},r={};function n(f,p){if(e[p]!==void 0)return e[p];let y=f.interleavedBuffers[p],m=s(f,y.buffer),v=Cg(y.type,m),x=new xy(v,y.stride);return x.uuid=y.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let y=f.arrayBuffers[p],m=new Uint32Array(y).buffer;return r[p]=m,m}let o=t.isInstancedBufferGeometry?new Tp:new Ne,a=t.data.index;if(a!==void 0){let f=Cg(a.type,a.array);o.setIndex(new Ye(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],g;if(p.isInterleavedBufferAttribute){let y=n(t.data,p.data);g=new gc(y,p.itemSize,p.offset,p.normalized)}else{let y=Cg(p.type,p.array),m=p.isInstancedBufferAttribute?co:Ye;g=new m(y,p.itemSize,p.normalized)}p.name!==void 0&&(g.name=p.name),p.usage!==void 0&&g.setUsage(p.usage),o.setAttribute(f,g)}let c=t.data.morphAttributes;if(c)for(let f in c){let p=c[f],g=[];for(let y=0,m=p.length;y<m;y++){let v=p[y],x;if(v.isInterleavedBufferAttribute){let b=n(t.data,v.data);x=new gc(b,v.itemSize,v.offset,v.normalized)}else{let b=Cg(v.type,v.array);x=new Ye(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),g.push(x)}o.morphAttributes[f]=g}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let g=h[f];o.addGroup(g.start,g.count,g.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new T;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new Or(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Oy=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=GC(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=GC();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function GC(){return(typeof performance>"u"?Date:performance).now()}var xw=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let n,s,o;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,n=this.valueSize,s=t*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,n=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,n=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,n,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(r[l]!==r[l+e]){a.setValue(r,n);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let s=r,o=n;s!==o;++s)e[s]=e[n+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,n,s){if(n>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,n){Qe.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,s){let o=this._workIndex*s;Qe.multiplyQuaternionsFlat(t,o,t,e,t,r),Qe.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,r,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*n}}_lerpAdditive(t,e,r,n,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*n}}},Iw="\\[\\]\\.:\\/",W4=new RegExp("["+Iw+"]","g"),Rw="[^"+Iw+"]",q4="[^"+Iw.replace("\\.","")+"]",X4=/((?:WC+[\/:])*)/.source.replace("WC",Rw),Y4=/(WCOD+)?/.source.replace("WCOD",q4),K4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rw),Q4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rw),Z4=new RegExp("^"+X4+Y4+K4+Q4+"$"),J4=["material","materials","bones","map"],bw=class{constructor(t,e,r){let n=r||er.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,n=this._bindings[r];n!==void 0&&n.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=r.length;n!==s;++n)r[n].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},er=class{constructor(t,e,r){this.path=e,this.parsedPath=r||er.parseTrackName(e),this.node=er.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new er.Composite(t,e,r):new er(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(W4,"")}static parseTrackName(t){let e=Z4.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=r.nodeName.substring(n+1);J4.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},n=r(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)t[e++]=r[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,s=e.propertyIndex;if(t||(t=er.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let c=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===c){c=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let o=t[n];if(o===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};er.Composite=bw;er.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};er.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};er.prototype.GetterByBindingType=[er.prototype._getValue_direct,er.prototype._getValue_array,er.prototype._getValue_arrayElement,er.prototype._getValue_toArray];er.prototype.SetterByBindingTypeAndVersioning=[[er.prototype._setValue_direct,er.prototype._setValue_direct_setNeedsUpdate,er.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[er.prototype._setValue_array,er.prototype._setValue_array_setNeedsUpdate,er.prototype._setValue_array_setMatrixWorldNeedsUpdate],[er.prototype._setValue_arrayElement,er.prototype._setValue_arrayElement_setNeedsUpdate,er.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[er.prototype._setValue_fromArray,er.prototype._setValue_fromArray_setNeedsUpdate,er.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Sw=class{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Cu,endingEnd:Cu};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Tw,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let n=this._clip.duration,s=t._clip.duration,o=s/n,a=n/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+r,c[0]=t/o,c[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case jF:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Mw:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,n=this.time+t,s=this._loopCount,o=r===Cp;if(t===0)return s===-1?n:o&&(s&1)===1?e-n:n;if(r===Ew){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=e||n<0){let a=Math.floor(n/e);n-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return e-n}return n}_setEndings(t,e,r){let n=this._interpolantSettings;r?(n.endingStart=_u,n.endingEnd=_u):(t?n.endingStart=this.zeroSlopeAtStart?_u:Cu:n.endingStart=ay,e?n.endingEnd=this.zeroSlopeAtEnd?_u:Cu:n.endingEnd=ay)}_scheduleFading(t,e,r){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},$4=new Float32Array(1),Iy=class extends gr{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,n=t._clip.tracks,s=n.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=n[h],f=d.name,p=u[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let g=e&&e._propertyBindings[h].binding.parsedPath;p=new xw(er.create(r,f,g),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,r)}let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let n=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=n.length,n.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],n=t._cacheIndex;r._cacheIndex=n,e[n]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let n=this._bindingsByRootAndName,s=this._bindings,o=n[e];o===void 0&&(o={},n[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,n=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[n],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[n]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Ay(new Float32Array(2),new Float32Array(2),1,$4),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let n=e||this._root,s=n.uuid,o=typeof t=="string"?Qu.findByName(n,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],c=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Mw),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new Sw(this,o,e,r);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(t,e){let r=e||this._root,n=r.uuid,s=typeof t=="string"?Qu.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,n=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==r;++c)e[c]._update(n,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,n=this._actionsByClip,s=n[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},he=class{constructor(t){this.value=t}clone(){return new he(this.value.clone===void 0?this.value:this.value.clone())}};var HC=new ue,$u=class{constructor(t,e,r=0,n=1/0){this.ray=new Rs(t,e),this.near=r,this.far=n,this.camera=null,this.layers=new fp,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return HC.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(HC),this}intersectObject(t,e=!0,r=[]){return ww(t,this,r,e),r.sort(jC),r}intersectObjects(t,e=!0,r=[]){for(let n=0,s=t.length;n<s;n++)ww(t[n],this,r,e);return r.sort(jC),r}};function jC(i,t){return i.distance-t.distance}function ww(i,t,e,r){if(i.layers.test(t.layers)&&i.raycast(t,e),r===!0){let n=i.children;for(let s=0,o=n.length;s<o;s++)ww(n[s],t,e,!0)}}var Mp=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(ti(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var WC=new U,eh=class{constructor(t=new U(1/0,1/0),e=new U(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=WC.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,WC).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},qC=new T,ty=new T,Ei=class{constructor(t=new T,e=new T){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){qC.subVectors(t,this.start),ty.subVectors(this.end,this.start);let r=ty.dot(ty),s=ty.dot(qC)/r;return e&&(s=ti(s,0,1)),s}closestPointToPoint(t,e,r){let n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},XC=new T,Ry=class extends Rt{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ne,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,u=a/l*Math.PI*2;n.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}r.setAttribute("position",new Ie(n,3));let s=new os({fog:!1,toneMapped:!1});this.cone=new il(r,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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),XC.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(XC),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Ly=class extends tr{constructor(t,e,r){let n=new Ls(e,4,2),s=new jn({wireframe:!0,fog:!1,toneMapped:!1});super(n,s),this.light=t,this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var YC=new T,ry=new T,KC=new T,Ny=class extends Rt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let n=new Ne;n.setAttribute("position",new Ie([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new os({fog:!1,toneMapped:!1});this.lightPlane=new yc(n,s),this.add(this.lightPlane),n=new Ne,n.setAttribute("position",new Ie([0,0,0,0,0,1],3)),this.targetLine=new yc(n,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),YC.setFromMatrixPosition(this.light.matrixWorld),ry.setFromMatrixPosition(this.light.target.matrixWorld),KC.subVectors(ry,YC),this.lightPlane.lookAt(ry),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(ry),this.targetLine.scale.z=KC.length()}},iy=new T,Xr=new Wn,ll=class extends il{constructor(t){let e=new Ne,r=new os({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,g){l(p),l(g)}function l(p){n.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(n.length/3-1)}e.setAttribute("position",new Ie(n,3)),e.setAttribute("color",new Ie(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let c=new ke(16755200),u=new ke(16711680),h=new ke(43775),d=new ke(16777215),f=new ke(3355443);this.setColors(c,u,h,d,f)}setColors(t,e,r,n,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,r=1,n=1;Xr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ei("c",e,t,Xr,0,0,-1),ei("t",e,t,Xr,0,0,1),ei("n1",e,t,Xr,-r,-n,-1),ei("n2",e,t,Xr,r,-n,-1),ei("n3",e,t,Xr,-r,n,-1),ei("n4",e,t,Xr,r,n,-1),ei("f1",e,t,Xr,-r,-n,1),ei("f2",e,t,Xr,r,-n,1),ei("f3",e,t,Xr,-r,n,1),ei("f4",e,t,Xr,r,n,1),ei("u1",e,t,Xr,r*.7,n*1.1,-1),ei("u2",e,t,Xr,-r*.7,n*1.1,-1),ei("u3",e,t,Xr,0,n*2,-1),ei("cf1",e,t,Xr,-r,0,1),ei("cf2",e,t,Xr,r,0,1),ei("cf3",e,t,Xr,0,-n,1),ei("cf4",e,t,Xr,0,n,1),ei("cn1",e,t,Xr,-r,0,-1),ei("cn2",e,t,Xr,r,0,-1),ei("cn3",e,t,Xr,0,-n,-1),ei("cn4",e,t,Xr,0,n,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ei(i,t,e,r,n,s,o){iy.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],iy.x,iy.y,iy.z)}}var cl=class extends il{constructor(t,e=16776960){let r=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]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ne;s.setIndex(new Ye(r,1)),s.setAttribute("position",new Ie(n,3)),super(s,new os({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var By=class extends il{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new Ne;n.setAttribute("position",new Ie(e,3)),n.setAttribute("color",new Ie(r,3));let s=new os({vertexColors:!0,toneMapped:!1});super(n,s),this.type="AxesHelper"}setColors(t,e,r){let n=new ke,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(r),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:la}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=la);var nh=".",_p=Symbol("target"),Lw=Symbol("unsubscribe");function Pp(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function w_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Kn=Array.isArray;function Ec(i){return typeof i=="symbol"}var eH={after:(i,t)=>Kn(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>Kn(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=nh),Ec(t)?i+t.toString():i+t):i,initial:i=>{if(Kn(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(nh);return t===-1?"":i.slice(0,t)},last:i=>{if(Kn(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(nh);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(Kn(i))for(let e of i)t(e);else if(i!==""){let e=0,r=i.indexOf(nh);if(r===-1)t(i);else for(;e<i.length;)r===-1&&(r=i.length),t(i.slice(e,r)),e=r+1,r=i.indexOf(nh,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},gn=eH;function Nw(i){return typeof i=="object"&&typeof i.next=="function"}function Bw(i,t,e,r,n){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],t,o.value[0],r),o.value[1]=n(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[_p].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,t,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,t,o.value,r)),o};return i}function Gy(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Ec(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Dp=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),n=r[e];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(t,e),r[e]=n),n}getProxy(t,e,r,n){if(this.isUnsubscribed)return t;let s=t[n],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,gn.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,n,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,n):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(t);n&&(delete n[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let n=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&n!==void 0&&Object.is(t.value,n.value)&&(t.writable||!1)===(n.writable||!1)&&(t.enumerable||!1)===(n.enumerable||!1)&&(t.configurable||!1)===(n.configurable||!1)&&t.get===n.get&&t.set===n.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function sh(i){return toString.call(i)==="[object Object]"}function oh(){return!0}function ul(i,t){return i.length!==t.length||i.some((e,r)=>t[r]!==e)}var Hy=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var tH=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Fw={push:oh,pop:oh,shift:oh,unshift:oh,copyWithin:ul,reverse:ul,sort:ul,splice:ul,flat:ul,fill:ul},A_=new Set([...Hy,...tH,...Object.keys(Fw)]);function ah(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var Uw=["keys","values","entries"],Vw=new Set(["has","toString"]),zw={add:ah,clear:ah,delete:ah,forEach:ah},E_=new Set([...Vw,...Object.keys(zw),...Uw]);function lh(i,t){if(i.size!==t.size)return!0;let e;for(let[r,n]of i)if(e=t.get(r),e!==n||e===void 0&&!t.has(r))return!0;return!1}var rH=new Set([...Vw,"get"]),kw={set:lh,clear:lh,delete:lh,forEach:lh},T_=new Set([...rH,...Object.keys(kw),...Uw]);var Ui=class{constructor(t,e,r,n){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Hy.has(t)}_shallowClone(t){let e=t;if(sh(t))e={...t};else if(Kn(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,n]of t.entries())e.set(r,this._shallowClone(n))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,n){return t?(Kn(n)?this._onIsChanged=Fw[e]:n instanceof Set?this._onIsChanged=zw[e]:n instanceof Map&&(this._onIsChanged=kw[e]),n):r}update(t,e,r){let n=gn.after(t,this._path);if(e!=="length"){let s=this.clone;gn.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],gn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ch=class extends Ui{static isHandledMethod(t){return A_.has(t)}};var Op=class extends Ui{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var uh=class extends Ui{static isHandledMethod(t){return E_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var hh=class extends Ui{static isHandledMethod(t){return T_.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Ip=class extends Ui{constructor(t,e,r,n){super(void 0,e,r,n),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var Rp=class extends Ui{constructor(t,e,r,n){super(void 0,e,r,n),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Bs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return sh(t)||Kn(t)||Pp(t)}static isHandledMethod(t,e){return sh(t)?Ui.isHandledMethod(e):Kn(t)?ch.isHandledMethod(e):t instanceof Set?uh.isHandledMethod(e):t instanceof Map?hh.isHandledMethod(e):Pp(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let n=Ui;Kn(t)?n=ch:t instanceof Date?n=Op:t instanceof Set?n=uh:t instanceof Map?n=hh:t instanceof WeakSet?n=Ip:t instanceof WeakMap&&(n=Rp),this._stack.push(new n(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:n}=t,s=Bs.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var iH={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Gw=(i,t,e={})=>{e={...iH,...e};let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=e,l=new Dp(n),c=typeof e.onValidate=="function",u=new Bs(c),h=(v,x,b,S,w)=>!c||u.isCloning||e.onValidate(gn.concat(l.getPath(v),x),b,S,w)===!0,d=(v,x,b,S)=>{!Gy(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,b,S)},f=(v,x,b,S,w)=>{u.isCloning?u.update(v,x,S):t(gn.concat(v,x),b,S,w)},p=v=>v&&(v[r]||v),g=(v,x,b,S)=>w_(v)||b==="constructor"||s&&!Bs.isHandledMethod(x,b)||Gy(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,gn.concat(S,b),y,r)),y={get(v,x,b){if(Ec(x)){if(x===r||x===_p)return v;if(x===Lw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Pp(v)?Reflect.get(v,x):Reflect.get(v,x,b);return g(S,v,x)},set(v,x,b,S){b=p(b);let w=v[r]||v,E=w[x];if(n(E,b)&&x in v)return!0;let A=h(v,x,b,E);return A&&l.setProperty(w,x,b,S,E)?(d(v,x,v[x],E),!0):!A},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let S=v[x];h(v,x,b.value,S)&&l.defineProperty(v,x,b,S)&&d(v,x,b.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),S=h(v,x,void 0,b);return S&&l.deleteProperty(v,x,b)?(d(v,x,void 0,b),!0):!S},apply(v,x,b){let S=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,b);if((a===!1||a!==!0&&!a.includes(v.name))&&Bs.isHandledType(S)){let w=gn.initial(l.getPath(v)),E=Bs.isHandledMethod(S,v.name);u.start(S,w,b);let A=Reflect.apply(v,u.preferredThisArg(v,x,S),E?b.map(C=>p(C)):b),P=u.isChanged(S,n),M=u.stop();if(Bs.isHandledType(A)&&E&&(x instanceof Map&&v.name==="get"&&(w=gn.concat(w,b[0])),A=l.getProxy(A,w,y)),P){let C={name:v.name,args:b,result:A},O=u.isCloning?gn.initial(w):w,L=u.isCloning?gn.last(w):"";h(gn.get(i,O),L,S,M,C)?f(O,L,S,M,C):u.undo(S)}return(x instanceof Map||x instanceof Set)&&Nw(A)?Bw(A,v,x,w,g):A}return Reflect.apply(v,x,b)}},m=l.getProxy(i,e.pathAsArray?[]:"",y);return t=t.bind(m),c&&(e.onValidate=e.onValidate.bind(m)),m};Gw.target=i=>i&&i[_p]||i;Gw.unsubscribe=i=>i[Lw]||i;var Hw=Gw;var nH=typeof global=="object"&&global&&global.Object===Object&&global,jy=nH;var sH=typeof self=="object"&&self&&self.Object===Object&&self,oH=jy||sH||Function("return this")(),Kr=oH;var aH=Kr.Symbol,Vi=aH;var M_=Object.prototype,lH=M_.hasOwnProperty,cH=M_.toString,Lp=Vi?Vi.toStringTag:void 0;function uH(i){var t=lH.call(i,Lp),e=i[Lp];try{i[Lp]=void 0;var r=!0}catch{}var n=cH.call(i);return r&&(t?i[Lp]=e:delete i[Lp]),n}var C_=uH;var hH=Object.prototype,dH=hH.toString;function fH(i){return dH.call(i)}var __=fH;var pH="[object Null]",mH="[object Undefined]",P_=Vi?Vi.toStringTag:void 0;function gH(i){return i==null?i===void 0?mH:pH:P_&&P_ in Object(i)?C_(i):__(i)}var Qn=gH;function yH(i){return i!=null&&typeof i=="object"}var Ki=yH;var vH="[object Symbol]";function xH(i){return typeof i=="symbol"||Ki(i)&&Qn(i)==vH}var hl=xH;function bH(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var Wy=bH;var SH=Array.isArray,Ti=SH;var wH=1/0,D_=Vi?Vi.prototype:void 0,O_=D_?D_.toString:void 0;function I_(i){if(typeof i=="string")return i;if(Ti(i))return Wy(i,I_)+"";if(hl(i))return O_?O_.call(i):"";var t=i+"";return t=="0"&&1/i==-wH?"-0":t}var R_=I_;var AH=/\s/;function EH(i){for(var t=i.length;t--&&AH.test(i.charAt(t)););return t}var L_=EH;var TH=/^\s+/;function MH(i){return i&&i.slice(0,L_(i)+1).replace(TH,"")}var N_=MH;function CH(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var gi=CH;var B_=0/0,_H=/^[-+]0x[0-9a-f]+$/i,PH=/^0b[01]+$/i,DH=/^0o[0-7]+$/i,OH=parseInt;function IH(i){if(typeof i=="number")return i;if(hl(i))return B_;if(gi(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=gi(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=N_(i);var e=PH.test(i);return e||DH.test(i)?OH(i.slice(2),e?2:8):_H.test(i)?B_:+i}var jw=IH;function RH(i){return i}var F_=RH;var LH="[object AsyncFunction]",NH="[object Function]",BH="[object GeneratorFunction]",FH="[object Proxy]";function UH(i){if(!gi(i))return!1;var t=Qn(i);return t==NH||t==BH||t==LH||t==FH}var qy=UH;var VH=Kr["__core-js_shared__"],Xy=VH;var U_=function(){var i=/[^.]+$/.exec(Xy&&Xy.keys&&Xy.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function zH(i){return!!U_&&U_ in i}var V_=zH;var kH=Function.prototype,GH=kH.toString;function HH(i){if(i!=null){try{return GH.call(i)}catch{}try{return i+""}catch{}}return""}var ca=HH;var jH=/[\\^$.*+?()[\]{}|]/g,WH=/^\[object .+?Constructor\]$/,qH=Function.prototype,XH=Object.prototype,YH=qH.toString,KH=XH.hasOwnProperty,QH=RegExp("^"+YH.call(KH).replace(jH,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ZH(i){if(!gi(i)||V_(i))return!1;var t=qy(i)?QH:WH;return t.test(ca(i))}var z_=ZH;function JH(i,t){return i?.[t]}var k_=JH;function $H(i,t){var e=k_(i,t);return z_(e)?e:void 0}var Pn=$H;var ej=Pn(Kr,"WeakMap"),Yy=ej;var G_=Object.create,tj=function(){function i(){}return function(t){if(!gi(t))return{};if(G_)return G_(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),H_=tj;function rj(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var j_=rj;function ij(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var W_=ij;var nj=800,sj=16,oj=Date.now;function aj(i){var t=0,e=0;return function(){var r=oj(),n=sj-(r-e);if(e=r,n>0){if(++t>=nj)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var q_=aj;function lj(i){return function(){return i}}var X_=lj;var cj=function(){try{var i=Pn(Object,"defineProperty");return i({},"",{}),i}catch{}}(),dh=cj;var uj=dh?function(i,t){return dh(i,"toString",{configurable:!0,enumerable:!1,value:X_(t),writable:!0})}:F_,Y_=uj;var hj=q_(Y_),K_=hj;function dj(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Q_=dj;var fj=9007199254740991,pj=/^(?:0|[1-9]\d*)$/;function mj(i,t){var e=typeof i;return t=t??fj,!!t&&(e=="number"||e!="symbol"&&pj.test(i))&&i>-1&&i%1==0&&i<t}var fh=mj;function gj(i,t,e){t=="__proto__"&&dh?dh(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Ky=gj;function yj(i,t){return i===t||i!==i&&t!==t}var ph=yj;var vj=Object.prototype,xj=vj.hasOwnProperty;function bj(i,t,e){var r=i[t];(!(xj.call(i,t)&&ph(r,e))||e===void 0&&!(t in i))&&Ky(i,t,e)}var mh=bj;function Sj(i,t,e,r){var n=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),n?Ky(e,a,l):mh(e,a,l)}return e}var uo=Sj;var Z_=Math.max;function wj(i,t,e){return t=Z_(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=Z_(r.length-t,0),o=Array(s);++n<s;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),j_(i,this,a)}}var J_=wj;var Aj=9007199254740991;function Ej(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Aj}var gh=Ej;function Tj(i){return i!=null&&gh(i.length)&&!qy(i)}var Qy=Tj;var Mj=Object.prototype;function Cj(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Mj;return i===e}var yh=Cj;function _j(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var $_=_j;var Pj="[object Arguments]";function Dj(i){return Ki(i)&&Qn(i)==Pj}var Ww=Dj;var eP=Object.prototype,Oj=eP.hasOwnProperty,Ij=eP.propertyIsEnumerable,Rj=Ww(function(){return arguments}())?Ww:function(i){return Ki(i)&&Oj.call(i,"callee")&&!Ij.call(i,"callee")},vh=Rj;function Lj(){return!1}var tP=Lj;var nP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rP=nP&&typeof module=="object"&&module&&!module.nodeType&&module,Nj=rP&&rP.exports===nP,iP=Nj?Kr.Buffer:void 0,Bj=iP?iP.isBuffer:void 0,Fj=Bj||tP,Tc=Fj;var Uj="[object Arguments]",Vj="[object Array]",zj="[object Boolean]",kj="[object Date]",Gj="[object Error]",Hj="[object Function]",jj="[object Map]",Wj="[object Number]",qj="[object Object]",Xj="[object RegExp]",Yj="[object Set]",Kj="[object String]",Qj="[object WeakMap]",Zj="[object ArrayBuffer]",Jj="[object DataView]",$j="[object Float32Array]",eW="[object Float64Array]",tW="[object Int8Array]",rW="[object Int16Array]",iW="[object Int32Array]",nW="[object Uint8Array]",sW="[object Uint8ClampedArray]",oW="[object Uint16Array]",aW="[object Uint32Array]",Nr={};Nr[$j]=Nr[eW]=Nr[tW]=Nr[rW]=Nr[iW]=Nr[nW]=Nr[sW]=Nr[oW]=Nr[aW]=!0;Nr[Uj]=Nr[Vj]=Nr[Zj]=Nr[zj]=Nr[Jj]=Nr[kj]=Nr[Gj]=Nr[Hj]=Nr[jj]=Nr[Wj]=Nr[qj]=Nr[Xj]=Nr[Yj]=Nr[Kj]=Nr[Qj]=!1;function lW(i){return Ki(i)&&gh(i.length)&&!!Nr[Qn(i)]}var sP=lW;function cW(i){return function(t){return i(t)}}var xh=cW;var oP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Np=oP&&typeof module=="object"&&module&&!module.nodeType&&module,uW=Np&&Np.exports===oP,qw=uW&&jy.process,hW=function(){try{var i=Np&&Np.require&&Np.require("util").types;return i||qw&&qw.binding&&qw.binding("util")}catch{}}(),ua=hW;var aP=ua&&ua.isTypedArray,dW=aP?xh(aP):sP,Zy=dW;var fW=Object.prototype,pW=fW.hasOwnProperty;function mW(i,t){var e=Ti(i),r=!e&&vh(i),n=!e&&!r&&Tc(i),s=!e&&!r&&!n&&Zy(i),o=e||r||n||s,a=o?$_(i.length,String):[],l=a.length;for(var c in i)(t||pW.call(i,c))&&!(o&&(c=="length"||n&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||fh(c,l)))&&a.push(c);return a}var Jy=mW;function gW(i,t){return function(e){return i(t(e))}}var $y=gW;var yW=$y(Object.keys,Object),lP=yW;var vW=Object.prototype,xW=vW.hasOwnProperty;function bW(i){if(!yh(i))return lP(i);var t=[];for(var e in Object(i))xW.call(i,e)&&e!="constructor"&&t.push(e);return t}var cP=bW;function SW(i){return Qy(i)?Jy(i):cP(i)}var bh=SW;function wW(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var uP=wW;var AW=Object.prototype,EW=AW.hasOwnProperty;function TW(i){if(!gi(i))return uP(i);var t=yh(i),e=[];for(var r in i)r=="constructor"&&(t||!EW.call(i,r))||e.push(r);return e}var hP=TW;function MW(i){return Qy(i)?Jy(i,!0):hP(i)}var cs=MW;var CW=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_W=/^\w*$/;function PW(i,t){if(Ti(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||hl(i)?!0:_W.test(i)||!CW.test(i)||t!=null&&i in Object(t)}var dP=PW;var DW=Pn(Object,"create"),ha=DW;function OW(){this.__data__=ha?ha(null):{},this.size=0}var fP=OW;function IW(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var pP=IW;var RW="__lodash_hash_undefined__",LW=Object.prototype,NW=LW.hasOwnProperty;function BW(i){var t=this.__data__;if(ha){var e=t[i];return e===RW?void 0:e}return NW.call(t,i)?t[i]:void 0}var mP=BW;var FW=Object.prototype,UW=FW.hasOwnProperty;function VW(i){var t=this.__data__;return ha?t[i]!==void 0:UW.call(t,i)}var gP=VW;var zW="__lodash_hash_undefined__";function kW(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=ha&&t===void 0?zW:t,this}var yP=kW;function Sh(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Sh.prototype.clear=fP;Sh.prototype.delete=pP;Sh.prototype.get=mP;Sh.prototype.has=gP;Sh.prototype.set=yP;var Xw=Sh;function GW(){this.__data__=[],this.size=0}var vP=GW;function HW(i,t){for(var e=i.length;e--;)if(ph(i[e][0],t))return e;return-1}var dl=HW;var jW=Array.prototype,WW=jW.splice;function qW(i){var t=this.__data__,e=dl(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():WW.call(t,e,1),--this.size,!0}var xP=qW;function XW(i){var t=this.__data__,e=dl(t,i);return e<0?void 0:t[e][1]}var bP=XW;function YW(i){return dl(this.__data__,i)>-1}var SP=YW;function KW(i,t){var e=this.__data__,r=dl(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var wP=KW;function wh(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}wh.prototype.clear=vP;wh.prototype.delete=xP;wh.prototype.get=bP;wh.prototype.has=SP;wh.prototype.set=wP;var fl=wh;var QW=Pn(Kr,"Map"),pl=QW;function ZW(){this.size=0,this.__data__={hash:new Xw,map:new(pl||fl),string:new Xw}}var AP=ZW;function JW(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var EP=JW;function $W(i,t){var e=i.__data__;return EP(t)?e[typeof t=="string"?"string":"hash"]:e.map}var ml=$W;function e5(i){var t=ml(this,i).delete(i);return this.size-=t?1:0,t}var TP=e5;function t5(i){return ml(this,i).get(i)}var MP=t5;function r5(i){return ml(this,i).has(i)}var CP=r5;function i5(i,t){var e=ml(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var _P=i5;function Ah(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Ah.prototype.clear=AP;Ah.prototype.delete=TP;Ah.prototype.get=MP;Ah.prototype.has=CP;Ah.prototype.set=_P;var Mc=Ah;var n5="Expected a function";function Yw(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(n5);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],s=e.cache;if(s.has(n))return s.get(n);var o=i.apply(this,r);return e.cache=s.set(n,o)||s,o};return e.cache=new(Yw.Cache||Mc),e}Yw.Cache=Mc;var PP=Yw;var s5=500;function o5(i){var t=PP(i,function(r){return e.size===s5&&e.clear(),r}),e=t.cache;return t}var DP=o5;var a5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l5=/\\(\\)?/g,c5=DP(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(a5,function(e,r,n,s){t.push(n?s.replace(l5,"$1"):r||e)}),t}),OP=c5;function u5(i){return i==null?"":R_(i)}var IP=u5;function h5(i,t){return Ti(i)?i:dP(i,t)?[i]:OP(IP(i))}var us=h5;var d5=1/0;function f5(i){if(typeof i=="string"||hl(i))return i;var t=i+"";return t=="0"&&1/i==-d5?"-0":t}var gl=f5;function p5(i,t){t=us(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[gl(t[e++])];return e&&e==r?i:void 0}var ev=p5;function m5(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var Eh=m5;var RP=Vi?Vi.isConcatSpreadable:void 0;function g5(i){return Ti(i)||vh(i)||!!(RP&&i&&i[RP])}var LP=g5;function NP(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=LP),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?NP(a,t-1,e,r,n):Eh(n,a):r||(n[n.length]=a)}return n}var BP=NP;function y5(i){var t=i==null?0:i.length;return t?BP(i,1):[]}var FP=y5;function v5(i){return K_(J_(i,void 0,FP),i+"")}var tv=v5;var x5=$y(Object.getPrototypeOf,Object),Th=x5;var b5="[object Object]",S5=Function.prototype,w5=Object.prototype,UP=S5.toString,A5=w5.hasOwnProperty,E5=UP.call(Object);function T5(i){if(!Ki(i)||Qn(i)!=b5)return!1;var t=Th(i);if(t===null)return!0;var e=A5.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&UP.call(e)==E5}var VP=T5;function M5(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+t];return s}var zP=M5;function C5(){this.__data__=new fl,this.size=0}var kP=C5;function _5(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var GP=_5;function P5(i){return this.__data__.get(i)}var HP=P5;function D5(i){return this.__data__.has(i)}var jP=D5;var O5=200;function I5(i,t){var e=this.__data__;if(e instanceof fl){var r=e.__data__;if(!pl||r.length<O5-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Mc(r)}return e.set(i,t),this.size=e.size,this}var WP=I5;function Mh(i){var t=this.__data__=new fl(i);this.size=t.size}Mh.prototype.clear=kP;Mh.prototype.delete=GP;Mh.prototype.get=HP;Mh.prototype.has=jP;Mh.prototype.set=WP;var Ch=Mh;function R5(i,t){return i&&uo(t,bh(t),i)}var qP=R5;function L5(i,t){return i&&uo(t,cs(t),i)}var XP=L5;var ZP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,YP=ZP&&typeof module=="object"&&module&&!module.nodeType&&module,N5=YP&&YP.exports===ZP,KP=N5?Kr.Buffer:void 0,QP=KP?KP.allocUnsafe:void 0;function B5(i,t){if(t)return i.slice();var e=i.length,r=QP?QP(e):new i.constructor(e);return i.copy(r),r}var JP=B5;function F5(i,t){for(var e=-1,r=i==null?0:i.length,n=0,s=[];++e<r;){var o=i[e];t(o,e,i)&&(s[n++]=o)}return s}var $P=F5;function U5(){return[]}var rv=U5;var V5=Object.prototype,z5=V5.propertyIsEnumerable,e2=Object.getOwnPropertySymbols,k5=e2?function(i){return i==null?[]:(i=Object(i),$P(e2(i),function(t){return z5.call(i,t)}))}:rv,_h=k5;function G5(i,t){return uo(i,_h(i),t)}var t2=G5;var H5=Object.getOwnPropertySymbols,j5=H5?function(i){for(var t=[];i;)Eh(t,_h(i)),i=Th(i);return t}:rv,iv=j5;function W5(i,t){return uo(i,iv(i),t)}var r2=W5;function q5(i,t,e){var r=t(i);return Ti(i)?r:Eh(r,e(i))}var nv=q5;function X5(i){return nv(i,bh,_h)}var Bp=X5;function Y5(i){return nv(i,cs,iv)}var sv=Y5;var K5=Pn(Kr,"DataView"),ov=K5;var Q5=Pn(Kr,"Promise"),av=Q5;var Z5=Pn(Kr,"Set"),lv=Z5;var i2="[object Map]",J5="[object Object]",n2="[object Promise]",s2="[object Set]",o2="[object WeakMap]",a2="[object DataView]",$5=ca(ov),e8=ca(pl),t8=ca(av),r8=ca(lv),i8=ca(Yy),Cc=Qn;(ov&&Cc(new ov(new ArrayBuffer(1)))!=a2||pl&&Cc(new pl)!=i2||av&&Cc(av.resolve())!=n2||lv&&Cc(new lv)!=s2||Yy&&Cc(new Yy)!=o2)&&(Cc=function(i){var t=Qn(i),e=t==J5?i.constructor:void 0,r=e?ca(e):"";if(r)switch(r){case $5:return a2;case e8:return i2;case t8:return n2;case r8:return s2;case i8:return o2}return t});var da=Cc;var n8=Object.prototype,s8=n8.hasOwnProperty;function o8(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&s8.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var l2=o8;var a8=Kr.Uint8Array,Ph=a8;function l8(i){var t=new i.constructor(i.byteLength);return new Ph(t).set(new Ph(i)),t}var Dh=l8;function c8(i,t){var e=t?Dh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var c2=c8;var u8=/\w*$/;function h8(i){var t=new i.constructor(i.source,u8.exec(i));return t.lastIndex=i.lastIndex,t}var u2=h8;var h2=Vi?Vi.prototype:void 0,d2=h2?h2.valueOf:void 0;function d8(i){return d2?Object(d2.call(i)):{}}var f2=d8;function f8(i,t){var e=t?Dh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var p2=f8;var p8="[object Boolean]",m8="[object Date]",g8="[object Map]",y8="[object Number]",v8="[object RegExp]",x8="[object Set]",b8="[object String]",S8="[object Symbol]",w8="[object ArrayBuffer]",A8="[object DataView]",E8="[object Float32Array]",T8="[object Float64Array]",M8="[object Int8Array]",C8="[object Int16Array]",_8="[object Int32Array]",P8="[object Uint8Array]",D8="[object Uint8ClampedArray]",O8="[object Uint16Array]",I8="[object Uint32Array]";function R8(i,t,e){var r=i.constructor;switch(t){case w8:return Dh(i);case p8:case m8:return new r(+i);case A8:return c2(i,e);case E8:case T8:case M8:case C8:case _8:case P8:case D8:case O8:case I8:return p2(i,e);case g8:return new r;case y8:case b8:return new r(i);case v8:return u2(i);case x8:return new r;case S8:return f2(i)}}var m2=R8;function L8(i){return typeof i.constructor=="function"&&!yh(i)?H_(Th(i)):{}}var g2=L8;var N8="[object Map]";function B8(i){return Ki(i)&&da(i)==N8}var y2=B8;var v2=ua&&ua.isMap,F8=v2?xh(v2):y2,x2=F8;var U8="[object Set]";function V8(i){return Ki(i)&&da(i)==U8}var b2=V8;var S2=ua&&ua.isSet,z8=S2?xh(S2):b2,w2=z8;var k8=1,G8=2,H8=4,A2="[object Arguments]",j8="[object Array]",W8="[object Boolean]",q8="[object Date]",X8="[object Error]",E2="[object Function]",Y8="[object GeneratorFunction]",K8="[object Map]",Q8="[object Number]",T2="[object Object]",Z8="[object RegExp]",J8="[object Set]",$8="[object String]",e6="[object Symbol]",t6="[object WeakMap]",r6="[object ArrayBuffer]",i6="[object DataView]",n6="[object Float32Array]",s6="[object Float64Array]",o6="[object Int8Array]",a6="[object Int16Array]",l6="[object Int32Array]",c6="[object Uint8Array]",u6="[object Uint8ClampedArray]",h6="[object Uint16Array]",d6="[object Uint32Array]",Ir={};Ir[A2]=Ir[j8]=Ir[r6]=Ir[i6]=Ir[W8]=Ir[q8]=Ir[n6]=Ir[s6]=Ir[o6]=Ir[a6]=Ir[l6]=Ir[K8]=Ir[Q8]=Ir[T2]=Ir[Z8]=Ir[J8]=Ir[$8]=Ir[e6]=Ir[c6]=Ir[u6]=Ir[h6]=Ir[d6]=!0;Ir[X8]=Ir[E2]=Ir[t6]=!1;function cv(i,t,e,r,n,s){var o,a=t&k8,l=t&G8,c=t&H8;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!gi(i))return i;var u=Ti(i);if(u){if(o=l2(i),!a)return W_(i,o)}else{var h=da(i),d=h==E2||h==Y8;if(Tc(i))return JP(i,a);if(h==T2||h==A2||d&&!n){if(o=l||d?{}:g2(i),!a)return l?r2(i,XP(o,i)):t2(i,qP(o,i))}else{if(!Ir[h])return n?i:{};o=m2(i,h,a)}}s||(s=new Ch);var f=s.get(i);if(f)return f;s.set(i,o),w2(i)?i.forEach(function(y){o.add(cv(y,t,e,y,i,s))}):x2(i)&&i.forEach(function(y,m){o.set(m,cv(y,t,e,m,i,s))});var p=c?l?sv:Bp:l?cs:bh,g=u?void 0:p(i);return Q_(g||i,function(y,m){g&&(m=y,y=i[m]),mh(o,m,cv(y,t,e,m,i,s))}),o}var uv=cv;var f6=1,p6=4;function m6(i){return uv(i,f6|p6)}var fa=m6;var g6="__lodash_hash_undefined__";function y6(i){return this.__data__.set(i,g6),this}var M2=y6;function v6(i){return this.__data__.has(i)}var C2=v6;function hv(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Mc;++t<e;)this.add(i[t])}hv.prototype.add=hv.prototype.push=M2;hv.prototype.has=C2;var _2=hv;function x6(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var P2=x6;function b6(i,t){return i.has(t)}var D2=b6;var S6=1,w6=2;function A6(i,t,e,r,n,s){var o=e&S6,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=s.get(i),u=s.get(t);if(c&&u)return c==t&&u==i;var h=-1,d=!0,f=e&w6?new _2:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],g=t[h];if(r)var y=o?r(g,p,h,t,i,s):r(p,g,h,i,t,s);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!P2(t,function(m,v){if(!D2(f,v)&&(p===m||n(p,m,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===g||n(p,g,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var dv=A6;function E6(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var O2=E6;function T6(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var I2=T6;var M6=1,C6=2,_6="[object Boolean]",P6="[object Date]",D6="[object Error]",O6="[object Map]",I6="[object Number]",R6="[object RegExp]",L6="[object Set]",N6="[object String]",B6="[object Symbol]",F6="[object ArrayBuffer]",U6="[object DataView]",R2=Vi?Vi.prototype:void 0,Kw=R2?R2.valueOf:void 0;function V6(i,t,e,r,n,s,o){switch(e){case U6:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case F6:return!(i.byteLength!=t.byteLength||!s(new Ph(i),new Ph(t)));case _6:case P6:case I6:return ph(+i,+t);case D6:return i.name==t.name&&i.message==t.message;case R6:case N6:return i==t+"";case O6:var a=O2;case L6:var l=r&M6;if(a||(a=I2),i.size!=t.size&&!l)return!1;var c=o.get(i);if(c)return c==t;r|=C6,o.set(i,t);var u=dv(a(i),a(t),r,n,s,o);return o.delete(i),u;case B6:if(Kw)return Kw.call(i)==Kw.call(t)}return!1}var L2=V6;var z6=1,k6=Object.prototype,G6=k6.hasOwnProperty;function H6(i,t,e,r,n,s){var o=e&z6,a=Bp(i),l=a.length,c=Bp(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:G6.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var g=!0;s.set(i,t),s.set(t,i);for(var y=o;++h<l;){d=a[h];var m=i[d],v=t[d];if(r)var x=o?r(v,m,d,t,i,s):r(m,v,d,i,t,s);if(!(x===void 0?m===v||n(m,v,e,r,s):x)){g=!1;break}y||(y=d=="constructor")}if(g&&!y){var b=i.constructor,S=t.constructor;b!=S&&"constructor"in i&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof S=="function"&&S instanceof S)&&(g=!1)}return s.delete(i),s.delete(t),g}var N2=H6;var j6=1,B2="[object Arguments]",F2="[object Array]",fv="[object Object]",W6=Object.prototype,U2=W6.hasOwnProperty;function q6(i,t,e,r,n,s){var o=Ti(i),a=Ti(t),l=o?F2:da(i),c=a?F2:da(t);l=l==B2?fv:l,c=c==B2?fv:c;var u=l==fv,h=c==fv,d=l==c;if(d&&Tc(i)){if(!Tc(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new Ch),o||Zy(i)?dv(i,t,e,r,n,s):L2(i,t,l,e,r,n,s);if(!(e&j6)){var f=u&&U2.call(i,"__wrapped__"),p=h&&U2.call(t,"__wrapped__");if(f||p){var g=f?i.value():i,y=p?t.value():t;return s||(s=new Ch),n(g,y,e,r,s)}}return d?(s||(s=new Ch),N2(i,t,e,r,n,s)):!1}var V2=q6;function z2(i,t,e,r,n){return i===t?!0:i==null||t==null||!Ki(i)&&!Ki(t)?i!==i&&t!==t:V2(i,t,e,r,z2,n)}var k2=z2;function X6(i,t){return i!=null&&t in Object(i)}var G2=X6;function Y6(i,t,e){t=us(t,i);for(var r=-1,n=t.length,s=!1;++r<n;){var o=gl(t[r]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++r!=n?s:(n=i==null?0:i.length,!!n&&gh(n)&&fh(o,n)&&(Ti(i)||vh(i)))}var H2=Y6;function K6(i,t){return i!=null&&H2(i,t,G2)}var j2=K6;var Q6=function(){return Kr.Date.now()},pv=Q6;var Z6="Expected a function",J6=Math.max,$6=Math.min;function eq(i,t,e){var r,n,s,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(Z6);t=jw(t)||0,gi(e)&&(u=!!e.leading,h="maxWait"in e,s=h?J6(jw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(w){var E=r,A=n;return r=n=void 0,c=w,o=i.apply(A,E),o}function p(w){return c=w,a=setTimeout(m,t),u?f(w):o}function g(w){var E=w-l,A=w-c,P=t-E;return h?$6(P,s-A):P}function y(w){var E=w-l,A=w-c;return l===void 0||E>=t||E<0||h&&A>=s}function m(){var w=pv();if(y(w))return v(w);a=setTimeout(m,g(w))}function v(w){return a=void 0,d&&r?f(w):(r=n=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=n=a=void 0}function b(){return a===void 0?o:v(pv())}function S(){var w=pv(),E=y(w);if(r=arguments,n=this,l=w,E){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(m,t),f(l)}return a===void 0&&(a=setTimeout(m,t)),o}return S.cancel=x,S.flush=b,S}var _c=eq;function tq(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var W2=tq;function rq(i,t){return t.length<2?i:ev(i,zP(t,0,-1))}var q2=rq;function iq(i,t){return k2(i,t)}var Fp=iq;function nq(i,t){return t=us(t,i),i=q2(i,t),i==null||delete i[gl(W2(t))]}var X2=nq;function sq(i){return VP(i)?void 0:i}var Y2=sq;var oq=1,aq=2,lq=4,cq=tv(function(i,t){var e={};if(i==null)return e;var r=!1;t=Wy(t,function(s){return s=us(s,i),r||(r=s.length>1),s}),uo(i,sv(i),e),r&&(e=uv(e,oq|aq|lq,Y2));for(var n=t.length;n--;)X2(e,t[n]);return e}),Oh=cq;function uq(i,t,e,r){if(!gi(i))return i;t=us(t,i);for(var n=-1,s=t.length,o=s-1,a=i;a!=null&&++n<s;){var l=gl(t[n]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(n!=o){var u=a[l];c=r?r(u,l,a):void 0,c===void 0&&(c=gi(u)?u:fh(t[n+1])?[]:{})}mh(a,l,c),a=a[l]}return i}var K2=uq;function hq(i,t,e){for(var r=-1,n=t.length,s={};++r<n;){var o=t[r],a=ev(i,o);e(a,o)&&K2(s,us(o,i),a)}return s}var Q2=hq;function dq(i,t){return Q2(i,t,function(e,r){return j2(i,r)})}var Z2=dq;var fq=tv(function(i,t){return i==null?{}:Z2(i,t)}),Zn=fq;var pq="Expected a function";function mq(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(pq);return gi(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),_c(i,t,{leading:r,maxWait:t,trailing:n})}var Qw=mq;function mv(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function yn(i,t){return Object.setPrototypeOf(i,t),i}var gq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),yq=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),vq=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ih&&"ontouchend"in document,xq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,bq=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,Sq=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},wq=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},Aq=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},Eq=gq(),zle=Eq?Aq():void 0,Ih=yq(),Rh=vq(),Up=xq(),Mi=bq(),Zw=Sq(),Jw=Number(wq());function gv(i){return Array.isArray(i)?i:[i]}function yv(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function Vp(i){return Ih?i.metaKey:i.ctrlKey}function J2(i){return i.wheelDeltaY===0||i.deltaY===0?Ih&&i.shiftKey&&Math.abs(i.wheelDeltaX)>=120?!1:i.wheelDeltaX?i.wheelDeltaX===-3*i.deltaX||i.wheelDeltaX===-3*window.devicePixelRatio*i.deltaX:i.deltaMode===0:i.wheelDeltaY?i.wheelDeltaY===-3*i.deltaY||i.wheelDeltaY===-3*window.devicePixelRatio*i.deltaY:i.deltaMode===0}var nt=[],xv={},zp={},vv={};function $2(i){nt.includes(i)||nt.push(i)}function Lh(i){delete xv[i.pointerId];for(let t=0;t<nt.length;t++)if(nt[t].pointerId===i.pointerId){nt.splice(t,1);break}}function eD(){nt.splice(0,nt.length)}function bv(i){if(i.pointerType!=="touch")return;let t=xv[i.pointerId];t===void 0&&(t={x:0,y:0},xv[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function Sv(i){let t=i.pointerId===nt[0].pointerId?nt[1]:nt[0];return xv[t.pointerId]}function tD(i){zp[i.key]=!0,vv[i.key]=vv[i.key]===void 0?1:vv[i.key]+1}function rD(i){if(Ih&&zp.Meta)for(let t in zp)zp[t]=!1;else zp[i.key]=!1;vv={}}function iD(i){i.addEventListener("pointerdown",$2,!0),i.addEventListener("pointerdown",bv,!0),i.addEventListener("pointermove",bv,!0),i.addEventListener("pointerup",Lh,!0),i.addEventListener("pointercancel",Lh,!0),i.addEventListener("pointerleave",Lh,!0),window.addEventListener("keydown",tD,!0),window.addEventListener("keyup",rD,!0)}function nD(i){i.removeEventListener("pointerdown",$2,!0),i.removeEventListener("pointerdown",bv,!0),i.removeEventListener("pointermove",bv,!0),i.removeEventListener("pointerup",Lh,!0),i.removeEventListener("pointercancel",Lh,!0),i.removeEventListener("pointerleave",Lh,!0),window.removeEventListener("keydown",tD,!0),window.removeEventListener("keyup",rD,!0)}var sD,oD=new Promise(i=>{sD=i});var wv;function aD(){if(wv)return wv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.0.88/build",n=import("./navmesh.js"),[s,o]=await Promise.all([n,fetch(`${e}/navmesh.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});sD(l)}return wv=i(),wv}var lD,cD=new Promise(i=>{lD=i});var Av;function uD(){if(Av)return Av;async function i(){let e=await import("./physics.js");await e.init(),lD(e)}return Av=i(),Av}var at=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,at.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,at.prototype),{data:a,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,at.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:n}}}}return null}};function kp(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&kp(r)}return Object.freeze(i)}function hD(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Nh=class extends Error{};function Ev(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function ho(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let r=[],n=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*n;r.push(o)}return r}function Bh(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function dD(){return typeof process<"u"}function fD(i,t){for(let e of i)t(e.id,e.data)!==!0&&fD(e.children,t)}function pD(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)pD(e,t)}var Sr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kp(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let n of e.children)this.fillCaches0(n,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,r){if(!this.has(e))return!0;for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}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,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&pD(n,r)}}traverse(e){fD(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let n=e,s=r;for(;n!==null;){let a=s,l=n;if(n=this.parent(n),n===void 0)throw new Error;s=this.childrenArray(n);let c=s.findIndex(u=>u.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,Sr.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let n of r)if(this.checkDuplicatedIdRec(n))return!0;return!1}addOp(e){let{parent:r,fi:n,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:n,id:s,data:o,children:a};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let s=this.childrenArray(n),o=s.findIndex(c=>c.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(n,s),actual:e,reverse:{type:7,...a,parent:n}}}}moveOp(e){let{parent:r,fi:n,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Nh("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let u=l.splice(c,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=u.fi;return u={...u,fi:n},l=[...l,u],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(u),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let n=null;for(let s of this.childrenArray(e)){if(s.id===r)return n;n=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)+1;if(s<n.length)return n[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(n[s].id):r}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push({...n,...s})}r.sort((n,s)=>hD(n.sortKey,s.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)n.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:n}}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let s=this.childrenArray(e);if(r===null){if(s.length===0)return ho(0,n,n);{let o=s[0].fi;return ho(o-n,o,n)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return ho(l,l+n,n)}else return ho(o.fi,a.fi,n)}}};var Fh;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let n=r.props,s={},o=[...e],a=!1;if(n)for(let l of Object.keys(n)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=n[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let n=r.props,s={},o={...e},a=!1;if(n)for(let l of Object.keys(n)){s[l]=o[l];let c=n[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=i})(Fh||(Fh={}));var je=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,je.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kp(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,je.prototype);let r=e;return dD()||r.fillCaches(),r}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:r,id:n,data:s}=e,o=this,a={fi:r,id:n,data:s};return o=[...o,a],o.sort((c,u)=>c.fi-u.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,s=n.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,n=[...n];let o=n.splice(s,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:n}=e,s=this;s=[...s];let o=s.findIndex(u=>u.id===n);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((u,h)=>u.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return ho(0,r,r);{let s=n[0].fi;return ho(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=n.find(a=>a.fi>s.fi);if(o===void 0){let a=n[n.length-1].fi;return ho(a,a+r,r)}else return ho(s.fi,o.fi,r)}}};function Uh(i){return i&&typeof i=="object"&&i instanceof wr}var wr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,n=0,s={};for(;n<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!Uh(r))return null;n+=1}r=r?Ev(r):new wr;for(let[l,c]of Object.entries(t.props)){let u=r[l];s[l]=u,c===void 0?delete r[l]:r[l]=c}for(;n>0;){if(Object.keys(r).length===0){let l=e[n-1];l&&(r=Ev(l),delete r[t.path[n-1]])}else{let l=e[n-1];if(l){let c=Ev(l);c[t.path[n-1]]=r,r=c}else{let c=new wr;c[t.path[n-1]]=r,r=c}}n-=1}let o=Object.setPrototypeOf(r,wr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},fo;(r=>{function i(n,s){return Gp(n,s)??n}r.apply=i;function t(n,s){return eA(n,s)}r.merge=t;function e(n,s){let o=0,a=s.path,l=n;for(;o<a.length&&l!==void 0;){if(l=Ur.zoomOnce(l,a[o]),l===void 0)return s;if(!Uh(l))return;o+=1}if(l===void 0)return s;if(!!Uh(l))if(s.type===0){let c={...s.props};for(let u of Object.keys(l))delete c[u];return{...s,props:c}}else if(s.type===1||s.type===4||s.type===7){let c=$w([s],l);return c?(console.log(c),c):s}else return s}r.filterOp=e})(fo||(fo={}));function $w(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=Gp(n.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=n.data),n.children){let a=$w(n.children,t);return a!==void 0?e=!0:a=n.children,{...n,id:s,data:o,children:a}}else return{...n,id:s,data:o}});if(e)return r}function Tq(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=Gp(n.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=n.data),{...n,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Gp(i,t){if(!Uh(t))return t;if(i instanceof Sr){let e=$w(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof je)return Tq(i,t);if(Array.isArray(i)){let e=!1,r=i.map((n,s)=>{let o=Gp(n,t[s]);return e=e||o!==void 0,o===void 0&&(o=n),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof wr)return eA(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[n,s]of Object.entries(i)){let o=Gp(s,t[n]);r=r||o!==void 0,o===void 0&&(o=s),e[n]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function eA(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Uh(t))return t;if(!Uh(i))return fo.apply(i,t);let e=new Set;for(let n of Object.keys(i))e.add(n);for(let n of Object.keys(t))e.add(n);let r=new wr;for(let n of e){let s=eA(i===void 0?void 0:i[n],t===void 0?void 0:t[n]);r[n]=s}return r}function mD(i,t){let e={cur:[],result:[],len:0};return i=Hp(i,t,e)??i,[i,e.result]}function Tv(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Mv(i){i&&(i.len-=1)}function Mq(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function gD(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Hp(s.data,t,Tv(e,o));Mv(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=gD(s.children,t,e);return c!==void 0?r=!0:c=s.children,{...s,id:o,data:l,children:c}});if(r)return n}function Cq(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Hp(s.data,t,Tv(e,o));return Mv(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function Hp(i,t,e){if(i instanceof Sr){let r=gD(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof je)return Cq(i,t,e);if(Array.isArray(i)){let r=!1,n=i.map((s,o)=>{let a=Hp(s,t,Tv(e,o));return Mv(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(i&&typeof i=="object"&&!Bh(i)){let r={},n=!1;for(let[s,o]of Object.entries(i))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");n=!0,s=a}let l=Hp(o,t,Tv(e,s));Mv(e),n=n||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&Mq(e),r}else return}}var Vh;(t=>{function i(e,r){let n=Ur.zoom(r,e.path);if(typeof n=="object"){let s={};for(let o of Object.keys(e.props))s[o]=n[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(Vh||(Vh={}));var Vr;(a=>{function i(l,c){return{...l,path:l.path.slice(c)}}a.drop=i;function t(l,c){return e(l,c)?.data??l}a.applySimple=t;function e(l,c){let u=c.path;for(var h=[];;){let d;if(l instanceof wr&&c.type===0&&(d=l.runOp({...c,path:u.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===u.length&&(l instanceof Sr||l instanceof je||l instanceof at?d=l.runOp(c):d=Fh.runOp(l,c)),d!==void 0)if(d!==null){let g=d.data;for(let y=h.length-1;y>=0;y--){let m=u[y],v=h[y];if(v instanceof Sr){if(typeof m=="number")throw new Error("illegal arg");g=v.modifyById(m,g)}else if(v instanceof je){if(typeof m=="number")throw new Error("illegal arg");g=v.modifyById(m,g)}else if(v instanceof at){if(typeof m=="number")throw new Error("illegal arg");g=v.modifyById(m,g)}else if(v instanceof wr){let x={...v,[m]:g};g=Object.setPrototypeOf(x,wr.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof m=="string"&&(m=parseInt(m),isNaN(m)))throw new Error("Invalid path");let x=g;g=[...v],g[m]=x}else g={...v,[m]:g};else return null}return{data:g,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],p;if(l instanceof Sr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof je){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}a.pathDisjoint=r;function n(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}a.pathEq=n;function s(l,c){return r(l.path,c.path)}a.commutative=s;function o(l,c){return l.type===0&&c.type===0&&n(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}a.subsumed=o})(Vr||(Vr={}));var jp;(l=>{function i(){return[]}l.empty=i;function t(c,u){let h=[];for(let d of c){let[f,...p]=d.path;f===u&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(c,u){return c.map(h=>({...h,path:[u,...h.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function n(c,u){return[...c.filter(d=>!u.some(f=>Vr.subsumed(d,f))),...u]}l.compress=n;function s(c,u){return c.every(h=>u.every(d=>Vr.commutative(h,d)))}l.commutative=s;function o(c,u){for(let h of u){let d=a(c,h);d!==null&&(c=d.data)}return c}l.applyAll=o;function a(c,u){var h=c;let d=[],f=[];for(let p of u)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let g,y,m;if(p.type===3?(g=Ur.zoom(h,[...p.path,p.id]),m=Vr.apply(h,{...p,type:2})):(g=Ur.zoom(h,[...p.path,p.id,"value"]),m=Vr.apply(h,p)),m!==null){h=m.data;let[v,x]=mD(h,{[p.id]:g});h=v;for(let b=0;b<x.length;b++){let S=x[b],w=S.pop();if(typeof w=="number"){let E=[w];for(let P=b+1;P<x.length;P++){let M=x[P],C=M[M.length-1];if(typeof C=="number"&&Ur.equal(S,M.slice(0,M.length-1)))E.push(C),x.splice(P,1);else break}let A=Ur.zoom(h,S);y=A.map((P,M)=>E.includes(M)?p.id:P),g=A,w=S.pop()}else{if(w==="alphaOverride"||w==="alpha"){g/=100;let E=g,A=Ur.zoom(h,S.slice(0,S.length-2)),P=A.layers.map(M=>M.id===S[S.length-1]?{...M,data:{...M.data,[w]:E}}:M);Object.setPrototypeOf(P,Object.getPrototypeOf(A.layers)),A.layers=P}y=p.id}d.push({type:0,path:S,props:{[w]:g}}),f.push({type:0,path:S,props:{[w]:y}})}f.push(m.reverse),d.push(m.actual)}}else{let g=Vr.apply(h,p);g!==null&&(d.push(g.actual),h=g.data,f.push(g.reverse))}}catch(g){if(g instanceof Nh)return null;throw g}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(jp||(jp={}));var yD=Symbol(),_q=Symbol(),_v=Symbol(),Pc=class{reportOp(t,e,r=[]){let n=this;if(e===null)return;n._current=e.data;let s=r;for(;!(n instanceof Cv);){let o=n._path,a=n._current;if(o!==""&&s.splice(0,0,o),n=n._parent,n===null)return;n.update(o,a)}n.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[_v];r&&r(),delete this._children[t]}}}},rA=class extends Pc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Fh.runOp(this._current,t),t.path)}},iA=class extends Pc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,at.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},vD={get(i,t){if(t===_v)return()=>{i._parent=null};if(t===yD)return i._current;if(t===_q)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e[t],o=Pv(i,t,s);return o!==s?(r===void 0&&(r={},i._children=r),r[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},Pq={...vD,set(i,t,e){let r={type:0,props:{[t]:Qr(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},Dq={...vD,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},zh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[_v]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=Pv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,n,s){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},kh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[_v]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),n,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=Pv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function tA(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Ur.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Cv=class extends Pc{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){tA(this.ts,e,t),tA(this.actual,r,t),tA(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Pv(i,t,e){return e instanceof Sr?new zh(i,t,e):e instanceof je?new kh(i,t,e):e instanceof at?new Proxy(new iA(i,t,e),Dq):e!==null&&typeof e=="object"?Bh(e)?e:new Proxy(new rA(i,t,e),Pq):e}function nA(i){let t=new Cv(i);return[Pv(t,"",i),t]}function yl(i,t){let[e,r]=nA(i);return t(e),r.result()}function Qr(i){return i instanceof zh||i instanceof kh?i._current:i!==null&&typeof i=="object"?i[yD]:i}var Ur;(n=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}n.equal=i;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...o};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return o}n.removeOverridden=t;function e(s,o){if((s instanceof Sr||s instanceof zh)&&typeof o=="string")return s.data(o);if((s instanceof je||s instanceof kh)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}n.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}n.zoom=r})(Ur||(Ur={}));function xD(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function Ut(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Dv=class{},Wp=class extends Dv{constructor(e){super();this.id=e}},qp=class extends Dv{constructor(e){super();this.data=e}};var oA;try{oA=new TextDecoder}catch{}var qe,xl,oe=0;var CD=[],aA=CD,lA=0,Dn={},Jt,vl,hs=0,po=0,Jn,pa,vn=[],lr,bD={useRecords:!1,mapsAsObjects:!0},Xp=class{},uA=new Xp;uA.name="MessagePack 0xC1";var Gh=!1,mo=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(qe)return ID(()=>(Iv(),this?this.unpack(t,e):mo.prototype.unpack.call(bD,t,e)));xl=e>-1?e:t.length,oe=0,lA=0,po=0,vl=null,aA=CD,Jn=null,qe=t;try{lr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw qe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof mo){if(Dn=this,this.structures)return Jt=this.structures,Ov();(!Jt||Jt.length>0)&&(Jt=[])}else Dn=bD,(!Jt||Jt.length>0)&&(Jt=[]);return Ov()}unpackMultiple(t,e){let r,n=0;try{Gh=!0;let s=t.length,o=this?this.unpack(t,s):Nv.unpack(t,s);if(e){for(e(o);oe<s;)if(n=oe,e(Ov())===!1)return}else{for(r=[o];oe<s;)n=oe,r.push(Ov());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{Gh=!1,Iv()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],s=e[r];s&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ov(){try{if(!Dn.trusted&&!Gh){let t=Jt.sharedLength||0;t<Jt.length&&(Jt.length=t)}let i=Zr();if(oe==xl)Jt.restoreStructures&&SD(),Jt=null,qe=null,pa&&(pa=null);else if(oe>xl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Gh)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Jt.restoreStructures&&SD(),Iv(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function SD(){for(let i in Jt.restoreStructures)Jt[i]=Jt.restoreStructures[i];Jt.restoreStructures=null}function Zr(){let i=qe[oe++];if(i<160)if(i<128){if(i<64)return i;{let t=Jt[i&63]||Dn.getStructures&&_D()[i&63];return t?(t.read||(t.read=hA(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Dn.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DD()]=Zr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Zr(),Zr());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Zr();return t}else if(i<192){let t=i-160;if(po>=oe)return vl.slice(oe-hs,(oe+=t)-hs);if(po==0&&xl<140){let e=t<16?dA(t):PD(t);if(e!=null)return e}return cA(t)}else{let t;switch(i){case 192:return null;case 193:return Jn?(t=Zr(),t>0?Jn[1].slice(Jn.position1,Jn.position1+=t):Jn[0].slice(Jn.position0,Jn.position0-=t)):uA;case 194:return!1;case 195:return!0;case 196:return sA(qe[oe++]);case 197:return t=lr.getUint16(oe),oe+=2,sA(t);case 198:return t=lr.getUint32(oe),oe+=4,sA(t);case 199:return Dc(qe[oe++]);case 200:return t=lr.getUint16(oe),oe+=2,Dc(t);case 201:return t=lr.getUint32(oe),oe+=4,Dc(t);case 202:if(t=lr.getFloat32(oe),Dn.useFloat32>2){let e=Lv[(qe[oe]&127)<<1|qe[oe+1]>>7];return oe+=4,(e*t+(t>0?.5:-.5)>>0)/e}return oe+=4,t;case 203:return t=lr.getFloat64(oe),oe+=8,t;case 204:return qe[oe++];case 205:return t=lr.getUint16(oe),oe+=2,t;case 206:return t=lr.getUint32(oe),oe+=4,t;case 207:return Dn.int64AsNumber?(t=lr.getUint32(oe)*4294967296,t+=lr.getUint32(oe+4)):t=lr.getBigUint64(oe),oe+=8,t;case 208:return lr.getInt8(oe++);case 209:return t=lr.getInt16(oe),oe+=2,t;case 210:return t=lr.getInt32(oe),oe+=4,t;case 211:return Dn.int64AsNumber?(t=lr.getInt32(oe)*4294967296,t+=lr.getUint32(oe+4)):t=lr.getBigInt64(oe),oe+=8,t;case 212:if(t=qe[oe++],t==114)return MD(qe[oe++]&63);{let e=vn[t];if(e)return e.read?(oe++,e.read(Zr())):e.noBuffer?(oe++,e()):e(qe.subarray(oe,++oe));throw new Error("Unknown extension "+t)}case 213:return t=qe[oe],t==114?(oe++,MD(qe[oe++]&63,qe[oe++])):Dc(2);case 214:return Dc(4);case 215:return Dc(8);case 216:return Dc(16);case 217:return t=qe[oe++],po>=oe?vl.slice(oe-hs,(oe+=t)-hs):Iq(t);case 218:return t=lr.getUint16(oe),oe+=2,po>=oe?vl.slice(oe-hs,(oe+=t)-hs):Rq(t);case 219:return t=lr.getUint32(oe),oe+=4,po>=oe?vl.slice(oe-hs,(oe+=t)-hs):Lq(t);case 220:return t=lr.getUint16(oe),oe+=2,AD(t);case 221:return t=lr.getUint32(oe),oe+=4,AD(t);case 222:return t=lr.getUint16(oe),oe+=2,ED(t);case 223:return t=lr.getUint32(oe),oe+=4,ED(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var Oq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function hA(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>Oq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Zr);return i.highByte===0&&(i.read=wD(t,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let o=i[n];r[o]=Zr()}return r}return e.count=0,i.highByte===0?wD(t,e):e}var wD=(i,t)=>function(){let e=qe[oe++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=Jt[r]||_D()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=hA(n,i)),n.read()};function _D(){let i=ID(()=>(qe=null,Dn.getStructures()));return Jt=Dn._mergeStructures(i,Jt)}var cA=Rv,Iq=Rv,Rq=Rv,Lq=Rv;function Rv(i){let t;if(i<16&&(t=dA(i)))return t;if(i>64&&oA)return oA.decode(qe.subarray(oe,oe+=i));let e=oe+i,r=[];for(t="";oe<e;){let n=qe[oe++];if((n&128)===0)r.push(n);else if((n&224)===192){let s=qe[oe++]&63;r.push((n&31)<<6|s)}else if((n&240)===224){let s=qe[oe++]&63,o=qe[oe++]&63;r.push((n&31)<<12|s<<6|o)}else if((n&248)===240){let s=qe[oe++]&63,o=qe[oe++]&63,a=qe[oe++]&63,l=(n&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(n);r.length>=4096&&(t+=zi.apply(String,r),r.length=0)}return r.length>0&&(t+=zi.apply(String,r)),t}function AD(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Zr();return t}function ED(i){if(Dn.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DD()]=Zr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Zr(),Zr());return t}}var zi=String.fromCharCode;function PD(i){let t=oe,e=new Array(i);for(let r=0;r<i;r++){let n=qe[oe++];if((n&128)>0){oe=t;return}e[r]=n}return zi.apply(String,e)}function dA(i){if(i<4)if(i<2){if(i===0)return"";{let t=qe[oe++];if((t&128)>1){oe-=1;return}return zi(t)}}else{let t=qe[oe++],e=qe[oe++];if((t&128)>0||(e&128)>0){oe-=2;return}if(i<3)return zi(t,e);let r=qe[oe++];if((r&128)>0){oe-=3;return}return zi(t,e,r)}else{let t=qe[oe++],e=qe[oe++],r=qe[oe++],n=qe[oe++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){oe-=4;return}if(i<6){if(i===4)return zi(t,e,r,n);{let s=qe[oe++];if((s&128)>0){oe-=5;return}return zi(t,e,r,n,s)}}else if(i<8){let s=qe[oe++],o=qe[oe++];if((s&128)>0||(o&128)>0){oe-=6;return}if(i<7)return zi(t,e,r,n,s,o);let a=qe[oe++];if((a&128)>0){oe-=7;return}return zi(t,e,r,n,s,o,a)}else{let s=qe[oe++],o=qe[oe++],a=qe[oe++],l=qe[oe++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){oe-=8;return}if(i<10){if(i===8)return zi(t,e,r,n,s,o,a,l);{let c=qe[oe++];if((c&128)>0){oe-=9;return}return zi(t,e,r,n,s,o,a,l,c)}}else if(i<12){let c=qe[oe++],u=qe[oe++];if((c&128)>0||(u&128)>0){oe-=10;return}if(i<11)return zi(t,e,r,n,s,o,a,l,c,u);let h=qe[oe++];if((h&128)>0){oe-=11;return}return zi(t,e,r,n,s,o,a,l,c,u,h)}else{let c=qe[oe++],u=qe[oe++],h=qe[oe++],d=qe[oe++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){oe-=12;return}if(i<14){if(i===12)return zi(t,e,r,n,s,o,a,l,c,u,h,d);{let f=qe[oe++];if((f&128)>0){oe-=13;return}return zi(t,e,r,n,s,o,a,l,c,u,h,d,f)}}else{let f=qe[oe++],p=qe[oe++];if((f&128)>0||(p&128)>0){oe-=14;return}if(i<15)return zi(t,e,r,n,s,o,a,l,c,u,h,d,f,p);let g=qe[oe++];if((g&128)>0){oe-=15;return}return zi(t,e,r,n,s,o,a,l,c,u,h,d,f,p,g)}}}}}function sA(i){return Dn.copyBuffers?Uint8Array.prototype.slice.call(qe,oe,oe+=i):qe.subarray(oe,oe+=i)}function Dc(i){let t=qe[oe++];if(vn[t])return vn[t](qe.subarray(oe,oe+=i));throw new Error("Unknown extension type "+t)}var TD=new Array(4096);function DD(){let i=qe[oe++];if(i>=160&&i<192){if(i=i-160,po>=oe)return vl.slice(oe-hs,(oe+=i)-hs);if(!(po==0&&xl<180))return cA(i)}else return oe--,Zr();let t=(i<<5^(i>1?lr.getUint16(oe):i>0?qe[oe]:0))&4095,e=TD[t],r=oe,n=oe+i-3,s,o=0;if(e&&e.bytes==i){for(;r<n;){if(s=lr.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=qe[r++],s!=e[o++]){r=1879048192;break}if(r===n)return oe=r,e.string;n-=3,r=oe}for(e=[],TD[t]=e,e.bytes=i;r<n;)s=lr.getUint32(r),e.push(s),r+=4;for(n+=3;r<n;)s=qe[r++],e.push(s);let a=i<16?dA(i):PD(i);return a!=null?e.string=a:e.string=cA(i)}var MD=(i,t)=>{var e=Zr();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=Jt[i];return n&&n.isShared&&((Jt.restoreStructures||(Jt.restoreStructures=[]))[i]=n),Jt[i]=e,e.read=hA(e,r),e.read()},OD=typeof self=="object"?self:global;vn[0]=()=>{};vn[0].noBuffer=!0;vn[101]=()=>{let i=Zr();return(OD[i[0]]||Error)(i[1])};vn[105]=i=>{let t=lr.getUint32(oe-4);pa||(pa=new Map);let e=qe[oe],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};pa.set(t,n);let s=Zr();return n.used?Object.assign(r,s):(n.target=s,s)};vn[112]=i=>{let t=lr.getUint32(oe-4),e=pa.get(t);return e.used=!0,e.target};vn[115]=()=>new Set(Zr());var fA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");vn[116]=i=>{let t=i[0],e=fA[t];if(!e)throw new Error("Could not find typed array for code "+t);return new OD[e](Uint8Array.prototype.slice.call(i,1).buffer)};vn[120]=()=>{let i=Zr();return new RegExp(i[0],i[1])};vn[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=oe;oe+=t-4,Jn=[Zr(),Zr()],Jn.position0=0,Jn.position1=0;let r=oe;oe=e;try{return Zr()}finally{oe=r}};vn[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function ID(i){let t=xl,e=oe,r=lA,n=hs,s=po,o=vl,a=aA,l=pa,c=Jn,u=new Uint8Array(qe.slice(0,xl)),h=Jt,d=Jt.slice(0,Jt.length),f=Dn,p=Gh,g=i();return xl=t,oe=e,lA=r,hs=n,po=s,vl=o,aA=a,pa=l,Jn=c,qe=u,Gh=p,Jt=h,Jt.splice(0,Jt.length,...d),Dn=f,lr=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),g}function Iv(){qe=null,pa=null,Jt=null}function RD(i){i.unpack?vn[i.type]=i.unpack:vn[i.type]=i}var Lv=new Array(147);for(let i=0;i<256;i++)Lv[i]=+("1e"+Math.floor(45.15-i*.30103));var Nv=new mo({useRecords:!1}),Nq=Nv.unpack,Bq=Nv.unpackMultiple,Fq=Nv.unpack,Bv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Uq=new Float32Array(1),Zce=new Uint8Array(Uq.buffer,0,4);var Fv;try{Fv=new TextEncoder}catch{}var Uv,mA,Vv=typeof Buffer<"u",pA=Vv?Buffer.allocUnsafeSlow:Uint8Array,FD=Vv?Buffer:Uint8Array,LD=Vv?4294967296:2144337920,we,oi,pe=0,go,yo=null,Vq=/[\u0080-\uFFFF]/,Yp=Symbol("record-id"),Oc=class extends mo{constructor(t){super(t),this.offset=0;let e,r,n,s,o,a,l=0,c=FD.prototype.utf8Write?function(A,P,M){return we.utf8Write(A,P,M)}:Fv&&Fv.encodeInto?function(A,P){return Fv.encodeInto(A,we.subarray(P)).written}:!1,u=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let g=f>32||p+f>64,y=f+64,m=f+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(A,P){if(we||(we=new pA(8192),oi=new DataView(we.buffer,0,8192),pe=0),go=we.length-10,go-pe<2048?(we=new pA(we.length),oi=new DataView(we.buffer,0,we.length),go=we.length-10,pe=0):pe=pe+7&2147483640,r=pe,a=u.structuredClone?new Map:null,u.bundleStrings?(yo=["",""],we[pe++]=214,we[pe++]=98,yo.position=pe-r,pe+=4):yo=null,n=u.structures,n){n.uninitialized&&(n=u._mergeStructures(u.getStructures()));let M=n.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let C=0;C<M;C++){let O=n[C];if(!O)continue;let L,D=n.transitions;for(let B=0,k=O.length;B<k;B++){let F=O[B];L=D[F],L||(L=D[F]=Object.create(null)),D=L}D[Yp]=C+64}l=M}h||(n.nextId=M+64)}s&&(s=!1),o=n||[];try{if(S(A),yo){oi.setUint32(yo.position+r,pe-yo.position-r);let M=yo;yo=null,S(M[0]),S(M[1])}if(u.offset=pe,a&&a.idsToInsert){pe+=a.idsToInsert.length*6,pe>go&&E(pe),u.offset=pe;let M=kq(we.subarray(r,pe),a.idsToInsert);return a=null,M}return P&VD?(we.start=r,we.end=pe,we):we.subarray(r,pe)}finally{if(n){if(b<10&&b++,x>1e4)n.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let M=0,C=v.length;M<C;M++)v[M][Yp]=0;v=[]}if(s&&u.saveStructures){let M=n.sharedLength||f;n.length>M&&(n=n.slice(0,M));let C=we.subarray(r,pe);return u.saveStructures(n,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(A)):(l=M,C)}}P&Yq&&(pe=r)}};let S=A=>{pe>go&&(we=E(pe));var P=typeof A,M;if(P==="string"){let C=A.length;if(yo&&C>=8&&C<4096){let D=Vq.test(A);yo[D?0:1]+=A,we[pe++]=193,S(D?-C:C);return}let O;C<32?O=1:C<256?O=2:C<65536?O=3:O=5;let L=C*3;if(pe+L>go&&(we=E(pe+L)),C<64||!c){let D,B,k,F=pe+O;for(D=0;D<C;D++)B=A.charCodeAt(D),B<128?we[F++]=B:B<2048?(we[F++]=B>>6|192,we[F++]=B&63|128):(B&64512)===55296&&((k=A.charCodeAt(D+1))&64512)===56320?(B=65536+((B&1023)<<10)+(k&1023),D++,we[F++]=B>>18|240,we[F++]=B>>12&63|128,we[F++]=B>>6&63|128,we[F++]=B&63|128):(we[F++]=B>>12|224,we[F++]=B>>6&63|128,we[F++]=B&63|128);M=F-pe-O}else M=c(A,pe+O,L);M<32?we[pe++]=160|M:M<256?(O<2&&we.copyWithin(pe+2,pe+1,pe+1+M),we[pe++]=217,we[pe++]=M):M<65536?(O<3&&we.copyWithin(pe+3,pe+2,pe+2+M),we[pe++]=218,we[pe++]=M>>8,we[pe++]=M&255):(O<5&&we.copyWithin(pe+5,pe+3,pe+3+M),we[pe++]=219,oi.setUint32(pe,M),pe+=4),pe+=M}else if(P==="number")if(A>>>0===A)A<64?we[pe++]=A:A<256?(we[pe++]=204,we[pe++]=A):A<65536?(we[pe++]=205,we[pe++]=A>>8,we[pe++]=A&255):(we[pe++]=206,oi.setUint32(pe,A),pe+=4);else if(A>>0===A)A>=-32?we[pe++]=256+A:A>=-128?(we[pe++]=208,we[pe++]=A+256):A>=-32768?(we[pe++]=209,oi.setInt16(pe,A),pe+=2):(we[pe++]=210,oi.setInt32(pe,A),pe+=4);else{let C;if((C=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){we[pe++]=202,oi.setFloat32(pe,A);let O;if(C<4||(O=A*Lv[(we[pe]&127)<<1|we[pe+1]>>7])>>0===O){pe+=4;return}else pe--}we[pe++]=203,oi.setFloat64(pe,A),pe+=8}else if(P==="object")if(!A)we[pe++]=192;else{if(a){let O=a.get(A);if(O){if(!O.id){let L=a.idsToInsert||(a.idsToInsert=[]);O.id=L.push(O)}we[pe++]=214,we[pe++]=112,oi.setUint32(pe,O.id),pe+=4;return}else a.set(A,{offset:pe-r})}let C=A.constructor;if(C===Object)w(A,!0);else if(C===Array){M=A.length,M<16?we[pe++]=144|M:M<65536?(we[pe++]=220,we[pe++]=M>>8,we[pe++]=M&255):(we[pe++]=221,oi.setUint32(pe,M),pe+=4);for(let O=0;O<M;O++)S(A[O])}else if(C===Map){M=A.size,M<16?we[pe++]=128|M:M<65536?(we[pe++]=222,we[pe++]=M>>8,we[pe++]=M&255):(we[pe++]=223,oi.setUint32(pe,M),pe+=4);for(let[O,L]of A)S(O),S(L)}else{for(let O=0,L=Uv.length;O<L;O++){let D=mA[O];if(A instanceof D){let B=Uv[O];if(B.write){B.type&&(we[pe++]=212,we[pe++]=B.type,we[pe++]=0),S(B.write.call(this,A));return}let k=we,F=oi,H=pe;we=null;let G;try{G=B.pack.call(this,A,X=>(we=k,k=null,pe+=X,pe>go&&E(pe),{target:we,targetView:oi,position:pe-X}),S)}finally{k&&(we=k,oi=F,pe=H,go=we.length-10)}G&&(G.length+pe>go&&E(G.length+pe),pe=zq(G,we,pe,B.type));return}}w(A,!A.hasOwnProperty)}}else if(P==="boolean")we[pe++]=A?195:194;else if(P==="bigint"){if(A<BigInt(1)<<BigInt(63)&&A>=-(BigInt(1)<<BigInt(63)))we[pe++]=211,oi.setBigInt64(pe,A);else if(A<BigInt(1)<<BigInt(64)&&A>0)we[pe++]=207,oi.setBigUint64(pe,A);else if(this.largeBigIntToFloat)we[pe++]=203,oi.setFloat64(pe,Number(A));else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");pe+=8}else if(P==="undefined")this.encodeUndefinedAsNil?we[pe++]=192:(we[pe++]=212,we[pe++]=0,we[pe++]=0);else if(P==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+P)},w=this.useRecords===!1?this.variableMapSize?A=>{let P=Object.keys(A),M=P.length;M<16?we[pe++]=128|M:M<65536?(we[pe++]=222,we[pe++]=M>>8,we[pe++]=M&255):(we[pe++]=223,oi.setUint32(pe,M),pe+=4);let C;for(let O=0;O<M;O++)S(C=P[O]),S(A[C])}:(A,P)=>{we[pe++]=222;let M=pe-r;pe+=2;let C=0;for(let O in A)(P||A.hasOwnProperty(O))&&(S(O),S(A[O]),C++);we[M+++r]=C>>8,we[M+r]=C&255}:A=>{let P=Object.keys(A),M,C=o.transitions||(o.transitions=Object.create(null)),O=0;for(let D=0,B=P.length;D<B;D++){let k=P[D];M=C[k],M||(M=C[k]=Object.create(null),O++),C=M}let L=C[Yp];if(L)L>=96&&g?(we[pe++]=((L-=96)&31)+96,we[pe++]=L>>5):we[pe++]=L;else{L=o.nextId,L||(L=64),L<y&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(L=o.nextOwnId,L<m||(L=y),o.nextOwnId=L+1):(L>=m&&(L=y),o.nextId=L+1);let D=P.highByte=L>=96&&g?L-96>>5:-1;C[Yp]=L,o[L-64]=P,L<y?(P.isShared=!0,o.sharedLength=L-63,s=!0,D>=0?(we[pe++]=(L&31)+96,we[pe++]=D):we[pe++]=L):(D>=0?(we[pe++]=213,we[pe++]=114,we[pe++]=(L&31)+96,we[pe++]=D):(we[pe++]=212,we[pe++]=114,we[pe++]=L),O&&(x+=b*O),v.length>=p&&(v.shift()[Yp]=0),v.push(C),S(P))}for(let D=0,B=P.length;D<B;D++)S(A[P[D]])},E=A=>{let P;if(A>16777216){if(A-r>LD)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(LD,Math.round(Math.max((A-r)*(A>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(A-r<<2,we.length-1)>>12)+1<<12;let M=new pA(P);return oi=new DataView(M.buffer,0,P),we.copy?we.copy(M,0,r,A):M.set(we.slice(r,A)),pe-=r,r=0,go=M.length-10,we=M}}useBuffer(t){we=t,oi=new DataView(we.buffer,we.byteOffset,we.byteLength),pe=0}};mA=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Xp];Uv=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:o}=t(6);n[o++]=214,n[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:o}=t(10);n[o++]=215,n[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:s,position:o}=t(3);n[o++]=212,n[o++]=255,n[o++]=255}else{let{target:n,targetView:s,position:o}=t(15);n[o++]=199,n[o++]=12,n[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?ND(i,16,t):BD(Vv?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==FD&&this.structuredClone?ND(i,fA.indexOf(e.name),t):BD(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function ND(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:s,position:o}=e(4+n);s[o++]=199,s[o++]=n+1}else if(n+1<65536){var{target:s,position:o}=e(5+n);s[o++]=200,s[o++]=n+1>>8,s[o++]=n+1&255}else{var{target:s,position:o,targetView:a}=e(7+n);s[o++]=201,a.setUint32(o,n+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function BD(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:s}=t(e+5);r[n++]=198,s.setUint32(n,e),n+=4}r.set(i,n)}function zq(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function kq(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+r,s,n),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,n=s}return i}function bl(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");mA.unshift(i.Class),Uv.unshift(i)}RD(i)}var UD=new Oc({useRecords:!1}),Gq=UD.pack,Hq=UD.pack;var{NEVER:jq,ALWAYS:Wq,DECIMAL_ROUND:qq,DECIMAL_FIT:Xq}=Bv,VD=512,Yq=1024;var zD=new Oc({structuredClone:!0});bl({Class:at.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,at.prototype),i}});bl({Class:je.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,je.prototype),i}});bl({Class:Sr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Sr.prototype),i}});bl({Class:Wp.prototype.constructor,type:4,write(i){return i.id},read(i){return new Wp(i)}});bl({Class:qp.prototype.constructor,type:5,write(i){return i.data},read(i){return new qp(i)}});bl({Class:wr.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,wr.prototype),i}});function Kq(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function gA(i){if(Bh(i))return i;if(Array.isArray(i))return i.map(gA);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=gA(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var zv;(r=>{function i(n){return zD.pack(n)}r.serialize=i;function t(n){return zD.unpack(n)}r.deserialize=t;function e(n){return Kq(i(gA(n))).toString()}r.checksum=e})(zv||(zv={}));var kD;(e=>{function i(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=i;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(kD||(kD={}));var xn={["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"]},GD;(e=>{function i(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=i;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new je}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new je}}e.defaultData=t})(GD||(GD={}));var kv;(e=>{function i(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(kv||(kv={}));var yA;(r=>{function i(n){return{type:"Comparison",operator:"==",lOperand:kv.propertyDefaultData(n),rOperand:{...kv.valueDefaultData}}}r.comparisonDefaultData=i;function t(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}}r.distanceDefaultData=t;function e(n,s){return{type:"State",object:n??null,state:s??null}}r.stateDefaultData=e})(yA||(yA={}));var HD;(e=>{function i(r){return r.type==="Conditional"}e.is=i;function t(r){return{type:"Conditional",disabled:!1,inActions:new je,outActions:new je,condition:yA.distanceDefaultData(r)}}e.defaultData=t})(HD||(HD={}));var jD;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new je,drop:new je}})(jD||(jD={}));var Gv;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new je})(Gv||(Gv={}));var Hv;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Hv||(Hv={}));var WD;(e=>{function i(r){return r.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new je}}e.defaultData=t})(WD||(WD={}));var qD;(e=>{function i(r){return r.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new je}}e.defaultData=t})(qD||(qD={}));var XD;(e=>{function i(r){return r.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new je}}e.defaultData=t})(XD||(XD={}));var YD;(e=>{function i(r){return r.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new je}}e.defaultData=t})(YD||(YD={}));var KD;(e=>{function i(r){return r.type==="Trigger"}e.is=i;function t(r,n){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new je,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(KD||(KD={}));var jv;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function n(){let a={size:"mobile",operator:"<",actions:new je},l={size:"tablet",operator:"<",actions:new je},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new je},u=new je;return u.push({id:_e.generateUUID(),fi:0,data:a},{id:_e.generateUUID(),fi:1,data:l},{id:_e.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:u}}o.defaultData=n;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new je}}o.defaultBreakpointData=s})(jv||(jv={}));var Wv;(r=>{r.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(n){return n.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new je,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Wv||(Wv={}));var ds="personal camera",wl="a218fcc3-276b-49b9-b485-49037fd14f5f",JD=2960946,ai=5526619;var Fs;(f=>{function i(p,g){return p[0]===g[0]&&p[1]===g[1]}f.isEqual=i;function t(p,g,y){return[p[0]+(g[0]-p[0])*y,p[1]+(g[1]-p[1])*y]}f.lerp=t;function e(p,g){return[p[0]+g[0],p[1]+g[1]]}f.add=e;function r(p,g){return[p[0]-g[0],p[1]-g[1]]}f.sub=r;function n(p,g){return[p[0]*g[0],p[1]*g[1]]}f.multiply=n;function s(p,g){return[p[0]/g[0],p[1]/g[1]]}f.divide=s;function o(p,g){return Math.pow(g[0]-p[0],2)+Math.pow(g[1]-p[1],2)}f.distanceSquared=o;function a(p,g){return Math.sqrt(o(p,g))}f.distance=a;function l(p,g){return p[0]*g[0]+p[1]*g[1]}f.dot=l;function c(p,g){return[p[0]*g,p[1]*g]}f.scalarMultiply=c;function u(p,g,y){let m=f.sub(g,p),v=f.sub(y,p),x=f.dot(m,v)/f.dot(m,m),b=f.scalarMultiply(m,x);return f.add(p,b)}f.projectionOnto=u;function h(p,g,y){return a(p,u(p,g,y))}f.projectionOntoDistance=h;function d(p,g){return[(p[0]+g[0])*.5,(p[1]+g[1])*.5]}f.center=d})(Fs||(Fs={}));var vo;(a=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}a.isEqual=i;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}a.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}a.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}a.div=r;function n(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}a.mul=n;function s(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}a.dist=s;function o(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}a.lerp=o})(vo||(vo={}));var Kp;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}e.lerp=t})(Kp||(Kp={}));var Sl;(n=>{n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}n.isEqual=t;function e(s){return s??n.identity}n.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let u=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/u,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/u,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/u}return a}n.applyMatrix4=r})(Sl||(Sl={}));var Ci;(h=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}h.isRGB=i,h.white={r:1,g:1,b:1},h.red={r:1,g:0,b:0},h.black={r:0,g:0,b:0};function n(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}h.toRgb255a1=n;function s(d){return{r:d.r,g:d.g,b:d.b}}h.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}h.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}h.toHex=a;function l(d,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}h.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}h.equalsFixed=c;function u(d,f,p){return{r:d.r+(f.r-d.r)*p,g:d.g+(f.g-d.g)*p,b:d.b+(f.b-d.b)*p}}h.lerp=u})(Ci||(Ci={}));var It;(c=>{c.white={...Ci.white,a:1},c.transparent={...Ci.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function r(u,h){return{...Ci.fromHex(u),a:h}}c.fromHexAndA=r;function n(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=n;function s(u,h){return Ci.equals(u,h)&&u.a===h.a}c.equals=s;function o(u,h){return Ci.equalsFixed(u,h)&&u.a.toFixed(2)===h.a.toFixed(2)}c.equalsFixed=o;function a(u,h,d){return{r:u.r+(h.r-u.r)*d,g:u.g+(h.g-u.g)*d,b:u.b+(h.b-u.b)*d,a:u.a+(h.a-u.a)*d}}c.lerp=a;function l({r:u,g:h,b:d,a:f}=c.white){return`rgba(${u*255}, ${h*255}, ${d*255}, ${f})`}c.toStyle=l})(It||(It={}));var qv;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(qv||(qv={}));var QD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(QD||(QD={}));var ZD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ZD||(ZD={}));var ma;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(ma||(ma={}));function vA(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var Us;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Us||(Us={}));var Al;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}n.getZoom=r})(Al||(Al={}));var xo;(e=>{function i(r,n=.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]*n,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+n)),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=i;function t(r,n){let s={...r};if(xA.forEach(o=>{Object.assign(s,{[o]:n[o]??r[o]})}),s.radial={...r.radial},n.radial){let o=r.radial,a=n.radial;bA.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},n.linear){let o=r.linear,a=n.linear;SA.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},n.grid){let o=r.grid,a=n.grid;wA.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},n.toObject){let o=r.toObject,a=n.toObject;AA.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},n.randomnessObject){let o=r.randomnessObject,a=n.randomnessObject;EA.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(xo||(xo={}));var Xv;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(n,s){let o=[];n.count!==void 0&&o.push({type:0,path:s,props:{count:n.count}});for(let a of t){let l=n[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Xv||(Xv={}));var xA=["count"],bA=["radius","start","end","position","scale","rotation"],SA=["position","scale","rotation"],wA=["count","size"],AA=["count","position","scale","rotation"],EA=["strength","scale","rotation","position","movement","seed","freqScale"];var Yv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Yv||(Yv={}));var Kv;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:It.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:It.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:It.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Kv||(Kv={}));var Hh;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(Hh||(Hh={}));var El;(t=>t.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]})(El||(El={}));var TA;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(TA||(TA={}));var MA;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(MA||(MA={}));var Qv;(t=>t.defaultData={...MA.defaultData,...TA.defaultData})(Qv||(Qv={}));var $D;(t=>{function i(e,r){let n=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&n.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&n.push(o)}return n}t.getMaterialData=i})($D||($D={}));var jh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(jh||(jh={}));var eO;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(eO||(eO={}));function rO(i){return i.type!=="displace"}var tO;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(tO||(tO={}));var Zv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],iO=["wrapping","image","video","name","minFilter"],Hr;(n=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let c=s.texture;c&&Object.assign(c,a)}}n.patch=i;function t(s,o){return s==="light"&&o?e(o):r(s)}n.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:jh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...o,type:"color",color:Ci.fromHex(ai)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ci.fromHex(6710886),a:1},colorB:{...Ci.fromHex(6710886),a:1},colorC:{...Ci.fromHex(16777215),a:1},colorD:{...Ci.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:It.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:It.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:It.fromHexAndA(0,1),contourColor:It.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ci.fromHex(0),a:1},colorB:{...Ci.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}}}})(Hr||(Hr={}));var li;(c=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=i;function t(u){let h="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,p])=>{h+=`${f}${p}`,Array.isArray(p)?p.forEach(g=>h+=`${g}`):typeof p=="object"?Object.values(p).forEach(g=>{typeof g=="number"?h+=`${g.toFixed(4)}`:h+=`${g}`}):h+=`${p}`})}),h}c.getHash=t;function e(){return{layers:new je}}c.defaultEmptyData=e;function r(u="layer1",h="layer2"){return s("phong",u,h)}c.defaultData=r;function n(u,h){return{...u,name:h}}c.withName=n;function s(u,h="layer1",d="layer2"){let f=new je;return f.push({fi:0,data:Hr.defaultData("light",u),id:h}),f.push({fi:1,data:Hr.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=s;function o(u){let h=Hr.defaultData("texture");u&&Object.assign(h.texture,{image:u});let d=new je;return d.push({fi:0,data:h,id:"layer1"}),d.push({fi:1,data:{...Hr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Hr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=o;function a(u,h="phong",d="layer1",f="layer2"){let p=Hr.defaultData("texture");Object.assign(p.texture,{image:u});let g=new je;return g.push({fi:0,data:p,id:d}),g.push({fi:1,data:Hr.defaultData("light",h),id:f}),{layers:g}}c.defaultTwoLayerTextureData=a;function l(u,h="phong",d="layer1",f="layer2"){let p=Hr.defaultData("video");Object.assign(p.texture,{video:u});let g=new je;return g.push({fi:0,data:p,id:d}),g.push({fi:1,data:Hr.defaultData("light",h),id:f}),{layers:g}}c.defaultTwoLayerVideoTextureData=l})(li||(li={}));var Wh;(t=>{function i(){return{points:new je,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Wh||(Wh={}));var qh;(t=>{function i(){return{points:new je,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(qh||(qh={}));var CA={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Jv;(t=>{function i(e,r){let n={...e};return _A.forEach(s=>{Object.assign(n,{[s]:r[s]??e[s]})}),n}t.merge=i})(Jv||(Jv={}));var $v={shape:CA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},_A=["depth","offset","angle","twist","startScale","endScale"];var Qp;(e=>{function i(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=i;function t(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=t})(Qp||(Qp={}));var e0;(t=>{function i(e,r){let n={...e};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...e.extrusion},Object.assign(n.extrusion,Jv.merge(n.extrusion,r.extrusion))),n}t.merge=i})(e0||(e0={}));var Tl;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:qh.defaultData(),extrusion:$v};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Wh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Tl||(Tl={}));var PA=["width","height","depth"];var t0;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Ci.white,near:.1,far:2e3})(t0||(t0={}));var Xh;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focusDistance:100,focalLength:20,bokehScale:5},noise:{...i,blendFunction:16}}})(Xh||(Xh={}));var DA;(t=>t.defaultData={softShadowQuality:"low"})(DA||(DA={}));var OA;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(OA||(OA={}));var IA;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(IA||(IA={}));var Ml;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ml||(Ml={}));var RA;(t=>t.defaultData={playCamera:ds,gameControlObject:null})(RA||(RA={}));var r0;(t=>t.defaultData={backgroundColor:It.fromHexAndA(JD,1),postprocessing:Xh.defaultData,fog:t0.defaultData,globalPhysics:Ml.defaultData,ambient:OA.defaultData,ao:IA.defaultData,shadow:DA.defaultData,publish:RA.defaultData})(r0||(r0={}));var i0;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(i0||(i0={}));var nO;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(nO||(nO={}));var Yh;(n=>{n.identity={...qv.identity,hiddenMatrix:Sl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}n.merge=e;function r(s,o){return mv({position:vo.isEqual(s.position,o.position)?void 0:o.position,rotation:vo.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:vo.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Sl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}n.diff=r})(Yh||(Yh={}));var _i;(t=>t.defaultData={states:new je,events:new je,visible:!0,raycastLock:!1,physics:El.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Yh.identity,cloner:null})(_i||(_i={}));var n0;(t=>t.defaultData={type:"Empty",..._i.defaultData})(n0||(n0={}));var sO;(t=>t.defaultData={type:"ParticleCollider",...i0.defaultData,..._i.defaultData})(sO||(sO={}));var oO;(t=>t.defaultData={type:"Component",..._i.defaultData})(oO||(oO={}));var aO;(t=>t.defaultData={type:"Particle",..._i.defaultData,...Hh.defaultData})(aO||(aO={}));var Ic;(t=>t.defaultData={type:"Mesh",..._i.defaultData,...Qv.defaultData})(Ic||(Ic={}));var Rc;(t=>t.defaultData={..._i.defaultData,...Yh.identity,position:[0,0,Al.DefaultTargetOffset],...Al.defaultData})(Rc||(Rc={}));var s0;(e=>{function i(r){return{..._i.defaultData,...Kv.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(s0||(s0={}));var Kh;(e=>{function i(r,n,s=0){for(;s<n.length;){let o=r?r[n[s]]:void 0;if(n.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(r,n,s=0){let o=i(r,n,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Kh||(Kh={}));var bo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{..._i.defaultData,...a,component:o,overrides:new wr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function n(o){let a=Yh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=n})(bo||(bo={}));var ga;(e=>{e.defaultData={type:"Page",..._i.defaultData,physics:{...El.defaultData,fusedBody:!1},...r0.defaultData,camera:Rc.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ga||(ga={}));var o0;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Sl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:El.defaultData,states:new je,events:new je,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Al.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",..._i.defaultData,...Ic.defaultData,geometry:Tl.defaultData("RectangleGeometry"),material:li.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",..._i.defaultData,...Ic.defaultData,geometry:Tl.defaultData("BooleanGeometry"),material:li.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",..._i.defaultData,...Ic.defaultData,geometry:Tl.defaultData("TextGeometry"),material:li.defaultTwoLayerData("phong","layer1","layer2")}))(o0||(o0={}));var ya;(n=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new wr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new wr})))):Us.is(s.type)&&(a.perspective={},a.orthographic={}),a}n.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=yl(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Hr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=yl(a.materials,l=>{for(let c=0;c<a.materials.length;c++){let u=o.materials[c];if(typeof u!="string")for(let[h,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(h);f&&Hr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],c={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:g,...y}=p;if(g!==void 0&&Object.keys(g).length>0){let m={path:[...h,"layers",f,"texture"],props:g,type:0};l.push(m)}if(Object.keys(y).length>0){let m={path:[...h,"layers",f],props:y,type:0};l.push(m)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Xv.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")u(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))u(["materials",f],p);else if(c[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}n.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Yh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Us.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:e0.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:xo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:xo.merge(a.cloner,o.cloner)});else if(Yv.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Ci.clone(l.color))}return a}n.patch=r})(ya||(ya={}));var Qh;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Qh||(Qh={}));var Vs;(t=>t.defaultData={orbitControls:Qh.defaultData,playPage:wl,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let n=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?n=30:(r===4||r===11||r===9)&&(n=-30),[120,[n,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})(Vs||(Vs={}));var LA;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(LA||(LA={}));var NA;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(NA||(NA={}));var va;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...LA.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:NA.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(va||(va={}));var Cl;(e=>{function i(r){return r.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,n,s){r.scene.objects.traverseFrom(n,(o,a)=>{if(a.type==="Instance"){let l=Zh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Cl||(Cl={}));var xa;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(c=!0){let u=[],h=o0.defaultMeshObject;c&&(u.push({fi:-1,data:s0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:h,children:[]}));let d=new Sr;return d.push({fi:1,id:wl,data:{...ga.defaultData,name:"Scene 1"},children:u}),d}l.defaultData={objects:t(),publish:Vs.defaultData,styles:va.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Sr,publish:Vs.defaultData,styles:va.defaultData()}},l.emptyDataWithPage=function(c=!0){return{objects:t(c),publish:Vs.defaultData,styles:va.defaultData()}},l.emptyData=function(){return{objects:new Sr,publish:{...Vs.defaultData},styles:va.defaultData()}};function o(c){return{...l.defaultData,objects:yn(c,Sr.prototype)}}l.withObjs=o;function a(c,u){return o([{id:c,data:u,children:[],fi:0}])}l.withObj=a})(xa||(xa={}));var Jh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Jh||(Jh={}));var ki;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function n(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=n})(ki||(ki={}));var BA;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(BA||(BA={}));var lO;(t=>t.all=[...BA.all,"components"])(lO||(lO={}));var cO;(t=>{function i(){return{images:new at,videos:new at,colors:new at,audios:new at,particles:new at,fonts:new at,materials:new at,components:new at,variables:new at}}t.defaultData=i})(cO||(cO={}));var ba;(t=>{function i(){return{images:new at,videos:new at,colors:new at,audios:new at,particles:new at,fonts:new at,materials:new at,components:new at,variables:new at}}t.defaultData=i})(ba||(ba={}));var bn;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},yn(o,at.prototype)}s.defaultColors=i;function t(){return yn({},at.prototype)}s.defaultImages=t;function e(){return{catelogs:new at,materials:new at,images:new at,videos:new at,colors:new at,audios:new at,particles:new at,fonts:new at,variables:new je,lib:ba.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function n(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),c=Math.floor((o-l*3600)/60),u=Math.round(o-l*3600-c*60);return{textValue:[l,c,u]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),c=Math.round(o-l*60);return{textValue:[l,c]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=n})(bn||(bn={}));var $h;(t=>t.list=["idle","move","jump","run"])($h||($h={}));var ed;(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 je,move:new je,jump:new je,run:new je},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:It.fromHexAndA(3728051,1)}}))(ed||(ed={}));function uO(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,n=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)n.push(n[1]),s.push(1);let o={...Zn(Qr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Qr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Sa(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function wa(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=li.defaultData(),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=li.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=li.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&Object.getPrototypeOf(n.material)!==wr.prototype&&t(n.material)})})}function Zq(i){Object.assign(i.scene.publish,{orbitControls:{...Qh.defaultData,...Qr(i.scene.publish.orbitControls)}})}function Jq(i){Object.assign(i.scene.publish.settings,{video:{...Vs.defaultData.settings.video,...Qr(i.scene.publish.settings.video)}})}function $q(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[n,s]of Object.entries(r))if((Zv.includes(n)||typeof s=="boolean")&&delete r[n],n==="texture")for(let[o,a]of Object.entries(s))(iO.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(n=>{let s=n;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function eX(i){i.scene.publish.withBackground=!0}function tX(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function rX(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(n=>n+1),r.linear.scale=r.linear.scale.map(n=>n+1))})}function iX(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function nX(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let n=Qr(i.scene.objects.data(r));n&&n.type==="Mesh"&&n.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Qr(e).booleanExclude!==!0)}})}function sX(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function oX(i){function t(r){Object.setPrototypeOf(r,wr.prototype),r.texture&&Object.setPrototypeOf(r.texture,wr.prototype)}function e(r){Object.setPrototypeOf(r,wr.prototype);for(let n in r)t(r[n])}i.scene.objects.traverse((r,n)=>{n.states.forEach(s=>{let o=s;if(o.material){let a=Qr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],c=Qr(l).layers;e(c),l.layers=c}})})}function hO(i){i.layers===void 0&&Object.assign(i,li.defaultTwoLayerData("lambert"))}function FA(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...Qr(t),colors:e,steps:r};Object.assign(t,n)}})}function aX(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function dO(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&FA(r)}):"material"in e&&typeof e.material!="string"&&FA(e.material)}),Object.values(i.shared.materials).forEach(t=>FA(t))}function lX(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function cX(i){i.shared.audios=yn({},at.prototype)}function uX(i){i.shared.videos=yn({},at.prototype)}function hX(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let n={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:n})}})}function dX(i){Object.entries(Qr(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(Qr(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function fX(i){i.scene.publish.settings.web.preload=!1}function fO(i){i.layers&&i.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 pO(i){i.layers&&i.layers.forEach(t=>{rO(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 pX(i){i.shared.fonts=yn({},at.prototype)}function mX(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function gX(i){let t=[];i.scene.objects.traverse((e,r)=>{let n=r;if(n.type==="TextFrame"){let s=li.defaultTwoLayerData("phong"),o=typeof n.color=="string"?i.shared.colors[n.color]:n.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=n.alpha;let a=mX(n.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:n.name,..._i.defaultData,...Ic.defaultData,flatShading:!1,wireframe:!1,geometry:{...Tl.defaultData("TextGeometry"),width:n.width,height:n.height,font:a,depth:0,horizontalAlign:n.horizontalAlign,verticalAlign:n.verticalAlign,fontSize:n.fontSize*1.40625,lineHeight:n.lineHeight/1.40625,letterSpacing:n.letterSpacing-1,text:n.text,textTransform:n.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Qr(n.states),events:Qr(n.events),visible:n.visible,raycastLock:n.raycastLock,position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix},c=Qr(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function yX(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(n=>{if(!!t[Number(n.type)])if(Object.assign(n,{type:t[Number(n.type)]}),n.type==="Audio"&&"audioEvent"in n&&(Object.assign(n,{playAudio:n.audioEvent}),delete n.audioEvent),n.type==="GameControl")Object.assign(n,{gameActions:{idle:new je,move:new je,jump:new je}});else{let s=new je;Object.assign(n,{actions:s}),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp")&&"url"in n&&s.push({fi:0,id:_e.generateUUID(),data:{type:"Link",url:n.url,delay:0}}),"targets"in n&&(n.targets.forEach((o,a,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(u,Zn(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(u,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...u},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new je({fi:0,id:_e.generateUUID(),data:c},{fi:1,id:_e.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete n.targets)}})})}function vX(i){i.scene.objects.traverse((t,e)=>{function r(n,s){let o=new je,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Zn(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")&&(h={...Zn(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:u,id:c,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(c=>c.type===n)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:_e.generateUUID(),data:{type:n,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function mO(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Hr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function gO(i){Sa(i,mO),wa(i,mO)}function xX(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function bX(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function SX(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=li.defaultTwoLayerData("phong"))})}function wX(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function AX(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function EX(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function TX(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function MX(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function CX(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function _X(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=ed.defaultDataThirdPerson.navmesh)})})}function PX(i){i.scene.styles||(i.scene.styles=va.defaultData())}function yO(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function DX(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),wa(i,yO),Sa(i,yO)}function OX(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new je})})})}function IX(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function vO(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function xO(i,t){if(t<1&&(wa(i,uO),Sa(i,uO),i.schema=1),t<2&&(Zq(i),i.schema=2),t<3&&($q(i),i.schema=3),t<4&&(eX(i),i.schema=4),t<5&&(tX(i),i.schema=5),t<6&&(rX(i),i.schema=6),t<7&&(iX(i),i.schema=7),t<8&&(i.schema=8),t<9&&(dO(i),i.schema=9),t<10&&(aX(i),i.schema=10),t<11&&(lX(i),i.schema=11),t<12&&(dO(i),i.schema=12),t<13&&(cX(i),i.schema=13),t<14&&(hX(i),i.schema=14),t<15&&(dX(i),i.schema=15),t<16&&(fX(i),i.schema=16),t<17&&(wa(i,fO),Sa(i,fO),i.schema=17),t<18&&(wa(i,hO),Sa(i,hO),i.schema=18),t<19&&(Jq(i),i.schema=19),t<20&&(pX(i),gX(i),i.schema=20),t<21&&(yX(i),vX(i),i.schema=21),t<22&&(gO(i),i.schema=22),t<23&&(xX(i),i.schema=23),t<24&&(bX(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(uX(i),t<25&&(i.schema=25)),t<26&&(nX(i),i.schema=26),t<27&&(sX(i),i.schema=27),t<28&&(gO(i),i.schema=28),t<29&&(oX(i),i.schema=29),t<30&&(SX(i),i.schema=30),t<31&&(wX(i),i.schema=31),t<33&&(AX(i),i.schema=33),t<34&&(EX(i),i.schema=34),t<35&&(TX(i),i.schema=35),t<36&&(MX(i),i.schema=36),t<37&&(CX(i),i.schema=37),t<38&&(wa(i,pO),Sa(i,pO),i.schema=38),t<39&&(_X(i),i.schema=39),t<40&&(PX(i),i.schema=40),t<41&&(DX(i),i.schema=41),t<42&&(OX(i),i.schema=42),t<43&&(IX(i),i.schema=43),t<99){wa(i,vO),Sa(i,vO),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=ds);let e=Qr(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=wl,r.insertBefore(null,null,[{id:wl,data:{...ga.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Zn(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Zn(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ml.defaultData,...Zn(i.scene.environment,"usePhysics","gravity")},camera:Qr(i.scene.ownerCamera)??ga.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==xa.TRASH_CAN_ID&&r.move(wl,o.fi,o.id);let n=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(n,2)],n+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,El.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function bO(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function RX(i){i.scene.objects.traverse((t,e)=>{let r=e.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 LX(i){Array.isArray(Qr(i.events))&&i.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var td=180/Math.PI;function SO(i){i.rotation=i.rotation.slice(0,3).map(t=>t*td)}function wO(i){SO(i),i.type==="Page"&&SO(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*td))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*td),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*td),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=td,t.extrusion.twist*=td),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(Qr(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function NX(i){i.shared.variables=yn({},at.prototype)}function BX(i){let t=Qr(i.shared.variables);i.shared.variables=yn(Object.entries(t??{}).map(([e,r],n)=>({fi:n,id:e,data:r})),je.prototype)}var So=112;function AO(i,t){t(i.data);for(let e of i.children)AO(e,t)}function FX(i){let t=i.schema??104;t!==So&&t<105&&(AO(i.asset,wO),i.schema=105)}function UX(i){i.shared.particles=yn({},at.prototype),i.shared.lib&&(i.shared.lib.particles=ba.defaultData().particles)}function VX(i){i.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function zX(i){i.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function a0(i){let t=i.schema??0;if(t!==So){console.warn("updating from ",t,"to ",So),xO(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Vs.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(wa(i,bO),Sa(i,bO),i.schema=101),t<102&&(RX(i),i.schema=102),t<104&&(i.shared.catelogs=new at,i.shared.lib=ba.defaultData(),i.schema=104),t<105&&(NX(i),i.scene.objects.traverse((e,r)=>{wO(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))FX(e);t<106&&(BX(i),i.schema=106),t<107&&(i.shared.lib.variables=ba.defaultData().variables,i.schema=107),t<109&&(UX(i),i.schema=109),t<110&&(VX(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{LX(r)}),i.schema=111),t<112&&(zX(i),i.schema=112)}}var Zh;(l=>{l.defaultData={schema:So,scene:xa.defaultData,frames:new at().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Jh.defaultData),shared:{...bn.emptyData(),colors:bn.defaultColors()}},l.emptyDataForImports=function(){let c=xa.emptyDataWithPage();return{schema:So,scene:c,frames:new at().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Jh.defaultData),shared:{...bn.emptyData(),colors:bn.defaultColors(),images:bn.defaultImages()}}},l.emptyData=function(){return{schema:So,scene:xa.emptyDataWithPage(),frames:new at().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Jh.defaultData),shared:bn.emptyData()}},l.clipboard2dData=function(){return{schema:So,scene:xa.emptyData(),frames:new at,shared:bn.emptyData()}},l.collabHelper={...jp,updateSchema(c){return(c.schema??0)<So?yl(c,a0):(c.schema??0)-So}};function s(c){let u=l.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}l.updateSchemaDirectly=s;function o(c){return{...c,shared:{...c.shared,lib:ba.defaultData()}}}l.withoutLib=o;function a(c,u){let h=c.scene.objects.get(u);if(h&&h.data.type==="Component")return h;{let d=c.shared.lib.components[u];if(d)return d.asset}}l.getComponentData=a})(Zh||(Zh={}));var l0;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(l0||(l0={}));var EO;(t=>{function i(e){return!0}t.is=i})(EO||(EO={}));var c0;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(n,s){return{position:s?.position??n.position,rotation:s?.rotation??n.rotation,scale:s?.scale??n.scale,shear:s?.shear??n.shear}}r.merge=t;function e(n,s){return mv({position:Fs.isEqual(n.position,s.position)?void 0:s.position,rotation:n.rotation===s.rotation?void 0:s.rotation,scale:Fs.isEqual(n.scale,s.scale)?void 0:s.scale,shear:n.shear&&s.shear&&Fs.isEqual(n.shear,s.shear)?void 0:s.shear})}r.diff=e})(c0||(c0={}));var UA;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(UA||(UA={}));var u0;(t=>t.defaultData={opacity:1,fill:{color:It.fromHexAndA(ai,1),enabled:!0},stroke:{color:It.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:It.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:It.from0to1([0,0,0,1]),enabled:!1,spread:0}})(u0||(u0={}));var Aa;(s=>{function i(o,a){return{name:a}}s.newEmpty=i;function t(o,a){if(a===void 0)return o;let l={...o},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in a&&a[u]!==void 0&&Object.assign(l,{[u]:a[u]});return l}function e(o,a){if(a===void 0)return o;let l={...o};return"fill"in l&&"fill"in a&&a.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...a.fill}}),"stroke"in l&&"stroke"in a&&a.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...a.stroke}}),"layerBlur"in l&&"layerBlur"in a&&a.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...a.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in a&&a.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...a.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in a&&a.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...a.dropShadow}}),"innerShadow"in l&&"innerShadow"in a&&a.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...a.innerShadow}}),l}function r(o,a){if(a===void 0)return o;let l={...o};return Object.assign(l,c0.merge(l,a)),l=t(l,a),l=e(l,a),l}s.patch=r;function n(o,a){let l,c=[];for(let[u,h]of Object.entries(a))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=h);return c}s.toOps=n})(Aa||(Aa={}));var Zp;(t=>t.defaultData={...c0.defaultData,...UA.defaultData,states:new je,events:new je,visible:!0,raycastLock:!1})(Zp||(Zp={}));var rd;(t=>t.defaultData={...Zp.defaultData,...u0.defaultData})(rd||(rd={}));var h0;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(h0||(h0={}));var VA;(t=>t.defaultData={...rd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(VA||(VA={}));var id;(t=>t.defaultData={...rd.defaultData,...h0.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(id||(id={}));var zA;(t=>t.defaultData={...rd.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"})(zA||(zA={}));var kA;(t=>t.defaultData={...rd.defaultData,type:"path2d",path:"",name:"Path"})(kA||(kA={}));var TO;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(TO||(TO={}));var Jp;(t=>t.defaultData={...Zp.defaultData,name:"Group",type:"group2d"})(Jp||(Jp={}));var GA;(t=>t.defaultData=()=>({...Zp.defaultData,...h0.defaultData,...u0.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:It.fromHexAndA(4737101,1),enabled:!0},stroke:{color:It.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(GA||(GA={}));var Ea;(n=>{function i(s){switch(s){case"rectangle2d":return{...id.defaultData};case"ellipse2d":return{...VA.defaultData};case"text2d":return{...zA.defaultData};case"vector2d":return{...id.defaultData};case"path2d":return{...kA.defaultData};case"frame2d":return{...GA.defaultData()};case"group2d":return{...Jp.defaultData}}}n.defaultData=i;function t(s){return"width"in s&&"height"in s?[typeof s.width=="number"?s.width*.5:0,typeof s.height=="number"?s.height*.5:0]:[0,0]}n.getPivot=t;function e(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"}n.isResizeable=e;function r(s){return s.type==="rectangle2d"||s.type==="frame2d"}n.hasCorners=r})(Ea||(Ea={}));var d0;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Sr},e.emptyData=function(){return{type:"scene2d",objects:new Sr}}))(d0||(d0={}));function zs(i,t=!1){let e=i[0].index!==null,r=new Set(Object.keys(i[0].attributes)),n=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ne,c=0;for(let u=0;u<i.length;++u){let h=i[u],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() 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 f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,u),c+=f}}if(e){let u=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+u);u+=i[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=MO(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<h;++d){let f=[];for(let g=0;g<o[u].length;++g)f.push(o[u][g][d]);let p=MO(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(p)}}return l}function MO(i){let t,e,r,n=-1,s=0;for(let c=0;c<i.length;++c){let u=i[c];if(t===void 0&&(t=u.array.constructor),t!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=u.itemSize),e!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=u.gpuType),n!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=u.count*e}let o=new t(s),a=new Ye(o,e,r),l=0;for(let c=0;c<i.length;++c){let u=i[c];if(u.isInterleavedBufferAttribute){let h=l/e;for(let d=0,f=u.count;d<f;d++)for(let p=0;p<e;p++){let g=u.getComponent(d,p);a.setComponent(d+h,p,g)}}else o.set(u.array,l);l+=u.count*e}return n!==void 0&&(a.gpuType=n),a}var CO=Math.pow(2,-24);var Lc=class{constructor(){}};function ps(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function HA(i){let t=-1,e=-1/0;for(let r=0;r<3;r++){let n=i[r+3]-i[r];n>e&&(e=n,t=r)}return t}function jA(i,t){t.set(i)}function WA(i,t,e){let r,n;for(let s=0;s<3;s++){let o=s+3;r=i[s],n=t[s],e[s]=r<n?r:n,r=i[o],n=t[o],e[o]=r>n?r:n}}function $p(i,t,e){for(let r=0;r<3;r++){let n=t[i+2*r],s=t[i+2*r+1],o=n-s,a=n+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function nd(i){let t=i[3]-i[0],e=i[4]-i[1],r=i[5]-i[2];return 2*(t*e+e*r+r*t)}function HX(i,t){if(!i.index){let e=i.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n;e>65535?n=new Uint32Array(new r(4*e)):n=new Uint16Array(new r(2*e)),i.setIndex(new Ye(n,1));for(let s=0;s<e;s++)n[s]=s}}function jX(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let n of i.groups)e.add(n.start),e.add(n.start+n.count);let r=Array.from(e.values()).sort((n,s)=>n-s);for(let n=0;n<r.length-1;n++){let s=r[n],o=r[n+1];t.push({offset:s/3,count:(o-s)/3})}return t}function XA(i,t,e,r,n=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,g=-1/0,y=-1/0,m=n!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=i[v+0],S=i[v+1],w=b-S,E=b+S;w<s&&(s=w),E>l&&(l=E),m&&b<h&&(h=b),m&&b>p&&(p=b);let A=i[v+2],P=i[v+3],M=A-P,C=A+P;M<o&&(o=M),C>c&&(c=C),m&&A<d&&(d=A),m&&A>g&&(g=A);let O=i[v+4],L=i[v+5],D=O-L,B=O+L;D<a&&(a=D),B>u&&(u=B),m&&O<f&&(f=O),m&&O>y&&(y=O)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=c,r[5]=u,m&&(n[0]=h,n[1]=d,n[2]=f,n[3]=p,n[4]=g,n[5]=y)}function WX(i,t,e,r){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t*6,h=(t+e)*6;u<h;u+=6){let d=i[u+0];d<n&&(n=d),d>a&&(a=d);let f=i[u+2];f<s&&(s=f),f>l&&(l=f);let p=i[u+4];p<o&&(o=p),p>c&&(c=p)}r[0]=n,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function qX(i,t,e,r,n){let s=e,o=e+r-1,a=n.pos,l=n.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let c=0;c<3;c++){let u=i[s*3+c];i[s*3+c]=i[o*3+c],i[o*3+c]=u;let h=t[s*6+c*2+0];t[s*6+c*2+0]=t[o*6+c*2+0],t[o*6+c*2+0]=h;let d=t[s*6+c*2+1];t[s*6+c*2+1]=t[o*6+c*2+1],t[o*6+c*2+1]=d}s++,o--}else return s}}var Ta=32,XX=(i,t)=>i.candidate-t.candidate,_l=new Array(Ta).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),f0=new Float32Array(6);function YX(i,t,e,r,n,s){let o=-1,a=0;if(s===0)o=HA(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=HA(i),o!==-1&&(a=KX(e,r,n,o));else if(s===2){let l=nd(i),c=1.25*n,u=r*6,h=(r+n)*6;for(let d=0;d<3;d++){let f=t[d],y=(t[d+3]-f)/Ta;if(n<Ta/4){let m=[..._l];m.length=n;let v=0;for(let b=u;b<h;b+=6,v++){let S=m[v];S.candidate=e[b+2*d],S.count=0;let{bounds:w,leftCacheBounds:E,rightCacheBounds:A}=S;for(let P=0;P<3;P++)A[P]=1/0,A[P+3]=-1/0,E[P]=1/0,E[P+3]=-1/0,w[P]=1/0,w[P+3]=-1/0;$p(b,e,w)}m.sort(XX);let x=n;for(let b=0;b<x;b++){let S=m[b];for(;b+1<x&&m[b+1].candidate===S.candidate;)m.splice(b+1,1),x--}for(let b=u;b<h;b+=6){let S=e[b+2*d];for(let w=0;w<x;w++){let E=m[w];S>=E.candidate?$p(b,e,E.rightCacheBounds):($p(b,e,E.leftCacheBounds),E.count++)}}for(let b=0;b<x;b++){let S=m[b],w=S.count,E=n-S.count,A=S.leftCacheBounds,P=S.rightCacheBounds,M=0;w!==0&&(M=nd(A)/l);let C=0;E!==0&&(C=nd(P)/l);let O=1+1.25*(M*w+C*E);O<c&&(o=d,c=O,a=S.candidate)}}else{for(let x=0;x<Ta;x++){let b=_l[x];b.count=0,b.candidate=f+y+x*y;let S=b.bounds;for(let w=0;w<3;w++)S[w]=1/0,S[w+3]=-1/0}for(let x=u;x<h;x+=6){let w=~~((e[x+2*d]-f)/y);w>=Ta&&(w=Ta-1);let E=_l[w];E.count++,$p(x,e,E.bounds)}let m=_l[Ta-1];jA(m.bounds,m.rightCacheBounds);for(let x=Ta-2;x>=0;x--){let b=_l[x],S=_l[x+1];WA(b.bounds,S.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<Ta-1;x++){let b=_l[x],S=b.count,w=b.bounds,A=_l[x+1].rightCacheBounds;S!==0&&(v===0?jA(w,f0):WA(w,f0,f0)),v+=S;let P=0,M=0;v!==0&&(P=nd(f0)/l);let C=n-v;C!==0&&(M=nd(A)/l);let O=1+1.25*(P*v+M*C);O<c&&(o=d,c=O,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function KX(i,t,e,r){let n=0;for(let s=t,o=t+e;s<o;s++)n+=i[s*6+r*2];return n/e}function QX(i,t){let e=i.attributes.position,r=i.index.array,n=r.length/3,s=new Float32Array(n*6),o=e.normalized,a=e.array,l=e.offset||0,c=3;e.isInterleavedBufferAttribute&&(c=e.data.stride);let u=["getX","getY","getZ"];for(let h=0;h<n;h++){let d=h*3,f=h*6,p,g,y;o?(p=r[d+0],g=r[d+1],y=r[d+2]):(p=r[d+0]*c+l,g=r[d+1]*c+l,y=r[d+2]*c+l);for(let m=0;m<3;m++){let v,x,b;o?(v=e[u[m]](p),x=e[u[m]](g),b=e[u[m]](y)):(v=a[p+m],x=a[g+m],b=a[y+m]);let S=v;x<S&&(S=x),b<S&&(S=b);let w=v;x>w&&(w=x),b>w&&(w=b);let E=(w-S)/2,A=m*2;s[f+A+0]=S+E,s[f+A+1]=E+(Math.abs(S)+E)*CO,S<t[m]&&(t[m]=S),w>t[m+3]&&(t[m+3]=w)}}return s}function ZX(i,t){function e(m){d&&d(m/f)}function r(m,v,x,b=null,S=0){if(!p&&S>=l&&(p=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=u||S>=l)return e(v+x),m.offset=v,m.count=x,m;let w=YX(m.boundingData,b,o,v,x,h);if(w.axis===-1)return e(v+x),m.offset=v,m.count=x,m;let E=qX(a,o,v,x,w);if(E===v||E===v+x)e(v+x),m.offset=v,m.count=x;else{m.splitAxis=w.axis;let A=new Lc,P=v,M=E-v;m.left=A,A.boundingData=new Float32Array(6),XA(o,P,M,A.boundingData,s),r(A,P,M,s,S+1);let C=new Lc,O=E,L=x-M;m.right=C,C.boundingData=new Float32Array(6),XA(o,O,L,C.boundingData,s),r(C,O,L,s,S+1)}return m}HX(i,t);let n=new Float32Array(6),s=new Float32Array(6),o=QX(i,n),a=i.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,g=[],y=jX(i);if(y.length===1){let m=y[0],v=new Lc;v.boundingData=n,WX(o,m.offset,m.count,s),r(v,m.offset,m.count,s),g.push(v)}else for(let m of y){let v=new Lc;v.boundingData=new Float32Array(6),XA(o,m.offset,m.count,v.boundingData,s),r(v,m.offset,m.count,s),g.push(v)}return g}function DO(i,t){let e=ZX(i,t),r,n,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<e.length;u++){let h=e[u],d=l(h),f=new a(32*d);r=new Float32Array(f),n=new Uint32Array(f),s=new Uint16Array(f),c(0,h),o.push(f)}return o;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function c(u,h){let d=u/4,f=u/2,p=!!h.count,g=h.boundingData;for(let y=0;y<6;y++)r[d+y]=g[y];if(p){let y=h.offset,m=h.count;return n[d+6]=y,s[f+14]=m,s[f+15]=65535,u+32}else{let y=h.left,m=h.right,v=h.splitAxis,x;if(x=c(u+32,y),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=x/4,x=c(x,m),n[d+7]=v,x}}}var On=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,n=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}setFromPoints(t,e){let r=1/0,n=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};On.prototype.setFromBox=function(){let i=new T;return function(e,r){let n=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){i.x=n.x*l+s.x*(1-l),i.y=n.y*c+s.y*(1-c),i.z=n.z*u+s.z*(1-u);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var ope=function(){let i=new On;return function(e,r){let n=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,c=r.satBounds;for(let u=0;u<3;u++){let h=o[u],d=s[u];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let u=0;u<3;u++){let h=c[u],d=l[u];if(i.setFromPoints(d,n),h.isSeparated(i))return!1}}}();var JX=function(){let i=new T,t=new T,e=new T;return function(n,s,o){let a=n.start,l=i,c=s.start,u=t;e.subVectors(a,c),i.subVectors(n.end,n.start),t.subVectors(s.end,s.start);let h=e.dot(u),d=u.dot(l),f=u.dot(u),p=e.dot(l),y=l.dot(l)*f-d*d,m,v;y!==0?m=(h*d-p*f)/y:m=0,v=(h+m*d)/f,o.x=m,o.y=v}}(),em=function(){let i=new U,t=new T,e=new T;return function(n,s,o,a){JX(n,s,i);let l=i.x,c=i.y;if(l>=0&&l<=1&&c>=0&&c<=1){n.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=n.start:u=n.end;let h;c<0?h=s.start:h=s.end;let d=t,f=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),OO=function(){let i=new T,t=new T,e=new ii,r=new Ei;return function(s,o){let{radius:a,center:l}=s,{a:c,b:u,c:h}=o;if(r.start=c,r.end=u,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let g=o.getPlane(e);if(Math.abs(g.distanceToPoint(l))<=a){let m=g.projectPoint(l,t);if(o.containsPoint(m))return!0}return!1}}();var $X=1e-15;function sd(i){return Math.abs(i)<$X}var In=class extends Er{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new T),this.satBounds=new Array(4).fill().map(()=>new On),this.points=[this.a,this.b,this.c],this.sphere=new Or,this.plane=new ii,this.needsUpdate=!0}intersectsSphere(t){return OO(t,this)}update(){let t=this.a,e=this.b,r=this.c,n=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);let c=s[1],u=o[1];c.subVectors(t,e),u.setFromPoints(c,n);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,n);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};In.prototype.closestPointToSegment=function(){let i=new T,t=new T,e=new Ei;return function(n,s=null,o=null){let{start:a,end:l}=n,c=this.points,u,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[f]),em(e,n,i,t),u=i.distanceToSquared(t),u<h&&(h=u,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),u=a.distanceToSquared(i),u<h&&(h=u,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),u=l.distanceToSquared(i),u<h&&(h=u,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();In.prototype.intersectsTriangle=function(){let i=new In,t=new Array(3),e=new Array(3),r=new On,n=new On,s=new T,o=new T,a=new T,l=new T,c=new Ei,u=new Ei,h=new Ei;return function(f,p=null,g=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let y=this.plane,m=f.plane;if(Math.abs(y.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let w=0;w<4;w++){let E=v[w],A=x[w];if(r.setFromPoints(A,e),E.isSeparated(r))return!1}let b=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let E=b[w],A=S[w];if(r.setFromPoints(A,t),E.isSeparated(r))return!1}for(let w=0;w<4;w++){let E=x[w];for(let A=0;A<4;A++){let P=S[A];if(s.crossVectors(E,P),r.setFromPoints(s,t),n.setFromPoints(s,e),r.isSeparated(n))return!1}}return p&&(g||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 v=this.points,x=!1,b=0;for(let D=0;D<3;D++){let B=v[D],k=v[(D+1)%3];c.start.copy(B),c.end.copy(k),c.delta(o);let F=x?u.start:u.end,H=sd(m.distanceToPoint(B));if(sd(m.normal.dot(o))&&H){u.copy(c),b=2;break}if((m.intersectLine(c,F)||H)&&!sd(F.distanceTo(k))){if(b++,x)break;x=!0}}if(b===1&&f.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(b!==2)return!1;let S=f.points,w=!1,E=0;for(let D=0;D<3;D++){let B=S[D],k=S[(D+1)%3];c.start.copy(B),c.end.copy(k),c.delta(a);let F=w?h.start:h.end,H=sd(y.distanceToPoint(B));if(sd(y.normal.dot(a))&&H){h.copy(c),E=2;break}if((y.intersectLine(c,F)||H)&&!sd(F.distanceTo(k))){if(E++,w)break;w=!0}}if(E===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(E!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let D=h.start;h.start=h.end,h.end=D}let A=u.start.dot(o),P=u.end.dot(o),M=h.start.dot(o),C=h.end.dot(o),O=P<M,L=A<C;return A!==C&&M!==P&&O===L?!1:(p&&(l.subVectors(u.start,h.start),l.dot(o)>0?p.start.copy(u.start):p.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?p.end.copy(u.end):p.end.copy(h.end)),!0)}}}();In.prototype.distanceToPoint=function(){let i=new T;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();In.prototype.distanceToTriangle=function(){let i=new T,t=new T,e=["a","b","c"],r=new Ei,n=new Ei;return function(o,a=null,l=null){let c=a||l?r:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<u&&(u=d,a&&a.copy(i),l&&l.copy(p));let g=this[f];o.closestPointToPoint(g,i),d=g.distanceToSquared(i),d<u&&(u=d,a&&a.copy(g),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let p=0;p<3;p++){let g=e[p],y=e[(p+1)%3];n.set(o[g],o[y]),em(r,n,i,t);let m=i.distanceToSquared(t);m<u&&(u=m,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(u)}}();var Rn=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new T,this.max=new T,this.matrix=new ue,this.invMatrix=new ue,this.points=new Array(8).fill().map(()=>new T),this.satAxes=new Array(3).fill().map(()=>new T),this.satBounds=new Array(3).fill().map(()=>new On),this.alignedSatBounds=new Array(3).fill().map(()=>new On),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Rn.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,n=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let d=1*c|2*u|4*h,f=n[d];f.x=c?r.x:e.x,f.y=u?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=n[0];for(let c=0;c<3;c++){let u=o[c],h=s[c],d=1<<c,f=n[d];u.subVectors(a,f),h.setFromPoints(u,n)}let l=this.alignedSatBounds;l[0].setFromPointsField(n,"x"),l[1].setFromPointsField(n,"y"),l[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Rn.prototype.intersectsBox=function(){let i=new On;return function(e){this.needsUpdate&&this.update();let r=e.min,n=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=r.x,i.max=n.x,a[0].isSeparated(i)||(i.min=r.y,i.max=n.y,a[1].isSeparated(i))||(i.min=r.z,i.max=n.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let c=o[l],u=s[l];if(i.setFromBox(c,e),u.isSeparated(i))return!1}return!0}}();Rn.prototype.intersectsTriangle=function(){let i=new In,t=new Array(3),e=new On,r=new On,n=new T;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let c=o.satBounds,u=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=c[d],p=u[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let g=u[p];if(n.crossVectors(f,g),e.setFromPoints(n,t),r.setFromPoints(n,h),e.isSeparated(r))return!1}}return!0}}();Rn.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Rn.prototype.distanceToPoint=function(){let i=new T;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Rn.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Ei),e=new Array(12).fill().map(()=>new Ei),r=new T,n=new T;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(n),this.closestPointToPoint(n,r),o.closestPointToPoint(r,n),l&&l.copy(r),c&&c.copy(n)),0;let u=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let y=0;y<8;y++){let m=f[y];n.copy(m).clamp(h,d);let v=m.distanceToSquared(n);if(v<p&&(p=v,l&&l.copy(m),c&&c.copy(n),v<u))return Math.sqrt(v)}let g=0;for(let y=0;y<3;y++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let x=(y+1)%3,b=(y+2)%3,S=m<<x|v<<b,w=1<<y|m<<x|v<<b,E=f[S],A=f[w];t[g].set(E,A);let M=i[y],C=i[x],O=i[b],L=e[g],D=L.start,B=L.end;D[M]=h[M],D[C]=m?h[C]:d[C],D[O]=v?h[O]:d[C],B[M]=d[M],B[C]=m?h[C]:d[C],B[O]=v?h[O]:d[C],g++}for(let y=0;y<=1;y++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){n.x=y?d.x:h.x,n.y=m?d.y:h.y,n.z=v?d.z:h.z,this.closestPointToPoint(n,r);let x=n.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),c&&c.copy(n),x<u))return Math.sqrt(x)}for(let y=0;y<12;y++){let m=t[y];for(let v=0;v<12;v++){let x=e[v];em(m,x,r,n);let b=r.distanceToSquared(n);if(b<p&&(p=b,l&&l.copy(r),c&&c.copy(n),b<u))return Math.sqrt(b)}}return Math.sqrt(p)}}();var od=new T,ad=new T,ld=new T,m0=new U,g0=new U,y0=new U,IO=new T,RO=new T,LO=new T,v0=new T;function eY(i,t,e,r,n,s){let o;return s===ni?o=i.intersectTriangle(r,e,t,!0,n):o=i.intersectTriangle(t,e,r,s!==Bi,n),o===null?null:{distance:i.origin.distanceTo(n),point:n.clone()}}function tY(i,t,e,r,n,s,o,a,l){od.fromBufferAttribute(t,s),ad.fromBufferAttribute(t,o),ld.fromBufferAttribute(t,a);let c=eY(i,od,ad,ld,v0,l);if(c){r&&(m0.fromBufferAttribute(r,s),g0.fromBufferAttribute(r,o),y0.fromBufferAttribute(r,a),c.uv=Er.getInterpolation(v0,od,ad,ld,m0,g0,y0,new U)),n&&(m0.fromBufferAttribute(n,s),g0.fromBufferAttribute(n,o),y0.fromBufferAttribute(n,a),c.uv1=Er.getInterpolation(v0,od,ad,ld,m0,g0,y0,new U)),e&&(IO.fromBufferAttribute(e,s),RO.fromBufferAttribute(e,o),LO.fromBufferAttribute(e,a),c.normal=Er.getInterpolation(v0,od,ad,ld,IO,RO,LO,new T),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new T,materialIndex:0};Er.getNormal(od,ad,ld,u.normal),c.face=u,c.faceIndex=s}return c}function KA(i,t,e,r,n){let s=r*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:c,normal:u,uv:h,uv1:d}=i.attributes,f=tY(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,n&&n.push(f),f):null}function NO(i,t,e,r,n,s){for(let o=r,a=r+n;o<a;o++)KA(i,t,e,o,s)}function BO(i,t,e,r,n){let s=1/0,o=null;for(let a=r,l=r+n;a<l;a++){let c=KA(i,t,e,a);c&&c.distance<s&&(o=c,s=c.distance)}return o}function ms(i,t,e,r){let n=i.a,s=i.b,o=i.c,a=t,l=t+1,c=t+2;e&&(a=e.getX(t),l=e.getX(t+1),c=e.getX(t+2)),n.x=r.getX(a),n.y=r.getY(a),n.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(c),o.y=r.getY(c),o.z=r.getZ(c)}function QA(i,t,e,r,n,s,o){let a=e.index,l=e.attributes.position;for(let c=i,u=t+i;c<u;c++)if(ms(o,c*3,a,l),o.needsUpdate=!0,r(o,c,n,s))return!0;return!1}var cd=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Ma(i,t){return t[i+15]===65535}function Nc(i,t){return t[i+6]}function ud(i,t){return t[i+14]}function hd(i){return i+8}function dd(i,t){return t[i+6]}function FO(i,t){return t[i+7]}var fd=new zt,b0=new T,iY=["x","y","z"];function S0(i,t,e,r,n){let s=i*2,o=pd,a=Pl,l=Dl;if(Ma(s,a)){let u=Nc(i,l),h=ud(s,a);NO(t,e,r,u,h,n)}else{let u=hd(i);A0(u,o,r,b0)&&S0(u,t,e,r,n);let h=dd(i,l);A0(h,o,r,b0)&&S0(h,t,e,r,n)}}function w0(i,t,e,r){let n=i*2,s=pd,o=Pl,a=Dl;if(Ma(n,o)){let c=Nc(i,a),u=ud(n,o);return BO(t,e,r,c,u)}else{let c=FO(i,a),u=iY[c],d=r.direction[u]>=0,f,p;d?(f=hd(i),p=dd(i,a)):(f=dd(i,a),p=hd(i));let y=A0(f,s,r,b0)?w0(f,t,e,r):null;if(y){let x=y.point[u];if(d?x<=s[p+c]:x>=s[p+c+3])return y}let v=A0(p,s,r,b0)?w0(p,t,e,r):null;return y&&v?y.distance<=v.distance?y:v:y||v||null}}var UO=function(){let i,t,e=[],r=new cd(()=>new zt);return function(...o){i=r.getPrimitive(),t=r.getPrimitive(),e.push(i,t);let a=n(...o);r.releasePrimitive(i),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function n(s,o,a,l,c=null,u=0,h=0){function d(x){let b=x*2,S=Pl,w=Dl;for(;!Ma(b,S);)x=hd(x),b=x*2;return Nc(x,w)}function f(x){let b=x*2,S=Pl,w=Dl;for(;!Ma(b,S);)x=dd(x,w),b=x*2;return Nc(x,w)+ud(b,S)}let p=s*2,g=pd,y=Pl,m=Dl;if(Ma(p,y)){let x=Nc(s,m),b=ud(p,y);return ps(s,g,i),l(x,b,!1,h,u+s,i)}else{let x=hd(s),b=dd(s,m),S=x,w=b,E,A,P,M;if(c&&(P=i,M=t,ps(S,g,P),ps(w,g,M),E=c(P),A=c(M),A<E)){S=b,w=x;let F=E;E=A,A=F,P=M}P||(P=i,ps(S,g,P));let C=Ma(S*2,y),O=a(P,C,E,h+1,u+S),L;if(O===2){let F=d(S),G=f(S)-F;L=l(F,G,!0,h+1,u+S,P)}else L=O&&n(S,o,a,l,c,u,h+1);if(L)return!0;M=t,ps(w,g,M);let D=Ma(w*2,y),B=a(M,D,A,h+1,u+w),k;if(B===2){let F=d(w),G=f(w)-F;k=l(F,G,!0,h+1,u+w,M)}else k=B&&n(w,o,a,l,c,u,h+1);return!!k}}}(),VO=function(){let i=new In,t=new In,e=new ue,r=new Rn,n=new Rn;return function s(o,a,l,c,u=null){let h=o*2,d=pd,f=Pl,p=Dl;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),Ma(h,f)){let y=a,m=y.index,v=y.attributes.position,x=l.index,b=l.attributes.position,S=Nc(o,p),w=ud(h,f);if(e.copy(c).invert(),l.boundsTree)return ps(o,d,n),n.matrix.copy(e),n.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>n.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(c),A.b.applyMatrix4(c),A.c.applyMatrix4(c),A.needsUpdate=!0;for(let P=S*3,M=(w+S)*3;P<M;P+=3)if(ms(t,P,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let E=S*3,A=w+S*3;E<A;E+=3){ms(i,E,m,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let P=0,M=x.count;P<M;P+=3)if(ms(t,P,x,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let y=o+8,m=p[o+6];return ps(y,d,fd),!!(u.intersectsBox(fd)&&s(y,a,l,c,u)||(ps(m,d,fd),u.intersectsBox(fd)&&s(m,a,l,c,u)))}}}();function A0(i,t,e,r){return ps(i,t,fd),e.intersectBox(fd,r)}var ZA=[],x0,pd,Pl,Dl;function md(i){x0&&ZA.push(x0),x0=i,pd=new Float32Array(i),Pl=new Uint16Array(i),Dl=new Uint32Array(i)}function tm(){x0=null,pd=null,Pl=null,Dl=null,ZA.length&&md(ZA.pop())}var JA=Symbol("skip tree generation"),$A=new zt,eE=new zt,gd=new ue,Bc=new Rn,rm=new Rn,im=new T,E0=new T,nY=new T,sY=new T,oY=new T,zO=new zt,wo=new cd(()=>new In),Ao=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ao.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,n=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:n.map(a=>a.slice()),index:s.array.slice()}:o={roots:n,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ao.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:n,roots:s}=t,o=new Ao(e,{...r,[JA]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Ye(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[JA]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[JA]||(this._roots=DO(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new zt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,n=e.attributes.position,s,o,a,l,c=0,u=this._roots;for(let d=0,f=u.length;d<f;d++)s=u[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,c),c+=s.byteLength;function h(d,f,p=!1){let g=d*2;if(a[g+15]===65535){let m=o[d+6],v=a[g+14],x=1/0,b=1/0,S=1/0,w=-1/0,E=-1/0,A=-1/0;for(let P=3*m,M=3*(m+v);P<M;P++){let C=r[P],O=n.getX(C),L=n.getY(C),D=n.getZ(C);O<x&&(x=O),O>w&&(w=O),L<b&&(b=L),L>E&&(E=L),D<S&&(S=D),D>A&&(A=D)}return l[d+0]!==x||l[d+1]!==b||l[d+2]!==S||l[d+3]!==w||l[d+4]!==E||l[d+5]!==A?(l[d+0]=x,l[d+1]=b,l[d+2]=S,l[d+3]=w,l[d+4]=E,l[d+5]=A,!0):!1}else{let m=d+8,v=o[d+6],x=m+f,b=v+f,S=p,w=!1,E=!1;t?S||(w=t.has(x),E=t.has(b),S=!w&&!E):(w=!0,E=!0);let A=S||w,P=S||E,M=!1;A&&(M=h(m,f,S));let C=!1;P&&(C=h(v,f,S));let O=M||C;if(O)for(let L=0;L<3;L++){let D=m+L,B=v+L,k=l[D],F=l[D+3],H=l[B],G=l[B+3];l[d+L]=k<H?k:H,l[d+L+3]=F>G?F:G}return O}}}traverse(t,e=0){let r=this._roots[e],n=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let c=a*2,u=s[c+15]===65535;if(u){let h=n[a+6],d=s[c+14];t(l,u,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=n[a+6],f=n[a+7];t(l,u,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Hn){let r=this._roots,n=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=n.groups,c=o?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=a?e[l[u].materialIndex].side:c,f=s.length;if(md(r[u]),S0(0,n,d,t,s),tm(),a){let p=l[u].materialIndex;for(let g=f,y=s.length;g<y;g++)s[g].face.materialIndex=p}}return s}raycastFirst(t,e=Hn){let r=this._roots,n=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=n.groups,c=s?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=o?e[l[u].materialIndex].side:c;md(r[u]);let f=w0(0,n,d,t);tm(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[u].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,n=!1;for(let s of this._roots)if(md(s),n=VO(0,r,t,e),tm(),n)break;return n}shapecast(t,e,r){let n=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,g,y)=>{let m=p*3;return d(f,m,m+1,m+2,g,y)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=wo.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,p,g,y,m)=>d(f,p,g,y,m)?!0:QA(f,p,n,c,g,y,s)}else l||(c?l=(d,f,p,g)=>QA(d,f,n,c,p,g,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(md(d),u=UO(0,n,a,l,o,h),tm(),u)break;h+=d.byteLength}return wo.releasePrimitive(s),u}bvhcast(t,e,r){let{intersectsRanges:n,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,c=t.geometry.attributes.position;gd.copy(e).invert();let u=wo.getPrimitive(),h=wo.getPrimitive();if(s){let f=function(p,g,y,m,v,x,b,S){for(let w=y,E=y+m;w<E;w++){ms(h,w*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let A=p,P=p+g;A<P;A++)if(ms(u,A*3,o,a),u.needsUpdate=!0,s(u,h,A,w,v,x,b,S))return!0}return!1};if(n){let p=n;n=function(g,y,m,v,x,b,S,w){return p(g,y,m,v,x,b,S,w)?!0:f(g,y,m,v,x,b,S,w)}}else n=f}t.getBoundingBox(eE),eE.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>eE.intersectsBox(f),intersectsRange:(f,p,g,y,m,v)=>($A.copy(v),$A.applyMatrix4(gd),t.shapecast({intersectsBounds:x=>$A.intersectsBox(x),intersectsRange:(x,b,S,w,E)=>n(f,p,x,b,y,m,w,E)}))});return wo.releasePrimitive(u),wo.releasePrimitive(h),d}intersectsBox(t,e){return Bc.set(t.min,t.max,e),Bc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Bc.intersectsBox(r),intersectsTriangle:r=>Bc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Bc.set(t.boundingBox.min,t.boundingBox.max,e),Bc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=wo.getPrimitive(),f=wo.getPrimitive(),p=E0,g=nY,y=null,m=null;n&&(y=sY,m=oY);let v=1/0,x=null,b=null;return gd.copy(e).invert(),rm.matrix.copy(gd),this.shapecast({boundsTraverseOrder:S=>Bc.distanceToBox(S),intersectsBounds:(S,w,E)=>E<v&&E<o?(w&&(rm.min.copy(S.min),rm.max.copy(S.max),rm.needsUpdate=!0),!0):!1,intersectsRange:(S,w)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>rm.distanceToBox(E),intersectsBounds:(E,A,P)=>P<v&&P<o,intersectsRange:(E,A)=>{for(let P=E*3,M=(E+A)*3;P<M;P+=3){ms(f,P,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=S*3,O=(S+w)*3;C<O;C+=3){ms(d,C,c,l),d.needsUpdate=!0;let L=d.distanceToTriangle(f,p,y);if(L<v&&(g.copy(p),m&&m.copy(y),v=L,x=C/3,b=P/3),L<s)return!0}}}});{let E=h?h.count:u.count;for(let A=0,P=E;A<P;A+=3){ms(f,A,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=S*3,C=(S+w)*3;M<C;M+=3){ms(d,M,c,l),d.needsUpdate=!0;let O=d.distanceToTriangle(f,p,y);if(O<v&&(g.copy(p),m&&m.copy(y),v=O,x=M/3,b=A/3),O<s)return!0}}}}}),wo.releasePrimitive(d),wo.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(g):r.point=g.clone(),r.distance=v,r.faceIndex=x,n&&(n.point?n.point.copy(m):n.point=m.clone(),n.point.applyMatrix4(gd),g.applyMatrix4(gd),n.distance=g.sub(n.point).length(),n.faceIndex=b),r)}closestPointToPoint(t,e={},r=0,n=1/0){let s=r*r,o=n*n,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:u=>(im.copy(t).clamp(u.min,u.max),im.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,im);let d=t.distanceToSquared(im);return d<a&&(E0.copy(im),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(E0):e.point=E0.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{ps(0,new Float32Array(r),zO),t.union(zO)}),t}};var cf=qo(GO());var aY=.5*(Math.sqrt(3)-1),nm=(3-Math.sqrt(3))/6,lY=1/3,Eo=1/6,$pe=(Math.sqrt(5)-1)/4,eme=(5-Math.sqrt(5))/20,sm=i=>Math.floor(i)|0,HO=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]),rE=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 T0(i=Math.random){let t=WO(i),e=new Float64Array(t).map(n=>HO[n%12*2]),r=new Float64Array(t).map(n=>HO[n%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*aY,h=sm(s+u),d=sm(o+u),f=(h+d)*nm,p=h-f,g=d-f,y=s-p,m=o-g,v,x;y>m?(v=1,x=0):(v=0,x=1);let b=y-v+nm,S=m-x+nm,w=y-1+2*nm,E=m-1+2*nm,A=h&255,P=d&255,M=.5-y*y-m*m;if(M>=0){let L=A+t[P],D=e[L],B=r[L];M*=M,a=M*M*(D*y+B*m)}let C=.5-b*b-S*S;if(C>=0){let L=A+v+t[P+x],D=e[L],B=r[L];C*=C,l=C*C*(D*b+B*S)}let O=.5-w*w-E*E;if(O>=0){let L=A+1+t[P+1],D=e[L],B=r[L];O*=O,c=O*O*(D*w+B*E)}return 70*(a+l+c)}}function jO(i=Math.random){let t=WO(i),e=new Float64Array(t).map(s=>rE[s%12*3]),r=new Float64Array(t).map(s=>rE[s%12*3+1]),n=new Float64Array(t).map(s=>rE[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*lY,p=sm(o+f),g=sm(a+f),y=sm(l+f),m=(p+g+y)*Eo,v=p-m,x=g-m,b=y-m,S=o-v,w=a-x,E=l-b,A,P,M,C,O,L;S>=w?w>=E?(A=1,P=0,M=0,C=1,O=1,L=0):S>=E?(A=1,P=0,M=0,C=1,O=0,L=1):(A=0,P=0,M=1,C=1,O=0,L=1):w<E?(A=0,P=0,M=1,C=0,O=1,L=1):S<E?(A=0,P=1,M=0,C=0,O=1,L=1):(A=0,P=1,M=0,C=1,O=1,L=0);let D=S-A+Eo,B=w-P+Eo,k=E-M+Eo,F=S-C+2*Eo,H=w-O+2*Eo,G=E-L+2*Eo,X=S-1+3*Eo,Y=w-1+3*Eo,Z=E-1+3*Eo,le=p&255,j=g&255,K=y&255,ee=.6-S*S-w*w-E*E;if(ee<0)c=0;else{let se=le+t[j+t[K]];ee*=ee,c=ee*ee*(e[se]*S+r[se]*w+n[se]*E)}let re=.6-D*D-B*B-k*k;if(re<0)u=0;else{let se=le+A+t[j+P+t[K+M]];re*=re,u=re*re*(e[se]*D+r[se]*B+n[se]*k)}let te=.6-F*F-H*H-G*G;if(te<0)h=0;else{let se=le+C+t[j+O+t[K+L]];te*=te,h=te*te*(e[se]*F+r[se]*H+n[se]*G)}let $=.6-X*X-Y*Y-Z*Z;if($<0)d=0;else{let se=le+1+t[j+1+t[K+1]];$*=$,d=$*$*(e[se]*X+r[se]*Y+n[se]*Z)}return 32*(c+u+h+d)}}function WO(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),s=e[r];e[r]=e[n],e[n]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var ks=new Er,M0=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let s=1;ks.a.fromBufferAttribute(t,n),ks.b.fromBufferAttribute(t,n+1),ks.c.fromBufferAttribute(t,n+2),s*=ks.getArea(),e[n/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,s=-1;for(;r<=n;){let o=Math.ceil((r+n)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?n=o-1:r=o+1}return s}sampleFace(t,e,r){let n=this.randomFunction(),s=this.randomFunction();return n+s>1&&(n=1-n,s=1-s),ks.a.fromBufferAttribute(this.positionAttribute,t*3),ks.b.fromBufferAttribute(this.positionAttribute,t*3+1),ks.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ks.a,n).addScaledVector(ks.b,s).addScaledVector(ks.c,1-(n+s)),ks.getNormal(r),this}};var XO=qo(iE()),cY=new ue,uY=new ue,hY=new ue,yd;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(yd||(yd={}));var vd=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Rt&&(r=r.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===r)return!0;n=n.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),n)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,n=0){for(let s of this.children)yd.is(s)&&s.traverseObject(r,n+1)}traverseObject(r,n=0){if(r(this,n)!==!0)for(let o of this.children)yd.is(o)&&o.traverseObject(r,n+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,n=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,XO.SVD)(n),l=cY.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),c=uY.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),u=hY.copy(c).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,n){this.updateWorldMatrix(!0,!1);let s=new ue().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ue?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),n!==void 0&&(this.children.pop(),this.children.splice(n,0,r)),this}copy(r,n=!1){return super.copy(r,n),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,n,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var nE=class extends vd(Rt){},dY=i=>i.type==="Mesh",zr=class extends nE{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new zr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix),n.expand(),e+=1,r=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 dY(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Fc=new T,Uc=new T,xd=new ue,KO=[new T(-1,1,1),new T(-1,-1,1),new T(1,-1,1),new T(1,1,1),new T(-1,1,-1),new T(-1,-1,-1),new T(1,-1,-1),new T(1,1,-1)],fY=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],pY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],YO=(i,t,e)=>{i.updateEntityBoxSize(Fc,Uc),xd.copy(t).multiply(i.matrixWorld),Uc.x===0&&Uc.y===0&&Uc.z===0?e.push(new T(Fc.x,Fc.y,Fc.z).applyMatrix4(xd)):KO.forEach(r=>{e.push(r.clone().multiply(Uc).add(Fc).applyMatrix4(xd))})},om=class extends zt{constructor(){super(...arguments);this.matrix=new ue;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let s=[];return n===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new T);return}YO(o,r,s)}}):YO(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Uc).multiplyScalar(.5),this.getCenter(Fc),xd.copy(this.matrix).setPosition(Fc),this.vertices=KO.map(e=>e.clone().multiply(Uc).applyMatrix4(xd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=fY.map(([e,r])=>new Ei(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new T))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=pY.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Gs={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var oE=class extends xp{constructor(){super()}getPoints(t=12){let e=[],r,n=this.getCurveLengths(),o=n[n.length-1]/n.length;for(let a=0,l=this.curves;a<l.length;a++){let c=l[a],u=a===0?n[a]:n[a]-n[a-1],h=Math.ceil(t*u/o),d=c.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var aE=.001;function lE(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=aE}function sE(i,t){let e=new T(...i.position),r=new T(...i.controlNext.position),n=new T(...t.controlPrevious.position),s=new T(...t.position);return lE(e,r,s)&&lE(e,n,s)}function _0(i){let t=i.points.map(u=>new T(...u.data.position)),e=[i.points[0]],r=new T(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)lE(r,t[u],t[u+1])||(e.push(i.points[u]),r=t[u]);e.push(i.points[i.points.length-1]);let n=i.isClosed,s=e.length-(n?0:1),o=e.length,a=[];for(let u=0;u<o;u++){let h=e[u].data,d=new T(...h.position),f=new T(...h.controlPrevious.position),p=new T(...h.controlNext.position),g={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(u===0||u===o-1)){a[u]={...g,removedLength:0};continue}let y=n&&u==0?o-1:u-1,m=n&&u==o-1?0:u+1,v=e[y].data,x=e[m].data,b=new T(...v.position),S=new T(...x.position),w=b.clone().sub(d).normalize(),E=S.clone().sub(d).normalize();Object.assign(g,{prevDir:w,nextDir:E});let A=sE(v,h),P=sE(h,x);if(!A||!P)a[u]={...g,removedLength:0};else{let M=w.clone().add(E).normalize(),C=M.clone().cross(w).length()/w.dot(M);a[u]={...g,tan:C,removedLength:h.roundness/C}}}for(let u=0;u<s;u++){let h=u,d=n&&u===o-1?0:u+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let g=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,g/2),p.removedLength=Math.min(p.removedLength,g/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=n&&u===o-1?0:u+1,f=a[h],p=a[d],g=null;if(!sE(e[h].data,e[d].data))f.position.distanceTo(p.position)>aE&&(g=new xc(f.position,f.controlNext,p.controlPrevious,p.position));else{let y=f.position.clone(),m=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&m.add(p.prevDir.clone().setLength(p.removedLength))),y.distanceTo(m)>aE&&(g=new xc(y,y.clone().lerp(m,.3),m.clone().lerp(y,.3),m))}l[2*u+1]=g}for(let u=0;u<o;u++){let h=a[u];if(h.removedLength===0){l[2*u]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),g=h.tan*h.removedLength,y=h.prevDir.clone().add(h.nextDir).normalize(),m=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=y.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(v,2))).add(m),b=y.clone().multiplyScalar(-g).add(x),S=d.distanceTo(b)/d.distanceTo(m),w=h.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),E=w.clone().lerp(b,2),A=f.clone().lerp(w,4/3),P=p.clone().lerp(E,4/3);l[2*u]=new xc(f,A,P,p)}let c=new oE;return l.forEach(u=>{u&&c.add(u)}),c}var At;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(At||(At={}));var To=i=>At.is(i),mY={type:"completeState",isfromEntity:!0},gY=["x","y","z"],cE=new T,yY=new T().set(0,1,0),bd=i=>class extends vd(i){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 om;this._recursiveBBox=new om;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let n=this.children[r];if(At.is(n))return n}entityChildrenCount(){let r=this.children.length;for(;r--;)if(At.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let n=r.parent;if(At.is(n))r=n;else return}return r}forInstancesRec(r){this.instances.forEach(n=>{n.disposed||r(n),n.forInstancesRec(r)})}super_Entity(r,n){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=n,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,n,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ya.toOps(this.data,o.data).forEach(l=>{let c=Vh.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,n)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ya.patch(this.data,o),ya.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,n)}))}s&&this.updateTransformState(this.dataPatched,n),this.stateSelection=r,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(r,n){r.setScalar(0),n.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{To(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let n;return this.traverseEntity(s=>{s.uuid===r&&(n=s)}),n}traverseSortNextHelper(){let r=this.parent;if(r){let n=r.children,s=n.indexOf(this)+1;if(At.is(n[s]))return n[s];if(At.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&At.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let n=this;for(;r>0&&n!==null;)n=n.parent,r-=1;return n}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let n=this.parent;for(;n;){if(r===n)return!0;n=n.parent}return!1}countToAccestor(r){let n=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,n+=1}return n}forEachEntity(r){for(let n of this.children)To(n)&&r(n)}traverseEntityAncestors(r){this.traverseAncestors(n=>{At.is(n)&&r(n)})}traverseConcreteEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)To(o)&&o.isConcreteEntity&&o.traverseEntity(r,n+1)}traverseEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)To(o)&&o.traverseEntity(r,n+1)}traverseVisibleEntity(r){r(this);for(let n of this.children)To(n)&&n.visible&&n.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,n=!1){return super.copy(r,n),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>To(r))}isAncestorOf(r){if(this.uuid===r)return!1;let n=!1;return this.traverseEntity(s=>{s.uuid===r&&(n=!0)}),n}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x*_e.RAD2DEG,this.rotation.y*_e.RAD2DEG,this.rotation.z*_e.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Oh(n,r)}getTransformValues(r,n,s){return n[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,gY[a]])??o)}updateTransformState(r,n){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,n)),s=!0),r.rotation&&(cE.fromArray(this.getTransformValues("rotation",r,n)).multiplyScalar(_e.DEG2RAD),this.rotation.setFromVector3(cE),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,n)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Sl.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)At.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{At.is(r)&&r.disposeRecursively()})}toState(r=[]){let n={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Oh(n,r)}updateByObjUpdateOp(r,n){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},n,!1)}updateByOp(r,n,s,o){let a=this.data;this.data=n;let l=r,c=Ut(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Ur.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let h=Ur.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ya.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Ut(r.path,["overrides"])){let u=[],h=[...r.path];for(u.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)u.push(h[1]),h.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=s.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(fo.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Ur.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[g,y]of Object.entries(r.props))y===void 0&&(p===r.props&&(p={...r.props}),p[g]=f[g]);r={...r,props:p}}d.overrideData=Kh.resolve(n.overrides,u),d.updateByOp(r,Vr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let h;for(let d of bo.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of bo.rootOverrideProps)if(Ut(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=fo.filterOp(h.overrideData,u);d&&h.updateByOp(d,Vr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=fo.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=n:f=Vr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,n,s){if(this.dataPatched=n,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Us.is(r.props.type)&&Gs.changeEntityProptotype(this,n,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Gs.changeEntityProptotype(this,n,s);for(let o of this.children)At.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,n,s)}updateByPatchedOp(r,n,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),Ut(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(n.pathSnapping),Ut(r.path,["cloner"])!==null){let o=Vr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(n.cloner,s.scene):(this.setFromClonerState(n.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let n=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(n===null)return;let l=r.find(n);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=_0(c.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=u.getPointAt(h);if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ue;l.updateMatrixWorld();let p=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let g={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let y=new ue().extractRotation(l.matrixWorld),m=u.getTangentAt(h).applyMatrix4(y).add(d),v=new ue().lookAt(d,m,yY),x=cE.setFromEuler(new Ht().setFromRotationMatrix(v)).multiplyScalar(_e.RAD2DEG);g={...g,rotation:x.toArray()}}this.updateTransformState(g),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(mY)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let n=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return n=!0,!0}),n&&r.reloadSplats()}updateState_Entity(r,n){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(n?.scene),this.resetBBoxNeedsUpdate()),n&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,n),this.updateVisible(n.scene)),this.updateTransformState(r,n)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Gs.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,n){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Gs.Cloner(this,r),n.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,n.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var P0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=_e.clamp(e.thetaLength,0,360);let r=e.width/2,n=e.radiusTop??r,s=e.radiusBottom??r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ne,p.setAttribute("position",new Ie([],3))):h||f?p=new am(c,u,r,n,s,o,a,l*Math.PI/180,h,h,d,f):p=new Sc(c,u,r,n,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function Ol(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function QO(i){return new U(i.y,-i.x)}var am=class extends Ne{constructor(t,e,r,n,s,o,a,l,c,u,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let p=[],g=[],y=[],m=[],v=0,x=r/2,b=new T,S=new T;f&&t==0&&(t=c),f&&e==0&&(e=u);let w=new U(t,x),E=new U(e,-x),A=null,P=null,M=null,C=null,O=w.clone().sub(E),L=0,D=0,B=0;d>0&&(L=Math.min(t,e)*(1-d),D=t-L,B=e-L);let k=w.clone();k.x-=L;let F=Math.PI-O.angle(),H=O.angle(),G=Math.tan(H/2),X=Math.tan(F/2),Y=G+X,Z=d?Y:X,le=d?Y:G;if(c=Math.min(c,(t-D)/Z,O.length()/Y),u=Math.min(u,(e-B)/le,O.length()/Y),c>0){let $=c/G;A=w.clone().sub(new U($,c)),d&&(M=A.clone(),M.x-=L-Y*c),w.sub(O.clone().setLength($))}if(u>0){let $=u/X;P=E.clone().sub(new U($,-u)),E.add(O.clone().setLength($)),d&&(C=P.clone(),C.x-=L-Y*u,k.sub(O.clone().setLength($)))}O=w.clone().sub(E);let j=O.length()<.5,K=[];for(let $=0;$<=n;$++){let se=[],Se=$/n,W=Se*l+a,Ae=new U(Math.sin(W),Math.cos(W));C&&P?(ee(se,Se,Ae,F,u,C,-1,!0),ee(se,Se,Ae,H,u,P,-1,!1)):P?(re(se,Ae,P.x,0,-1),ee(se,Se,Ae,H,u,P,-1,!1)):o||re(se,Ae,e,B,-1);let xe=QO(O).normalize();if(Ol(xe,Ae,b),!j)for(let be=0;be<=s;be++){let Ee=be/s,De=O.clone().multiplyScalar(Ee).add(E);Ol(De,Ae,S),g.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),m.push(Se,.5+S.y/r),se.push(v++)}if(M&&A?(ee(se,Se,Ae,F,c,A,1,!1),ee(se,Se,Ae,H,c,M,1,!0)):A?(ee(se,Se,Ae,F,c,A,1,!1),re(se,Ae,A.x,0,1)):o||re(se,Ae,t,D,1),d&&!j){let be=QO(O).multiplyScalar(-1).normalize();Ol(be,Ae,b);for(let Ee=0;Ee<=s;Ee++){let De=Ee/s,Pe=O.clone().multiplyScalar(-De).add(k);Ol(Pe,Ae,S),g.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),m.push(Se,.5+S.y/r),se.push(v++)}}d&&!o&&se.push(se[0]),K.push(se)}for(let $=0;$<K.length-1;$++)for(let se=0;se<K[0].length-1;se++){if(o&&d&&se==s)continue;let Se=K[$][se],W=K[$+1][se],Ae=K[$+1][se+1],xe=K[$][se+1],be=g[Ae*3+0],Ee=g[Ae*3+2];p.push(Se,W,xe),(be!=0||Ee!=0)&&p.push(W,Ae,xe)}l<Math.PI*2&&(te(-1,K[0],a),te(1,K[K.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new Ie(g,3)),this.setAttribute("normal",new Ie(y,3)),this.setAttribute("uv",new Ie(m,2));function ee($,se,Se,W,Ae,xe,be,Ee){for(let De=0;De<h+1;De++){let Pe=De/h,Re=be<0?Pe:1-Pe;Ee&&(Re-=1),Re*=W;let ze=new U(Math.sin(Re),Math.cos(Re)*be),_=ze.clone().multiplyScalar(Ae).add(xe);Ol(_,Se,S),g.push(S.x,S.y,S.z),Ol(ze,Se,b),y.push(b.x,b.y,b.z),m.push(se,.5+S.y/r),$.push(v++)}}function re($,se,Se,W,Ae){let xe=new T,be=new U,Ee=[Se,W];Ae<0&&Ee.reverse();for(let De of Ee)be.set(De,x*Ae),Ol(be,se,xe),g.push(xe.x,xe.y,xe.z),y.push(0,Ae,0),m.push(.5,.5),$.push(v++)}function te($,se,Se){let W=new U(Math.sin(Se),Math.cos(Se)),Ae=new U(-Math.cos(Se),Math.sin(Se)),xe=new T,be=$<0?(Pe,Re,ze)=>p.push(Pe,Re,ze):(Pe,Re,ze)=>p.push(Pe,ze,Re),Ee=new U((t+e+D+B)/4,0);Ol(Ee,W,xe),g.push(xe.x,xe.y,xe.z),y.push(Ae.x,0,Ae.y),m.push(.5,.5);let De=v++;for(let Pe of se){let Re=g.slice(Pe*3,Pe*3+3);g.push(...Re),y.push(Ae.x,0,Ae.y);let ze=m.slice(Pe*2,Pe*2+2);m.push(...ze),v++}for(let Pe=De+1;Pe<v-1;Pe++)be(De,Pe,Pe+1);be(De,v-1,De+1)}}};var ZO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=_e.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ne,d.setAttribute("position",new Ie([],3))):c>0||u>0||l<360?d=new am(0,t/2,r,n,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new nl(t/2,r,n,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var JO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new mi(t,e,r,n,s,o):c=new hE(t,e,r,n,s,o,a,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},uE=Math.PI/2,hE=class extends Ne{constructor(t=1,e=1,r=1,n=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let c=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let u=[],h=[],d=[],f=[],p=0,g=0;y("z","y","x",-1,-1,r,e,t,o,s,0),y("z","y","x",1,-1,r,e,-t,o,s,1),y("x","z","y",1,1,t,r,e,n,o,2),y("x","z","y",1,-1,t,r,-e,n,o,3),y("x","y","z",1,-1,t,e,r,n,s,4),y("x","y","z",-1,-1,t,e,-r,n,s,5),a>0&&(m("z","y","x",-1,-1,1,r,e,t,o,0),m("z","y","x",1,-1,-1,r,e,t,o,1),m("z","y","x",-1,1,-1,r,e,t,o,1),m("z","y","x",1,1,1,r,e,t,o,0),m("x","y","z",-1,-1,-1,t,e,r,n,0),m("x","y","z",1,-1,1,t,e,r,n,1),m("x","y","z",-1,1,1,t,e,r,n,0),m("x","y","z",1,1,-1,t,e,r,n,1),m("y","x","z",-1,-1,1,e,t,r,s,0),m("y","x","z",1,-1,-1,e,t,r,s,1),m("y","x","z",1,1,1,e,t,r,s,1),m("y","x","z",-1,1,-1,e,t,r,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new Ie(h,3)),this.setAttribute("normal",new Ie(d,3)),this.setAttribute("uv",new Ie(f,2));function y(x,b,S,w,E,A,P,M,C,O,L){let D=(A-2*a)/C,B=(P-2*a)/O,k=A/2-a,F=P/2-a,H=M/2,G=C+1,X=O+1,Y=0,Z=0,le=new T;for(let j=0;j<X;j++){let K=j*B-F;for(let ee=0;ee<G;ee++){let re=ee*D-k;le[x]=re*w,le[b]=K*E,le[S]=H,h.push(le.x,le.y,le.z),le[x]=0,le[b]=0,le[S]=M>0?1:-1,d.push(le.x,le.y,le.z),f.push(ee/C),f.push(1-j/O),Y+=1}}for(let j=0;j<O;j++)for(let K=0;K<C;K++){let ee=p+K+G*j,re=p+K+G*(j+1),te=p+(K+1)+G*(j+1),$=p+(K+1)+G*j;u.push(ee,re,$),u.push(re,te,$),Z+=6}c.addGroup(g,Z,L),g+=Z,p+=Y}function m(x,b,S,w,E,A,P,M,C,O,L){let D=(P-2*a)/O,B=P/2-a,k=M/2-a,F=C/2,H=O+1,G=0,X=0,Y=new T,Z=new T;for(let le=0;le<l+1;le++){let j=le/l*uE,K=Math.sin(j)*a,ee=(1-Math.cos(j))*a,re=Math.sin(j),te=Math.cos(j);Y[b]=(k+K)*E,Y[S]=(F-ee)*A,Z[x]=0,Z[b]=re*Math.sign(Y[b]),Z[S]=te*Math.sign(Y[S]);for(let $=0;$<H;$++){let se=$*D-B;Y[x]=se*w,h.push(Y.x,Y.y,Y.z),d.push(Z.x,Z.y,Z.z),f.push($/O),f.push(0),G+=1}}for(let le=0;le<l;le++)for(let j=0;j<O;j++){let K=p+j+H*le,ee=p+j+H*(le+1),re=p+(j+1)+H*(le+1),te=p+(j+1)+H*le;u.push(K,ee,te),u.push(ee,re,te),X+=6}c.addGroup(g,X,L),g+=X,p+=G}function v(x,b,S){let w=new T,E=new T(t/2,e/2,r/2);E.subScalar(a);let A=[],P=x*b*S>0?(C,O,L)=>u.push(C,O,L):(C,O,L)=>u.push(C,L,O);for(let C=0;C<=l;C++){let O=[],L=uE*(1-C/l),D=Math.cos(L),B=Math.sin(L),k=0;for(let F=0;F<=C;F++){let H=Math.cos(k),G=Math.sin(k);w.x=D*H,w.y=B,w.z=D*G;let X=E.clone().addScaledVector(w,a);h.push(x*X.x,b*X.y,S*X.z),d.push(x*w.x,b*w.y,S*w.z),f.push(0,0),O.push(p++),k+=uE/C}A.push(O)}let M=A.length-1;for(let C=0;C<M;C++){let O=A[C],L=A[C+1],D=O.length-1;P(O[0],L[1],L[0]);for(let B=1;B<=D;B++)P(O[B-1],O[B],L[B]),P(O[B],L[B+1],L[B])}}}};var Il=class extends Ne{constructor(t=[],e=[],r="",n=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Ie(a,3)),this.setAttribute("normal",new Ie(c,3)),this.setAttribute("uv",new Ie(l,2));return;function u(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],p=new T,g=p.clone(),y=new Er,m=s*n,v=n-m,x=o+1,b=new T,S=(G,X)=>b.subVectors(G,X).normalize(),w=(G,X)=>Array(G).fill(void 0).map(X),E=w(t.length/3,(G,X)=>new T().fromArray(t,X*3).setLength(n)),A=[],P=1e6;for(let G=0;G<E.length;G++){let X=E[G],Y=[],Z,le,j,K=1e10,ee=-1;for(;(ee=e.indexOf(G,ee+1))!=-1;){let se=ee-ee%3;Z=e[se+(ee+1)%3],le=e[se+(ee+2)%3],j=X.distanceToSquared(E[Z]),K=Math.min(K,j),Y.push([Z,le,j])}K+=1e-6;let re=[],te=0,$=Y.length;for(let se=0;se<$;se++){[Z,le,j]=Y[te];let Se=A[Z]?.includes(G)==!0;j<=K&&re.push(Z+ +Se*P),te=Y.findIndex(W=>W[0]==le)}A.push(re)}let M=[];{let G=0,X=0,Y,Z,le=f==3;for(let j=0;j<=o;j++){Y=j*(j+1)/2,Z=(j+1)*(j+2)/2;for(let K=0;K<o-j;K++)[G,X]=[Y+K+j+2,Z+K+j+3],M.push(Y,Z,...le?[X,Y]:[G,Z],X,G),[Y,Z]=[G,X];M.push(Y,Z,Y+o+2)}}let C=p.clone(),O=p.clone(),L=p.clone(),D=p.clone(),B=p.clone(),k=[],F=w(E.length,()=>w(f,()=>p.clone()));for(let G=0;G<E.length;G++){p.copy(E[G]).normalize(),C.copy(p).multiplyScalar(v);let X=A[G];for(let re=0;re<X.length;re++){let te=X[re],$=X[(re+1)%f];y.setFromPointsAndIndices(E,G,te%P,$%P),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(C,F[G][re])}let Y=[],Z=[],le=[],j=new T;o==0&&[...F[G]].reduce((re,te)=>re.add(te),j).multiplyScalar(1/f);for(let re=0;re<f;re++){let te=[],$=(re-1+f)%f,se=F[G][$],Se=F[G][re];p.copy(se).sub(C),g.copy(Se).sub(C);let W=C.angleTo(p),Ae=p.angleTo(g),xe=Math.cos(W)*m;o==0?O.copy(j):O.copy(C).setLength(v+xe),Z.push(xe);let be=[O,se,Se];for(let Ee=0;Ee<2;Ee++){let De=be[Ee],Pe=be[Ee+1];D.subVectors(De,C),B.subVectors(Pe,C),L.crossVectors(D,B).normalize();for(let Re=0;Re<x;Re++){let ze=[W,Ae][Ee]*Re/x;p.copy(D).applyAxisAngle(L,ze).add(C),Y.push(p.clone()),Ee&&(S(p,C),te.push([Re==0?De:p.clone(),b.clone()]))}Ee&&(S(Pe,C),te.push([Pe,b.clone()]))}le.push(te)}k.push(le);let K=2*x,ee=2;for(let re=0;re<f;re++){let te=K*re,$=K*((re+1)%f),se=[Y[te]];for(let W=1;W<x;W++){D=Y[te+W],B=Y[$+W],se.push(D);for(let Ae=1,xe=W-ee+1;Ae<=xe;Ae++)p.lerpVectors(D,B,Ae/(xe+1)),p.sub(C).setLength(Z[re]).add(C),se.push(p.clone());se.push(B)}for(let W=0;W<x;W++)se.push(Y[W+x+te]);se.push(Y[$+x]);let Se=M.map(W=>se[W]);a.push(...Se.map(W=>[W.x,W.y,W.z]).flat()),c.push(...Se.map(W=>(S(W,C),[b.x,b.y,b.z])).flat())}}let H=[];for(let G=0;G<A.length;G++)for(let X=0;X<f;X++){let Y=A[G][X];if(Y<P){let Z=A[Y].findIndex(K=>K%P==G),le=k[G][X],j=k[Y][Z];for(let K=0;K<x;K++){let ee=le[K],re=j[x-K],te=le[K+1],$=j[x-(K+1)];[ee,re,te,te,re,$].forEach(se=>{a.push(se[0].x,se[0].y,se[0].z),c.push(se[1].x,se[1].y,se[1].z)})}H.push(le[0][0],j[x][0],le[x][0],j[0][0])}}for(;H.length;){let G,X,Y,Z;[G,X]=H.splice(0,2);let le=[G];for(;G!=X;)le.push(X),Y=H.indexOf(X),Z=Y%2,X=H.splice(Y-Z,2)[1-Z];b.subVectors(le[0],le[1]).cross(p.subVectors(le[0],le[2])).normalize();let j=b.dot(le[0])<0;j&&b.negate();for(let K=1;K<=le.length-2;K++)[le[K+ +j],le[K+1-+j],le[0]].forEach(ee=>{a.push(ee.x,ee.y,ee.z),c.push(b.x,b.y,b.z)})}}function h(){let d=new T;for(let E=0;E<a.length;E+=3){d.x=a[E+0],d.y=a[E+1],d.z=a[E+2];let A=S(d)/2/Math.PI+.5,P=w(d)/Math.PI+.5;l.push(A,1-P)}let f=new T,p=new T,g=new T,y=new T,m=new U,v=new U,x=new U,b=(E,A,P,M)=>{M<0&&E.x===1&&(l[A]=E.x-1),P.x===0&&P.z===0&&(l[A]=M/2/Math.PI+.5)};for(let E=0,A=0;E<a.length;E+=9,A+=6){f.set(a[E+0],a[E+1],a[E+2]),p.set(a[E+3],a[E+4],a[E+5]),g.set(a[E+6],a[E+7],a[E+8]),m.set(l[A+0],l[A+1]),v.set(l[A+2],l[A+3]),x.set(l[A+4],l[A+5]),y.copy(f).add(p).add(g).divideScalar(3);let P=S(y);b(m,A+0,f,P),b(v,A+2,p,P),b(x,A+4,g,P)}for(let E=0;E<l.length;E+=6){let A=l[E+0],P=l[E+2],M=l[E+4],C=Math.max(A,P,M),O=Math.min(A,P,M);C>.9&&O<.1&&(A<.2&&(l[E+0]+=1),P<.2&&(l[E+2]+=1),M<.2&&(l[E+4]+=1))}function S(E){return Math.atan2(E.z,-E.x)}function w(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new Il(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var $O=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new lm(t*.5,s,o):new Gu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},lm=class extends Il{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new lm(t.radius,t.corner,t.cornerSides)}};var cm=1e-12,Sd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=_e.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Sd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},wd=class extends Sd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new wd(this.parent).copy(this)}},Hs=class extends Sd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new wd(this),new wd(this))}static create(e,r){let n=new Hs(e,new U(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,s=this.controls.length;n<s;n++){let o=this.controls[n];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Hs(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new U,r=new U){let[n,s]=this.computeTangents();return n&&s&&(eI(n,e),eI(s,r)),[e,r]}computeTangent(e=new U){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new U){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function eI(i,t=new U){let e=i.length();return t.set(-i.y/e,i.x/e)}var fE=i=>i,Ad=new U,D0=new U,vY=new U,xY=new U,bY=new U,SY=new U,rI=new T,iI=new T;function nI(i){let t=new U;t.addVectors(i.v0,Ad.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(i.v2,D0.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new on(i.v0,t,e,i.v2)}function um(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function wY(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function AY(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function pE(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function sI(i,t,e){return tI(i,t)&&tI(t,e)&&dE(i.position,t.position,e.position)}function dE(i,t,e){return Ad.copy(t).sub(i).cross(D0.copy(e).sub(i))===0}function oI(i,t,e,r,n){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,c=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return r.set(a+l,o+c),n.set(a-l,o-c),[r,n]}function aI(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function lI(i,t,e,r,n,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),h;return pE(t,i,e)>Math.PI&&(u*=-1),um(c,a)?h=(a+c)*(r/u-.5)*8/3/(o-l):h=(o+l)*(r/u-.5)*8/3/(c-a),n.set(t.x-h*a,t.y+h*o),s.set(e.x+h*c,e.y-h*l),[n,s]}function mE(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function tI(i,t){return dE(i.position,i.controls[1].position,t.position)&&dE(i.position,t.controls[0].position,t.position)}function cI(i,t,e,r,n=.5){let s=Ad.subVectors(t,i).multiplyScalar(n).add(i),o=D0.subVectors(e,t).multiplyScalar(n).add(t),a=vY.subVectors(r,e).multiplyScalar(n).add(e),l=s,c=xY.subVectors(o,s).multiplyScalar(n).add(s),u=bY.subVectors(a,o).multiplyScalar(n).add(o),h=a,d=SY.subVectors(u,c).multiplyScalar(n).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,r.x,r.y]}function uI(i,t,e=12,r=!0){let n=iI.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=fE(t[l]),u=Ad,h=Rl(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof on||c instanceof Xn||c instanceof mn){if(c.getPoint(d/h,u),n.set(u.x,u.y,0),s!==void 0&&AY(s,n))continue;s===void 0&&(s=rI),s.copy(n),i.setXYZ(o,n.x,n.y,n.z),o++}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function hI(i,t,e,r=12,n=!0){let s=iI.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=fE(t[l]),h=Ad,d=Rl(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof on||u instanceof Xn||u instanceof mn){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=rI:(i.setXYZ(o,c.x,c.y,c.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function gE(i,t=12,e=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let o=i[n],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Rl(o.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Rl(o.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Rl(i[0].roundedCurveCorner,t)*.5),r}function Rl(i,t=12){return i&&i instanceof vc?t*2:i&&(i instanceof mn||i instanceof vp)?1:i&&i instanceof Vu?t*i.points.length:t}function dI(i,t,e=12,r=!0){let n,s=0;for(let o=0;o<t.length;o++){let a=fE(t[o]),l=Rl(a,e),c=Ad;for(let u=0;u<=l;u++)if(a instanceof on||a instanceof Xn||a instanceof mn){if(a.getPoint(u/l,c),n!==void 0&&wY(n,c,cm))continue;n===void 0&&(n=D0),n.copy(c),i.push(c.x,c.y),s++}}return um(i[0],i[i.length-2],cm)&&um(i[1],i[i.length-1],cm)&&(i.pop(),i.pop()),r&&s>1&&!(um(i[s-1],i[1],cm)&&um(i[s-2],i[0],cm))&&(i.push(i[0],i[1]),s++),i}var yE=new U,EY=new U,TY=new U,MY=new U,CY=new U,_Y=new U,Yt=class extends oa{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new ii(new T(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=_e.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let s=new Yt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Hs.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Yt.createFromState(o)),r!==void 0&&n!==void 0&&s.applySize(r,n),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(s=>s.uuid===e);if(n<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length,u=l.getPointIndexById(e);if(u<0)s+=c;else return u+s}}return n}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=yE.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(n),a.controls[0].position.multiply(n),a.controls[1].position.multiply(n)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,n=_e.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new Hs(n,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=n?this.roundedCurveDivisions:this.curveDivisions;return uI(e,n?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=gE(this.points,e,!1),this.roundedCurveDivisions=gE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return hI(e,this.curves,r,n,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),dI(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=Rl(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let u=s[l];if(a<n+u)return[l,(a-n+1)/u];n+=u}return[0,1]}getCurveT(e,r,n){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(mE(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(yE.set(n.x,n.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){mE(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let s=n.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,s=this.points.length;n<s;n++){let o=this.points[n],a=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],c=o.roundness,u=a&&l&&sI(a,o,l);if(!o.controlsMoved()&&c>0&&!u){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,g=h.getLength(),y=d.getLength(),m=Math.min(c,g*.499),v=Math.min(c,y*.499),x=Math.min(m,v),b=1-x/g,S=x/y,w=h.getPointAt(b,yE),E=d.getPointAt(S,EY);this._subSplitCurve(h,f,b,w,void 0),this._subSplitCurve(d,p,S,void 0,E);let A;if(this.useCubicForRoundedCorners){let P=pE(w,o.position,E)/2,M=Math.tan(P)*w.distanceTo(o.position),[C,O]=oI(w,E,M,TY,MY),L=aI(C,O,o.position),[D,B]=lI(L,w,E,M,CY,_Y);A=new on(w.clone(),D.clone(),B.clone(),E.clone())}else A=new Xn(w.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=A,this.roundedCurves.splice(n+r,0,A),r++}}}}_subSplitCurve(e,r,n,s,o){if(e instanceof mn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,c=a.getUtoTmapping(n,0),u=cI(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),o!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new Yt(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let n=0;n<r;n++){let s=n*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],c=e.points[s+3],u=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new Hs(_e.generateUUID(),new U(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(u,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let s=new Yt;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(o,a)=>{a instanceof on&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,c;for(l=0,c=o.length;l<c;l++)o[l]instanceof Xn&&(o[l]=nI(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof on?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof mn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&n(p,f),a.push(p))}let u=o[o.length-1],h=!1;return u instanceof on?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof mn&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof oa&&(this.shapeHoles=e.holes.map(o=>{let a=new Yt;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var xE=Math.PI*2;function vE({x:i,y:t},e,r,n,s){return{x:i*e+n,y:t*r+s}}function PY(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function fI(i,t,e,r){let n=i*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(s)}function DY(i,t,e,r,n,s,o,a,l,c){let u=Math.pow(n,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let g=p*n/s*a,y=p*-s/n*o,m=g+(i+e)/2,v=y+(t+r)/2,x=(o-g)/n,b=(a-y)/s,S=(-o-g)/n,w=(-a-y)/s,E=fI(1,0,x,b),A=fI(x,b,S,w);return!c&&A>0&&(A-=xE),c&&A<0&&(A+=xE),{centerx:m,centery:v,ang1:E,ang2:A}}function pI({px:i,py:t,cx:e,cy:r,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(n===0||s===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];n=Math.abs(n),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(n,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(n*=Math.sqrt(h),s*=Math.sqrt(h));let d=DY(i,t,e,r,n,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:g,centery:y}=d,m=Math.abs(p)/(xE/4);Math.abs(1-m)<1e-7&&(m=1);let v=Math.max(Math.ceil(m),1);p/=v;for(let x=0;x<v;x++)l.push(PY(f,p)),f+=p;return l.map(x=>{let{x:b,y:S}=vE(x[0],n,s,g,y),{x:w,y:E}=vE(x[1],n,s,g,y),{x:A,y:P}=vE(x[2],n,s,g,y);return{x1:b,y1:S,x2:w,y2:E,x:A,y:P}})}var jt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(jt||(jt={}));var jr;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(jr||(jr={}));function dt(i,t){if(!i)throw t||"Assertion Failed!"}var lt=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){dt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?n<s?e.t-t.t+(t.t-r.t)*(n/(n+s)):e.t-r.t+(r.t-t.t)*(s/(n+s)):0},i.edgeSign=function(t,e,r){dt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?(e.t-r.t)*n+(e.t-t.t)*s:0},i.transEval=function(t,e,r){dt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?n<s?e.s-t.s+(t.s-r.s)*(n/(n+s)):e.s-r.s+(r.s-t.s)*(s/(n+s)):0},i.transSign=function(t,e,r){dt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?(e.s-r.s)*n+(e.s-t.s)*s:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(o=i.edgeEval(t,r,e),a=i.edgeEval(r,e,n),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,e.s)):(o=i.edgeSign(t,r,e),a=-i.edgeSign(t,n,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,n.s)):s.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(o=i.transEval(t,r,e),a=i.transEval(r,e,n),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,e.t)):(o=i.transSign(t,r,e),a=-i.transSign(t,n,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,n.t)):s.t=(r.t+e.t)/2},i}(),hm=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),O0=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Ed=function(){function i(){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 i}(),mI=function(){function i(){var t=new Ed,e=new hm,r=new O0(0),n=new O0(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new O0(0),r=new O0(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;dt(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e;var o=e;do o.Org=n,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;dt(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var o=e;do o.Lface=n,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Ed,e=new Ed,r=new hm,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var s=new Ed;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new hm;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=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 n=new hm;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new Ed;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),s=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(s,e),n.Org=t.Dst,s.Org=e.Org,n.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new hm;this.makeFace_(o,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,s,o,a;n=e.Lnext;do r=n,n=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&lt.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&lt.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,s,o,a,l,c;for(s=t,s=t;(n=s.next)!==t;s=n){dt(n.prev===s),l=n.anEdge;do dt(l.Sym!==l),dt(l.Sym.Sym===l),dt(l.Lnext.Onext.Sym===l),dt(l.Onext.Sym.Lnext===l),dt(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(dt(n.prev===s&&n.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){dt(o.prev===a),l=o.anEdge;do dt(l.Sym!==l),dt(l.Sym.Sym===l),dt(l.Lnext.Onext.Sym===l),dt(l.Onext.Sym.Lnext===l),dt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(dt(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)dt(l.Sym.next===c.Sym),dt(l.Sym!==l),dt(l.Sym.Sym===l),dt(l.Org!==null),dt(l.Dst!==null),dt(l.Lnext.Onext.Sym===l),dt(l.Onext.Sym.Lnext===l);dt(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),gI=function(){function i(){this.handle=null}return i}(),yI=function(){function i(){this.key=null,this.node=0}return i}(),OY=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new gI,this.handles[r]=new yI;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,dt(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[n].key,r[s].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new gI;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new yI}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;dt(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),bE=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),vI=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),IY=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new vI,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new vI;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),RY=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,s=e.eUp,o=r.eUp;if(s.Dst===n)return o.Dst===n?lt.vertLeq(s.Org,o.Org)?lt.edgeSign(o.Dst,s.Org,o.Org)<=0:lt.edgeSign(s.Dst,o.Org,s.Org)>=0:lt.edgeSign(o.Dst,n,o.Org)<=0;if(o.Dst===n)return lt.edgeSign(s.Dst,n,s.Org)>=0;var a=lt.edgeEval(s.Dst,n,s.Org),l=lt.edgeEval(o.Dst,n,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&dt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){dt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new bE;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case jt.ODD:return(e&1)!==0;case jt.NONZERO:return e!==0;case jt.POSITIVE:return e>0;case jt.NEGATIVE:return e<0;case jt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),n=s.eUp,n.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),i.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,r,n,s,o){var a,l,c,u,h=!0;c=r;do dt(lt.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==n);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,u=s;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,dt(l.windingNumber-c.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=lt.vertL1dist(e,t),s=lt.vertL1dist(r,t),o=.5*s/(n+s),a=.5*n/(n+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,n,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp;if(lt.vertLeq(n.Org,s.Org)){if(lt.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;lt.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),e.dirty=r.dirty=!0)}else{if(lt.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o;if(dt(!lt.vertEq(n.Dst,s.Dst)),lt.vertLeq(n.Dst,s.Dst)){if(lt.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(n),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(lt.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(n.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o=n.Org,a=s.Org,l=n.Dst,c=s.Dst,u,h,d=new Ed,f,p;if(dt(!lt.vertEq(c,l)),dt(lt.edgeSign(l,t.event,o)<=0),dt(lt.edgeSign(c,t.event,a)>=0),dt(o!==t.event&&a!==t.event),dt(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(lt.vertLeq(o,a)){if(lt.edgeSign(c,o,a)>0)return!1}else if(lt.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),lt.intersect(l,o,c,a,d),dt(Math.min(o.t,l.t)<=d.t),dt(d.t<=Math.max(a.t,c.t)),dt(Math.min(c.s,l.s)<=d.s),dt(d.s<=Math.max(a.s,o.s)),lt.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=lt.vertLeq(o,a)?o:a,lt.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),lt.vertEq(d,o)||lt.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!lt.vertEq(l,t.event)&&lt.edgeSign(l,t.event,d)>=0||!lt.vertEq(c,t.event)&&lt.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Lnext,s.Oprev),r=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,s.Onext,n.Rprev,p,!0),!0):(lt.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),lt.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,n),n.Org.s=d.s,n.Org.t=d.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,o,l,a,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,s;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(s),r=i.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,s=r.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),lt.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),c=!0),lt.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,o,null),c=!0),c){i.addRightEdges(t,e,r.Onext,s,s,!0);return}lt.vertLeq(l.Org,a.Org)?n=l.Oprev:n=a,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,s,o,a,l;if(n=e.eUp,lt.vertEq(n.Org,r)){dt(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!lt.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}dt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(dt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),lt.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var r,n,s,o,a,l,c=new bE;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,n=i.regionBelow(r),!!n){if(o=r.eUp,a=n.eUp,lt.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(s=lt.vertLeq(a.Dst,o.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);dt(n!==null);var s=i.regionBelow(n),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,n,a):i.addRightEdges(t,n,a.Onext,o,o,!0)},i.addSentinel=function(t,e,r,n){var s=new bE,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=n,o.Dst.s=e,o.Dst.t=n,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new IY(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,n,s,o),i.addSentinel(t,n,s,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(dt(e.fixUpperEdge),dt(++r===1)),dt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,n=e.Lnext,lt.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,s=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,e=t.pq=new OY(s,lt.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,s;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,s=r.anEdge,dt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!lt.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),LY=function(){function i(){this.mesh=new mI,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=jt.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 i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],g=this.mesh.vHead;e=g.next;for(var y=0;y<3;++y)s=e.coords[y],c[y]=s,p[y]=e,l[y]=s,f[y]=e;for(e=g.next;e!==g;e=e.next)for(var m=0;m<3;++m)s=e.coords[m],s<c[m]&&(c[m]=s,p[m]=e),s>l[m]&&(l[m]=s,f[m]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],n=f[v],u[0]=r.coords[0]-n.coords[0],u[1]=r.coords[1]-n.coords[1],u[2]=r.coords[2]-n.coords[2],e=g.next;e!==g;e=e.next)h[0]=e.coords[0]-n.coords[0],h[1]=e.coords[1]-n.coords[1],h[2]=e.coords[2]-n.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,s=0,o=t.next;o!==t;o=o.next)if(n=o.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,n=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,n);s&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;lt.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;lt.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(lt.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(lt.edgeGoesLeft(n.Lnext)||lt.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=t.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(lt.edgeGoesRight(r.Lprev)||lt.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=t.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,s=t.eHead.next;s!==t.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,e===jr.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*n,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*n;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],n>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===jr.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){n=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,n=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==n);this.elements[u++]=s,this.elements[u++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new mI),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,s,o){if(t===void 0&&(t=jt.ODD),e===void 0&&(e=jr.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),RY.computeInterior(this,o);var a=this.mesh;return e===jr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===jr.BOUNDARY_CONTOURS?this.outputContours_(a,n):this.outputPolymesh_(a,e,r,n),!0},i}();function js(i){var t=i.windingRule,e=t===void 0?jt.ODD:t,r=i.elementType,n=r===void 0?jr.POLYGONS:r,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,u=c===void 0?[0,0,1]:c,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,g=i.debug,y=g===void 0?!1:g;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var m=new LY;i.edgeCreateCallback&&(m.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(m.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)m.addContour(l||2,d[v]);return m.tesselate(e,n,o,l,u,p),{vertices:m.vertices,vertexIndices:m.vertexIndices,vertexCount:m.vertexCount,elements:m.elements,elementCount:m.elementCount,mesh:y?m.mesh:void 0}}}var _ge=jt.ODD,Pge=jt.NONZERO,Dge=jt.POSITIVE,Oge=jt.NEGATIVE,Ige=jt.ABS_GEQ_TWO,Rge=jr.POLYGONS,Lge=jr.CONNECTED_POLYGONS,Nge=jr.BOUNDARY_CONTOURS;var I0=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*I0.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*I0.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(n,o*s,3*t);o+=3*t;let l=new Float32Array(n,o*s,3*t);o+=3*t;let c=new Float32Array(n,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=n,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},dm=I0;dm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var wI=qo(SI()),fm={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},TE={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},ME={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},EE=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),Nl=class extends Ne{constructor(e,r,n=0,s=12,o=3,a=jt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let c=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(C=>{let O=C.extractShapePointsToFlatArray([],s),L=[];for(let D=O.length-1;D>=1;D-=2){let B=O[D-1],k=O[D-0];L.push(B,k)}return L}),h=[],d=[];for(let C=0;C<c.length;C+=2)d.push([c[C],c[C+1]]);h.push(d);for(let C=0;C<u.length;C++){let O=u[C],L=[];for(let D=0;D<O.length;D+=2)L.push([O[D],O[D+1]]);h.push(L)}let f;e.isText?f=new eh().setFromPoints(e.points.map(O=>O.position)).getSize(new U).length()*.1:h[0].length===0?f=n:f=(0,wI.default)(h).distance,n<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(n,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=js({windingRule:a,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{p=fm}let g;try{g=js({windingRule:jt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{g=TE}if(!p)throw new Error("error generating geometry");let y=p.elementCount;if(g){p.elementCount+=g.elementCount;for(let C=0;C<g.elements.length;C++){let O=g.elements[C],L=C%2===0?p.vertexCount:0;p.elements.push(O+L)}for(let C=0;C<g.vertexIndices.length;C++){let O=g.vertexIndices[C],L=p.vertexCount;p.vertexIndices.push(O+L)}for(let C=0;C<g.vertices.length;C++){let O=g.vertices[C];p.vertices.push(O)}}let m=1/0,v=-1/0,x=1/0,b=-1/0;for(let C=0,O=p.vertexCount;C<O;C++){let L=C*2,D=p.vertices[L+0],B=p.vertices[L+1];D<m&&(m=D),D>v&&(v=D),B<x&&(x=B),B>b&&(b=B)}this._minX=m,this._minY=x,this._width=v-m,this._height=b-x,this._buffer=new dm(this._computeBufferEstimatedSize(p));let S=[],w=[];for(let C=p.elementCount-1;C>=0;C--){let O=C>=y,L=C*2,D=p.elements[L+0],B=p.elements[L+1],k=D+B,F={start:D,count:B,normals:[],continuous:[],concave:[]},H=D,G=k-1,X=D+1,Y=this._shape.roundedCurves.length;do{let ee=H-D,re=p.vertices[G*2+0],te=p.vertices[G*2+1],$=p.vertices[H*2+0],se=p.vertices[H*2+1],Se=p.vertices[X*2+0],W=p.vertices[X*2+1],Ae=$-re,xe=se-te,be=Math.sqrt(Ae*Ae+xe*xe);Ae/=be,xe/=be;let Ee=$-Se,De=se-W,Pe=Math.sqrt(Ee*Ee+De*De);Ee/=Pe,De/=Pe,F.normals[ee*2+0]=-De,F.normals[ee*2+1]=Ee,F.concave[ee]=Ae*De-xe*Ee>0;let Re=p.vertexIndices[H];if(Array.isArray(Re))F.continuous[ee]=!1;else{let[ze,_]=this._shape.getCurveIndexFromVertexId(Re-1,!0);if(_>0&&_<1)F.continuous[ee]=!0;else{let I=_===1?ze+1:ze-1;I=(I+Y)%Y;let ie=_===1?0:1,de=this._shape.roundedCurves[ze].getTangent(_),ve=this._shape.roundedCurves[I].getTangent(ie);F.continuous[ee]=de.dot(ve)>.95}}O&&(F.normals[ee*2+0]*=-1,F.normals[ee*2+1]*=-1),[G,H,X]=[H,X,X+1],X>=k&&(X-=B)}while(X!==D+1);let Z=[];Z.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(D*2,k*2),vertexCount:B,vertexIndices:new Array(B).fill(!0).map((ee,re)=>[re,re]),elements:[0,B],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(D*2,k*2)});let le=0;for(let ee=1;ee<=this._bevelSegments;ee++){let re=ee/this._bevelSegments*Math.PI/2,te=(1-Math.cos(re))*this._bevel,$=[],se=[],Se=[],W=[],Ae=0;for(let be=0;be<B;be++){let Ee=be*2,De=(be-1+B)%B*2,Pe=p.vertices[F.start*2+Ee+0],Re=p.vertices[F.start*2+Ee+1],ze=-F.normals[De+0]*te,_=-F.normals[De+1]*te,I=-F.normals[Ee+0]*te,ie=-F.normals[Ee+1]*te;if(F.concave[be]||!F.concave[be]&&O){let de=Math.atan2(_,ze),ve=Math.atan2(ie,I);ve>de&&(ve-=Math.PI*2);let fe=ve-de;if(F.continuous[be]||O){let et=de+fe/2,Ue=Math.cos(et)*te,Oe=Math.sin(et)*te;$[2*Ae+0]=Pe+Ue*(O?-1:1),$[2*Ae+1]=Re+Oe*(O?-1:1),W[Ae]=be,Ae++}else{let et=Math.max(1,Math.floor(s/4*Math.abs(fe)/Math.PI));for(let Ue=0;Ue<=et;Ue++){let Oe=de+fe*(Ue/et),Be=Math.cos(Oe)*te,xt=Math.sin(Oe)*te;$[2*Ae+0]=Pe+Be,$[2*Ae+1]=Re+xt,W[Ae]=be,Ae++}}}else $[2*Ae+0]=Pe+ze,$[2*Ae+1]=Re+_,W[Ae]=be,se[be]=Ae,Ae++,$[2*Ae+0]=Pe,$[2*Ae+1]=Re,W[Ae]=be,Ae++,$[2*Ae+0]=Pe+I,$[2*Ae+1]=Re+ie,W[Ae]=be,Se[be]=Ae,Ae++}let xe=js({windingRule:jt.POSITIVE,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[$],edgeCreateCallback:be=>{let De=be.Org.idx,Pe=W[De],Re=W[(De+1)%W.length];be.idx=[Pe,Re],be.Sym.idx=[Re,Pe]},vertexIdCallback:be=>{let Ee=be.Lprev.idx;return[Ee?Ee[1]:0,be.idx?be.idx[0]:0]}});if(!xe)throw console.log("Error"),new Error(`error generating bevel geometry for ${ee}'th loop`);if(!xe.vertexCount){let be=(ee-1)/this._bevelSegments*Math.PI/2;le=(1-Math.sin(be))*this._bevel;break}for(let be=0;be<xe.vertexIndices.length;be++){let[Ee,De]=xe.vertexIndices[be];if(Ee===De)continue;let Pe=De;De<Ee&&(Pe+=B);for(let Re=Ee;Re<Pe;Re++){let ze=Re%B,_=(Re+1)%B;if(!F.continuous[ze]||!F.continuous[_]){xe.vertexIndices[be]=[Ee,ze],xe.vertexIndices.splice(be+1,0,[_,De]),xe.vertices.splice((be+1)*2,0,xe.vertices[be*2],xe.vertices[be*2+1]);break}}}Z.push({bevelI:ee,angle:re,size:te,boundary:xe,reverseMap:W,insetPoints:$})}let j=(ee,re,te)=>{let $=0,se=ee.boundary.vertexIndices.length;for(;$<se&&te(ee.boundary.vertexIndices[re]);)re=(re+1)%se,$++;return $},K=S.length;for(let ee=1;ee<Z.length;ee++){let re=Z[ee-1],te=Z[ee],$=re.boundary.vertexIndices.length,se=te.boundary.vertexIndices.length;if(!$||!se)break;let Se=F.concave.length,W=0,Ae=EE(W,B);for(;!re.boundary.vertexIndices.filter(Ae).length||!te.boundary.vertexIndices.filter(Ae).length;)W++,Ae=EE(W,B);let xe=re.boundary.vertexIndices.findIndex(Ae),be=te.boundary.vertexIndices.findIndex(Ae);do xe=(xe+1)%$;while(Ae(re.boundary.vertexIndices[xe]));do be=(be+1)%se;while(Ae(te.boundary.vertexIndices[be]));W=(W+1)%B;let Ee=W,De=0,Pe=this._buildBevelVert(F,re,(xe-1+$)%$,void 0,De),Re=this._buildBevelVert(F,te,(be-1+se)%se,void 0,De),ze=Pe,_=Re,I,ie,de=!1;do{De=(W||Se)/Se,Ae=EE(W,B);let ve=j(re,xe,Ae),fe=j(te,be,Ae),et=de;if(de=!1,ve&&!fe){for(let Ue=0;Ue<ve;Ue++)I=this._buildBevelVert(F,re,(xe+Ue)%$,Ue/(ve-1),De),S.push(ze.topN,I.topP,_.topN),l===!1&&S.push(I.bottomP,ze.bottomN,_.bottomN),ze=I;de=!0}else if(!ve&&fe)for(let Ue=0;Ue<fe;Ue++)ie=this._buildBevelVert(F,te,(be+Ue)%se,Ue/(fe-1),De),S.push(_.topN,ze.topP,ie.topP),l===!1&&S.push(ze.bottomP,_.bottomN,ie.bottomP),_=ie;else if(ve&&fe)if(I=this._buildBevelVert(F,re,xe,0,De),ie=this._buildBevelVert(F,te,be,0,De),et?(S.push(ze.topN,ie.topP,_.topN),S.push(ze.topN,I.topP,ie.topP),l===!1&&(S.push(ie.bottomP,ze.bottomN,_.bottomN),S.push(ie.bottomP,I.bottomP,ze.bottomN))):(S.push(_.topN,ze.topN,I.topP),S.push(_.topN,I.topP,ie.topP),l===!1&&(S.push(I.bottomP,ze.bottomN,_.bottomN),S.push(I.bottomP,_.bottomN,ie.bottomP))),ze=I,_=ie,ve===fe)for(let Ue=1;Ue<ve;Ue++)I=this._buildBevelVert(F,re,(xe+Ue)%$,Ue/(ve-1),De),ie=this._buildBevelVert(F,te,(be+Ue)%se,Ue/(fe-1),De),S.push(ze.topN,I.topP,_.topN),S.push(_.topN,I.topP,ie.topP),l===!1&&(S.push(I.bottomP,ze.bottomN,_.bottomN),S.push(I.bottomP,_.bottomN,ie.bottomP)),ze=I,_=ie;else if(ve>fe){let Ue=ve/fe,Oe=0;for(let Be=1;Be<ve;Be++)I=this._buildBevelVert(F,re,(xe+Be)%$,Be/(ve-1),De),S.push(ze.topN,I.topP,_.topN),l===!1&&S.push(I.bottomP,ze.bottomN,_.bottomN),ze=I,Be>(Oe+1)*Ue&&(Oe++,ie=this._buildBevelVert(F,te,(be+Oe)%se,Oe/(fe-1),De),S.push(_.topN,I.topP,ie.topP),l===!1&&S.push(I.bottomP,_.bottomN,ie.bottomP),_=ie)}else{let Ue=fe/ve,Oe=0;for(let Be=1;Be<fe;Be++)ie=this._buildBevelVert(F,te,(be+Be)%se,Be/(fe-1),De),S.push(_.topN,I.topP,ie.topP),l===!1&&S.push(I.bottomP,_.bottomN,ie.bottomP),_=ie,Be>(Oe+1)*Ue&&(Oe++,I=this._buildBevelVert(F,re,(xe+Oe)%$,Oe/(ve-1),De),S.push(ze.topN,I.topP,_.topN),l===!1&&S.push(I.bottomP,ze.bottomN,_.bottomN),ze=I)}xe=(xe+ve)%$,be=(be+fe)%se,W=(W+1)%Se}while(W!==Ee)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(Z,F,S),O){let ee=[];for(let re=S.length-1;re>=K+2;re-=3){let te=S[re-2],$=S[re-1],se=S[re-0];ee.push(se,$,te)}S.splice(K,S.length-K,...ee)}if(O){let ee=[];for(let re=Z[Z.length-1].boundary.vertices.length-1;re>=1;re-=2){let te=Z[Z.length-1].boundary.vertices[re-1],$=Z[Z.length-1].boundary.vertices[re-0];ee.push(te,$)}w.push(ee)}if(!O){let ee=Z[Z.length-1],re;try{re=js({windingRule:Z.length>1?jt.POSITIVE:jt.ODD,elementType:jr.POLYGONS,vertexSize:2,strict:!0,contours:[ee.insetPoints,...w]})}catch{re=ME}if(!re)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let te=0;te<re.elementCount*3;te+=3){let $=this._buildSurfaceVert(re,re.elements[te+0],le),se=this._buildSurfaceVert(re,re.elements[te+1],le),Se=this._buildSurfaceVert(re,re.elements[te+2],le);S.push($.top,se.top,Se.top),l===!1&&S.push(Se.bottom,se.bottom,$.bottom)}}this.vertexCache={}}this._buffer.shrink();let E=new Ye(Uint32Array.from(S),1),A=new Ye(this._buffer.positions,3),P=new Ye(this._buffer.normals,3),M=new Ye(this._buffer.uvs,2);A.needsUpdate=!0,P.needsUpdate=!0,M.needsUpdate=!0,E.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",P),this.setAttribute("uv",M),this.setIndex(E)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);n.push(c.topP,l.topN,l.bottomN),n.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,n){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,c=(a-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),h=u*3,d=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-n,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=n,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[s]=f,f}_buildBevelVert(e,r,n,s=1,o){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,c]=r.boundary.vertexIndices[n],u,h,d,f;l!==c?(h=l,u=c,f=!1,d=e.continuous[h]&&e.continuous[u]):(u=l,h=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,d=e.continuous[u]||f);let p=Math.cos(r.angle),g=Math.sin(r.angle),y=n*2,m=u*2,v=h*2,x=r.boundary.vertices[y+0],b=r.boundary.vertices[y+1],S=(1-g)*this._bevel,w=(x-this._minX)/this._width,E=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(w=o),E=1);let A=e.normals[m+0],P=e.normals[m+1],M=e.normals[v+0],C=e.normals[v+1];if(f){let k=M-A,F=C-P;A=A+k*(1-s),P=P+F*(1-s);let H=Math.sqrt(A*A+P*P);A/=H,P/=H}let O=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),L=O*3,D=O*2,B={i:n,fi:u,topP:O+0,topN:O+0,bottomP:O+1,bottomN:O+1,pathBevelUCoord:o};return this._buffer.positions[L+0]=x,this._buffer.positions[L+1]=b,this._buffer.positions[L+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[L+0]=A*p,this._buffer.normals[L+1]=P*p,this._buffer.normals[L+2]=g,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=E,this.forPathBevel===!1&&(this._buffer.positions[L+3]=x,this._buffer.positions[L+4]=b,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=A*p,this._buffer.normals[L+4]=P*p,this._buffer.normals[L+5]=-g,this._buffer.uvs[D+2]=E,this._buffer.uvs[D+3]=w),d||(this.forPathBevel?(O+=1,L+=3,D+=2):(O+=2,L+=6,D+=4),B.topP=O+0,B.bottomP=O+1,this._buffer.positions[L+0]=x,this._buffer.positions[L+1]=b,this._buffer.positions[L+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[L+0]=M*p,this._buffer.normals[L+1]=C*p,this._buffer.normals[L+2]=g,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=E,this.forPathBevel===!1&&(this._buffer.positions[L+3]=x,this._buffer.positions[L+4]=b,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=M*p,this._buffer.normals[L+4]=C*p,this._buffer.normals[L+5]=-g,this._buffer.uvs[D+2]=E,this._buffer.uvs[D+3]=w)),this.vertexCache[a]=B,B}clone(){let e=new Nl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fa(this.userData),e}};var Td=class extends Ne{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=jt.ODD;this.elementType=jr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:jt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let p=0,g=s.length/2;p<g;p++){let y=p*2,m=s[y+0],v=s[y+1];if(u!==void 0&&m!==u&&(l=!1),h!==void 0&&v!==h&&(c=!1),u=m,h=v,!l&&!c)break}if(!l&&!c)try{a=js({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=fm}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ye(new Float32Array(d*3),3),this._normalAttribute=new Ye(new Float32Array(d*3),3),this._uvAttribute=new Ye(new Float32Array(d*2),2),this._indexAttribute=new Ye(new Uint32Array(f*3),1),a){let p=1/0,g=-1/0,y=1/0,m=-1/0;for(let b=0,S=d;b<S;b++){let w=b*2,E=a.vertices[w+0],A=a.vertices[w+1];E<p&&(p=E),E>g&&(g=E),A<y&&(y=A),A>m&&(m=A)}let v=g-p,x=m-y;for(let b=0,S=d;b<S;b++){let w=b*2,E=a.vertices[w+0],A=a.vertices[w+1],P=(E-p)/v,M=(A-y)/x;this._positionAttribute.setXYZ(b,E,A,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,P,M)}for(let b=0,S=f;b<S;b++){let w=b*3,E=a.elements[w+0],A=a.elements[w+1],P=a.elements[w+2];this._indexAttribute.setX(w+0,E),this._indexAttribute.setX(w+1,A),this._indexAttribute.setX(w+2,P)}}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 Td(this._shape,this._curveSegments);return e.userData=fa(this.userData),e}};var Md=class extends Nl{constructor(e,r,n=0,s=12,o=3,a=jt.ODD){super(e,r,n,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);n.push(c.topP,l.topN,l.bottomN),n.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Md(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fa(this.userData),e}};var Ln=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:jt.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Yt?(o.width!==r||o.height!==n)&&o.applySize(r,n):o=new Yt(r,n).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Yt(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new Td(i.shape,n,{windingRule:o}):a=new Md(i.shape,t,e,n,r,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var EI=Math.PI*2,_d=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=_e.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=t*.5,h=e*.5,d=VY(c,u,h,n*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return n===0?(f=new Ne,f.setAttribute("position",new Ie([],3))):f=Ln.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function VY(i,t,e,r,n,s){if(r>=EI)return n>30||n%4===0?(kY(i,t,e,s),Math.round(n/4)):AI(i,r,n,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=pI({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%c.length===0?zY(i,o.x,o.y,c,n,t,e,s):AI(i,r,n,t,e,s)}function zY(i,t,e,r,n,s,o,a){let l=Math.round(n/r.length);i.addPoint(Cd(t,e));for(let c=0,u=r.length;c<u;c++){let h=r[c],d=i.points[c],f=Cd(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?TI(i,s,o,a):i.addPoint(Cd(0,0)),l}function AI(i,t,e,r,n,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,c=Math.sin(l)*r,u=Math.cos(l)*n;i.addPoint(Cd(c,u))}return t<EI?s>0?TI(i,r,n,s):i.addPoint(Cd(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&MI(i,r,n,s)),1}function kY(i,t,e,r=0,n=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(L0(n-t,s,n-t,s-l,n-t,s+l)),i.addPoint(L0(n,s+e,n-a,s+e,n+a,s+e)),i.addPoint(L0(n+t,s,n+t,s+l,n+t,s-l)),i.addPoint(L0(n,s-e,n+a,s-e,n-a,s-e)),r>0&&MI(i,t,e,r)}function Cd(i,t){return new Hs(_e.generateUUID(),new U(i,t))}function L0(i,t,e,r,n,s){let o=Cd(i,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(n,s),o}function TI(i,t,e,r){CI(i,t,e,r).forEach(s=>i.addPoint(s))}function MI(i,t,e,r){let n=CI(i,t,e,r),s=new Yt;n.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function CI(i,t,e,r){let n=r*t/100,s=n*(Math.abs(e)/Math.abs(t)),o=new U(n/t,s/e),a=i.points.map(l=>{let c=l.clone();return c.uuid=_e.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),u=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}var _I=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:h}=i.parameters,d=new pm(!1,t,e,r,n,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},CE=new lo([0,0,0],1),pm=class extends Ne{constructor(t=!0,e=1,r=1,n=1,s=1,o=1,a=1,l=1,c=1,u=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new T,g=new T,y=p(),m=p(),v=p(),x,b,S,w,E,A,P,M,C=p(),O=p(),L=p(),D=p(),B=p(),k=p(),F=p(),H=p(),G=r-2*l+.001,X=G/o,Y=Math.ceil(a*o),Z=Y+1,le=G/Y,j=-G/2,K=u+1,ee=2*Math.PI/u,re=Math.PI/2/d,te=.01,$=Math.min((1-h/100)*l,l-te),se=l-$,Se=0,W=2,Ae=d*W+W,xe=K*Ae/W,be=xe+K*Z,Ee=Math.max(0,K*(Z+Ae)),[De,Pe,Re]=[3,3,2].map(Te=>Array(Ee*Te).fill(0)),ze=[],_=s-l;function I(Te,mt){let gt=Math.PI/2;A=mt*le,M=2*Math.PI*(A%X)/X+gt,A+=j,P=Math.sin(M)*_,E=Math.cos(M)*_,t?Te.set(E,P,A):Te.set(E,A,P)}I(g,-1e-10),I(y,0),C.copy(g),I(g,1);let ie=g.distanceTo(y),de=f?0:se+$,ve=ie*Y+2*de,fe=$,et=ve-de;for(let Te=0;Te<=Y;Te++){I(m,Te),H.subVectors(m,C).normalize(),C.copy(m),k.copy(m).setComponent(+t+1,0).normalize(),F.crossVectors(H,k).normalize();let mt=Te===0,gt=Te===Y,ct=mt?3*Math.PI/2:re,tt=mt?fe:et,rt=mt?K:be,Pt=mt?0:Ee-K,Ke=H.clone().multiplyScalar(mt?-se:se).add(m),vr=H.clone().multiplyScalar(mt?-1:1).normalize();for(let J=0;J<K;J++){let Ge=J*ee;if(O.addVectors(g.copy(k).multiplyScalar(l*Math.cos(Ge)),y.copy(F).multiplyScalar(l*Math.sin(Ge))),L.copy(O).normalize(),mt||gt){f||(Se=Pt+J,[0,1,2].forEach(ce=>{De[Se*3+ce]=Ke.getComponent(ce),Pe[Se*3+ce]=vr.getComponent(ce)}),Re[Se*2]=+gt,Re[Se*2+1]=J/u),y.copy(L).multiplyScalar($),v.addVectors(m,y);for(let ce=0;ce<d;ce++){let Fe=ce*re+ct;D.addVectors(g.copy(H).multiplyScalar(se*Math.sin(Fe)),y.copy(L).multiplyScalar(se*Math.cos(Fe))),B.copy(D).normalize(),y.addVectors(v,D),D.normalize(),Se=rt+ce*K+J,[0,1,2].forEach(Ct=>{De[Se*3+Ct]=y.getComponent(Ct),Pe[Se*3+Ct]=B.getComponent(Ct)});let He=+mt+Math.sin(Fe);Re[Se*2]=(tt+se*He)/ve,Re[Se*2+1]=J/u}}y.addVectors(m,O),Se=xe+Te*K+J,[0,1,2].forEach(ce=>{De[Se*3+ce]=y.getComponent(ce),Pe[Se*3+ce]=L.getComponent(ce)}),Re[Se*2]=(de+Te*ie)/ve,Re[Se*2+1]=J/u}}let Ue=Z+2*d+W,Oe=1,[Be,xt]=[+f,Ue-1];for(let Te=Be;Te<=xt-1;Te++){let mt=f&&Te===xt-1;for(let gt=0;gt<K-1;gt++)x=Te*K+gt,b=x+1,S=(mt?gt:x)+K,w=(mt?gt+1:b)+K,Te===0?ze.push(b,w,S):Te===Ue-2?ze.push(x,b,S):ze.push(x,b,S,b,w,S)}this.setIndex(ze),this.setAttribute("position",new Ie(De,3)),this.setAttribute("normal",new Ie(Pe,3)),this.setAttribute("uv",new Ie(Re,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,n=Array.from(this.getIndex().array),s,o,a,l,c=6*(e-1)*t.radialSegments,u=e,h=u===e;for(let d=0;d<t.radialSegments;d++)s=u*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,n[c++]=s,n[c++]=o,n[c++]=a,n[c++]=o,n[c++]=l,n[c++]=a;return n.length=c,CE.array=n,CE.count=n.length,CE}};var PI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new mm(t*.5,s,o):new ju(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},mm=class extends Il{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new mm(t.radius,t.corner,t.cornerSides)}};var DI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new oa;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new zu(n.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Mo=new ue,_E=new Rt,N0=new T,Bl=class extends gr{constructor(){super(),this.uuid=_e.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new ut().getNormalMatrix(t);for(let r=0,n=this.vertices.length;r<n;r++)this.vertices[r].applyMatrix4(t);for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Mo.makeRotationX(t),this.applyMatrix4(Mo),this}rotateY(t){return Mo.makeRotationY(t),this.applyMatrix4(Mo),this}rotateZ(t){return Mo.makeRotationZ(t),this.applyMatrix4(Mo),this}translate(t,e,r){return Mo.makeTranslation(t,e,r),this.applyMatrix4(Mo),this}scale(t,e,r){return Mo.makeScale(t,e,r),this.applyMatrix4(Mo),this}lookAt(t){return _E.lookAt(t),_E.updateMatrix(),this.applyMatrix4(_E.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,n=t.attributes;if(n.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=n.position,o=n.normal,a=n.color,l=n.uv,c=n.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new T().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new ke().fromBufferAttribute(a,d));function u(d,f,p,g){let y=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],m=o===void 0?[]:[new T().fromBufferAttribute(o,d),new T().fromBufferAttribute(o,f),new T().fromBufferAttribute(o,p)],v=new Pd(d,f,p,m,y,g);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new U().fromBufferAttribute(l,d),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,p)]),c!==void 0&&e.faceVertexUvs[1].push([new U().fromBufferAttribute(c,d),new U().fromBufferAttribute(c,f),new U().fromBufferAttribute(c,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,g=f.count;for(let y=p,m=p+g;y<m;y+=3)r!==void 0?u(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)u(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(N0).negate(),this.translate(N0.x,N0.y,N0.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,n=new ue;return n.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(n),this}computeFaceNormals(){let t=new T,e=new T;for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,n=this.vertices.length;r<n;r++)e[r]=new T;if(t){let r=new T,n=new T;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],u=this.vertices[a.c];r.subVectors(u,c),n.subVectors(l,c),r.cross(n),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,n=this.vertices.length;r<n;r++)e[r].normalize();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],n=r.vertexNormals;n.length===3?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]);for(let s=0,o=n.vertexNormals.length;s<o;s++)n.__originalVertexNormals[s]?n.__originalVertexNormals[s].copy(n.vertexNormals[s]):n.__originalVertexNormals[s]=n.vertexNormals[s].clone()}let t=new Bl;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new T,u={a:new T,b:new T,c:new T};s.push(c),o.push(u)}}let n=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=n.faceNormals[s],c=n.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Or),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let n,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,c=t.faces,u=this.colors,h=t.colors;e!==void 0&&(n=new ut().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let g=a[d].clone();e!==void 0&&g.applyMatrix4(e),o.push(g)}for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone());for(let d=0,f=c.length;d<f;d++){let p=c[d],g,y,m=p.vertexNormals,v=p.vertexColors,x=new Pd(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),n!==void 0&&x.normal.applyMatrix3(n).normalize();for(let b=0,S=m.length;b<S;b++)g=m[b].clone(),n!==void 0&&g.applyMatrix3(n).normalize(),x.vertexNormals.push(g);x.color.copy(p.color);for(let b=0,S=v.length;b<S;b++)y=v[b],x.vertexColors.push(y.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let g=0,y=p.length;g<y;g++){let m=p[g],v=[];for(let x=0,b=m.length;x<b;x++)v.push(m[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],n=[],s=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],h=Math.round(u.x*s)+"_"+Math.round(u.y*s)+"_"+Math.round(u.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),n[l]=r.length-1):n[l]=n[e[h]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=n[u.a],u.b=n[u.b],u.c=n[u.c];let h=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u<h;u++)this.faceVertexUvs[u].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let n=t[e];this.vertices.push(new T(n.x,n.y,n.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let n=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;n&&n.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let c=t[l]._id;o&&o.push(n[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let g in p)p[g]!==void 0&&(t[g]=p[g]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let g=this.vertices[p];e.push(g.x,g.y,g.z)}let r=[],n=[],s={},o=[],a={},l=[],c={};for(let p=0;p<this.faces.length;p++){let g=this.faces[p],y=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,x=g.normal.length()>0,b=g.vertexNormals.length>0,S=g.color.r!==1||g.color.g!==1||g.color.b!==1,w=g.vertexColors.length>0,E=0;if(E=u(E,0,0),E=u(E,1,y),E=u(E,2,m),E=u(E,3,v),E=u(E,4,x),E=u(E,5,b),E=u(E,6,S),E=u(E,7,w),r.push(E),r.push(g.a,g.b,g.c),r.push(g.materialIndex),v){let A=this.faceVertexUvs[0][p];r.push(f(A[0]),f(A[1]),f(A[2]))}if(x&&r.push(h(g.normal)),b){let A=g.vertexNormals;r.push(h(A[0]),h(A[1]),h(A[2]))}if(S&&r.push(d(g.color)),w){let A=g.vertexColors;r.push(d(A[0]),d(A[1]),d(A[2]))}}function u(p,g,y){return y?p|1<<g:p&~(1<<g)}function h(p){let g=p.x.toString()+p.y.toString()+p.z.toString();return s[g]!==void 0||(s[g]=n.length/3,n.push(p.x,p.y,p.z)),s[g]}function d(p){let g=p.r.toString()+p.g.toString()+p.b.toString();return a[g]!==void 0||(a[g]=o.length,o.push(p.getHex())),a[g]}function f(p){let g=p.x.toString()+p.y.toString();return c[g]!==void 0||(c[g]=l.length/2,l.push(p.x,p.y)),c[g]}return t.data={},t.data.vertices=e,t.data.normals=n,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Bl().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let n=t.faces;for(let d=0,f=n.length;d<f;d++)this.faces.push(n[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let g=0,y=p.length;g<y;g++){let m=p[g],v=[];for(let x=0,b=m.length;x<b;x++){let S=m[x];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let g=0,y=s[d].vertices.length;g<y;g++)p.vertices.push(s[d].vertices[g].clone())}if(s[d].normals!==void 0){p.normals=[];for(let g=0,y=s[d].normals.length;g<y;g++)p.normals.push(s[d].normals[g].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let g=0,y=o[d].vertexNormals.length;g<y;g++){let m=o[d].vertexNormals[g],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let g=0,y=o[d].faceNormals.length;g<y;g++)p.faceNormals.push(o[d].faceNormals[g].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=t.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new PE().fromGeometry(this),e=new Ne,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",B0.call(new Ye(r,3),t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);e.setAttribute("normal",B0.call(new Ye(n,3),t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);e.setAttribute("color",OI.call(new Ye(n,3),t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);e.setAttribute("uv",II.call(new Ye(n,2),t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",II.call(new Ye(n,2),t.uvs2))}e.groups=t.groups;for(let n in t.morphTargets){let s=[],o=t.morphTargets[n];for(let a=0,l=o.length;a<l;a++){let c=o[a],u=new Ie(c.data.length*3,3);u.name=c.name,s.push(B0.call(u,c.data))}e.morphAttributes[n]=s}if(t.skinIndices.length>0){let n=new Ie(t.skinIndices.length*4,4);e.setAttribute("skinIndex",RI.call(n,t.skinIndices))}if(t.skinWeights.length>0){let n=new Ie(t.skinWeights.length*4,4);e.setAttribute("skinWeight",RI.call(n,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ne,r=t.geometry;if(t.isPoints||t.isLine){let n=new Ie(r.vertices.length*3,3),s=new Ie(r.colors.length*3,3);if(e.setAttribute("position",B0.call(n,r.vertices)),e.setAttribute("color",OI.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Ie(r.lineDistances.length,1);e.setAttribute("lineDistance",GY.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Bl.prototype.isGeometry=!0;var PE=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,n,s,o=t.faces;for(n=0;n<o.length;n++){let a=o[n];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=n*3-r.start,e.push(r)),r={start:n*3,materialIndex:s})}r!==void 0&&(r.count=n*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,n=t.faceVertexUvs,s=n[0]&&n[0].length>0,o=n[1]&&n[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let m=0;m<l;m++)c[m]={name:a[m].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,h=u.length,d;if(h>0){d=[];for(let m=0;m<h;m++)d[m]={name:u[m].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,g=f.length===r.length,y=p.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<e.length;m++){let v=e[m];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=n[0][m];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new U,new U,new U))}if(o===!0){let S=n[1][m];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new U,new U,new U))}for(let S=0;S<l;S++){let w=a[S].vertices;c[S].data.push(w[v.a],w[v.b],w[v.c])}for(let S=0;S<h;S++){let w=u[S].vertexNormals[m];d[S].data.push(w.a,w.b,w.c)}g&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Pd=class{constructor(t,e,r,n,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=n&&n.isVector3?n:new T,this.vertexNormals=Array.isArray(n)?n:[],this.color=s&&s.isColor?s:new ke,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function GY(i){return this.array.set(i),this}function OI(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new ke),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function II(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new U),t[e++]=s.x,t[e++]=s.y}return this}function B0(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new T),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function RI(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Ze),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var HY=["a","b","c"];function jY(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function DE(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),s=r+"_"+n;return e.get(s)}function OE(i,t,e,r,n,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,c;if(r.has(l))c=r.get(l);else{let u=e[o],h=e[a];c={a:u,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(n),s[i].edges.push(c),s[t].edges.push(c)}function WY(i,t,e,r){let n,s,o;for(n=0,s=i.length;n<s;n++)e[n]={edges:[]};for(n=0,s=t.length;n<s;n++)o=t[n],OE(o.a,o.b,i,r,o,e),OE(o.b,o.c,i,r,o,e),OE(o.c,o.a,i,r,o,e)}function F0(i,t,e,r,n){i.push(new Pd(t,e,r,void 0,void 0,n))}function Dd(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function U0(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var V0=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ne?t=new Bl().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new T,r,n,s,o,a,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],h=u!==void 0&&u.length>0,d=[],f=new Map;WY(l,c,d,f);let p=[],g,y,m,v,x,b,S;for(let te of Array.from(f.keys())){for(y=f.get(te),m=new T,x=3/8,b=1/8,S=y.faces.length,S!=2&&(x=.5,b=0,S!=1),m.addVectors(y.a,y.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=y.faces[o],a=0;a<3&&(g=l[jY(v,HY[a])],!(g!==y.a&&g!==y.b));a++);g&&e.add(g)}e.multiplyScalar(b),m.add(e),y.newEdge=p.length,p.push(m)}let w,E,A,P,M,C,O,L=[];for(n=0,s=l.length;n<s;n++){for(C=l[n],M=d[n].edges,r=M.length,r==3?w=3/16:r>3&&(w=3/(8*r)),E=1-r*Number(w),A=w,r<=2&&(r==2?(E=3/4,A=1/8):r==1||r==0),O=C.clone().multiplyScalar(E),e.set(0,0,0),o=0;o<r;o++)P=M[o],g=P.a!==C?P.a:P.b,e.add(g);e.multiplyScalar(Number(A)),O.add(e),L.push(O)}let D=L.concat(p),B=L.length,k,F,H,G=[],X=[],Y,Z,le,j,K=new U,ee=new U,re=new U;for(n=0,s=c.length;n<s;n++)v=c[n],k=Number(DE(v.a,v.b,f).newEdge)+B,F=Number(DE(v.b,v.c,f).newEdge)+B,H=Number(DE(v.c,v.a,f).newEdge)+B,F0(G,k,F,H,v.materialIndex),F0(G,v.a,k,H,v.materialIndex),F0(G,v.b,F,k,v.materialIndex),F0(G,v.c,H,F,v.materialIndex),h&&(Y=u[n],Z=Y[0],le=Y[1],j=Y[2],K.set(Dd(Z.x,le.x),Dd(Z.y,le.y)),ee.set(Dd(le.x,j.x),Dd(le.y,j.y)),re.set(Dd(Z.x,j.x),Dd(Z.y,j.y)),U0(X,K,ee,re),U0(X,Z,K,re),U0(X,le,ee,K),U0(X,j,re,ee));t.vertices=D,t.faces=G,h&&(t.faceVertexUvs[0]=X)}};var Pi=new T,LI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ne().copy(new mi(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Pi),r={width:Pi.x,height:Pi.y,depth:Pi.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,s=i.geometry??new Ne().copy(new mi(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Pi)):Pi.set(o.width,o.height,o.depth),(t!==Pi.x||e!==Pi.y||r!==Pi.z)&&s.scale(Pi.x===0?1:t/Pi.x,Pi.y===0?1:e/Pi.y,Pi.z===0?1:r/Pi.z);let a=s.originalGeometry;try{n>0?(a===void 0||o?.subdivisions!==n)&&(a===void 0&&(a=s),s=new V0(n).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Ju(e).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(Pi);let o=100/Pi.x;Object.assign(s.parameters,{width:100,height:Pi.y*o,depth:Pi.z*o}),t(this.build(s))})}};var z0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,c=t*.5,u=e*.5,h=0,d=0,f=2*Math.PI/r;for(let g=0;g<r;g++){let y=f*g,m=h+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(m,v))}l.isClosed=!0;for(let g=0,y=l.points.length;g<y;g++)l.points[g].roundness=n;l.roundness=n,l.update();let p=Ln.create({shape:l,parameters:{roundness:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var NI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,c=new RE(t*.5,e,n,s,o,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function gm(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function IE(i,t,e,r,n,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===n){let c=o.add(a).normalize();s.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(i),s.addScaledVector(o,n/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function qY(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var RE=class extends Ne{constructor(t=.5,e=1,r=4,n=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),a=Math.floor(a);let l=[],c=[],u=[],h=[],d=0,f=e/2,p=Math.PI/r,g=t*Math.cos(Math.PI/r),y=2*Math.PI/r,m=(r-2)*Math.PI/r,v=Math.PI-m,x=new T(0,-f,0),b=new T(0,f,0),S=new U(t,-f),w=new U(g,-f),E=new U(0,b.y).sub(w),A=new U(0,b.y).sub(S),P=new U(E.y,-E.x).normalize(),M=new U(A.y,-A.x).normalize(),O=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;o=Math.min(o,O);let L;{let X=new T(P.x,P.y,0),Y=new T(Math.cos(y)*X.x,X.y,Math.sin(y)*X.x);L=X.angleTo(Y)}let D=o/Math.tan((Math.PI-E.angle())/2),B=o/Math.tan((Math.PI-L)/2),k=new T;if(!s){c.push(x.x,x.y,x.z),u.push(0,-1,0),h.push(0,0);let X=d++,Y=[],Z=S.clone(),le=D/Math.cos(Math.PI/r);Z.x-=le;for(let j=0;j<r;j++){let K=j/r*Math.PI*2+p,ee=new U(Math.sin(K),Math.cos(K));gm(Z,ee,k),c.push(k.x,k.y,k.z),u.push(0,-1,0),h.push(0,0),Y.push(d++)}for(let j=0;j<Y.length;j++)l.push(Y[j],X,Y[(j+1)%Y.length])}let F=[];{let X=new T,Y=new T,Z=new T,le=new T,j=new T,K=new T;for(let ee=0;ee<r;ee++){let re=ee/r*Math.PI*2+p,te=(ee+.5)/r*Math.PI*2+p,$=(ee+1)/r*Math.PI*2+p,se=new U(Math.sin(re),Math.cos(re)),Se=new U(Math.sin(te),Math.cos(te)),W=new U(Math.sin($),Math.cos($));gm(S,se,Y),gm(S,W,Z),gm(P,Se,X),IE(b,Y,Z,B,B,le),c.push(le.x,le.y,le.z),IE(Y,b,Z,B,D,j),c.push(j.x,j.y,j.z),IE(Z,Y,b,D,B,K),c.push(K.x,K.y,K.z),u.push(X.x,X.y,X.z),u.push(X.x,X.y,X.z),u.push(X.x,X.y,X.z),h.push(0,0),h.push(0,0),h.push(0,0);let Ae=d++,xe=d++,be=d++;if(l.push(Ae,xe,be),o>0){{let Pe=Y.clone().add(Z).multiplyScalar(.5),Re=b.clone().sub(Pe).normalize(),_=x.clone().sub(Pe).normalize().add(Re).normalize().multiplyScalar(-1),I=K.clone().sub(j);H(Pe,I,_,E.angle())}let Ee,De;{let Pe=new T;gm(M,W,Pe);let Re=K.clone().add(le).multiplyScalar(.5);Re=qY(Re,Z,b);let ze=K.clone().sub(le);[Ee,De]=H(Re,ze,Pe,L,le.y)}{let Pe=Ee,Re=Pe.clone().setY(0).normalize(),ze=new T(0,-1,0),_=Re.clone().cross(ze);G(Pe,Re,ze,_)}F.concat(De);{let Pe=E.angle(),Re=Math.PI-Pe,ze=b.clone();ze.y-=o/Math.sin(Pe-Math.PI/2);let _=new T,I=[];for(let de=0;de<a;de++){let ve=[],fe=Math.PI/2-Re*de/a,et=Math.cos(fe),Ue=Math.sin(fe),Oe=te;for(let Be=0;Be<=de;Be++){let xt=Math.cos(Oe),Te=Math.sin(Oe);X.x=et*Te,X.y=Ue,X.z=et*xt,_.copy(ze).addScaledVector(X,o),c.push(_.x,_.y,_.z),u.push(X.x,X.y,X.z),h.push(0,0),ve.push(d++),Oe+=Math.PI*2/de/r}I.push(ve)}De.reverse(),I.push(De);let ie=I.length-1;for(let de=0;de<ie;de++){let ve=I[de],fe=I[de+1],et=ve.length-1;l.push(fe[1],ve[0],fe[0]);for(let Ue=1;Ue<=et;Ue++)l.push(ve[Ue],ve[Ue-1],fe[Ue]),l.push(fe[Ue+1],ve[Ue],fe[Ue])}}}}}this.setIndex(l),this.setAttribute("position",new Ie(c,3)),this.setAttribute("normal",new Ie(u,3)),this.setAttribute("uv",new Ie(h,2));function H(X,Y,Z,le,j){let K=-le/2,ee=(Math.PI-le)/2,re=Y.clone().normalize().cross(Z);X.addScaledVector(Z,-o/Math.sin(ee));let te=new T,$=new T,se=1,Se=d,W=[];for(let Ae=0;Ae<=a;Ae++){let xe=K+Ae/a*le;$.set(0,0,0),$.addScaledVector(re,Math.sin(xe)),$.addScaledVector(Z,Math.cos(xe));for(let be=0;be<=se;be++){let Ee=be/se-.5;if(te.copy(X),te.addScaledVector(Y,Ee),te.addScaledVector($,o),j!=null){let De=Math.max(0,te.y-j);te.addScaledVector(Y,-De/Y.y)}c.push(te.x,te.y,te.z),u.push($.x,$.y,$.z),h.push(0,0),be===0&&W.push(d),d++}}for(let Ae=0;Ae<a;Ae++)for(let xe=0;xe<se;xe++){let be=Se+xe+(se+1)*Ae,Ee=be+(se+1),De=Ee+1,Pe=be+1;l.push(be,Ee,Pe),l.push(Ee,De,Pe)}return[X.clone().addScaledVector(Y,.5),W]}function G(X,Y,Z,le){let j=Math.PI/2,K=A.angle()-j,ee=[],re=new T,te=new T;for(let se=0;se<=a;se++){let Se=[],W=se/a;for(let Ae=0;Ae<=se;Ae++){let be=((se?Ae/se:0)-.5)*v,Ee=Math.cos(be),De=Math.sin(be),Pe=Math.atan(Math.tan(K)*Ee),Re=(j+Pe)*W,ze=Math.cos(Re),_=Math.sin(Re);re.set(0,0,0),re.addScaledVector(Y,_*Ee),re.addScaledVector(Z,ze),re.addScaledVector(le,_*De),te.copy(X).addScaledVector(re,o),c.push(te.x,te.y,te.z),u.push(re.x,re.y,re.z),h.push(0,0),Se.push(d++)}ee.push(Se)}let $=ee.length-1;for(let se=0;se<$;se++){let Se=ee[se],W=ee[se+1],Ae=Se.length-1;l.push(Se[0],W[1],W[0]);for(let xe=1;xe<=Ae;xe++)l.push(Se[xe-1],Se[xe],W[xe]),l.push(Se[xe],W[xe+1],W[xe])}}}};var Od=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},h={x:c.x,y:c.y};function d(b,S,w){return S>e&&w>r?Math.min(b*e/S,b*r/w):S>e?b*e/S:w>r?b*r/w:b}let f=[];f[0]=n[0]===0?0:d(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:d(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:d(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:d(n[3],n[3]+n[0],n[3]+n[2]);let p=u.x,g=h.x,y=h.y,m=u.y;t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(p,m)),t.isClosed=!0;let v=!0;for(let b=0,S=t.points.length;b<S;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Ln.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var BI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=_e.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new Ne,u.setAttribute("position",new Ie([],3))):u=new Ls(.5*t,n,s,o,a,l,c*_e.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};var FI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new sn(t,e,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var UI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:s,cornerSegments:o}=i.parameters,a=new LE(t,e,r,n,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},LE=class extends Ne{constructor(t=1,e=1,r=1,n=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],u=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),n=Math.min(180-u,n),n*=Math.PI/180;let h=[],d=Math.PI/2,f=(te=0,$=0,se=0)=>new T(te,$,se),p=f(),g=f(),[y,m,v]=[e/2,t/2,r/2],x=-m,b=+m,[S,w,E]=[f(x,-y,+v),f(x,-y,-v),f(x,+y,-v)],A=(te,$=!1)=>Math.sin(te-Math.PI/(1+ +$)),P=(te,$=!1)=>Math.cos(te-Math.PI/(1+ +$));E.y=Math.sin(n)*e-y;let M=Math.cos(n)*e-v,C=S.z-u;n<=d?(E.z=Math.min(M,C),E.z==C&&(E.y-=(M-C)/Math.tan(d-n))):w.z=Math.min(w.z-M-v,S.z-u),p.subVectors(S,w),g.subVectors(E,w);let O=Math.min(p.length(),g.length())*s/100,L=O*Math.tan(n/2),D=O/Math.cos(n/2),B=p.clone().normalize().add(g.normalize()).setLength(D).add(w);p.set(0,A(n,!0),P(n,!0)),h.push([E,p.clone()]);let k=(Math.PI-n)/o;for(let te=0;te<=o;te++){let $=d+n+te*k;p.set(0,Math.sin($)*L,Math.cos($)*L),p.add(B),g.set(0,A($),P($)),h.push([p.clone(),g.clone()])}h.push([S,f(0,1,0)]);let F=Math.sin(k/2)*L*2,H=h.length-1,G=h[0][0].distanceTo(h[1][0]),X=h[H-1][0].distanceTo(h[H][0]),Y=G+F*o+X;h[0].push(1);for(let te=0;te<=o;te++)h[te+1].push(1-(G+te*F)/Y);h[H].push(0);let[Z,le,j]=h[0],K,ee,re;for(let te=1;te<h.length;te++)[K,ee,re]=h[te],a.push(x,Z.y,Z.z,x,K.y,K.z,b,Z.y,Z.z,b,Z.y,Z.z,x,K.y,K.z,b,K.y,K.z),l.push(0,le.y,le.z,0,ee.y,ee.z,0,le.y,le.z,0,le.y,le.z,0,ee.y,ee.z,0,ee.y,ee.z),c.push(0,j,0,re,1,j,1,j,0,re,1,re),[Z,le,j]=[K,ee,re];this.setAttribute("position",new Ie(a,3)),this.setAttribute("normal",new Ie(l,3)),this.setAttribute("uv",new Ie(c,2))}};var k0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,h=t*.5,d=e*.5,f=0,p=0,g=o*Math.PI/360/n,y=Math.PI/2*3*-1,m=h*r/100,v=d*r/100;if(n===3&&r===50){g=2*Math.PI/n;for(let b=0;b<n;b++){let S=g*b,w=f+Math.sin(S)*h,E=p+Math.cos(S)*d;u.addPoint(u.createPoint(w,E))}}else for(let b=0;b<n;b++){let S=f+Math.cos(y)*h,w=p+Math.sin(y)*d;u.addPoint(u.createPoint(S,w)),y+=g,S=f+Math.cos(y)*m,w=p+Math.sin(y)*v,b<=n,u.addPoint(u.createPoint(S,w)),y+=g}u.isClosed=!0;for(let b=0,S=u.points.length;b<S;b++)u.points[b].roundness=s;u.roundness=s,u.update();let x=Ln.create({shape:u,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var VI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new sn(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var zI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:s})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,c=XY(t,e,r,t*.5,o,s,0,0,n,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function XY(i,t,e,r,n,s,o,a,l,c,u){[t,e]=[e,t],o=t/2;let h=_e.clamp(n/360,0,1);if(h===0){let d=new Ne;return d.setAttribute("position",new Ie([],3)),d}return h===1&&(c=0),new pm(!0,i,t,e,r,h,s,o,a,l,c,u)}var kI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new qu(a,e,r,n,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var GI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,c=t*.5,u=e*.5;a?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=Ln.create({shape:l,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function HI(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var NE=class{add(t,e,r){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(n){this[n]=this[n]||[],e&&this[n][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},BE=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ye=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ye.version}static addUnaryOp(t){return ye.max_unop_len=Math.max(t.length,ye.max_unop_len),ye.unary_ops[t]=1,ye}static addBinaryOp(t,e,r){return ye.max_binop_len=Math.max(t.length,ye.max_binop_len),ye.binary_ops[t]=e,r?ye.right_associative.add(t):ye.right_associative.delete(t),ye}static addIdentifierChar(t){return ye.additional_identifier_chars.add(t),ye}static addLiteral(t,e){return ye.literals[t]=e,ye}static removeUnaryOp(t){return delete ye.unary_ops[t],t.length===ye.max_unop_len&&(ye.max_unop_len=ye.getMaxKeyLen(ye.unary_ops)),ye}static removeAllUnaryOps(){return ye.unary_ops={},ye.max_unop_len=0,ye}static removeIdentifierChar(t){return ye.additional_identifier_chars.delete(t),ye}static removeBinaryOp(t){return delete ye.binary_ops[t],t.length===ye.max_binop_len&&(ye.max_binop_len=ye.getMaxKeyLen(ye.binary_ops)),ye.right_associative.delete(t),ye}static removeAllBinaryOps(){return ye.binary_ops={},ye.max_binop_len=0,ye}static removeLiteral(t){return delete ye.literals[t],ye}static removeAllLiterals(){return ye.literals={},ye}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ye(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ye.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ye.binary_ops[String.fromCharCode(t)]||ye.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ye.isIdentifierStart(t)||ye.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ye.hooks[t]){let r={context:this,node:e};return ye.hooks.run(t,r),r.node}return e}searchHook(t){if(ye.hooks[t]){let e={context:this};return ye.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ye.SPACE_CODE||t===ye.TAB_CODE||t===ye.LF_CODE||t===ye.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ye.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index<this.expr.length;)if(r=this.code,r===ye.SEMCOL_CODE||r===ye.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())e.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ye.max_binop_len),e=t.length;for(;e>0;){if(ye.binary_ops.hasOwnProperty(t)&&(!ye.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ye.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,n,s,o,a,l,c;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ye.binaryPrecedence(e),right_a:ye.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),n=[o,s,a];e=this.gobbleBinaryOp();){if(r=ye.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:ye.right_associative.has(e)},c=e;let u=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;n.length>2&&u(n[n.length-2]);)a=n.pop(),e=n.pop().value,o=n.pop(),t={type:ye.BINARY_EXP,operator:e,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),n.push(s,t)}for(l=n.length-1,t=n[l];l>1;)t={type:ye.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,ye.isDecimalDigit(t)||t===ye.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ye.SQUOTE_CODE||t===ye.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===ye.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,ye.max_unop_len),r=e.length;r>0;){if(ye.unary_ops.hasOwnProperty(e)&&(!ye.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ye.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ye.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}ye.isIdentifierStart(t)?(n=this.gobbleIdentifier(),ye.literals.hasOwnProperty(n.name)?n={type:ye.LITERAL,value:ye.literals[n.name],raw:n.name}:n.name===ye.this_str&&(n={type:ye.THIS_EXP})):t===ye.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ye.PERIOD_CODE||e===ye.OBRACK_CODE||e===ye.OPAREN_CODE||e===ye.QUMARK_CODE;){let r;if(e===ye.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ye.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ye.OBRACK_CODE?(t={type:ye.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ye.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ye.OPAREN_CODE?t={type:ye.CALL_EXP,arguments:this.gobbleArguments(ye.CPAREN_CODE),callee:t}:(e===ye.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:ye.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;ye.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ye.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ye.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ye.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ye.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,ye.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===ye.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ye.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ye.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){n=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
3800
+ }`,iw=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,r){if(this.texture===null){let n=new Zt,s=t.properties.get(n);s.__webglTexture=e.texture,(e.depthNear!=r.depthNear||e.depthFar!=r.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}render(t,e){if(this.texture!==null){if(this.mesh===null){let r=e.cameras[0].viewport,n=new ot({extensions:{fragDepth:!0},vertexShader:c4,fragmentShader:u4,uniforms:{depthColor:{value:this.texture},depthWidth:{value:r.z},depthHeight:{value:r.w}}});this.mesh=new tr(new sn(20,20),n)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},nw=class extends gr{constructor(t,e){super();let r=this,n=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,p=null,g=new iw,y=e.getContextAttributes(),m=null,v=null,x=[],b=[],S=new U,w=null,E=new ri;E.layers.enable(1),E.viewport=new Ze;let A=new ri;A.layers.enable(2),A.viewport=new Ze;let P=[E,A],M=new rw;M.layers.enable(1),M.layers.enable(2);let C=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let K=x[j];return K===void 0&&(K=new cp,x[j]=K),K.getTargetRaySpace()},this.getControllerGrip=function(j){let K=x[j];return K===void 0&&(K=new cp,x[j]=K),K.getGripSpace()},this.getHand=function(j){let K=x[j];return K===void 0&&(K=new cp,x[j]=K),K.getHandSpace()};function L(j){let K=b.indexOf(j.inputSource);if(K===-1)return;let ee=x[K];ee!==void 0&&(ee.update(j.inputSource,j.frame,c||o),ee.dispatchEvent({type:j.type,data:j.inputSource}))}function D(){n.removeEventListener("select",L),n.removeEventListener("selectstart",L),n.removeEventListener("selectend",L),n.removeEventListener("squeeze",L),n.removeEventListener("squeezestart",L),n.removeEventListener("squeezeend",L),n.removeEventListener("end",D),n.removeEventListener("inputsourceschange",B);for(let j=0;j<x.length;j++){let K=b[j];K!==null&&(b[j]=null,x[j].disconnect(K))}C=null,O=null,g.reset(),t.setRenderTarget(m),f=null,d=null,h=null,n=null,v=null,le.stop(),r.isPresenting=!1,t.setPixelRatio(w),t.setSize(S.width,S.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){a=j,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(j){c=j},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(j){if(n=j,n!==null){if(m=t.getRenderTarget(),n.addEventListener("select",L),n.addEventListener("selectstart",L),n.addEventListener("selectend",L),n.addEventListener("squeeze",L),n.addEventListener("squeezestart",L),n.addEventListener("squeezeend",L),n.addEventListener("end",D),n.addEventListener("inputsourceschange",B),y.xrCompatible!==!0&&await e.makeXRCompatible(),w=t.getPixelRatio(),t.getSize(S),n.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let K={antialias:n.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,K),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),v=new yt(f.framebufferWidth,f.framebufferHeight,{format:Yr,type:Dr,colorSpace:t.outputColorSpace,stencilBuffer:y.stencil})}else{let K=null,ee=null,re=null;y.depth&&(re=y.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,K=y.stencil?tl:pc,ee=y.stencil?na:is);let te={colorFormat:e.RGBA8,depthFormat:re,scaleFactor:s};h=new XRWebGLBinding(n,e),d=h.createProjectionLayer(te),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),v=new yt(d.textureWidth,d.textureHeight,{format:Yr,type:Dr,depthTexture:new qn(d.textureWidth,d.textureHeight,ee,void 0,void 0,void 0,void 0,void 0,void 0,K),stencilBuffer:y.stencil,colorSpace:t.outputColorSpace,samples:y.antialias?4:0});let $=t.properties.get(v);$.__ignoreDepthValues=d.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await n.requestReferenceSpace(a),le.setContext(n),le.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};function B(j){for(let K=0;K<j.removed.length;K++){let ee=j.removed[K],re=b.indexOf(ee);re>=0&&(b[re]=null,x[re].disconnect(ee))}for(let K=0;K<j.added.length;K++){let ee=j.added[K],re=b.indexOf(ee);if(re===-1){for(let $=0;$<x.length;$++)if($>=b.length){b.push(ee),re=$;break}else if(b[$]===null){b[$]=ee,re=$;break}if(re===-1)break}let te=x[re];te&&te.connect(ee)}}let k=new T,F=new T;function H(j,K,ee){k.setFromMatrixPosition(K.matrixWorld),F.setFromMatrixPosition(ee.matrixWorld);let re=k.distanceTo(F),te=K.projectionMatrix.elements,$=ee.projectionMatrix.elements,se=te[14]/(te[10]-1),Se=te[14]/(te[10]+1),W=(te[9]+1)/te[5],Ae=(te[9]-1)/te[5],xe=(te[8]-1)/te[0],be=($[8]+1)/$[0],Ee=se*xe,De=se*be,Pe=re/(-xe+be),Re=Pe*-xe;K.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Re),j.translateZ(Pe),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert();let ze=se+Pe,_=Se+Pe,I=Ee-Re,ie=De+(re-Re),de=W*Se/_*ze,ve=Ae*Se/_*ze;j.projectionMatrix.makePerspective(I,ie,de,ve,ze,_),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}function G(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(n===null)return;g.texture!==null&&(j.near=g.depthNear,j.far=g.depthFar),M.near=A.near=E.near=j.near,M.far=A.far=E.far=j.far,(C!==M.near||O!==M.far)&&(n.updateRenderState({depthNear:M.near,depthFar:M.far}),C=M.near,O=M.far,E.near=C,E.far=O,A.near=C,A.far=O,E.updateProjectionMatrix(),A.updateProjectionMatrix(),j.updateProjectionMatrix());let K=j.parent,ee=M.cameras;G(M,K);for(let re=0;re<ee.length;re++)G(ee[re],K);ee.length===2?H(M,E,A):M.projectionMatrix.copy(E.projectionMatrix),X(j,M,K)};function X(j,K,ee){ee===null?j.matrix.copy(K.matrixWorld):(j.matrix.copy(ee.matrixWorld),j.matrix.invert(),j.matrix.multiply(K.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(K.projectionMatrix),j.projectionMatrixInverse.copy(K.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Lu*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(j){l=j,d!==null&&(d.fixedFoveation=j),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=j)},this.hasDepthSensing=function(){return g.texture!==null};let Y=null;function Z(j,K){if(u=K.getViewerPose(c||o),p=K,u!==null){let ee=u.views;f!==null&&(t.setRenderTargetFramebuffer(v,f.framebuffer),t.setRenderTarget(v));let re=!1;ee.length!==M.cameras.length&&(M.cameras.length=0,re=!0);for(let $=0;$<ee.length;$++){let se=ee[$],Se=null;if(f!==null)Se=f.getViewport(se);else{let Ae=h.getViewSubImage(d,se);Se=Ae.viewport,$===0&&(t.setRenderTargetTextures(v,Ae.colorTexture,d.ignoreDepthValues?void 0:Ae.depthStencilTexture),t.setRenderTarget(v))}let W=P[$];W===void 0&&(W=new ri,W.layers.enable($),W.viewport=new Ze,P[$]=W),W.matrix.fromArray(se.transform.matrix),W.matrix.decompose(W.position,W.quaternion,W.scale),W.projectionMatrix.fromArray(se.projectionMatrix),W.projectionMatrixInverse.copy(W.projectionMatrix).invert(),W.viewport.set(Se.x,Se.y,Se.width,Se.height),$===0&&(M.matrix.copy(W.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),re===!0&&M.cameras.push(W)}let te=n.enabledFeatures;if(te&&te.includes("depth-sensing")){let $=h.getDepthInformation(ee[0]);$&&$.isValid&&$.texture&&g.init(t,$,n.renderState)}}for(let ee=0;ee<x.length;ee++){let re=b[ee],te=x[ee];re!==null&&te!==void 0&&te.update(re,K,c||o)}g.render(t,M),Y&&Y(j,K),K.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:K}),p=null}let le=new d_;le.setAnimationLoop(Z),this.setAnimationLoop=function(j){Y=j},this.dispose=function(){}}},uc=new Ht,h4=new ue;function d4(i,t){function e(y,m){y.matrixAutoUpdate===!0&&y.updateMatrix(),m.value.copy(y.matrix)}function r(y,m){m.color.getRGB(y.fogColor.value,h_(i)),m.isFog?(y.fogNear.value=m.near,y.fogFar.value=m.far):m.isFogExp2&&(y.fogDensity.value=m.density)}function n(y,m,v,x,b){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(y,m):m.isMeshToonMaterial?(s(y,m),h(y,m)):m.isMeshPhongMaterial?(s(y,m),u(y,m)):m.isMeshStandardMaterial?(s(y,m),d(y,m),m.isMeshPhysicalMaterial&&f(y,m,b)):m.isMeshMatcapMaterial?(s(y,m),p(y,m)):m.isMeshDepthMaterial?s(y,m):m.isMeshDistanceMaterial?(s(y,m),g(y,m)):m.isMeshNormalMaterial?s(y,m):m.isLineBasicMaterial?(o(y,m),m.isLineDashedMaterial&&a(y,m)):m.isPointsMaterial?l(y,m,v,x):m.isSpriteMaterial?c(y,m):m.isShadowMaterial?(y.color.value.copy(m.color),y.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(y,m){y.opacity.value=m.opacity,m.color&&y.diffuse.value.copy(m.color),m.emissive&&y.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(y.map.value=m.map,e(m.map,y.mapTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,e(m.alphaMap,y.alphaMapTransform)),m.bumpMap&&(y.bumpMap.value=m.bumpMap,e(m.bumpMap,y.bumpMapTransform),y.bumpScale.value=m.bumpScale,m.side===ni&&(y.bumpScale.value*=-1)),m.normalMap&&(y.normalMap.value=m.normalMap,e(m.normalMap,y.normalMapTransform),y.normalScale.value.copy(m.normalScale),m.side===ni&&y.normalScale.value.negate()),m.displacementMap&&(y.displacementMap.value=m.displacementMap,e(m.displacementMap,y.displacementMapTransform),y.displacementScale.value=m.displacementScale,y.displacementBias.value=m.displacementBias),m.emissiveMap&&(y.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,y.emissiveMapTransform)),m.specularMap&&(y.specularMap.value=m.specularMap,e(m.specularMap,y.specularMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest);let v=t.get(m),x=v.envMap,b=v.envMapRotation;if(x&&(y.envMap.value=x,uc.copy(b),uc.x*=-1,uc.y*=-1,uc.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(uc.y*=-1,uc.z*=-1),y.envMapRotation.value.setFromMatrix4(h4.makeRotationFromEuler(uc)),y.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=m.reflectivity,y.ior.value=m.ior,y.refractionRatio.value=m.refractionRatio),m.lightMap){y.lightMap.value=m.lightMap;let S=i._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=m.lightMapIntensity*S,e(m.lightMap,y.lightMapTransform)}m.aoMap&&(y.aoMap.value=m.aoMap,y.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,y.aoMapTransform))}function o(y,m){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,m.map&&(y.map.value=m.map,e(m.map,y.mapTransform))}function a(y,m){y.dashSize.value=m.dashSize,y.totalSize.value=m.dashSize+m.gapSize,y.scale.value=m.scale}function l(y,m,v,x){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,y.size.value=m.size*v,y.scale.value=x*.5,m.map&&(y.map.value=m.map,e(m.map,y.uvTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,e(m.alphaMap,y.alphaMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest)}function c(y,m){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,y.rotation.value=m.rotation,m.map&&(y.map.value=m.map,e(m.map,y.mapTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,e(m.alphaMap,y.alphaMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest)}function u(y,m){y.specular.value.copy(m.specular),y.shininess.value=Math.max(m.shininess,1e-4)}function h(y,m){m.gradientMap&&(y.gradientMap.value=m.gradientMap)}function d(y,m){y.metalness.value=m.metalness,m.metalnessMap&&(y.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,y.metalnessMapTransform)),y.roughness.value=m.roughness,m.roughnessMap&&(y.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,y.roughnessMapTransform)),t.get(m).envMap&&(y.envMapIntensity.value=m.envMapIntensity)}function f(y,m,v){y.ior.value=m.ior,m.sheen>0&&(y.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),y.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(y.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,y.sheenColorMapTransform)),m.sheenRoughnessMap&&(y.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,y.sheenRoughnessMapTransform))),m.clearcoat>0&&(y.clearcoat.value=m.clearcoat,y.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(y.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,y.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(y.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===ni&&y.clearcoatNormalScale.value.negate())),m.iridescence>0&&(y.iridescence.value=m.iridescence,y.iridescenceIOR.value=m.iridescenceIOR,y.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(y.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,y.iridescenceMapTransform)),m.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),m.transmission>0&&(y.transmission.value=m.transmission,y.transmissionSamplerMap.value=v.texture,y.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(y.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,y.transmissionMapTransform)),y.thickness.value=m.thickness,m.thicknessMap&&(y.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=m.attenuationDistance,y.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(y.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(y.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=m.specularIntensity,y.specularColor.value.copy(m.specularColor),m.specularColorMap&&(y.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,y.specularColorMapTransform)),m.specularIntensityMap&&(y.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,y.specularIntensityMapTransform))}function p(y,m){m.matcap&&(y.matcap.value=m.matcap)}function g(y,m){let v=t.get(m).light;y.referencePosition.value.setFromMatrixPosition(v.matrixWorld),y.nearDistance.value=v.shadow.camera.near,y.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:n}}function f4(i,t,e,r){let n={},s={},o=[],a=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(v,x){let b=x.program;r.uniformBlockBinding(v,b)}function c(v,x){let b=n[v.id];b===void 0&&(p(v),b=u(v),n[v.id]=b,v.addEventListener("dispose",y));let S=x.program;r.updateUBOMapping(v,S);let w=t.render.frame;s[v.id]!==w&&(d(v),s[v.id]=w)}function u(v){let x=h();v.__bindingPointIndex=x;let b=i.createBuffer(),S=v.__size,w=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,S,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,b),b}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let x=n[v.id],b=v.uniforms,S=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let w=0,E=b.length;w<E;w++){let A=Array.isArray(b[w])?b[w]:[b[w]];for(let P=0,M=A.length;P<M;P++){let C=A[P];if(f(C,w,P,S)===!0){let O=C.__offset,L=Array.isArray(C.value)?C.value:[C.value],D=0;for(let B=0;B<L.length;B++){let k=L[B],F=g(k);typeof k=="number"||typeof k=="boolean"?(C.__data[0]=k,i.bufferSubData(i.UNIFORM_BUFFER,O+D,C.__data)):k.isMatrix3?(C.__data[0]=k.elements[0],C.__data[1]=k.elements[1],C.__data[2]=k.elements[2],C.__data[3]=0,C.__data[4]=k.elements[3],C.__data[5]=k.elements[4],C.__data[6]=k.elements[5],C.__data[7]=0,C.__data[8]=k.elements[6],C.__data[9]=k.elements[7],C.__data[10]=k.elements[8],C.__data[11]=0):(k.toArray(C.__data,D),D+=F.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,O,C.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(v,x,b,S){let w=v.value,E=x+"_"+b;if(S[E]===void 0)return typeof w=="number"||typeof w=="boolean"?S[E]=w:S[E]=w.clone(),!0;{let A=S[E];if(typeof w=="number"||typeof w=="boolean"){if(A!==w)return S[E]=w,!0}else if(A.equals(w)===!1)return A.copy(w),!0}return!1}function p(v){let x=v.uniforms,b=0,S=16;for(let E=0,A=x.length;E<A;E++){let P=Array.isArray(x[E])?x[E]:[x[E]];for(let M=0,C=P.length;M<C;M++){let O=P[M],L=Array.isArray(O.value)?O.value:[O.value];for(let D=0,B=L.length;D<B;D++){let k=L[D],F=g(k),H=b%S;H!==0&&S-H<F.boundary&&(b+=S-H),O.__data=new Float32Array(F.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=b,b+=F.storage}}}let w=b%S;return w>0&&(b+=S-w),v.__size=b,v.__cache={},this}function g(v){let x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function y(v){let x=v.target;x.removeEventListener("dispose",y);let b=o.indexOf(x.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(n[x.id]),delete n[x.id],delete s[x.id]}function m(){for(let v in n)i.deleteBuffer(n[v]);o=[],n={},s={}}return{bind:l,update:c,dispose:m}}var gp=class{constructor(t={}){let{canvas:e=mU(),context:r=null,depth:n=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=t;this.isWebGLRenderer=!0;let d;r!==null?d=r.getContextAttributes().alpha:d=o;let f=new Uint32Array(4),p=new Int32Array(4),g=null,y=null,m=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ot,this._useLegacyLights=!1,this.toneMapping=Ja,this.toneMappingExposure=1;let x=this,b=!1,S=0,w=0,E=null,A=-1,P=null,M=new Ze,C=new Ze,O=null,L=new ke(0),D=0,B=e.width,k=e.height,F=1,H=null,G=null,X=new Ze(0,0,B,k),Y=new Ze(0,0,B,k),Z=!1,le=new pp,j=!1,K=!1,ee=null,re=new ue,te=new U,$=new T,se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Se(){return E===null?F:1}let W=r;function Ae(z,ne){for(let me=0;me<z.length;me++){let ge=z[me],ae=e.getContext(ge,ne);if(ae!==null)return ae}return null}try{let z={alpha:!0,depth:n,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${la}`),e.addEventListener("webglcontextlost",vr,!1),e.addEventListener("webglcontextrestored",J,!1),e.addEventListener("webglcontextcreationerror",Ge,!1),W===null){let ne=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&ne.shift(),W=Ae(ne,z),W===null)throw Ae(ne)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&W instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(z){throw console.error("THREE.WebGLRenderer: "+z.message),z}let xe,be,Ee,De,Pe,Re,ze,_,I,ie,de,ve,fe,et,Ue,Oe,Be,xt,Te,mt,gt,ct,tt,rt;function Pt(){xe=new Pk(W),be=new Ak(W,xe,t),xe.init(be),ct=new a4(W,xe,be),Ee=new s4(W,xe,be),De=new Ik(W),Pe=new XG,Re=new o4(W,xe,Ee,Pe,be,ct,De),ze=new Tk(x),_=new _k(x),I=new UU(W,be),tt=new Sk(W,xe,I,be),ie=new Dk(W,I,De,tt),de=new Bk(W,ie,I,De),Te=new Nk(W,be,Re),Oe=new Ek(Pe),ve=new qG(x,ze,_,xe,be,tt,Oe),fe=new d4(x,Pe),et=new KG,Ue=new t4(xe,be),xt=new bk(x,ze,_,Ee,de,d,l),Be=new n4(x,de,be),rt=new f4(W,De,be,Ee),mt=new wk(W,xe,De,be),gt=new Ok(W,xe,De,be),De.programs=ve.programs,x.capabilities=be,x.extensions=xe,x.properties=Pe,x.renderLists=et,x.shadowMap=Be,x.state=Ee,x.info=De}Pt();let Ke=new nw(x,W);this.xr=Ke,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let z=xe.get("WEBGL_lose_context");z&&z.loseContext()},this.forceContextRestore=function(){let z=xe.get("WEBGL_lose_context");z&&z.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(z){z!==void 0&&(F=z,this.setSize(B,k,!1))},this.getSize=function(z){return z.set(B,k)},this.setSize=function(z,ne,me=!0){if(Ke.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=z,k=ne,e.width=Math.floor(z*F),e.height=Math.floor(ne*F),me===!0&&(e.style.width=z+"px",e.style.height=ne+"px"),this.setViewport(0,0,z,ne)},this.getDrawingBufferSize=function(z){return z.set(B*F,k*F).floor()},this.setDrawingBufferSize=function(z,ne,me){B=z,k=ne,F=me,e.width=Math.floor(z*me),e.height=Math.floor(ne*me),this.setViewport(0,0,z,ne)},this.getCurrentViewport=function(z){return z.copy(M)},this.getViewport=function(z){return z.copy(X)},this.setViewport=function(z,ne,me,ge){z.isVector4?X.set(z.x,z.y,z.z,z.w):X.set(z,ne,me,ge),Ee.viewport(M.copy(X).multiplyScalar(F).round())},this.getScissor=function(z){return z.copy(Y)},this.setScissor=function(z,ne,me,ge){z.isVector4?Y.set(z.x,z.y,z.z,z.w):Y.set(z,ne,me,ge),Ee.scissor(C.copy(Y).multiplyScalar(F).round())},this.getScissorTest=function(){return Z},this.setScissorTest=function(z){Ee.setScissorTest(Z=z)},this.setOpaqueSort=function(z){H=z},this.setTransparentSort=function(z){G=z},this.getClearColor=function(z){return z.copy(xt.getClearColor())},this.setClearColor=function(){xt.setClearColor.apply(xt,arguments)},this.getClearAlpha=function(){return xt.getClearAlpha()},this.setClearAlpha=function(){xt.setClearAlpha.apply(xt,arguments)},this.clear=function(z=!0,ne=!0,me=!0){let ge=0;if(z){let ae=!1;if(E!==null){let Xe=E.texture.format;ae=Xe===Uy||Xe===i_||Xe===r_}if(ae){let Xe=E.texture.type,Je=Xe===Dr||Xe===is||Xe===Aw||Xe===na||Xe===$C||Xe===e_,pt=xt.getClearColor(),We=xt.getClearAlpha(),Dt=pt.r,Tt=pt.g,_t=pt.b;Je?(f[0]=Dt,f[1]=Tt,f[2]=_t,f[3]=We,W.clearBufferuiv(W.COLOR,0,f)):(p[0]=Dt,p[1]=Tt,p[2]=_t,p[3]=We,W.clearBufferiv(W.COLOR,0,p))}else ge|=W.COLOR_BUFFER_BIT}ne&&(ge|=W.DEPTH_BUFFER_BIT),me&&(ge|=W.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W.clear(ge)},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(){e.removeEventListener("webglcontextlost",vr,!1),e.removeEventListener("webglcontextrestored",J,!1),e.removeEventListener("webglcontextcreationerror",Ge,!1),et.dispose(),Ue.dispose(),Pe.dispose(),ze.dispose(),_.dispose(),de.dispose(),tt.dispose(),rt.dispose(),ve.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",dn),Ke.removeEventListener("sessionend",br),ee&&(ee.dispose(),ee=null),Li.stop()};function vr(z){z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function J(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let z=De.autoReset,ne=Be.enabled,me=Be.autoUpdate,ge=Be.needsUpdate,ae=Be.type;Pt(),De.autoReset=z,Be.enabled=ne,Be.autoUpdate=me,Be.needsUpdate=ge,Be.type=ae}function Ge(z){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",z.statusMessage)}function ce(z){let ne=z.target;ne.removeEventListener("dispose",ce),Fe(ne)}function Fe(z){He(z),Pe.remove(z)}function He(z){let ne=Pe.get(z).programs;ne!==void 0&&(ne.forEach(function(me){ve.releaseProgram(me)}),z.isShaderMaterial&&ve.releaseShaderCache(z))}this.renderBufferDirect=function(z,ne,me,ge,ae,Xe){ne===null&&(ne=se);let Je=ae.isMesh&&ae.matrixWorld.determinant()<0,pt=Jb(z,ne,me,ge,ae);Ee.setMaterial(ge,Je);let We=me.index,Dt=1;if(ge.wireframe===!0){if(We=ie.getWireframeAttribute(me),We===void 0)return;Dt=2}let Tt=me.drawRange,_t=me.attributes.position,Fr=Tt.start*Dt,Yi=(Tt.start+Tt.count)*Dt;Xe!==null&&(Fr=Math.max(Fr,Xe.start*Dt),Yi=Math.min(Yi,(Xe.start+Xe.count)*Dt)),We!==null?(Fr=Math.max(Fr,0),Yi=Math.min(Yi,We.count)):_t!=null&&(Fr=Math.max(Fr,0),Yi=Math.min(Yi,_t.count));let Pr=Yi-Fr;if(Pr<0||Pr===1/0)return;tt.setup(ae,ge,pt,me,We);let St,Rr=mt;if(We!==null&&(St=I.get(We),Rr=gt,Rr.setIndex(St)),ae.isMesh)ge.wireframe===!0?(Ee.setLineWidth(ge.wireframeLinewidth*Se()),Rr.setMode(W.LINES)):Rr.setMode(W.TRIANGLES);else if(ae.isLine){let Mt=ge.linewidth;Mt===void 0&&(Mt=1),Ee.setLineWidth(Mt*Se()),ae.isLineSegments?Rr.setMode(W.LINES):ae.isLineLoop?Rr.setMode(W.LINE_LOOP):Rr.setMode(W.LINE_STRIP)}else ae.isPoints?Rr.setMode(W.POINTS):ae.isSprite&&Rr.setMode(W.TRIANGLES);if(ae.isBatchedMesh)Rr.renderMultiDraw(ae._multiDrawStarts,ae._multiDrawCounts,ae._multiDrawCount);else if(ae.isInstancedMesh)Rr.renderInstances(Fr,Pr,ae.count);else if(me.isInstancedBufferGeometry){let Mt=me._maxInstanceCount!==void 0?me._maxInstanceCount:1/0,cu=Math.min(me.instanceCount,Mt);Rr.renderInstances(Fr,Pr,cu)}else Rr.render(Fr,Pr)};function Ct(z,ne,me){z.transparent===!0&&z.side===Bi&&z.forceSinglePass===!1?(z.side=ni,z.needsUpdate=!0,au(z,ne,me),z.side=Hn,z.needsUpdate=!0,au(z,ne,me),z.side=Bi):au(z,ne,me)}this.compile=function(z,ne,me=null){me===null&&(me=z),y=Ue.get(me),y.init(),v.push(y),me.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ne.layers)&&(y.pushLight(ae),ae.castShadow&&y.pushShadow(ae))}),z!==me&&z.traverseVisible(function(ae){ae.isLight&&ae.layers.test(ne.layers)&&(y.pushLight(ae),ae.castShadow&&y.pushShadow(ae))}),y.setupLights(x._useLegacyLights);let ge=new Set;return z.traverse(function(ae){let Xe=ae.material;if(Xe)if(Array.isArray(Xe))for(let Je=0;Je<Xe.length;Je++){let pt=Xe[Je];Ct(pt,me,ae),ge.add(pt)}else Ct(Xe,me,ae),ge.add(Xe)}),v.pop(),y=null,ge},this.compileAsync=function(z,ne,me=null){let ge=this.compile(z,ne,me);return new Promise(ae=>{function Xe(){if(ge.forEach(function(Je){Pe.get(Je).currentProgram.isReady()&&ge.delete(Je)}),ge.size===0){ae(z);return}setTimeout(Xe,10)}xe.get("KHR_parallel_shader_compile")!==null?Xe():setTimeout(Xe,10)})};let xr=null;function bi(z){xr&&xr(z)}function dn(){Li.stop()}function br(){Li.start()}let Li=new d_;Li.setAnimationLoop(bi),typeof self<"u"&&Li.setContext(self),this.setAnimationLoop=function(z){xr=z,Ke.setAnimationLoop(z),z===null?Li.stop():Li.start()},Ke.addEventListener("sessionstart",dn),Ke.addEventListener("sessionend",br),this.render=function(z,ne){if(ne!==void 0&&ne.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),ne.parent===null&&ne.matrixWorldAutoUpdate===!0&&ne.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(ne),ne=Ke.getCamera()),z.isScene===!0&&z.onBeforeRender(x,z,ne,E),y=Ue.get(z,v.length),y.init(),v.push(y),re.multiplyMatrices(ne.projectionMatrix,ne.matrixWorldInverse),le.setFromProjectionMatrix(re),K=this.localClippingEnabled,j=Oe.init(this.clippingPlanes,K),g=et.get(z,m.length),g.init(),m.push(g),ts(z,ne,0,x.sortObjects),g.finish(),x.sortObjects===!0&&g.sort(H,G),this.info.render.frame++,j===!0&&Oe.beginShadows();let me=y.state.shadowsArray;if(Be.render(me,z,ne),j===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1)&&xt.render(g,z),y.setupLights(x._useLegacyLights),ne.isArrayCamera){let ge=ne.cameras;for(let ae=0,Xe=ge.length;ae<Xe;ae++){let Je=ge[ae];Eg(g,z,Je,Je.viewport)}}else Eg(g,z,ne);E!==null&&(Re.updateMultisampleRenderTarget(E),Re.updateRenderTargetMipmap(E)),z.isScene===!0&&z.onAfterRender(x,z,ne),tt.resetDefaultState(),A=-1,P=null,v.pop(),v.length>0?y=v[v.length-1]:y=null,m.pop(),m.length>0?g=m[m.length-1]:g=null};function ts(z,ne,me,ge){if(z.visible===!1)return;if(z.layers.test(ne.layers)){if(z.isGroup)me=z.renderOrder;else if(z.isLOD)z.autoUpdate===!0&&z.update(ne);else if(z.isLight)y.pushLight(z),z.castShadow&&y.pushShadow(z);else if(z.isSprite){if(!z.frustumCulled||le.intersectsSprite(z)){ge&&$.setFromMatrixPosition(z.matrixWorld).applyMatrix4(re);let Je=de.update(z),pt=z.material;pt.visible&&g.push(z,Je,pt,me,$.z,null)}}else if((z.isMesh||z.isLine||z.isPoints)&&(!z.frustumCulled||le.intersectsObject(z))){let Je=de.update(z),pt=z.material;if(ge&&(z.boundingSphere!==void 0?(z.boundingSphere===null&&z.computeBoundingSphere(),$.copy(z.boundingSphere.center)):(Je.boundingSphere===null&&Je.computeBoundingSphere(),$.copy(Je.boundingSphere.center)),$.applyMatrix4(z.matrixWorld).applyMatrix4(re)),Array.isArray(pt)){let We=Je.groups;for(let Dt=0,Tt=We.length;Dt<Tt;Dt++){let _t=We[Dt],Fr=pt[_t.materialIndex];Fr&&Fr.visible&&g.push(z,Je,Fr,me,$.z,_t)}}else pt.visible&&g.push(z,Je,pt,me,$.z,null)}}let Xe=z.children;for(let Je=0,pt=Xe.length;Je<pt;Je++)ts(Xe[Je],ne,me,ge)}function Eg(z,ne,me,ge){let ae=z.opaque,Xe=z.transmissive,Je=z.transparent;y.setupLightsView(me),j===!0&&Oe.setGlobalState(x.clippingPlanes,me),Xe.length>0&&Zb(ae,Xe,ne,me),ge&&Ee.viewport(M.copy(ge)),ae.length>0&&Ga(ae,ne,me),Xe.length>0&&Ga(Xe,ne,me),Je.length>0&&Ga(Je,ne,me),Ee.buffers.depth.setTest(!0),Ee.buffers.depth.setMask(!0),Ee.buffers.color.setMask(!0),Ee.setPolygonOffset(!1)}function Zb(z,ne,me,ge){if((me.isScene===!0?me.overrideMaterial:null)!==null)return;let Xe=be.isWebGL2;ee===null&&(ee=new yt(1,1,{generateMipmaps:!0,type:xe.has("EXT_color_buffer_half_float")?sa:Dr,minFilter:ra,samples:Xe?4:0})),x.getDrawingBufferSize(te),Xe?ee.setSize(te.x,te.y):ee.setSize(dy(te.x),dy(te.y));let Je=x.getRenderTarget();x.setRenderTarget(ee),x.getClearColor(L),D=x.getClearAlpha(),D<1&&x.setClearColor(16777215,.5),x.clear();let pt=x.toneMapping;x.toneMapping=Ja,Ga(z,me,ge),Re.updateMultisampleRenderTarget(ee),Re.updateRenderTargetMipmap(ee);let We=!1;for(let Dt=0,Tt=ne.length;Dt<Tt;Dt++){let _t=ne[Dt],Fr=_t.object,Yi=_t.geometry,Pr=_t.material,St=_t.group;if(Pr.side===Bi&&Fr.layers.test(ge.layers)){let Rr=Pr.side;Pr.side=ni,Pr.needsUpdate=!0,Tg(Fr,me,ge,Yi,Pr,St),Pr.side=Rr,Pr.needsUpdate=!0,We=!0}}We===!0&&(Re.updateMultisampleRenderTarget(ee),Re.updateRenderTargetMipmap(ee)),x.setRenderTarget(Je),x.setClearColor(L,D),x.toneMapping=pt}function Ga(z,ne,me){let ge=ne.isScene===!0?ne.overrideMaterial:null;for(let ae=0,Xe=z.length;ae<Xe;ae++){let Je=z[ae],pt=Je.object,We=Je.geometry,Dt=ge===null?Je.material:ge,Tt=Je.group;pt.layers.test(me.layers)&&Tg(pt,ne,me,We,Dt,Tt)}}function Tg(z,ne,me,ge,ae,Xe){z.onBeforeRender(x,ne,me,ge,ae,Xe),z.modelViewMatrix.multiplyMatrices(me.matrixWorldInverse,z.matrixWorld),z.normalMatrix.getNormalMatrix(z.modelViewMatrix),ae.onBeforeRender(x,ne,me,ge,z,Xe),ae.transparent===!0&&ae.side===Bi&&ae.forceSinglePass===!1?(ae.side=ni,ae.needsUpdate=!0,x.renderBufferDirect(me,ne,ge,ae,z,Xe),ae.side=Hn,ae.needsUpdate=!0,x.renderBufferDirect(me,ne,ge,ae,z,Xe),ae.side=Bi):x.renderBufferDirect(me,ne,ge,ae,z,Xe),z.onAfterRender(x,ne,me,ge,ae,Xe)}function au(z,ne,me){ne.isScene!==!0&&(ne=se);let ge=Pe.get(z),ae=y.state.lights,Xe=y.state.shadowsArray,Je=ae.state.version,pt=ve.getParameters(z,ae.state,Xe,ne,me),We=ve.getProgramCacheKey(pt),Dt=ge.programs;ge.environment=z.isMeshStandardMaterial?ne.environment:null,ge.fog=ne.fog,ge.envMap=(z.isMeshStandardMaterial?_:ze).get(z.envMap||ge.environment),ge.envMapRotation=ge.environment!==null&&z.envMap===null?ne.environmentRotation:z.envMapRotation,Dt===void 0&&(z.addEventListener("dispose",ce),Dt=new Map,ge.programs=Dt);let Tt=Dt.get(We);if(Tt!==void 0){if(ge.currentProgram===Tt&&ge.lightsStateVersion===Je)return Mg(z,pt),Tt}else pt.uniforms=ve.getUniforms(z),z.onBuild(me,pt,x),z.onBeforeCompile(pt,x),Tt=ve.acquireProgram(pt,We),Dt.set(We,Tt),ge.uniforms=pt.uniforms;let _t=ge.uniforms;return(!z.isShaderMaterial&&!z.isRawShaderMaterial||z.clipping===!0)&&(_t.clippingPlanes=Oe.uniform),Mg(z,pt),ge.needsLights=$b(z),ge.lightsStateVersion=Je,ge.needsLights&&(_t.ambientLightColor.value=ae.state.ambient,_t.lightProbe.value=ae.state.probe,_t.directionalLights.value=ae.state.directional,_t.directionalLightShadows.value=ae.state.directionalShadow,_t.spotLights.value=ae.state.spot,_t.spotLightShadows.value=ae.state.spotShadow,_t.rectAreaLights.value=ae.state.rectArea,_t.ltc_1.value=ae.state.rectAreaLTC1,_t.ltc_2.value=ae.state.rectAreaLTC2,_t.pointLights.value=ae.state.point,_t.pointLightShadows.value=ae.state.pointShadow,_t.hemisphereLights.value=ae.state.hemi,_t.directionalShadowMap.value=ae.state.directionalShadowMap,_t.directionalShadowMatrix.value=ae.state.directionalShadowMatrix,_t.spotShadowMap.value=ae.state.spotShadowMap,_t.spotLightMatrix.value=ae.state.spotLightMatrix,_t.spotLightMap.value=ae.state.spotLightMap,_t.pointShadowMap.value=ae.state.pointShadowMap,_t.pointShadowMatrix.value=ae.state.pointShadowMatrix),ge.currentProgram=Tt,ge.uniformsList=null,Tt}function lu(z){if(z.uniformsList===null){let ne=z.currentProgram.getUniforms();z.uniformsList=Ru.seqWithValue(ne.seq,z.uniforms)}return z.uniformsList}function Mg(z,ne){let me=Pe.get(z);me.outputColorSpace=ne.outputColorSpace,me.batching=ne.batching,me.instancing=ne.instancing,me.instancingColor=ne.instancingColor,me.instancingMorph=ne.instancingMorph,me.skinning=ne.skinning,me.morphTargets=ne.morphTargets,me.morphNormals=ne.morphNormals,me.morphColors=ne.morphColors,me.morphTargetsCount=ne.morphTargetsCount,me.numClippingPlanes=ne.numClippingPlanes,me.numIntersection=ne.numClipIntersection,me.vertexAlphas=ne.vertexAlphas,me.vertexTangents=ne.vertexTangents,me.toneMapping=ne.toneMapping}function Jb(z,ne,me,ge,ae){ne.isScene!==!0&&(ne=se),Re.resetTextureUnits();let Xe=ne.fog,Je=ge.isMeshStandardMaterial?ne.environment:null,pt=E===null?x.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:an,We=(ge.isMeshStandardMaterial?_:ze).get(ge.envMap||Je),Dt=ge.vertexColors===!0&&!!me.attributes.color&&me.attributes.color.itemSize===4,Tt=!!me.attributes.tangent&&(!!ge.normalMap||ge.anisotropy>0),_t=!!me.morphAttributes.position,Fr=!!me.morphAttributes.normal,Yi=!!me.morphAttributes.color,Pr=Ja;ge.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Pr=x.toneMapping);let St=me.morphAttributes.position||me.morphAttributes.normal||me.morphAttributes.color,Rr=St!==void 0?St.length:0,Mt=Pe.get(ge),cu=y.state.lights;if(j===!0&&(K===!0||z!==P)){let tn=z===P&&ge.id===A;Oe.setState(ge,z,tn)}let $t=!1;ge.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==cu.state.version||Mt.outputColorSpace!==pt||ae.isBatchedMesh&&Mt.batching===!1||!ae.isBatchedMesh&&Mt.batching===!0||ae.isInstancedMesh&&Mt.instancing===!1||!ae.isInstancedMesh&&Mt.instancing===!0||ae.isSkinnedMesh&&Mt.skinning===!1||!ae.isSkinnedMesh&&Mt.skinning===!0||ae.isInstancedMesh&&Mt.instancingColor===!0&&ae.instanceColor===null||ae.isInstancedMesh&&Mt.instancingColor===!1&&ae.instanceColor!==null||ae.isInstancedMesh&&Mt.instancingMorph===!0&&ae.morphTexture===null||ae.isInstancedMesh&&Mt.instancingMorph===!1&&ae.morphTexture!==null||Mt.envMap!==We||ge.fog===!0&&Mt.fog!==Xe||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==Oe.numPlanes||Mt.numIntersection!==Oe.numIntersection)||Mt.vertexAlphas!==Dt||Mt.vertexTangents!==Tt||Mt.morphTargets!==_t||Mt.morphNormals!==Fr||Mt.morphColors!==Yi||Mt.toneMapping!==Pr||be.isWebGL2===!0&&Mt.morphTargetsCount!==Rr)&&($t=!0):($t=!0,Mt.__version=ge.version);let R=Mt.currentProgram;$t===!0&&(R=au(ge,ne,ae));let N=!1,q=!1,V=!1,Q=R.getUniforms(),Ce=Mt.uniforms;if(Ee.useProgram(R.program)&&(N=!0,q=!0,V=!0),ge.id!==A&&(A=ge.id,q=!0),N||P!==z){Q.setValue(W,"projectionMatrix",z.projectionMatrix),Q.setValue(W,"viewMatrix",z.matrixWorldInverse);let tn=Q.map.cameraPosition;tn!==void 0&&tn.setValue(W,$.setFromMatrixPosition(z.matrixWorld)),be.logarithmicDepthBuffer&&Q.setValue(W,"logDepthBufFC",2/(Math.log(z.far+1)/Math.LN2)),(ge.isMeshPhongMaterial||ge.isMeshToonMaterial||ge.isMeshLambertMaterial||ge.isMeshBasicMaterial||ge.isMeshStandardMaterial||ge.isShaderMaterial)&&Q.setValue(W,"isOrthographic",z.isOrthographicCamera===!0),P!==z&&(P=z,q=!0,V=!0)}if(ae.isSkinnedMesh){Q.setOptional(W,ae,"bindMatrix"),Q.setOptional(W,ae,"bindMatrixInverse");let tn=ae.skeleton;tn&&(be.floatVertexTextures?(tn.boneTexture===null&&tn.computeBoneTexture(),Q.setValue(W,"boneTexture",tn.boneTexture,Re)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ae.isBatchedMesh&&(Q.setOptional(W,ae,"batchingTexture"),Q.setValue(W,"batchingTexture",ae._matricesTexture,Re));let oo=me.morphAttributes;if((oo.position!==void 0||oo.normal!==void 0||oo.color!==void 0&&be.isWebGL2===!0)&&Te.update(ae,me,R),(q||Mt.receiveShadow!==ae.receiveShadow)&&(Mt.receiveShadow=ae.receiveShadow,Q.setValue(W,"receiveShadow",ae.receiveShadow)),ge.isMeshGouraudMaterial&&ge.envMap!==null&&(Ce.envMap.value=We,Ce.flipEnvMap.value=We.isCubeTexture&&We.isRenderTargetTexture===!1?-1:1),q&&(Q.setValue(W,"toneMappingExposure",x.toneMappingExposure),Mt.needsLights&&Qf(Ce,V),Xe&&ge.fog===!0&&fe.refreshFogUniforms(Ce,Xe),fe.refreshMaterialUniforms(Ce,ge,F,k,ee),Ru.upload(W,lu(Mt),Ce,Re)),ge.isShaderMaterial&&ge.uniformsNeedUpdate===!0&&(Ru.upload(W,lu(Mt),Ce,Re),ge.uniformsNeedUpdate=!1),ge.isSpriteMaterial&&Q.setValue(W,"center",ae.center),Q.setValue(W,"modelViewMatrix",ae.modelViewMatrix),Q.setValue(W,"normalMatrix",ae.normalMatrix),Q.setValue(W,"modelMatrix",ae.matrixWorld),ae.previousModelViewMatrix&&Q.setValue(W,"previousModelViewMatrix",ae.previousModelViewMatrix),z.previousProjectionMatrix&&Q.setValue(W,"previousProjectionMatrix",z.previousProjectionMatrix),ge.isShaderMaterial||ge.isRawShaderMaterial){let tn=ge.uniformsGroups;for(let Ha=0,Zf=tn.length;Ha<Zf;Ha++)if(be.isWebGL2){let nc=tn[Ha];rt.update(nc,R),rt.bind(nc,R)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return R}function Qf(z,ne){z.ambientLightColor.needsUpdate=ne,z.lightProbe.needsUpdate=ne,z.directionalLights.needsUpdate=ne,z.directionalLightShadows.needsUpdate=ne,z.pointLights.needsUpdate=ne,z.pointLightShadows.needsUpdate=ne,z.spotLights.needsUpdate=ne,z.spotLightShadows.needsUpdate=ne,z.rectAreaLights.needsUpdate=ne,z.hemisphereLights.needsUpdate=ne}function $b(z){return z.isMeshLambertMaterial||z.isMeshToonMaterial||z.isMeshPhongMaterial||z.isMeshStandardMaterial||z.isShadowMaterial||z.isShaderMaterial&&z.lights===!0}this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(z,ne,me){Pe.get(z.texture).__webglTexture=ne,Pe.get(z.depthTexture).__webglTexture=me;let ge=Pe.get(z);ge.__hasExternalTextures=!0,ge.__autoAllocateDepthBuffer=me===void 0,ge.__autoAllocateDepthBuffer||xe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ge.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(z,ne){let me=Pe.get(z);me.__webglFramebuffer=ne,me.__useDefaultFramebuffer=ne===void 0},this.setRenderTarget=function(z,ne=0,me=0){E=z,S=ne,w=me;let ge=!0,ae=null,Xe=!1,Je=!1;if(z){let We=Pe.get(z);We.__useDefaultFramebuffer!==void 0?(Ee.bindFramebuffer(W.FRAMEBUFFER,null),ge=!1):We.__webglFramebuffer===void 0?Re.setupRenderTarget(z):We.__hasExternalTextures&&Re.rebindTextures(z,Pe.get(z.texture).__webglTexture,Pe.get(z.depthTexture).__webglTexture);let Dt=z.texture;(Dt.isData3DTexture||Dt.isDataArrayTexture||Dt.isCompressedArrayTexture)&&(Je=!0);let Tt=Pe.get(z).__webglFramebuffer;z.isWebGLCubeRenderTarget?(Array.isArray(Tt[ne])?ae=Tt[ne][me]:ae=Tt[ne],Xe=!0):be.isWebGL2&&z.samples>0&&Re.useMultisampledRTT(z)===!1?ae=Pe.get(z).__webglMultisampledFramebuffer:Array.isArray(Tt)?ae=Tt[me]:ae=Tt,M.copy(z.viewport),C.copy(z.scissor),O=z.scissorTest}else M.copy(X).multiplyScalar(F).floor(),C.copy(Y).multiplyScalar(F).floor(),O=Z;if(Ee.bindFramebuffer(W.FRAMEBUFFER,ae)&&be.drawBuffers&&ge&&Ee.drawBuffers(z,ae),Ee.viewport(M),Ee.scissor(C),Ee.setScissorTest(O),Xe){let We=Pe.get(z.texture);W.framebufferTexture2D(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,W.TEXTURE_CUBE_MAP_POSITIVE_X+ne,We.__webglTexture,me)}else if(Je){let We=Pe.get(z.texture),Dt=ne||0;W.framebufferTextureLayer(W.FRAMEBUFFER,W.COLOR_ATTACHMENT0,We.__webglTexture,me||0,Dt)}A=-1},this.readRenderTargetPixels=function(z,ne,me,ge,ae,Xe,Je){if(!(z&&z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let pt=Pe.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&Je!==void 0&&(pt=pt[Je]),pt){Ee.bindFramebuffer(W.FRAMEBUFFER,pt);try{let We=z.texture,Dt=We.format,Tt=We.type;if(Dt!==Yr&&ct.convert(Dt)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let _t=Tt===sa&&(xe.has("EXT_color_buffer_half_float")||be.isWebGL2&&xe.has("EXT_color_buffer_float"));if(Tt!==Dr&&ct.convert(Tt)!==W.getParameter(W.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Tt===ar&&(be.isWebGL2||xe.has("OES_texture_float")||xe.has("WEBGL_color_buffer_float")))&&!_t){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ne>=0&&ne<=z.width-ge&&me>=0&&me<=z.height-ae&&W.readPixels(ne,me,ge,ae,ct.convert(Dt),ct.convert(Tt),Xe)}finally{let We=E!==null?Pe.get(E).__webglFramebuffer:null;Ee.bindFramebuffer(W.FRAMEBUFFER,We)}}},this.copyFramebufferToTexture=function(z,ne,me=0){let ge=Math.pow(2,-me),ae=Math.floor(ne.image.width*ge),Xe=Math.floor(ne.image.height*ge);Re.setTexture2D(ne,0),W.copyTexSubImage2D(W.TEXTURE_2D,me,0,0,z.x,z.y,ae,Xe),Ee.unbindTexture()},this.copyTextureToTexture=function(z,ne,me,ge=0){let ae=ne.image.width,Xe=ne.image.height,Je=ct.convert(me.format),pt=ct.convert(me.type);Re.setTexture2D(me,0),W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,me.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,me.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,me.unpackAlignment),ne.isDataTexture?W.texSubImage2D(W.TEXTURE_2D,ge,z.x,z.y,ae,Xe,Je,pt,ne.image.data):ne.isCompressedTexture?W.compressedTexSubImage2D(W.TEXTURE_2D,ge,z.x,z.y,ne.mipmaps[0].width,ne.mipmaps[0].height,Je,ne.mipmaps[0].data):W.texSubImage2D(W.TEXTURE_2D,ge,z.x,z.y,Je,pt,ne.image),ge===0&&me.generateMipmaps&&W.generateMipmap(W.TEXTURE_2D),Ee.unbindTexture()},this.copyTextureToTexture3D=function(z,ne,me,ge,ae=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Xe=Math.round(z.max.x-z.min.x),Je=Math.round(z.max.y-z.min.y),pt=z.max.z-z.min.z+1,We=ct.convert(ge.format),Dt=ct.convert(ge.type),Tt;if(ge.isData3DTexture)Re.setTexture3D(ge,0),Tt=W.TEXTURE_3D;else if(ge.isDataArrayTexture||ge.isCompressedArrayTexture)Re.setTexture2DArray(ge,0),Tt=W.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(W.UNPACK_FLIP_Y_WEBGL,ge.flipY),W.pixelStorei(W.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ge.premultiplyAlpha),W.pixelStorei(W.UNPACK_ALIGNMENT,ge.unpackAlignment);let _t=W.getParameter(W.UNPACK_ROW_LENGTH),Fr=W.getParameter(W.UNPACK_IMAGE_HEIGHT),Yi=W.getParameter(W.UNPACK_SKIP_PIXELS),Pr=W.getParameter(W.UNPACK_SKIP_ROWS),St=W.getParameter(W.UNPACK_SKIP_IMAGES),Rr=me.isCompressedTexture?me.mipmaps[ae]:me.image;W.pixelStorei(W.UNPACK_ROW_LENGTH,Rr.width),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Rr.height),W.pixelStorei(W.UNPACK_SKIP_PIXELS,z.min.x),W.pixelStorei(W.UNPACK_SKIP_ROWS,z.min.y),W.pixelStorei(W.UNPACK_SKIP_IMAGES,z.min.z),me.isDataTexture||me.isData3DTexture?W.texSubImage3D(Tt,ae,ne.x,ne.y,ne.z,Xe,Je,pt,We,Dt,Rr.data):ge.isCompressedArrayTexture?W.compressedTexSubImage3D(Tt,ae,ne.x,ne.y,ne.z,Xe,Je,pt,We,Rr.data):W.texSubImage3D(Tt,ae,ne.x,ne.y,ne.z,Xe,Je,pt,We,Dt,Rr),W.pixelStorei(W.UNPACK_ROW_LENGTH,_t),W.pixelStorei(W.UNPACK_IMAGE_HEIGHT,Fr),W.pixelStorei(W.UNPACK_SKIP_PIXELS,Yi),W.pixelStorei(W.UNPACK_SKIP_ROWS,Pr),W.pixelStorei(W.UNPACK_SKIP_IMAGES,St),ae===0&&ge.generateMipmaps&&W.generateMipmap(Tt),Ee.unbindTexture()},this.initTexture=function(z){z.isCubeTexture?Re.setTextureCube(z,0):z.isData3DTexture?Re.setTexture3D(z,0):z.isDataArrayTexture||z.isCompressedArrayTexture?Re.setTexture2DArray(z,0):Re.setTexture2D(z,0),Ee.unbindTexture()},this.resetState=function(){S=0,w=0,E=null,Ee.reset(),tt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ia}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===_w?"display-p3":"srgb",e.unpackColorSpace=or.workingColorSpace===Vy?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},sw=class extends gp{};sw.prototype.isWebGL1Renderer=!0;var Uu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new ke(t),this.near=e,this.far=r}clone(){return new Uu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Ai=class extends Rt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ht,this.environmentRotation=new Ht,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),e.object.environmentRotation=this.environmentRotation.toArray(),e}},xy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=HS,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=ss()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return l_("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[r+n];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ss()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ss()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},fn=new T,gc=class{constructor(t,e,r,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=r,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,r=this.data.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.applyMatrix4(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.applyNormalMatrix(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)fn.fromBufferAttribute(this,e),fn.transformDirection(t),this.setXYZ(e,fn.x,fn.y,fn.z);return this}getComponent(t,e){let r=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(r=Os(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=mr(r,this.array)),this.data.array[t*this.data.stride+this.offset+e]=r,this}setX(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=mr(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Os(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Os(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Os(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Os(e,this.array)),e}setXY(t,e,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=mr(e,this.array),r=mr(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this}setXYZ(t,e,r,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=mr(e,this.array),r=mr(r,this.array),n=mr(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this}setXYZW(t,e,r,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=mr(e,this.array),r=mr(r,this.array),n=mr(n,this.array),s=mr(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=r,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new Ye(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new gc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let r=0;r<this.count;r++){let n=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var yp=class extends Rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},si=class extends Zt{constructor(t=null,e=1,r=1,n,s,o,a,l,c=Vt,u=Vt,h,d){super(null,o,a,l,c,u,n,s,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},TC=new ue,p4=new ue,rl=class{constructor(t=[],e=[]){this.uuid=ss(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let r=0,n=this.bones.length;r<n;r++)this.boneInverses.push(new ue)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let r=new ue;this.bones[t]&&r.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&r.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let r=this.bones[t];r&&(r.parent&&r.parent.isBone?(r.matrix.copy(r.parent.matrixWorld).invert(),r.matrix.multiply(r.matrixWorld)):r.matrix.copy(r.matrixWorld),r.matrix.decompose(r.position,r.quaternion,r.scale))}}update(){let t=this.bones,e=this.boneInverses,r=this.boneMatrices,n=this.boneTexture;for(let s=0,o=t.length;s<o;s++){let a=t[s]?t[s].matrixWorld:p4;TC.multiplyMatrices(a,e[s]),TC.toArray(r,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new rl(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let r=new si(e,t,t,Yr,ar);return r.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=r,this}getBoneByName(t){for(let e=0,r=this.bones.length;e<r;e++){let n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let r=0,n=t.bones.length;r<n;r++){let s=t.bones[r],o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new yp),this.bones.push(o),this.boneInverses.push(new ue().fromArray(t.boneInverses[r]))}return this.init(),this}toJSON(){let t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,r=this.boneInverses;for(let n=0,s=e.length;n<s;n++){let o=e[n];t.bones.push(o.uuid);let a=r[n];t.boneInverses.push(a.toArray())}return t}},co=class extends Ye{constructor(t,e,r,n=1){super(t,e,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},Mu=new ue,MC=new ue,Kg=[],CC=new zt,m4=new ue,np=new tr,sp=new Or,by=class extends tr{constructor(t,e,r){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new co(new Float32Array(r*16),16),this.instanceColor=null,this.morphTexture=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<r;n++)this.setMatrixAt(n,m4)}computeBoundingBox(){let t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new zt),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<e;r++)this.getMatrixAt(r,Mu),CC.copy(t.boundingBox).applyMatrix4(Mu),this.boundingBox.union(CC)}computeBoundingSphere(){let t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Or),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<e;r++)this.getMatrixAt(r,Mu),sp.copy(t.boundingSphere).applyMatrix4(Mu),this.boundingSphere.union(sp)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){let r=e.morphTargetInfluences,n=this.morphTexture.source.data.data,s=r.length+1,o=t*s+1;for(let a=0;a<r.length;a++)r[a]=n[o+a]}raycast(t,e){let r=this.matrixWorld,n=this.count;if(np.geometry=this.geometry,np.material=this.material,np.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),sp.copy(this.boundingSphere),sp.applyMatrix4(r),t.ray.intersectsSphere(sp)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Mu),MC.multiplyMatrices(r,Mu),np.matrixWorld=MC,np.raycast(t,Kg);for(let o=0,a=Kg.length;o<a;o++){let l=Kg[o];l.instanceId=s,l.object=this,e.push(l)}Kg.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new co(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){let r=e.morphTargetInfluences,n=r.length+1;this.morphTexture===null&&(this.morphTexture=new si(new Float32Array(n*this.count),n,this.count,t_,ar));let s=this.morphTexture.source.data.data,o=0;for(let c=0;c<r.length;c++)o+=r[c];let a=this.geometry.morphTargetsRelative?1:1-o,l=n*t;s[l]=a,s.set(r,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}};var os=class extends mc{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ke(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},_C=new T,PC=new T,DC=new ue,IS=new Rs,Qg=new Or,yc=class extends Rt{constructor(t=new Ne,e=new os){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[0];for(let n=1,s=e.count;n<s;n++)_C.fromBufferAttribute(e,n-1),PC.fromBufferAttribute(e,n),r[n]=r[n-1],r[n]+=_C.distanceTo(PC);t.setAttribute("lineDistance",new Ie(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let r=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Qg.copy(r.boundingSphere),Qg.applyMatrix4(n),Qg.radius+=s,t.ray.intersectsSphere(Qg)===!1)return;DC.copy(n).invert(),IS.copy(t.ray).applyMatrix4(DC);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new T,u=new T,h=new T,d=new T,f=this.isLineSegments?2:1,p=r.index,y=r.attributes.position;if(p!==null){let m=Math.max(0,o.start),v=Math.min(p.count,o.start+o.count);for(let x=m,b=v-1;x<b;x+=f){let S=p.getX(x),w=p.getX(x+1);if(c.fromBufferAttribute(y,S),u.fromBufferAttribute(y,w),IS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);A<t.near||A>t.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,o.start),v=Math.min(y.count,o.start+o.count);for(let x=m,b=v-1;x<b;x+=f){if(c.fromBufferAttribute(y,x),u.fromBufferAttribute(y,x+1),IS.distanceSqToSegment(c,u,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let w=t.ray.origin.distanceTo(d);w<t.near||w>t.far||e.push({distance:w,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let n=e[r[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){let a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},OC=new T,IC=new T,il=class extends yc{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,r=[];for(let n=0,s=e.count;n<s;n+=2)OC.fromBufferAttribute(e,n),IC.fromBufferAttribute(e,n+1),r[n]=n===0?0:r[n-1],r[n+1]=r[n]+OC.distanceTo(IC);t.setAttribute("lineDistance",new Ie(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Sy=class extends Zt{constructor(t,e,r,n,s,o,a,l,c){super(t,e,r,n,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:it,this.magFilter=s!==void 0?s:it,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var wy=class extends Zt{constructor(t,e,r,n,s,o,a,l,c){super(t,e,r,n,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},as=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(n),e.push(s),n=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),n=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=r[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,r[n]===o)return n/(s-1);let u=r[n],d=r[n+1]-u,f=(o-u)/d;return(n+f)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=e||(o.isVector2?new U:new T);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new T,n=[],s=[],o=[],a=new T,l=new ue;for(let f=0;f<=t;f++){let p=f/t;n[f]=this.getTangentAt(p,new T)}s[0]=new T,o[0]=new T;let c=Number.MAX_VALUE,u=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);u<=c&&(c=u,r.set(1,0,0)),h<=c&&(c=h,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(n[0],r).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(n[f-1],n[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(ti(n[f-1].dot(n[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(n[f],s[f])}if(e===!0){let f=Math.acos(ti(s[0].dot(s[t]),-1,1));f/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(n[p],f*p)),o[p].crossVectors(n[p],s[p])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},vc=class extends as{constructor(t=0,e=0,r=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new U){let r=e,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=n;for(;s>n;)s-=n;s<Number.EPSILON&&(o?s=0:s=n),this.aClockwise===!0&&!o&&(s===n?s=-n:s=s-n);let a=this.aStartAngle+t*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},ow=class extends vc{constructor(t,e,r,n,s,o){super(t,e,r,r,n,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function Ow(){let i=0,t=0,e=0,r=0;function n(s,o,a,l){i=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){n(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let d=(o-s)/c-(a-s)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,f*=u,n(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return i+t*s+e*o+r*a}}}var Zg=new T,RS=new Ow,LS=new Ow,NS=new Ow,aw=class extends as{constructor(t=[],e=!1,r="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=n}getPoint(t,e=new T){let r=e,n=this.points,s=n.length,o=(s-(this.closed?0:1))*t,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%s]:(Zg.subVectors(n[0],n[1]).add(n[0]),c=Zg);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2<s?u=n[(a+2)%s]:(Zg.subVectors(n[s-1],n[s-2]).add(n[s-1]),u=Zg),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,p=Math.pow(c.distanceToSquared(h),f),g=Math.pow(h.distanceToSquared(d),f),y=Math.pow(d.distanceToSquared(u),f);g<1e-4&&(g=1),p<1e-4&&(p=g),y<1e-4&&(y=g),RS.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,p,g,y),LS.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,p,g,y),NS.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,p,g,y)}else this.curveType==="catmullrom"&&(RS.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),LS.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),NS.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return r.set(RS.calc(l),LS.calc(l),NS.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new T().fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function RC(i,t,e,r,n){let s=(r-t)*.5,o=(n-e)*.5,a=i*i,l=i*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*i+e}function g4(i,t){let e=1-i;return e*e*t}function y4(i,t){return 2*(1-i)*i*t}function v4(i,t){return i*i*t}function up(i,t,e,r){return g4(i,t)+y4(i,e)+v4(i,r)}function x4(i,t){let e=1-i;return e*e*e*t}function b4(i,t){let e=1-i;return 3*e*e*i*t}function S4(i,t){return 3*(1-i)*i*i*t}function w4(i,t){return i*i*i*t}function hp(i,t,e,r,n){return x4(i,t)+b4(i,e)+S4(i,r)+w4(i,n)}var on=class extends as{constructor(t=new U,e=new U,r=new U,n=new U){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new U){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(hp(t,n.x,s.x,o.x,a.x),hp(t,n.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},xc=class extends as{constructor(t=new T,e=new T,r=new T,n=new T){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=n}getPoint(t,e=new T){let r=e,n=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(hp(t,n.x,s.x,o.x,a.x),hp(t,n.y,s.y,o.y,a.y),hp(t,n.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},mn=class extends as{constructor(t=new U,e=new U){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new U){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new U){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},vp=class extends as{constructor(t=new T,e=new T){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new T){let r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new T){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Xn=class extends as{constructor(t=new U,e=new U,r=new U){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new U){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(up(t,n.x,s.x,o.x),up(t,n.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},lw=class extends as{constructor(t=new T,e=new T,r=new T){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new T){let r=e,n=this.v0,s=this.v1,o=this.v2;return r.set(up(t,n.x,s.x,o.x),up(t,n.y,s.y,o.y),up(t,n.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Vu=class extends as{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new U){let r=e,n=this.points,s=(n.length-1)*t,o=Math.floor(s),a=s-o,l=n[o===0?o:o-1],c=n[o],u=n[o>n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return r.set(RC(a,l.x,c.x,u.x,h.x),RC(a,l.y,c.y,u.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){let n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){let n=t.points[e];this.points.push(new U().fromArray(n))}return this}},LC=Object.freeze({__proto__:null,ArcCurve:ow,CatmullRomCurve3:aw,CubicBezierCurve:on,CubicBezierCurve3:xc,EllipseCurve:vc,LineCurve:mn,LineCurve3:vp,QuadraticBezierCurve:Xn,QuadraticBezierCurve3:lw,SplineCurve:Vu}),xp=class extends as{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new LC[r](e,t))}return this}getPoint(t,e){let r=t*this.getLength(),n=this.getCurveLengths(),s=0;for(;s<n.length;){if(n[s]>=r){let o=n[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let r=0,n=this.curves.length;r<n;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],r;for(let n=0,s=this.curves;n<s.length;n++){let o=s[n],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){let u=l[c];r&&r.equals(u)||(e.push(u),r=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){let n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){let n=t.curves[e];this.curves.push(new LC[n.type]().fromJSON(n))}return this}},bc=class extends xp{constructor(t){super(),this.type="Path",this.currentPoint=new U,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let r=new mn(this.currentPoint.clone(),new U(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,n){let s=new Xn(this.currentPoint.clone(),new U(t,e),new U(r,n));return this.curves.push(s),this.currentPoint.set(r,n),this}bezierCurveTo(t,e,r,n,s,o){let a=new on(this.currentPoint.clone(),new U(t,e),new U(r,n),new U(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),r=new Vu(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,n,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,n,s,o),this}absarc(t,e,r,n,s,o){return this.absellipse(t,e,r,r,n,s,o),this}ellipse(t,e,r,n,s,o,a,l){let c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+c,e+u,r,n,s,o,a,l),this}absellipse(t,e,r,n,s,o,a,l){let c=new vc(t,e,r,n,s,o,a,l);if(this.curves.length>0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},zu=class extends Ne{constructor(t=[new U(0,-.5),new U(.5,0),new U(0,.5)],e=12,r=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:n},e=Math.floor(e),n=ti(n,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new T,d=new U,f=new T,p=new T,g=new T,y=0,m=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:y=t[v+1].x-t[v].x,m=t[v+1].y-t[v].y,f.x=m*1,f.y=-y,f.z=m*0,g.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(g.x,g.y,g.z);break;default:y=t[v+1].x-t[v].x,m=t[v+1].y-t[v].y,f.x=m*1,f.y=-y,f.z=m*0,p.copy(f),f.x+=g.x,f.y+=g.y,f.z+=g.z,f.normalize(),l.push(f.x,f.y,f.z),g.copy(p)}for(let v=0;v<=e;v++){let x=r+v*u*n,b=Math.sin(x),S=Math.cos(x);for(let w=0;w<=t.length-1;w++){h.x=t[w].x*b,h.y=t[w].y,h.z=t[w].x*S,o.push(h.x,h.y,h.z),d.x=v/e,d.y=w/(t.length-1),a.push(d.x,d.y);let E=l[3*w+0]*b,A=l[3*w+1],P=l[3*w+0]*S;c.push(E,A,P)}}for(let v=0;v<e;v++)for(let x=0;x<t.length-1;x++){let b=x+v*t.length,S=b,w=b+t.length,E=b+t.length+1,A=b+1;s.push(S,w,A),s.push(E,A,w)}this.setIndex(s),this.setAttribute("position",new Ie(o,3)),this.setAttribute("uv",new Ie(a,2)),this.setAttribute("normal",new Ie(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zu(t.points,t.segments,t.phiStart,t.phiLength)}};var Sc=class extends Ne{constructor(t=1,e=1,r=1,n=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;n=Math.floor(n),s=Math.floor(s);let u=[],h=[],d=[],f=[],p=0,g=[],y=r/2,m=0;v(),o===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Ie(h,3)),this.setAttribute("normal",new Ie(d,3)),this.setAttribute("uv",new Ie(f,2));function v(){let b=new T,S=new T,w=0,E=(e-t)/r;for(let A=0;A<=s;A++){let P=[],M=A/s,C=M*(e-t)+t;for(let O=0;O<=n;O++){let L=O/n,D=L*l+a,B=Math.sin(D),k=Math.cos(D);S.x=C*B,S.y=-M*r+y,S.z=C*k,h.push(S.x,S.y,S.z),b.set(B,E,k).normalize(),d.push(b.x,b.y,b.z),f.push(L,1-M),P.push(p++)}g.push(P)}for(let A=0;A<n;A++)for(let P=0;P<s;P++){let M=g[P][A],C=g[P+1][A],O=g[P+1][A+1],L=g[P][A+1];u.push(M,C,L),u.push(C,O,L),w+=6}c.addGroup(m,w,0),m+=w}function x(b){let S=p,w=new U,E=new T,A=0,P=b===!0?t:e,M=b===!0?1:-1;for(let O=1;O<=n;O++)h.push(0,y*M,0),d.push(0,M,0),f.push(.5,.5),p++;let C=p;for(let O=0;O<=n;O++){let D=O/n*l+a,B=Math.cos(D),k=Math.sin(D);E.x=P*k,E.y=y*M,E.z=P*B,h.push(E.x,E.y,E.z),d.push(0,M,0),w.x=B*.5+.5,w.y=k*.5*M+.5,f.push(w.x,w.y),p++}for(let O=0;O<n;O++){let L=S+O,D=C+O;b===!0?u.push(D,D+1,L):u.push(D+1,D,L),A+=3}c.addGroup(m,A,b===!0?1:2),m+=A}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Sc(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},nl=class extends Sc{constructor(t=1,e=1,r=32,n=1,s=!1,o=0,a=Math.PI*2){super(0,t,e,r,n,s,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(t){return new nl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ku=class extends Ne{constructor(t=[],e=[],r=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:n};let s=[],o=[];a(n),c(r),u(),this.setAttribute("position",new Ie(s,3)),this.setAttribute("normal",new Ie(s.slice(),3)),this.setAttribute("uv",new Ie(o,2)),n===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let x=new T,b=new T,S=new T;for(let w=0;w<e.length;w+=3)f(e[w+0],x),f(e[w+1],b),f(e[w+2],S),l(x,b,S,v)}function l(v,x,b,S){let w=S+1,E=[];for(let A=0;A<=w;A++){E[A]=[];let P=v.clone().lerp(b,A/w),M=x.clone().lerp(b,A/w),C=w-A;for(let O=0;O<=C;O++)O===0&&A===w?E[A][O]=P:E[A][O]=P.clone().lerp(M,O/C)}for(let A=0;A<w;A++)for(let P=0;P<2*(w-A)-1;P++){let M=Math.floor(P/2);P%2===0?(d(E[A][M+1]),d(E[A+1][M]),d(E[A][M])):(d(E[A][M+1]),d(E[A+1][M+1]),d(E[A+1][M]))}}function c(v){let x=new T;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(v),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function u(){let v=new T;for(let x=0;x<s.length;x+=3){v.x=s[x+0],v.y=s[x+1],v.z=s[x+2];let b=y(v)/2/Math.PI+.5,S=m(v)/Math.PI+.5;o.push(b,1-S)}p(),h()}function h(){for(let v=0;v<o.length;v+=6){let x=o[v+0],b=o[v+2],S=o[v+4],w=Math.max(x,b,S),E=Math.min(x,b,S);w>.9&&E<.1&&(x<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let b=v*3;x.x=t[b+0],x.y=t[b+1],x.z=t[b+2]}function p(){let v=new T,x=new T,b=new T,S=new T,w=new U,E=new U,A=new U;for(let P=0,M=0;P<s.length;P+=9,M+=6){v.set(s[P+0],s[P+1],s[P+2]),x.set(s[P+3],s[P+4],s[P+5]),b.set(s[P+6],s[P+7],s[P+8]),w.set(o[M+0],o[M+1]),E.set(o[M+2],o[M+3]),A.set(o[M+4],o[M+5]),S.copy(v).add(x).add(b).divideScalar(3);let C=y(S);g(w,M+0,v,C),g(E,M+2,x,C),g(A,M+4,b,C)}}function g(v,x,b,S){S<0&&v.x===1&&(o[x]=v.x-1),b.x===0&&b.z===0&&(o[x]=S/2/Math.PI+.5)}function y(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ku(t.vertices,t.indices,t.radius,t.details)}},Gu=class extends ku{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=1/r,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,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Gu(t.radius,t.detail)}};var oa=class extends bc{constructor(t){super(t),this.uuid=ss(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let r=0,n=this.holes.length;r<n;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){let n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){let n=t.holes[e];this.holes.push(new bc().fromJSON(n))}return this}},A4={triangulate:function(i,t,e=2){let r=t&&t.length,n=r?t[0]*e:i.length,s=v_(i,0,n,e,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,d,f;if(r&&(s=_4(i,t,s,e)),i.length>80*e){a=c=i[0],l=u=i[1];for(let p=e;p<n;p+=e)h=i[p],d=i[p+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return bp(s,o,e,a,l,f,0),o}};function v_(i,t,e,r,n){let s,o;if(n===V4(i,t,e,r)>0)for(s=t;s<e;s+=r)o=NC(s,i[s],i[s+1],o);else for(s=e-r;s>=t;s-=r)o=NC(s,i[s],i[s+1],o);return o&&ky(o,o.next)&&(wp(o),o=o.next),o}function wc(i,t){if(!i)return i;t||(t=i);let e=i,r;do if(r=!1,!e.steiner&&(ky(e,e.next)||Gr(e.prev,e,e.next)===0)){if(wp(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function bp(i,t,e,r,n,s,o){if(!i)return;!o&&s&&R4(i,r,n,s);let a=i,l,c;for(;i.prev!==i.next;){if(l=i.prev,c=i.next,s?T4(i,r,n,s):E4(i)){t.push(l.i/e|0),t.push(i.i/e|0),t.push(c.i/e|0),wp(i),i=c.next,a=c.next;continue}if(i=c,i===a){o?o===1?(i=M4(wc(i),t,e),bp(i,t,e,r,n,s,2)):o===2&&C4(i,t,e,r,n,s):bp(wc(i),t,e,r,n,s,1);break}}}function E4(i){let t=i.prev,e=i,r=i.next;if(Gr(t,e,r)>=0)return!1;let n=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,u=n<s?n<o?n:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,d=n>s?n>o?n:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Ou(n,a,s,l,o,c,p.x,p.y)&&Gr(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function T4(i,t,e,r){let n=i.prev,s=i,o=i.next;if(Gr(n,s,o)>=0)return!1;let a=n.x,l=s.x,c=o.x,u=n.y,h=s.y,d=o.y,f=a<l?a<c?a:c:l<c?l:c,p=u<h?u<d?u:d:h<d?h:d,g=a>l?a>c?a:c:l>c?l:c,y=u>h?u>d?u:d:h>d?h:d,m=cw(f,p,t,e,r),v=cw(g,y,t,e,r),x=i.prevZ,b=i.nextZ;for(;x&&x.z>=m&&b&&b.z<=v;){if(x.x>=f&&x.x<=g&&x.y>=p&&x.y<=y&&x!==n&&x!==o&&Ou(a,u,l,h,c,d,x.x,x.y)&&Gr(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Ou(a,u,l,h,c,d,b.x,b.y)&&Gr(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=m;){if(x.x>=f&&x.x<=g&&x.y>=p&&x.y<=y&&x!==n&&x!==o&&Ou(a,u,l,h,c,d,x.x,x.y)&&Gr(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=y&&b!==n&&b!==o&&Ou(a,u,l,h,c,d,b.x,b.y)&&Gr(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function M4(i,t,e){let r=i;do{let n=r.prev,s=r.next.next;!ky(n,s)&&x_(n,r,r.next,s)&&Sp(n,s)&&Sp(s,n)&&(t.push(n.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),wp(r),wp(r.next),r=i=s),r=r.next}while(r!==i);return wc(r)}function C4(i,t,e,r,n,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&B4(o,a)){let l=b_(o,a);o=wc(o,o.next),l=wc(l,l.next),bp(o,t,e,r,n,s,0),bp(l,t,e,r,n,s,0);return}a=a.next}o=o.next}while(o!==i)}function _4(i,t,e,r){let n=[],s,o,a,l,c;for(s=0,o=t.length;s<o;s++)a=t[s]*r,l=s<o-1?t[s+1]*r:i.length,c=v_(i,a,l,r,!1),c===c.next&&(c.steiner=!0),n.push(N4(c));for(n.sort(P4),s=0;s<n.length;s++)e=D4(n[s],e);return e}function P4(i,t){return i.x-t.x}function D4(i,t){let e=O4(i,t);if(!e)return t;let r=b_(e,i);return wc(r,r.next),wc(e,e.next)}function O4(i,t){let e=t,r=-1/0,n,s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,n=e.x<e.next.x?e:e.next,d===s))return n}e=e.next}while(e!==t);if(!n)return null;let a=n,l=n.x,c=n.y,u=1/0,h;e=n;do s>=e.x&&e.x>=l&&s!==e.x&&Ou(o<c?s:r,o,l,c,o<c?r:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),Sp(e,i)&&(h<u||h===u&&(e.x>n.x||e.x===n.x&&I4(n,e)))&&(n=e,u=h)),e=e.next;while(e!==a);return n}function I4(i,t){return Gr(i.prev,i,t.prev)<0&&Gr(t.next,i,i.next)<0}function R4(i,t,e,r){let n=i;do n.z===0&&(n.z=cw(n.x,n.y,t,e,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,L4(n)}function L4(i){let t,e,r,n,s,o,a,l,c=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t<c&&(a++,r=r.nextZ,!!r);t++);for(l=c;a>0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(n=e,e=e.nextZ,a--):(n=r,r=r.nextZ,l--),s?s.nextZ=n:i=n,n.prevZ=s,s=n;e=r}s.nextZ=null,c*=2}while(o>1);return i}function cw(i,t,e,r,n){return i=(i-e)*n|0,t=(t-r)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function N4(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Ou(i,t,e,r,n,s,o,a){return(n-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(r-a)}function B4(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!F4(i,t)&&(Sp(i,t)&&Sp(t,i)&&U4(i,t)&&(Gr(i.prev,i,t.prev)||Gr(i,t.prev,t))||ky(i,t)&&Gr(i.prev,i,i.next)>0&&Gr(t.prev,t,t.next)>0)}function Gr(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function ky(i,t){return i.x===t.x&&i.y===t.y}function x_(i,t,e,r){let n=$g(Gr(i,t,e)),s=$g(Gr(i,t,r)),o=$g(Gr(e,r,i)),a=$g(Gr(e,r,t));return!!(n!==s&&o!==a||n===0&&Jg(i,e,t)||s===0&&Jg(i,r,t)||o===0&&Jg(e,i,r)||a===0&&Jg(e,t,r))}function Jg(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function $g(i){return i>0?1:i<0?-1:0}function F4(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&x_(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Sp(i,t){return Gr(i.prev,i,i.next)<0?Gr(i,t,i.next)>=0&&Gr(i,i.prev,t)>=0:Gr(i,t,i.prev)<0||Gr(i,i.next,t)<0}function U4(i,t){let e=i,r=!1,n=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==i);return r}function b_(i,t){let e=new uw(i.i,i.x,i.y),r=new uw(t.i,t.x,t.y),n=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function NC(i,t,e,r){let n=new uw(i,t,e);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function wp(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function uw(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function V4(i,t,e,r){let n=0;for(let s=t,o=e-r;s<e;s+=r)n+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return n}var Hu=class{static area(t){let e=t.length,r=0;for(let n=e-1,s=0;s<e;n=s++)r+=t[n].x*t[s].y-t[s].x*t[n].y;return r*.5}static isClockWise(t){return Hu.area(t)<0}static triangulateShape(t,e){let r=[],n=[],s=[];BC(t),FC(r,t);let o=t.length;e.forEach(BC);for(let l=0;l<e.length;l++)n.push(o),o+=e[l].length,FC(r,e[l]);let a=A4.triangulate(r,n);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function BC(i){let t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function FC(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}var ju=class extends ku{constructor(t=1,e=0){let r=(1+Math.sqrt(5))/2,n=[-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],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(n,s,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new ju(t.radius,t.detail)}};var Ls=class extends Ne{constructor(t=1,e=32,r=16,n=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:n,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),r=Math.max(2,Math.floor(r));let l=Math.min(o+a,Math.PI),c=0,u=[],h=new T,d=new T,f=[],p=[],g=[],y=[];for(let m=0;m<=r;m++){let v=[],x=m/r,b=0;m===0&&o===0?b=.5/e:m===r&&l===Math.PI&&(b=-.5/e);for(let S=0;S<=e;S++){let w=S/e;h.x=-t*Math.cos(n+w*s)*Math.sin(o+x*a),h.y=t*Math.cos(o+x*a),h.z=t*Math.sin(n+w*s)*Math.sin(o+x*a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),g.push(d.x,d.y,d.z),y.push(w+b,1-x),v.push(c++)}u.push(v)}for(let m=0;m<r;m++)for(let v=0;v<e;v++){let x=u[m][v+1],b=u[m][v],S=u[m+1][v],w=u[m+1][v+1];(m!==0||o>0)&&f.push(x,b,w),(m!==r-1||l<Math.PI)&&f.push(b,S,w)}this.setIndex(f),this.setAttribute("position",new Ie(p,3)),this.setAttribute("normal",new Ie(g,3)),this.setAttribute("uv",new Ie(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ls(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}};var Wu=class extends Ne{constructor(t=1,e=.4,r=12,n=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:n,arc:s},r=Math.floor(r),n=Math.floor(n);let o=[],a=[],l=[],c=[],u=new T,h=new T,d=new T;for(let f=0;f<=r;f++)for(let p=0;p<=n;p++){let g=p/n*s,y=f/r*Math.PI*2;h.x=(t+e*Math.cos(y))*Math.cos(g),h.y=(t+e*Math.cos(y))*Math.sin(g),h.z=e*Math.sin(y),a.push(h.x,h.y,h.z),u.x=t*Math.cos(g),u.y=t*Math.sin(g),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(p/n),c.push(f/r)}for(let f=1;f<=r;f++)for(let p=1;p<=n;p++){let g=(n+1)*f+p-1,y=(n+1)*(f-1)+p-1,m=(n+1)*(f-1)+p,v=(n+1)*f+p;o.push(g,y,v),o.push(y,m,v)}this.setIndex(o),this.setAttribute("position",new Ie(a,3)),this.setAttribute("normal",new Ie(l,3)),this.setAttribute("uv",new Ie(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wu(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},qu=class extends Ne{constructor(t=1,e=.4,r=64,n=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o},r=Math.floor(r),n=Math.floor(n);let a=[],l=[],c=[],u=[],h=new T,d=new T,f=new T,p=new T,g=new T,y=new T,m=new T;for(let x=0;x<=r;++x){let b=x/r*s*Math.PI*2;v(b,s,o,t,f),v(b+.01,s,o,t,p),y.subVectors(p,f),m.addVectors(p,f),g.crossVectors(y,m),m.crossVectors(g,y),g.normalize(),m.normalize();for(let S=0;S<=n;++S){let w=S/n*Math.PI*2,E=-e*Math.cos(w),A=e*Math.sin(w);h.x=f.x+(E*m.x+A*g.x),h.y=f.y+(E*m.y+A*g.y),h.z=f.z+(E*m.z+A*g.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(x/r),u.push(S/n)}}for(let x=1;x<=r;x++)for(let b=1;b<=n;b++){let S=(n+1)*(x-1)+(b-1),w=(n+1)*x+(b-1),E=(n+1)*x+b,A=(n+1)*(x-1)+b;a.push(S,w,A),a.push(w,E,A)}this.setIndex(a),this.setAttribute("position",new Ie(l,3)),this.setAttribute("normal",new Ie(c,3)),this.setAttribute("uv",new Ie(u,2));function v(x,b,S,w,E){let A=Math.cos(x),P=Math.sin(x),M=S/b*x,C=Math.cos(M);E.x=w*(2+C)*.5*A,E.y=w*(2+C)*P*.5,E.z=w*Math.sin(M)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qu(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}};function ey(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function z4(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function k4(i){function t(n,s){return i[n]-i[s]}let e=i.length,r=new Array(e);for(let n=0;n!==e;++n)r[n]=n;return r.sort(t),r}function UC(i,t,e){let r=i.length,n=new i.constructor(r);for(let s=0,o=0;o!==r;++s){let a=e[s]*t;for(let l=0;l!==t;++l)n[o++]=i[a+l]}return n}function S_(i,t,e,r){let n=1,s=i[0];for(;s!==void 0&&s[r]===void 0;)s=i[n++];if(s===void 0)return;let o=s[r];if(o!==void 0)if(Array.isArray(o))do o=s[r],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=i[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[r],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=i[n++];while(s!==void 0);else do o=s[r],o!==void 0&&(t.push(s.time),e.push(o)),s=i[n++];while(s!==void 0)}var Xu=class{constructor(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,r=this._cachedIndex,n=e[r],s=e[r-1];e:{t:{let o;r:{i:if(!(t<n)){for(let a=r+2;;){if(n===void 0){if(t<s)break i;return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}if(r===a)break;if(s=n,n=e[++r],t<n)break t}o=e.length;break r}if(!(t>=s)){let a=e[1];t<a&&(r=2,s=a);for(let l=r-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===l)break;if(n=s,s=e[--r-1],t>=s)break t}o=r,r=0;break r}break e}for(;r<o;){let a=r+o>>>1;t<e[a]?o=a:r=a+1}if(n=e[r],s=e[r-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return r=e.length,this._cachedIndex=r,this.copySampleValue_(r-1)}this._cachedIndex=r,this.intervalChanged_(r,s,n)}return this.interpolate_(r,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=t*n;for(let o=0;o!==n;++o)e[o]=r[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},hw=class extends Xu{constructor(t,e,r,n){super(t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Cu,endingEnd:Cu}}intervalChanged_(t,e,r){let n=this.parameterPositions,s=t-2,o=t+1,a=n[s],l=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case _u:s=t,a=2*e-r;break;case ay:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=r}if(l===void 0)switch(this.getSettings_().endingEnd){case _u:o=t,l=2*r-e;break;case ay:o=1,l=r+n[1]-n[0];break;default:o=t-1,l=e}let c=(r-e)*.5,u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-r),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(r-e)/(n-e),g=p*p,y=g*p,m=-d*y+2*d*g-d*p,v=(1+d)*y+(-1.5-2*d)*g+(-.5+d)*p+1,x=(-1-f)*y+(1.5+f)*g+.5*p,b=f*y-f*g;for(let S=0;S!==a;++S)s[S]=m*o[u+S]+v*o[c+S]+x*o[l+S]+b*o[h+S];return s}},Ay=class extends Xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=(r-e)/(n-e),h=1-u;for(let d=0;d!==a;++d)s[d]=o[c+d]*h+o[l+d]*u;return s}},dw=class extends Xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t){return this.copySampleValue_(t-1)}},ls=class{constructor(t,e,r,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ey(e,this.TimeBufferType),this.values=ey(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,r;if(e.toJSON!==this.toJSON)r=e.toJSON(t);else{r={name:t.name,times:ey(t.times,Array),values:ey(t.values,Array)};let n=t.getInterpolation();n!==t.DefaultInterpolation&&(r.interpolation=n)}return r.type=t.ValueTypeName,r}InterpolantFactoryMethodDiscrete(t){return new dw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ay(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new hw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case sy:e=this.InterpolantFactoryMethodDiscrete;break;case oy:e=this.InterpolantFactoryMethodLinear;break;case aS:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let r="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(r);return console.warn("THREE.KeyframeTrack:",r),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return sy;case this.InterpolantFactoryMethodLinear:return oy;case this.InterpolantFactoryMethodSmooth:return aS}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let r=0,n=e.length;r!==n;++r)e[r]*=t}return this}trim(t,e){let r=this.times,n=r.length,s=0,o=n-1;for(;s!==n&&r[s]<t;)++s;for(;o!==-1&&r[o]>e;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=r.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,n=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(n!==void 0&&z4(n))for(let a=0,l=n.length;a!==l;++a){let c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),r=this.getValueSize(),n=this.getInterpolation()===aS,s=t.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=t[a],u=t[a+1];if(c!==u&&(a!==1||c!==t[0]))if(n)l=!0;else{let h=a*r,d=h-r,f=h+r;for(let p=0;p!==r;++p){let g=e[h+p];if(g!==e[d+p]||g!==e[f+p]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let h=a*r,d=o*r;for(let f=0;f!==r;++f)e[d+f]=e[h+f]}++o}}if(s>0){t[o]=t[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*r)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}};ls.prototype.TimeBufferType=Float32Array;ls.prototype.ValueBufferType=Float32Array;ls.prototype.DefaultInterpolation=oy;var sl=class extends ls{};sl.prototype.ValueTypeName="bool";sl.prototype.ValueBufferType=Array;sl.prototype.DefaultInterpolation=sy;sl.prototype.InterpolantFactoryMethodLinear=void 0;sl.prototype.InterpolantFactoryMethodSmooth=void 0;var Ey=class extends ls{};Ey.prototype.ValueTypeName="color";var Yu=class extends ls{};Yu.prototype.ValueTypeName="number";var fw=class extends Xu{constructor(t,e,r,n){super(t,e,r,n)}interpolate_(t,e,r,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(n-e),c=t*a;for(let u=c+a;c!==u;c+=4)Qe.slerpFlat(s,0,o,c-a,o,c,l);return s}},Ac=class extends ls{InterpolantFactoryMethodLinear(t){return new fw(this.times,this.values,this.getValueSize(),t)}};Ac.prototype.ValueTypeName="quaternion";Ac.prototype.DefaultInterpolation=oy;Ac.prototype.InterpolantFactoryMethodSmooth=void 0;var ol=class extends ls{};ol.prototype.ValueTypeName="string";ol.prototype.ValueBufferType=Array;ol.prototype.DefaultInterpolation=sy;ol.prototype.InterpolantFactoryMethodLinear=void 0;ol.prototype.InterpolantFactoryMethodSmooth=void 0;var Ku=class extends ls{};Ku.prototype.ValueTypeName="vector";var Qu=class{constructor(t,e=-1,r,n=Mw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=n,this.uuid=ss(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,n=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(H4(r[o]).scale(n));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(ls.toJSON(r[s]));return n}static CreateFromMorphTargetSequence(t,e,r,n){let s=e.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);let u=k4(l);l=UC(l,1,u),c=UC(c,1,u),!n&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Yu(".morphTargetInfluences["+e[a].name+"]",l,c).scale(1/r))}return new this(t,-1,o)}static findByName(t,e){let r=t;if(!Array.isArray(t)){let n=t;r=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<r.length;n++)if(r[n].name===e)return r[n];return null}static CreateClipsFromMorphTargetSequences(t,e,r){let n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=t.length;a<l;a++){let c=t[a],u=c.name.match(s);if(u&&u.length>1){let h=u[1],d=n[h];d||(n[h]=d=[]),d.push(c)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,g){if(f.length!==0){let y=[],m=[];S_(f,y,m,p),y.length!==0&&g.push(new h(d,y,m))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let h=0;h<c.length;h++){let d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let f={},p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let g=0;g<d[p].morphTargets.length;g++)f[d[p].morphTargets[g]]=-1;for(let g in f){let y=[],m=[];for(let v=0;v!==d[p].morphTargets.length;++v){let x=d[p];y.push(x.time),m.push(x.morphTarget===g?1:0)}n.push(new Yu(".morphTargetInfluence["+g+"]",y,m))}l=f.length*o}else{let f=".bones["+e[h].name+"]";r(Ku,f+".position",d,"pos",n),r(Ac,f+".quaternion",d,"rot",n),r(Ku,f+".scale",d,"scl",n)}}return n.length===0?null:new this(s,l,n,a)}resetDuration(){let t=this.tracks,e=0;for(let r=0,n=t.length;r!==n;++r){let s=this.tracks[r];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function G4(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Yu;case"vector":case"vector2":case"vector3":case"vector4":return Ku;case"color":return Ey;case"quaternion":return Ac;case"bool":case"boolean":return sl;case"string":return ol}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function H4(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=G4(i.type);if(i.times===void 0){let e=[],r=[];S_(i.keys,e,r,"value"),i.times=e,i.values=r}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}var Ty={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},Ap=class{constructor(t,e,r){let n=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(u){a++,s===!1&&n.onStart!==void 0&&n.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,n.onProgress!==void 0&&n.onProgress(u,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(u){n.onError!==void 0&&n.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){let h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){let f=c[h],p=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return p}return null}}},j4=new Ap,aa=class{constructor(t){this.manager=t!==void 0?t:j4,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let r=this;return new Promise(function(n,s){r.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};aa.DEFAULT_MATERIAL_NAME="__DEFAULT";var $o={},pw=class extends Error{constructor(t,e){super(t),this.response=e}},Zu=class extends aa{constructor(t){super(t)}load(t,e,r,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=Ty.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if($o[t]!==void 0){$o[t].push({onLoad:e,onProgress:r,onError:n});return}$o[t]=[],$o[t].push({onLoad:e,onProgress:r,onError:n});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=$o[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,g=0,y=new ReadableStream({start(m){v();function v(){h.read().then(({done:x,value:b})=>{if(x)m.close();else{g+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:p,loaded:g,total:f});for(let w=0,E=u.length;w<E;w++){let A=u[w];A.onProgress&&A.onProgress(S)}m.enqueue(b),v()}})}}});return new Response(y)}else throw new pw(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{Ty.add(t,c);let u=$o[t];delete $o[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{let u=$o[t];if(u===void 0)throw this.manager.itemError(t),c;delete $o[t];for(let h=0,d=u.length;h<d;h++){let f=u[h];f.onError&&f.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var mw=class extends aa{constructor(t){super(t)}load(t,e,r,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=this,o=Ty.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=dp("img");function l(){u(),Ty.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(h){u(),n&&n(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}};var My=class extends aa{constructor(t){super(t)}load(t,e,r,n){let s=new Zt,o=new mw(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,n),s}},al=class extends Rt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ke(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Cy=class extends al{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ke(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},BS=new ue,VC=new T,zC=new T,Ep=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new pp,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;VC.setFromMatrixPosition(t.matrixWorld),e.position.copy(VC),zC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(zC),e.updateMatrixWorld(),BS.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(BS),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(BS)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},gw=class extends Ep{constructor(){super(new ri(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=Lu*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},_y=class extends al{constructor(t,e,r=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.distance=r,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new gw}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},kC=new ue,op=new T,FS=new T,yw=class extends Ep{constructor(){super(new ri(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new U(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new T(1,0,0),new T(-1,0,0),new T(0,0,1),new T(0,0,-1),new T(0,1,0),new T(0,-1,0)],this._cubeUps=[new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,1,0),new T(0,0,1),new T(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,n=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),op.setFromMatrixPosition(t.matrixWorld),r.position.copy(op),FS.copy(r.position),FS.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(FS),r.updateMatrixWorld(),n.makeTranslation(-op.x,-op.y,-op.z),kC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kC)}},Py=class extends al{constructor(t,e,r=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=n,this.shadow=new yw}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},vw=class extends Ep{constructor(){super(new Fu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Dy=class extends al{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Rt.DEFAULT_UP),this.updateMatrix(),this.target=new Rt,this.shadow=new vw}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Tp=class extends Ne{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Ju=class extends aa{constructor(t){super(t)}load(t,e,r,n){let s=this,o=new Zu(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){n?n(l):console.error(l),s.manager.itemError(t)}},r,n)}parse(t){let e={},r={};function n(f,p){if(e[p]!==void 0)return e[p];let y=f.interleavedBuffers[p],m=s(f,y.buffer),v=Cg(y.type,m),x=new xy(v,y.stride);return x.uuid=y.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let y=f.arrayBuffers[p],m=new Uint32Array(y).buffer;return r[p]=m,m}let o=t.isInstancedBufferGeometry?new Tp:new Ne,a=t.data.index;if(a!==void 0){let f=Cg(a.type,a.array);o.setIndex(new Ye(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],g;if(p.isInterleavedBufferAttribute){let y=n(t.data,p.data);g=new gc(y,p.itemSize,p.offset,p.normalized)}else{let y=Cg(p.type,p.array),m=p.isInstancedBufferAttribute?co:Ye;g=new m(y,p.itemSize,p.normalized)}p.name!==void 0&&(g.name=p.name),p.usage!==void 0&&g.setUsage(p.usage),o.setAttribute(f,g)}let c=t.data.morphAttributes;if(c)for(let f in c){let p=c[f],g=[];for(let y=0,m=p.length;y<m;y++){let v=p[y],x;if(v.isInterleavedBufferAttribute){let b=n(t.data,v.data);x=new gc(b,v.itemSize,v.offset,v.normalized)}else{let b=Cg(v.type,v.array);x=new Ye(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),g.push(x)}o.morphAttributes[f]=g}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let f=0,p=h.length;f!==p;++f){let g=h[f];o.addGroup(g.start,g.count,g.materialIndex)}let d=t.data.boundingSphere;if(d!==void 0){let f=new T;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new Or(f,d.radius)}return t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}};var Oy=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=GC(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=GC();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function GC(){return(typeof performance>"u"?Date:performance).now()}var xw=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let n,s,o;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:n=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,n=this.valueSize,s=t*n+n,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==n;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,n)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,n=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,n=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,n,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,n,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(r[l]!==r[l+e]){a.setValue(r,n);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,n=r*this._origIndex;t.getValue(e,n);for(let s=r,o=n;s!==o;++s)e[s]=e[n+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r<e;r++)this.buffer[r]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let r=0;r<this.valueSize;r++)this.buffer[e+r]=this.buffer[t+r]}_select(t,e,r,n,s){if(n>=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,n){Qe.slerpFlat(t,e,t,e,t,r,n)}_slerpAdditive(t,e,r,n,s){let o=this._workIndex*s;Qe.multiplyQuaternionsFlat(t,o,t,e,t,r),Qe.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,r,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*n}}_lerpAdditive(t,e,r,n,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*n}}},Iw="\\[\\]\\.:\\/",W4=new RegExp("["+Iw+"]","g"),Rw="[^"+Iw+"]",q4="[^"+Iw.replace("\\.","")+"]",X4=/((?:WC+[\/:])*)/.source.replace("WC",Rw),Y4=/(WCOD+)?/.source.replace("WCOD",q4),K4=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Rw),Q4=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Rw),Z4=new RegExp("^"+X4+Y4+K4+Q4+"$"),J4=["material","materials","bones","map"],bw=class{constructor(t,e,r){let n=r||er.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,n=this._bindings[r];n!==void 0&&n.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=r.length;n!==s;++n)r[n].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},er=class{constructor(t,e,r){this.path=e,this.parsedPath=r||er.parseTrackName(e),this.node=er.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new er.Composite(t,e,r):new er(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(W4,"")}static parseTrackName(t){let e=Z4.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=r.nodeName.substring(n+1);J4.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===e||a.uuid===e)return a;let l=r(a.children);if(l)return l}return null},n=r(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)t[e++]=r[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let r=this.resolvedProperty;for(let n=0,s=r.length;n!==s;++n)r[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,r=e.objectName,n=e.propertyName,s=e.propertyIndex;if(t||(t=er.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(r){let c=e.objectIndex;switch(r){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===c){c=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[r]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let o=t[n];if(o===void 0){let c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+n+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};er.Composite=bw;er.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};er.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};er.prototype.GetterByBindingType=[er.prototype._getValue_direct,er.prototype._getValue_array,er.prototype._getValue_arrayElement,er.prototype._getValue_toArray];er.prototype.SetterByBindingTypeAndVersioning=[[er.prototype._setValue_direct,er.prototype._setValue_direct_setNeedsUpdate,er.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[er.prototype._setValue_array,er.prototype._setValue_array_setNeedsUpdate,er.prototype._setValue_array_setMatrixWorldNeedsUpdate],[er.prototype._setValue_arrayElement,er.prototype._setValue_arrayElement_setNeedsUpdate,er.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[er.prototype._setValue_fromArray,er.prototype._setValue_fromArray_setNeedsUpdate,er.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Sw=class{constructor(t,e,r=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=r,this.blendMode=n;let s=e.tracks,o=s.length,a=new Array(o),l={endingStart:Cu,endingEnd:Cu};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Tw,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(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,r){if(t.fadeOut(e),this.fadeIn(e),r){let n=this._clip.duration,s=t._clip.duration,o=s/n,a=n/s;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,r){return t.crossFadeFrom(this,e,r)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,r){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+r,c[0]=t/o,c[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,r,n){if(!this.enabled){this._updateWeight(t);return}let s=this._startTime;if(s!==null){let l=(t-s)*r;l<0||r===0?e=0:(this._startTime=null,e=r*l)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case jF:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Mw:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,n=this.time+t,s=this._loopCount,o=r===Cp;if(t===0)return s===-1?n:o&&(s&1)===1?e-n:n;if(r===Ew){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=e||n<0){let a=Math.floor(n/e);n-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return e-n}return n}_setEndings(t,e,r){let n=this._interpolantSettings;r?(n.endingStart=_u,n.endingEnd=_u):(t?n.endingStart=this.zeroSlopeAtStart?_u:Cu:n.endingStart=ay,e?n.endingEnd=this.zeroSlopeAtEnd?_u:Cu:n.endingEnd=ay)}_scheduleFading(t,e,r){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},$4=new Float32Array(1),Iy=class extends gr{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,n=t._clip.tracks,s=n.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=n[h],f=d.name,p=u[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let g=e&&e._propertyBindings[h].binding.parsedPath;p=new xw(er.create(r,f,g),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,r)}let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,r){let n=this._actions,s=this._actionsByClip,o=s[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=n.length,n.push(t),o.actionByRoot[r]=t}_removeInactiveAction(t){let e=this._actions,r=e[e.length-1],n=t._cacheIndex;r._cacheIndex=n,e[n]=r,e.pop(),t._cacheIndex=null;let s=t._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let r=0,n=e.length;r!==n;++r){let s=e[r];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){let e=this._actions,r=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackAction(t){let e=this._actions,r=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_addInactiveBinding(t,e,r){let n=this._bindingsByRootAndName,s=this._bindings,o=n[e];o===void 0&&(o={},n[e]=o),o[r]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){let e=this._bindings,r=t.binding,n=r.rootNode.uuid,s=r.path,o=this._bindingsByRootAndName,a=o[n],l=e[e.length-1],c=t._cacheIndex;l._cacheIndex=c,e[c]=l,e.pop(),delete a[s],Object.keys(a).length===0&&delete o[n]}_lendBinding(t){let e=this._bindings,r=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_takeBackBinding(t){let e=this._bindings,r=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=r,e[r]=s}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,r=t[e];return r===void 0&&(r=new Ay(new Float32Array(2),new Float32Array(2),1,$4),r.__cacheIndex=e,t[e]=r),r}_takeBackControlInterpolant(t){let e=this._controlInterpolants,r=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=r,e[r]=s}clipAction(t,e,r){let n=e||this._root,s=n.uuid,o=typeof t=="string"?Qu.findByName(n,t):t,a=o!==null?o.uuid:t,l=this._actionsByClip[a],c=null;if(r===void 0&&(o!==null?r=o.blendMode:r=Mw),l!==void 0){let h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===r)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;let u=new Sw(this,o,e,r);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(t,e){let r=e||this._root,n=r.uuid,s=typeof t=="string"?Qu.findByName(r,t):t,o=s?s.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[n]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let r=e-1;r>=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,n=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==r;++c)e[c]._update(n,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,r=t.uuid,n=this._actionsByClip,s=n[r];if(s!==void 0){let o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){let c=o[a];this._deactivateAction(c);let u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[r]}}uncacheRoot(t){let e=t.uuid,r=this._actionsByClip;for(let o in r){let a=r[o].actionByRoot,l=a[e];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}let n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let r=this.existingAction(t,e);r!==null&&(this._deactivateAction(r),this._removeInactiveAction(r))}},he=class{constructor(t){this.value=t}clone(){return new he(this.value.clone===void 0?this.value:this.value.clone())}};var HC=new ue,$u=class{constructor(t,e,r=0,n=1/0){this.ray=new Rs(t,e),this.near=r,this.far=n,this.camera=null,this.layers=new fp,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return HC.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(HC),this}intersectObject(t,e=!0,r=[]){return ww(t,this,r,e),r.sort(jC),r}intersectObjects(t,e=!0,r=[]){for(let n=0,s=t.length;n<s;n++)ww(t[n],this,r,e);return r.sort(jC),r}};function jC(i,t){return i.distance-t.distance}function ww(i,t,e,r){if(i.layers.test(t.layers)&&i.raycast(t,e),r===!0){let n=i.children;for(let s=0,o=n.length;s<o;s++)ww(n[s],t,e,!0)}}var Mp=class{constructor(t=1,e=0,r=0){return this.radius=t,this.phi=e,this.theta=r,this}set(t,e,r){return this.radius=t,this.phi=e,this.theta=r,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,r){return this.radius=Math.sqrt(t*t+e*e+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,r),this.phi=Math.acos(ti(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var WC=new U,eh=class{constructor(t=new U(1/0,1/0),e=new U(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let r=WC.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,WC).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},qC=new T,ty=new T,Ei=class{constructor(t=new T,e=new T){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){qC.subVectors(t,this.start),ty.subVectors(this.end,this.start);let r=ty.dot(ty),s=ty.dot(qC)/r;return e&&(s=ti(s,0,1)),s}closestPointToPoint(t,e,r){let n=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},XC=new T,Ry=class extends Rt{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new Ne,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,u=a/l*Math.PI*2;n.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}r.setAttribute("position",new Ie(n,3));let s=new os({fog:!1,toneMapped:!1});this.cone=new il(r,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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),XC.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(XC),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Ly=class extends tr{constructor(t,e,r){let n=new Ls(e,4,2),s=new jn({wireframe:!0,fog:!1,toneMapped:!1});super(n,s),this.light=t,this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var YC=new T,ry=new T,KC=new T,Ny=class extends Rt{constructor(t,e,r){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,this.type="DirectionalLightHelper",e===void 0&&(e=1);let n=new Ne;n.setAttribute("position",new Ie([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let s=new os({fog:!1,toneMapped:!1});this.lightPlane=new yc(n,s),this.add(this.lightPlane),n=new Ne,n.setAttribute("position",new Ie([0,0,0,0,0,1],3)),this.targetLine=new yc(n,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),YC.setFromMatrixPosition(this.light.matrixWorld),ry.setFromMatrixPosition(this.light.target.matrixWorld),KC.subVectors(ry,YC),this.lightPlane.lookAt(ry),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(ry),this.targetLine.scale.z=KC.length()}},iy=new T,Xr=new Wn,ll=class extends il{constructor(t){let e=new Ne,r=new os({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,g){l(p),l(g)}function l(p){n.push(0,0,0),s.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(n.length/3-1)}e.setAttribute("position",new Ie(n,3)),e.setAttribute("color",new Ie(s,3)),super(e,r),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let c=new ke(16755200),u=new ke(16711680),h=new ke(43775),d=new ke(16777215),f=new ke(3355443);this.setColors(c,u,h,d,f)}setColors(t,e,r,n,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,r.r,r.g,r.b),a.setXYZ(33,r.r,r.g,r.b),a.setXYZ(34,r.r,r.g,r.b),a.setXYZ(35,r.r,r.g,r.b),a.setXYZ(36,r.r,r.g,r.b),a.setXYZ(37,r.r,r.g,r.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let t=this.geometry,e=this.pointMap,r=1,n=1;Xr.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ei("c",e,t,Xr,0,0,-1),ei("t",e,t,Xr,0,0,1),ei("n1",e,t,Xr,-r,-n,-1),ei("n2",e,t,Xr,r,-n,-1),ei("n3",e,t,Xr,-r,n,-1),ei("n4",e,t,Xr,r,n,-1),ei("f1",e,t,Xr,-r,-n,1),ei("f2",e,t,Xr,r,-n,1),ei("f3",e,t,Xr,-r,n,1),ei("f4",e,t,Xr,r,n,1),ei("u1",e,t,Xr,r*.7,n*1.1,-1),ei("u2",e,t,Xr,-r*.7,n*1.1,-1),ei("u3",e,t,Xr,0,n*2,-1),ei("cf1",e,t,Xr,-r,0,1),ei("cf2",e,t,Xr,r,0,1),ei("cf3",e,t,Xr,0,-n,1),ei("cf4",e,t,Xr,0,n,1),ei("cn1",e,t,Xr,-r,0,-1),ei("cn2",e,t,Xr,r,0,-1),ei("cn3",e,t,Xr,0,-n,-1),ei("cn4",e,t,Xr,0,n,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ei(i,t,e,r,n,s,o){iy.set(n,s,o).unproject(r);let a=t[i];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],iy.x,iy.y,iy.z)}}var cl=class extends il{constructor(t,e=16776960){let r=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]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ne;s.setIndex(new Ye(r,1)),s.setAttribute("position",new Ie(n,3)),super(s,new os({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}};var By=class extends il{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],n=new Ne;n.setAttribute("position",new Ie(e,3)),n.setAttribute("color",new Ie(r,3));let s=new os({vertexColors:!0,toneMapped:!1});super(n,s),this.type="AxesHelper"}setColors(t,e,r){let n=new ke,s=this.geometry.attributes.color.array;return n.set(t),n.toArray(s,0),n.toArray(s,3),n.set(e),n.toArray(s,6),n.toArray(s,9),n.set(r),n.toArray(s,12),n.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:la}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=la);var nh=".",_p=Symbol("target"),Lw=Symbol("unsubscribe");function Pp(i){return i instanceof Date||i instanceof Set||i instanceof Map||i instanceof WeakSet||i instanceof WeakMap||ArrayBuffer.isView(i)}function w_(i){return(typeof i=="object"?i===null:typeof i!="function")||i instanceof RegExp}var Kn=Array.isArray;function Ec(i){return typeof i=="symbol"}var eH={after:(i,t)=>Kn(i)?i.slice(t.length):t===""?i:i.slice(t.length+1),concat:(i,t)=>Kn(i)?(i=[...i],t&&i.push(t),i):t&&t.toString!==void 0?(i!==""&&(i+=nh),Ec(t)?i+t.toString():i+t):i,initial:i=>{if(Kn(i))return i.slice(0,-1);if(i==="")return i;let t=i.lastIndexOf(nh);return t===-1?"":i.slice(0,t)},last:i=>{if(Kn(i))return i[i.length-1]||"";if(i==="")return i;let t=i.lastIndexOf(nh);return t===-1?i:i.slice(t+1)},walk:(i,t)=>{if(Kn(i))for(let e of i)t(e);else if(i!==""){let e=0,r=i.indexOf(nh);if(r===-1)t(i);else for(;e<i.length;)r===-1&&(r=i.length),t(i.slice(e,r)),e=r+1,r=i.indexOf(nh,e)}},get(i,t){return this.walk(t,e=>{i&&(i=i[e])}),i}},gn=eH;function Nw(i){return typeof i=="object"&&typeof i.next=="function"}function Bw(i,t,e,r,n){let s=i.next;if(t.name==="entries")i.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=n(o.value[0],t,o.value[0],r),o.value[1]=n(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[_p].keys();i.next=function(){let a=s.call(this);return a.done===!1&&(a.value=n(a.value,t,o.next().value,r)),a}}else i.next=function(){let o=s.call(this);return o.done===!1&&(o.value=n(o.value,t,o.value,r)),o};return i}function Gy(i,t,e){return i.isUnsubscribed||t.ignoreSymbols&&Ec(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Dp=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),n=r[e];return n===void 0&&(n=Reflect.getOwnPropertyDescriptor(t,e),r[e]=n),n}getProxy(t,e,r,n){if(this.isUnsubscribed)return t;let s=t[n],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,gn.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,n,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,n):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let n=this._getDescriptorCache().get(t);n&&(delete n[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let n=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&n!==void 0&&Object.is(t.value,n.value)&&(t.writable||!1)===(n.writable||!1)&&(t.enumerable||!1)===(n.enumerable||!1)&&(t.configurable||!1)===(n.configurable||!1)&&t.get===n.get&&t.set===n.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function sh(i){return toString.call(i)==="[object Object]"}function oh(){return!0}function ul(i,t){return i.length!==t.length||i.some((e,r)=>t[r]!==e)}var Hy=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var tH=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Fw={push:oh,pop:oh,shift:oh,unshift:oh,copyWithin:ul,reverse:ul,sort:ul,splice:ul,flat:ul,fill:ul},A_=new Set([...Hy,...tH,...Object.keys(Fw)]);function ah(i,t){if(i.size!==t.size)return!0;for(let e of i)if(!t.has(e))return!0;return!1}var Uw=["keys","values","entries"],Vw=new Set(["has","toString"]),zw={add:ah,clear:ah,delete:ah,forEach:ah},E_=new Set([...Vw,...Object.keys(zw),...Uw]);function lh(i,t){if(i.size!==t.size)return!0;let e;for(let[r,n]of i)if(e=t.get(r),e!==n||e===void 0&&!t.has(r))return!0;return!1}var rH=new Set([...Vw,"get"]),kw={set:lh,clear:lh,delete:lh,forEach:lh},T_=new Set([...rH,...Object.keys(kw),...Uw]);var Ui=class{constructor(t,e,r,n){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=n,this._changes=n?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Hy.has(t)}_shallowClone(t){let e=t;if(sh(t))e={...t};else if(Kn(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,n]of t.entries())e.set(r,this._shallowClone(n))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,n){return t?(Kn(n)?this._onIsChanged=Fw[e]:n instanceof Set?this._onIsChanged=zw[e]:n instanceof Map&&(this._onIsChanged=kw[e]),n):r}update(t,e,r){let n=gn.after(t,this._path);if(e!=="length"){let s=this.clone;gn.walk(n,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:n,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],gn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ch=class extends Ui{static isHandledMethod(t){return A_.has(t)}};var Op=class extends Ui{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var uh=class extends Ui{static isHandledMethod(t){return E_.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var hh=class extends Ui{static isHandledMethod(t){return T_.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Ip=class extends Ui{constructor(t,e,r,n){super(void 0,e,r,n),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var Rp=class extends Ui{constructor(t,e,r,n){super(void 0,e,r,n),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Bs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return sh(t)||Kn(t)||Pp(t)}static isHandledMethod(t,e){return sh(t)?Ui.isHandledMethod(e):Kn(t)?ch.isHandledMethod(e):t instanceof Set?uh.isHandledMethod(e):t instanceof Map?hh.isHandledMethod(e):Pp(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let n=Ui;Kn(t)?n=ch:t instanceof Date?n=Op:t instanceof Set?n=uh:t instanceof Map?n=hh:t instanceof WeakSet?n=Ip:t instanceof WeakMap&&(n=Rp),this._stack.push(new n(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:n}=t,s=Bs.isHandledMethod(r,n);return this._stack[this._stack.length-1].preferredThisArg(s,n,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var iH={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Gw=(i,t,e={})=>{e={...iH,...e};let r=Symbol("ProxyTarget"),{equals:n,isShallow:s,ignoreDetached:o,details:a}=e,l=new Dp(n),c=typeof e.onValidate=="function",u=new Bs(c),h=(v,x,b,S,w)=>!c||u.isCloning||e.onValidate(gn.concat(l.getPath(v),x),b,S,w)===!0,d=(v,x,b,S)=>{!Gy(l,e,x)&&!(o&&l.isDetached(v,i))&&f(l.getPath(v),x,b,S)},f=(v,x,b,S,w)=>{u.isCloning?u.update(v,x,S):t(gn.concat(v,x),b,S,w)},p=v=>v&&(v[r]||v),g=(v,x,b,S)=>w_(v)||b==="constructor"||s&&!Bs.isHandledMethod(x,b)||Gy(l,e,b)||l.isGetInvariant(x,b)||o&&l.isDetached(x,i)?v:(S===void 0&&(S=l.getPath(x)),l.getProxy(v,gn.concat(S,b),y,r)),y={get(v,x,b){if(Ec(x)){if(x===r||x===_p)return v;if(x===Lw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Pp(v)?Reflect.get(v,x):Reflect.get(v,x,b);return g(S,v,x)},set(v,x,b,S){b=p(b);let w=v[r]||v,E=w[x];if(n(E,b)&&x in v)return!0;let A=h(v,x,b,E);return A&&l.setProperty(w,x,b,S,E)?(d(v,x,v[x],E),!0):!A},defineProperty(v,x,b){if(!l.isSameDescriptor(b,v,x)){let S=v[x];h(v,x,b.value,S)&&l.defineProperty(v,x,b,S)&&d(v,x,b.value,S)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let b=Reflect.get(v,x),S=h(v,x,void 0,b);return S&&l.deleteProperty(v,x,b)?(d(v,x,void 0,b),!0):!S},apply(v,x,b){let S=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,S,b);if((a===!1||a!==!0&&!a.includes(v.name))&&Bs.isHandledType(S)){let w=gn.initial(l.getPath(v)),E=Bs.isHandledMethod(S,v.name);u.start(S,w,b);let A=Reflect.apply(v,u.preferredThisArg(v,x,S),E?b.map(C=>p(C)):b),P=u.isChanged(S,n),M=u.stop();if(Bs.isHandledType(A)&&E&&(x instanceof Map&&v.name==="get"&&(w=gn.concat(w,b[0])),A=l.getProxy(A,w,y)),P){let C={name:v.name,args:b,result:A},O=u.isCloning?gn.initial(w):w,L=u.isCloning?gn.last(w):"";h(gn.get(i,O),L,S,M,C)?f(O,L,S,M,C):u.undo(S)}return(x instanceof Map||x instanceof Set)&&Nw(A)?Bw(A,v,x,w,g):A}return Reflect.apply(v,x,b)}},m=l.getProxy(i,e.pathAsArray?[]:"",y);return t=t.bind(m),c&&(e.onValidate=e.onValidate.bind(m)),m};Gw.target=i=>i&&i[_p]||i;Gw.unsubscribe=i=>i[Lw]||i;var Hw=Gw;var nH=typeof global=="object"&&global&&global.Object===Object&&global,jy=nH;var sH=typeof self=="object"&&self&&self.Object===Object&&self,oH=jy||sH||Function("return this")(),Kr=oH;var aH=Kr.Symbol,Vi=aH;var M_=Object.prototype,lH=M_.hasOwnProperty,cH=M_.toString,Lp=Vi?Vi.toStringTag:void 0;function uH(i){var t=lH.call(i,Lp),e=i[Lp];try{i[Lp]=void 0;var r=!0}catch{}var n=cH.call(i);return r&&(t?i[Lp]=e:delete i[Lp]),n}var C_=uH;var hH=Object.prototype,dH=hH.toString;function fH(i){return dH.call(i)}var __=fH;var pH="[object Null]",mH="[object Undefined]",P_=Vi?Vi.toStringTag:void 0;function gH(i){return i==null?i===void 0?mH:pH:P_&&P_ in Object(i)?C_(i):__(i)}var Qn=gH;function yH(i){return i!=null&&typeof i=="object"}var Ki=yH;var vH="[object Symbol]";function xH(i){return typeof i=="symbol"||Ki(i)&&Qn(i)==vH}var hl=xH;function bH(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var Wy=bH;var SH=Array.isArray,Ti=SH;var wH=1/0,D_=Vi?Vi.prototype:void 0,O_=D_?D_.toString:void 0;function I_(i){if(typeof i=="string")return i;if(Ti(i))return Wy(i,I_)+"";if(hl(i))return O_?O_.call(i):"";var t=i+"";return t=="0"&&1/i==-wH?"-0":t}var R_=I_;var AH=/\s/;function EH(i){for(var t=i.length;t--&&AH.test(i.charAt(t)););return t}var L_=EH;var TH=/^\s+/;function MH(i){return i&&i.slice(0,L_(i)+1).replace(TH,"")}var N_=MH;function CH(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var gi=CH;var B_=0/0,_H=/^[-+]0x[0-9a-f]+$/i,PH=/^0b[01]+$/i,DH=/^0o[0-7]+$/i,OH=parseInt;function IH(i){if(typeof i=="number")return i;if(hl(i))return B_;if(gi(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=gi(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=N_(i);var e=PH.test(i);return e||DH.test(i)?OH(i.slice(2),e?2:8):_H.test(i)?B_:+i}var jw=IH;function RH(i){return i}var F_=RH;var LH="[object AsyncFunction]",NH="[object Function]",BH="[object GeneratorFunction]",FH="[object Proxy]";function UH(i){if(!gi(i))return!1;var t=Qn(i);return t==NH||t==BH||t==LH||t==FH}var qy=UH;var VH=Kr["__core-js_shared__"],Xy=VH;var U_=function(){var i=/[^.]+$/.exec(Xy&&Xy.keys&&Xy.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function zH(i){return!!U_&&U_ in i}var V_=zH;var kH=Function.prototype,GH=kH.toString;function HH(i){if(i!=null){try{return GH.call(i)}catch{}try{return i+""}catch{}}return""}var ca=HH;var jH=/[\\^$.*+?()[\]{}|]/g,WH=/^\[object .+?Constructor\]$/,qH=Function.prototype,XH=Object.prototype,YH=qH.toString,KH=XH.hasOwnProperty,QH=RegExp("^"+YH.call(KH).replace(jH,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ZH(i){if(!gi(i)||V_(i))return!1;var t=qy(i)?QH:WH;return t.test(ca(i))}var z_=ZH;function JH(i,t){return i?.[t]}var k_=JH;function $H(i,t){var e=k_(i,t);return z_(e)?e:void 0}var Pn=$H;var ej=Pn(Kr,"WeakMap"),Yy=ej;var G_=Object.create,tj=function(){function i(){}return function(t){if(!gi(t))return{};if(G_)return G_(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),H_=tj;function rj(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var j_=rj;function ij(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var W_=ij;var nj=800,sj=16,oj=Date.now;function aj(i){var t=0,e=0;return function(){var r=oj(),n=sj-(r-e);if(e=r,n>0){if(++t>=nj)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var q_=aj;function lj(i){return function(){return i}}var X_=lj;var cj=function(){try{var i=Pn(Object,"defineProperty");return i({},"",{}),i}catch{}}(),dh=cj;var uj=dh?function(i,t){return dh(i,"toString",{configurable:!0,enumerable:!1,value:X_(t),writable:!0})}:F_,Y_=uj;var hj=q_(Y_),K_=hj;function dj(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Q_=dj;var fj=9007199254740991,pj=/^(?:0|[1-9]\d*)$/;function mj(i,t){var e=typeof i;return t=t??fj,!!t&&(e=="number"||e!="symbol"&&pj.test(i))&&i>-1&&i%1==0&&i<t}var fh=mj;function gj(i,t,e){t=="__proto__"&&dh?dh(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Ky=gj;function yj(i,t){return i===t||i!==i&&t!==t}var ph=yj;var vj=Object.prototype,xj=vj.hasOwnProperty;function bj(i,t,e){var r=i[t];(!(xj.call(i,t)&&ph(r,e))||e===void 0&&!(t in i))&&Ky(i,t,e)}var mh=bj;function Sj(i,t,e,r){var n=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],l=r?r(e[a],i[a],a,e,i):void 0;l===void 0&&(l=i[a]),n?Ky(e,a,l):mh(e,a,l)}return e}var uo=Sj;var Z_=Math.max;function wj(i,t,e){return t=Z_(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=Z_(r.length-t,0),o=Array(s);++n<s;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),j_(i,this,a)}}var J_=wj;var Aj=9007199254740991;function Ej(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Aj}var gh=Ej;function Tj(i){return i!=null&&gh(i.length)&&!qy(i)}var Qy=Tj;var Mj=Object.prototype;function Cj(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Mj;return i===e}var yh=Cj;function _j(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var $_=_j;var Pj="[object Arguments]";function Dj(i){return Ki(i)&&Qn(i)==Pj}var Ww=Dj;var eP=Object.prototype,Oj=eP.hasOwnProperty,Ij=eP.propertyIsEnumerable,Rj=Ww(function(){return arguments}())?Ww:function(i){return Ki(i)&&Oj.call(i,"callee")&&!Ij.call(i,"callee")},vh=Rj;function Lj(){return!1}var tP=Lj;var nP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rP=nP&&typeof module=="object"&&module&&!module.nodeType&&module,Nj=rP&&rP.exports===nP,iP=Nj?Kr.Buffer:void 0,Bj=iP?iP.isBuffer:void 0,Fj=Bj||tP,Tc=Fj;var Uj="[object Arguments]",Vj="[object Array]",zj="[object Boolean]",kj="[object Date]",Gj="[object Error]",Hj="[object Function]",jj="[object Map]",Wj="[object Number]",qj="[object Object]",Xj="[object RegExp]",Yj="[object Set]",Kj="[object String]",Qj="[object WeakMap]",Zj="[object ArrayBuffer]",Jj="[object DataView]",$j="[object Float32Array]",eW="[object Float64Array]",tW="[object Int8Array]",rW="[object Int16Array]",iW="[object Int32Array]",nW="[object Uint8Array]",sW="[object Uint8ClampedArray]",oW="[object Uint16Array]",aW="[object Uint32Array]",Nr={};Nr[$j]=Nr[eW]=Nr[tW]=Nr[rW]=Nr[iW]=Nr[nW]=Nr[sW]=Nr[oW]=Nr[aW]=!0;Nr[Uj]=Nr[Vj]=Nr[Zj]=Nr[zj]=Nr[Jj]=Nr[kj]=Nr[Gj]=Nr[Hj]=Nr[jj]=Nr[Wj]=Nr[qj]=Nr[Xj]=Nr[Yj]=Nr[Kj]=Nr[Qj]=!1;function lW(i){return Ki(i)&&gh(i.length)&&!!Nr[Qn(i)]}var sP=lW;function cW(i){return function(t){return i(t)}}var xh=cW;var oP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Np=oP&&typeof module=="object"&&module&&!module.nodeType&&module,uW=Np&&Np.exports===oP,qw=uW&&jy.process,hW=function(){try{var i=Np&&Np.require&&Np.require("util").types;return i||qw&&qw.binding&&qw.binding("util")}catch{}}(),ua=hW;var aP=ua&&ua.isTypedArray,dW=aP?xh(aP):sP,Zy=dW;var fW=Object.prototype,pW=fW.hasOwnProperty;function mW(i,t){var e=Ti(i),r=!e&&vh(i),n=!e&&!r&&Tc(i),s=!e&&!r&&!n&&Zy(i),o=e||r||n||s,a=o?$_(i.length,String):[],l=a.length;for(var c in i)(t||pW.call(i,c))&&!(o&&(c=="length"||n&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||fh(c,l)))&&a.push(c);return a}var Jy=mW;function gW(i,t){return function(e){return i(t(e))}}var $y=gW;var yW=$y(Object.keys,Object),lP=yW;var vW=Object.prototype,xW=vW.hasOwnProperty;function bW(i){if(!yh(i))return lP(i);var t=[];for(var e in Object(i))xW.call(i,e)&&e!="constructor"&&t.push(e);return t}var cP=bW;function SW(i){return Qy(i)?Jy(i):cP(i)}var bh=SW;function wW(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var uP=wW;var AW=Object.prototype,EW=AW.hasOwnProperty;function TW(i){if(!gi(i))return uP(i);var t=yh(i),e=[];for(var r in i)r=="constructor"&&(t||!EW.call(i,r))||e.push(r);return e}var hP=TW;function MW(i){return Qy(i)?Jy(i,!0):hP(i)}var cs=MW;var CW=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_W=/^\w*$/;function PW(i,t){if(Ti(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||hl(i)?!0:_W.test(i)||!CW.test(i)||t!=null&&i in Object(t)}var dP=PW;var DW=Pn(Object,"create"),ha=DW;function OW(){this.__data__=ha?ha(null):{},this.size=0}var fP=OW;function IW(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var pP=IW;var RW="__lodash_hash_undefined__",LW=Object.prototype,NW=LW.hasOwnProperty;function BW(i){var t=this.__data__;if(ha){var e=t[i];return e===RW?void 0:e}return NW.call(t,i)?t[i]:void 0}var mP=BW;var FW=Object.prototype,UW=FW.hasOwnProperty;function VW(i){var t=this.__data__;return ha?t[i]!==void 0:UW.call(t,i)}var gP=VW;var zW="__lodash_hash_undefined__";function kW(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=ha&&t===void 0?zW:t,this}var yP=kW;function Sh(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Sh.prototype.clear=fP;Sh.prototype.delete=pP;Sh.prototype.get=mP;Sh.prototype.has=gP;Sh.prototype.set=yP;var Xw=Sh;function GW(){this.__data__=[],this.size=0}var vP=GW;function HW(i,t){for(var e=i.length;e--;)if(ph(i[e][0],t))return e;return-1}var dl=HW;var jW=Array.prototype,WW=jW.splice;function qW(i){var t=this.__data__,e=dl(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():WW.call(t,e,1),--this.size,!0}var xP=qW;function XW(i){var t=this.__data__,e=dl(t,i);return e<0?void 0:t[e][1]}var bP=XW;function YW(i){return dl(this.__data__,i)>-1}var SP=YW;function KW(i,t){var e=this.__data__,r=dl(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var wP=KW;function wh(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}wh.prototype.clear=vP;wh.prototype.delete=xP;wh.prototype.get=bP;wh.prototype.has=SP;wh.prototype.set=wP;var fl=wh;var QW=Pn(Kr,"Map"),pl=QW;function ZW(){this.size=0,this.__data__={hash:new Xw,map:new(pl||fl),string:new Xw}}var AP=ZW;function JW(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var EP=JW;function $W(i,t){var e=i.__data__;return EP(t)?e[typeof t=="string"?"string":"hash"]:e.map}var ml=$W;function e5(i){var t=ml(this,i).delete(i);return this.size-=t?1:0,t}var TP=e5;function t5(i){return ml(this,i).get(i)}var MP=t5;function r5(i){return ml(this,i).has(i)}var CP=r5;function i5(i,t){var e=ml(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var _P=i5;function Ah(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Ah.prototype.clear=AP;Ah.prototype.delete=TP;Ah.prototype.get=MP;Ah.prototype.has=CP;Ah.prototype.set=_P;var Mc=Ah;var n5="Expected a function";function Yw(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(n5);var e=function(){var r=arguments,n=t?t.apply(this,r):r[0],s=e.cache;if(s.has(n))return s.get(n);var o=i.apply(this,r);return e.cache=s.set(n,o)||s,o};return e.cache=new(Yw.Cache||Mc),e}Yw.Cache=Mc;var PP=Yw;var s5=500;function o5(i){var t=PP(i,function(r){return e.size===s5&&e.clear(),r}),e=t.cache;return t}var DP=o5;var a5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l5=/\\(\\)?/g,c5=DP(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(a5,function(e,r,n,s){t.push(n?s.replace(l5,"$1"):r||e)}),t}),OP=c5;function u5(i){return i==null?"":R_(i)}var IP=u5;function h5(i,t){return Ti(i)?i:dP(i,t)?[i]:OP(IP(i))}var us=h5;var d5=1/0;function f5(i){if(typeof i=="string"||hl(i))return i;var t=i+"";return t=="0"&&1/i==-d5?"-0":t}var gl=f5;function p5(i,t){t=us(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[gl(t[e++])];return e&&e==r?i:void 0}var ev=p5;function m5(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var Eh=m5;var RP=Vi?Vi.isConcatSpreadable:void 0;function g5(i){return Ti(i)||vh(i)||!!(RP&&i&&i[RP])}var LP=g5;function NP(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=LP),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?NP(a,t-1,e,r,n):Eh(n,a):r||(n[n.length]=a)}return n}var BP=NP;function y5(i){var t=i==null?0:i.length;return t?BP(i,1):[]}var FP=y5;function v5(i){return K_(J_(i,void 0,FP),i+"")}var tv=v5;var x5=$y(Object.getPrototypeOf,Object),Th=x5;var b5="[object Object]",S5=Function.prototype,w5=Object.prototype,UP=S5.toString,A5=w5.hasOwnProperty,E5=UP.call(Object);function T5(i){if(!Ki(i)||Qn(i)!=b5)return!1;var t=Th(i);if(t===null)return!0;var e=A5.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&UP.call(e)==E5}var VP=T5;function M5(i,t,e){var r=-1,n=i.length;t<0&&(t=-t>n?0:n+t),e=e>n?n:e,e<0&&(e+=n),n=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(n);++r<n;)s[r]=i[r+t];return s}var zP=M5;function C5(){this.__data__=new fl,this.size=0}var kP=C5;function _5(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var GP=_5;function P5(i){return this.__data__.get(i)}var HP=P5;function D5(i){return this.__data__.has(i)}var jP=D5;var O5=200;function I5(i,t){var e=this.__data__;if(e instanceof fl){var r=e.__data__;if(!pl||r.length<O5-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Mc(r)}return e.set(i,t),this.size=e.size,this}var WP=I5;function Mh(i){var t=this.__data__=new fl(i);this.size=t.size}Mh.prototype.clear=kP;Mh.prototype.delete=GP;Mh.prototype.get=HP;Mh.prototype.has=jP;Mh.prototype.set=WP;var Ch=Mh;function R5(i,t){return i&&uo(t,bh(t),i)}var qP=R5;function L5(i,t){return i&&uo(t,cs(t),i)}var XP=L5;var ZP=typeof exports=="object"&&exports&&!exports.nodeType&&exports,YP=ZP&&typeof module=="object"&&module&&!module.nodeType&&module,N5=YP&&YP.exports===ZP,KP=N5?Kr.Buffer:void 0,QP=KP?KP.allocUnsafe:void 0;function B5(i,t){if(t)return i.slice();var e=i.length,r=QP?QP(e):new i.constructor(e);return i.copy(r),r}var JP=B5;function F5(i,t){for(var e=-1,r=i==null?0:i.length,n=0,s=[];++e<r;){var o=i[e];t(o,e,i)&&(s[n++]=o)}return s}var $P=F5;function U5(){return[]}var rv=U5;var V5=Object.prototype,z5=V5.propertyIsEnumerable,e2=Object.getOwnPropertySymbols,k5=e2?function(i){return i==null?[]:(i=Object(i),$P(e2(i),function(t){return z5.call(i,t)}))}:rv,_h=k5;function G5(i,t){return uo(i,_h(i),t)}var t2=G5;var H5=Object.getOwnPropertySymbols,j5=H5?function(i){for(var t=[];i;)Eh(t,_h(i)),i=Th(i);return t}:rv,iv=j5;function W5(i,t){return uo(i,iv(i),t)}var r2=W5;function q5(i,t,e){var r=t(i);return Ti(i)?r:Eh(r,e(i))}var nv=q5;function X5(i){return nv(i,bh,_h)}var Bp=X5;function Y5(i){return nv(i,cs,iv)}var sv=Y5;var K5=Pn(Kr,"DataView"),ov=K5;var Q5=Pn(Kr,"Promise"),av=Q5;var Z5=Pn(Kr,"Set"),lv=Z5;var i2="[object Map]",J5="[object Object]",n2="[object Promise]",s2="[object Set]",o2="[object WeakMap]",a2="[object DataView]",$5=ca(ov),e8=ca(pl),t8=ca(av),r8=ca(lv),i8=ca(Yy),Cc=Qn;(ov&&Cc(new ov(new ArrayBuffer(1)))!=a2||pl&&Cc(new pl)!=i2||av&&Cc(av.resolve())!=n2||lv&&Cc(new lv)!=s2||Yy&&Cc(new Yy)!=o2)&&(Cc=function(i){var t=Qn(i),e=t==J5?i.constructor:void 0,r=e?ca(e):"";if(r)switch(r){case $5:return a2;case e8:return i2;case t8:return n2;case r8:return s2;case i8:return o2}return t});var da=Cc;var n8=Object.prototype,s8=n8.hasOwnProperty;function o8(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&s8.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var l2=o8;var a8=Kr.Uint8Array,Ph=a8;function l8(i){var t=new i.constructor(i.byteLength);return new Ph(t).set(new Ph(i)),t}var Dh=l8;function c8(i,t){var e=t?Dh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var c2=c8;var u8=/\w*$/;function h8(i){var t=new i.constructor(i.source,u8.exec(i));return t.lastIndex=i.lastIndex,t}var u2=h8;var h2=Vi?Vi.prototype:void 0,d2=h2?h2.valueOf:void 0;function d8(i){return d2?Object(d2.call(i)):{}}var f2=d8;function f8(i,t){var e=t?Dh(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var p2=f8;var p8="[object Boolean]",m8="[object Date]",g8="[object Map]",y8="[object Number]",v8="[object RegExp]",x8="[object Set]",b8="[object String]",S8="[object Symbol]",w8="[object ArrayBuffer]",A8="[object DataView]",E8="[object Float32Array]",T8="[object Float64Array]",M8="[object Int8Array]",C8="[object Int16Array]",_8="[object Int32Array]",P8="[object Uint8Array]",D8="[object Uint8ClampedArray]",O8="[object Uint16Array]",I8="[object Uint32Array]";function R8(i,t,e){var r=i.constructor;switch(t){case w8:return Dh(i);case p8:case m8:return new r(+i);case A8:return c2(i,e);case E8:case T8:case M8:case C8:case _8:case P8:case D8:case O8:case I8:return p2(i,e);case g8:return new r;case y8:case b8:return new r(i);case v8:return u2(i);case x8:return new r;case S8:return f2(i)}}var m2=R8;function L8(i){return typeof i.constructor=="function"&&!yh(i)?H_(Th(i)):{}}var g2=L8;var N8="[object Map]";function B8(i){return Ki(i)&&da(i)==N8}var y2=B8;var v2=ua&&ua.isMap,F8=v2?xh(v2):y2,x2=F8;var U8="[object Set]";function V8(i){return Ki(i)&&da(i)==U8}var b2=V8;var S2=ua&&ua.isSet,z8=S2?xh(S2):b2,w2=z8;var k8=1,G8=2,H8=4,A2="[object Arguments]",j8="[object Array]",W8="[object Boolean]",q8="[object Date]",X8="[object Error]",E2="[object Function]",Y8="[object GeneratorFunction]",K8="[object Map]",Q8="[object Number]",T2="[object Object]",Z8="[object RegExp]",J8="[object Set]",$8="[object String]",e6="[object Symbol]",t6="[object WeakMap]",r6="[object ArrayBuffer]",i6="[object DataView]",n6="[object Float32Array]",s6="[object Float64Array]",o6="[object Int8Array]",a6="[object Int16Array]",l6="[object Int32Array]",c6="[object Uint8Array]",u6="[object Uint8ClampedArray]",h6="[object Uint16Array]",d6="[object Uint32Array]",Ir={};Ir[A2]=Ir[j8]=Ir[r6]=Ir[i6]=Ir[W8]=Ir[q8]=Ir[n6]=Ir[s6]=Ir[o6]=Ir[a6]=Ir[l6]=Ir[K8]=Ir[Q8]=Ir[T2]=Ir[Z8]=Ir[J8]=Ir[$8]=Ir[e6]=Ir[c6]=Ir[u6]=Ir[h6]=Ir[d6]=!0;Ir[X8]=Ir[E2]=Ir[t6]=!1;function cv(i,t,e,r,n,s){var o,a=t&k8,l=t&G8,c=t&H8;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!gi(i))return i;var u=Ti(i);if(u){if(o=l2(i),!a)return W_(i,o)}else{var h=da(i),d=h==E2||h==Y8;if(Tc(i))return JP(i,a);if(h==T2||h==A2||d&&!n){if(o=l||d?{}:g2(i),!a)return l?r2(i,XP(o,i)):t2(i,qP(o,i))}else{if(!Ir[h])return n?i:{};o=m2(i,h,a)}}s||(s=new Ch);var f=s.get(i);if(f)return f;s.set(i,o),w2(i)?i.forEach(function(y){o.add(cv(y,t,e,y,i,s))}):x2(i)&&i.forEach(function(y,m){o.set(m,cv(y,t,e,m,i,s))});var p=c?l?sv:Bp:l?cs:bh,g=u?void 0:p(i);return Q_(g||i,function(y,m){g&&(m=y,y=i[m]),mh(o,m,cv(y,t,e,m,i,s))}),o}var uv=cv;var f6=1,p6=4;function m6(i){return uv(i,f6|p6)}var fa=m6;var g6="__lodash_hash_undefined__";function y6(i){return this.__data__.set(i,g6),this}var M2=y6;function v6(i){return this.__data__.has(i)}var C2=v6;function hv(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Mc;++t<e;)this.add(i[t])}hv.prototype.add=hv.prototype.push=M2;hv.prototype.has=C2;var _2=hv;function x6(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var P2=x6;function b6(i,t){return i.has(t)}var D2=b6;var S6=1,w6=2;function A6(i,t,e,r,n,s){var o=e&S6,a=i.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=s.get(i),u=s.get(t);if(c&&u)return c==t&&u==i;var h=-1,d=!0,f=e&w6?new _2:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],g=t[h];if(r)var y=o?r(g,p,h,t,i,s):r(p,g,h,i,t,s);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!P2(t,function(m,v){if(!D2(f,v)&&(p===m||n(p,m,e,r,s)))return f.push(v)})){d=!1;break}}else if(!(p===g||n(p,g,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var dv=A6;function E6(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var O2=E6;function T6(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var I2=T6;var M6=1,C6=2,_6="[object Boolean]",P6="[object Date]",D6="[object Error]",O6="[object Map]",I6="[object Number]",R6="[object RegExp]",L6="[object Set]",N6="[object String]",B6="[object Symbol]",F6="[object ArrayBuffer]",U6="[object DataView]",R2=Vi?Vi.prototype:void 0,Kw=R2?R2.valueOf:void 0;function V6(i,t,e,r,n,s,o){switch(e){case U6:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case F6:return!(i.byteLength!=t.byteLength||!s(new Ph(i),new Ph(t)));case _6:case P6:case I6:return ph(+i,+t);case D6:return i.name==t.name&&i.message==t.message;case R6:case N6:return i==t+"";case O6:var a=O2;case L6:var l=r&M6;if(a||(a=I2),i.size!=t.size&&!l)return!1;var c=o.get(i);if(c)return c==t;r|=C6,o.set(i,t);var u=dv(a(i),a(t),r,n,s,o);return o.delete(i),u;case B6:if(Kw)return Kw.call(i)==Kw.call(t)}return!1}var L2=V6;var z6=1,k6=Object.prototype,G6=k6.hasOwnProperty;function H6(i,t,e,r,n,s){var o=e&z6,a=Bp(i),l=a.length,c=Bp(t),u=c.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var d=a[h];if(!(o?d in t:G6.call(t,d)))return!1}var f=s.get(i),p=s.get(t);if(f&&p)return f==t&&p==i;var g=!0;s.set(i,t),s.set(t,i);for(var y=o;++h<l;){d=a[h];var m=i[d],v=t[d];if(r)var x=o?r(v,m,d,t,i,s):r(m,v,d,i,t,s);if(!(x===void 0?m===v||n(m,v,e,r,s):x)){g=!1;break}y||(y=d=="constructor")}if(g&&!y){var b=i.constructor,S=t.constructor;b!=S&&"constructor"in i&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof S=="function"&&S instanceof S)&&(g=!1)}return s.delete(i),s.delete(t),g}var N2=H6;var j6=1,B2="[object Arguments]",F2="[object Array]",fv="[object Object]",W6=Object.prototype,U2=W6.hasOwnProperty;function q6(i,t,e,r,n,s){var o=Ti(i),a=Ti(t),l=o?F2:da(i),c=a?F2:da(t);l=l==B2?fv:l,c=c==B2?fv:c;var u=l==fv,h=c==fv,d=l==c;if(d&&Tc(i)){if(!Tc(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new Ch),o||Zy(i)?dv(i,t,e,r,n,s):L2(i,t,l,e,r,n,s);if(!(e&j6)){var f=u&&U2.call(i,"__wrapped__"),p=h&&U2.call(t,"__wrapped__");if(f||p){var g=f?i.value():i,y=p?t.value():t;return s||(s=new Ch),n(g,y,e,r,s)}}return d?(s||(s=new Ch),N2(i,t,e,r,n,s)):!1}var V2=q6;function z2(i,t,e,r,n){return i===t?!0:i==null||t==null||!Ki(i)&&!Ki(t)?i!==i&&t!==t:V2(i,t,e,r,z2,n)}var k2=z2;function X6(i,t){return i!=null&&t in Object(i)}var G2=X6;function Y6(i,t,e){t=us(t,i);for(var r=-1,n=t.length,s=!1;++r<n;){var o=gl(t[r]);if(!(s=i!=null&&e(i,o)))break;i=i[o]}return s||++r!=n?s:(n=i==null?0:i.length,!!n&&gh(n)&&fh(o,n)&&(Ti(i)||vh(i)))}var H2=Y6;function K6(i,t){return i!=null&&H2(i,t,G2)}var j2=K6;var Q6=function(){return Kr.Date.now()},pv=Q6;var Z6="Expected a function",J6=Math.max,$6=Math.min;function eq(i,t,e){var r,n,s,o,a,l,c=0,u=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(Z6);t=jw(t)||0,gi(e)&&(u=!!e.leading,h="maxWait"in e,s=h?J6(jw(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function f(w){var E=r,A=n;return r=n=void 0,c=w,o=i.apply(A,E),o}function p(w){return c=w,a=setTimeout(m,t),u?f(w):o}function g(w){var E=w-l,A=w-c,P=t-E;return h?$6(P,s-A):P}function y(w){var E=w-l,A=w-c;return l===void 0||E>=t||E<0||h&&A>=s}function m(){var w=pv();if(y(w))return v(w);a=setTimeout(m,g(w))}function v(w){return a=void 0,d&&r?f(w):(r=n=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=n=a=void 0}function b(){return a===void 0?o:v(pv())}function S(){var w=pv(),E=y(w);if(r=arguments,n=this,l=w,E){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(m,t),f(l)}return a===void 0&&(a=setTimeout(m,t)),o}return S.cancel=x,S.flush=b,S}var _c=eq;function tq(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var W2=tq;function rq(i,t){return t.length<2?i:ev(i,zP(t,0,-1))}var q2=rq;function iq(i,t){return k2(i,t)}var Fp=iq;function nq(i,t){return t=us(t,i),i=q2(i,t),i==null||delete i[gl(W2(t))]}var X2=nq;function sq(i){return VP(i)?void 0:i}var Y2=sq;var oq=1,aq=2,lq=4,cq=tv(function(i,t){var e={};if(i==null)return e;var r=!1;t=Wy(t,function(s){return s=us(s,i),r||(r=s.length>1),s}),uo(i,sv(i),e),r&&(e=uv(e,oq|aq|lq,Y2));for(var n=t.length;n--;)X2(e,t[n]);return e}),Oh=cq;function uq(i,t,e,r){if(!gi(i))return i;t=us(t,i);for(var n=-1,s=t.length,o=s-1,a=i;a!=null&&++n<s;){var l=gl(t[n]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(n!=o){var u=a[l];c=r?r(u,l,a):void 0,c===void 0&&(c=gi(u)?u:fh(t[n+1])?[]:{})}mh(a,l,c),a=a[l]}return i}var K2=uq;function hq(i,t,e){for(var r=-1,n=t.length,s={};++r<n;){var o=t[r],a=ev(i,o);e(a,o)&&K2(s,us(o,i),a)}return s}var Q2=hq;function dq(i,t){return Q2(i,t,function(e,r){return j2(i,r)})}var Z2=dq;var fq=tv(function(i,t){return i==null?{}:Z2(i,t)}),Zn=fq;var pq="Expected a function";function mq(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(pq);return gi(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),_c(i,t,{leading:r,maxWait:t,trailing:n})}var Qw=mq;function mv(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function yn(i,t){return Object.setPrototypeOf(i,t),i}var gq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),yq=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),vq=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ih&&"ontouchend"in document,xq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,bq=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,Sq=()=>{if(typeof window>"u")return!1;let i=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(i)&&/Apple Computer/.test(t)},wq=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},Aq=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},Eq=gq(),zle=Eq?Aq():void 0,Ih=yq(),Rh=vq(),Up=xq(),Mi=bq(),Zw=Sq(),Jw=Number(wq());function gv(i){return Array.isArray(i)?i:[i]}function yv(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}function Vp(i){return Ih?i.metaKey:i.ctrlKey}function J2(i){return i.wheelDeltaY===0||i.deltaY===0?Ih&&i.shiftKey&&Math.abs(i.wheelDeltaX)>=120?!1:i.wheelDeltaX?i.wheelDeltaX===-3*i.deltaX||i.wheelDeltaX===-3*window.devicePixelRatio*i.deltaX:i.deltaMode===0:i.wheelDeltaY?i.wheelDeltaY===-3*i.deltaY||i.wheelDeltaY===-3*window.devicePixelRatio*i.deltaY:i.deltaMode===0}var nt=[],xv={},zp={},vv={};function $2(i){nt.includes(i)||nt.push(i)}function Lh(i){delete xv[i.pointerId];for(let t=0;t<nt.length;t++)if(nt[t].pointerId===i.pointerId){nt.splice(t,1);break}}function eD(){nt.splice(0,nt.length)}function bv(i){if(i.pointerType!=="touch")return;let t=xv[i.pointerId];t===void 0&&(t={x:0,y:0},xv[i.pointerId]=t),t.x=i.pageX,t.y=i.pageY}function Sv(i){let t=i.pointerId===nt[0].pointerId?nt[1]:nt[0];return xv[t.pointerId]}function tD(i){zp[i.key]=!0,vv[i.key]=vv[i.key]===void 0?1:vv[i.key]+1}function rD(i){if(Ih&&zp.Meta)for(let t in zp)zp[t]=!1;else zp[i.key]=!1;vv={}}function iD(i){i.addEventListener("pointerdown",$2,!0),i.addEventListener("pointerdown",bv,!0),i.addEventListener("pointermove",bv,!0),i.addEventListener("pointerup",Lh,!0),i.addEventListener("pointercancel",Lh,!0),i.addEventListener("pointerleave",Lh,!0),window.addEventListener("keydown",tD,!0),window.addEventListener("keyup",rD,!0)}function nD(i){i.removeEventListener("pointerdown",$2,!0),i.removeEventListener("pointerdown",bv,!0),i.removeEventListener("pointermove",bv,!0),i.removeEventListener("pointerup",Lh,!0),i.removeEventListener("pointercancel",Lh,!0),i.removeEventListener("pointerleave",Lh,!0),window.removeEventListener("keydown",tD,!0),window.removeEventListener("keyup",rD,!0)}var sD,oD=new Promise(i=>{sD=i});var wv;function aD(){if(wv)return wv;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.0.89/build",n=import("./navmesh.js"),[s,o]=await Promise.all([n,fetch(`${e}/navmesh.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});sD(l)}return wv=i(),wv}var lD,cD=new Promise(i=>{lD=i});var Av;function uD(){if(Av)return Av;async function i(){let e=await import("./physics.js");await e.init(),lD(e)}return Av=i(),Av}var at=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,at.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],n;r===void 0?n={type:2,id:t.id}:n={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,at.prototype),{data:a,actual:t,reverse:n}}else if(t.type===2){let{id:r}=t,n=e[r];if(n===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,at.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:n}}}}return null}};function kp(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&kp(r)}return Object.freeze(i)}function hD(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var Nh=class extends Error{};function Ev(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function ho(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let s=i;i=t,t=s}let r=[],n=1/(e+1);for(let s=0;s<e;s++){let o=i+(t-i)*(s+.75+Math.random()*.5)*n;r.push(o)}return r}function Bh(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function dD(){return typeof process<"u"}function fD(i,t){for(let e of i)t(e.id,e.data)!==!0&&fD(e.children,t)}function pD(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)pD(e,t)}var Sr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kp(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let n of e.children)this.fillCaches0(n,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,r){if(!this.has(e))return!0;for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let n=this.parent(e);if(n===r)return!0;e=n}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,r){if(e===null)this.traverse(r);else{let n=this.get(e);n&&pD(n,r)}}traverse(e){fD(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this.parent(e),o=this.childrenArray(s),a=o.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let n=e,s=r;for(;n!==null;){let a=s,l=n;if(n=this.parent(n),n===void 0)throw new Error;s=this.childrenArray(n);let c=s.findIndex(u=>u.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,Sr.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let n of r)if(this.checkDuplicatedIdRec(n))return!0;return!1}addOp(e){let{parent:r,fi:n,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:n,id:s,data:o,children:a};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let n=this.parent(r);if(n===void 0)return null;let s=this.childrenArray(n),o=s.findIndex(c=>c.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(n,s),actual:e,reverse:{type:7,...a,parent:n}}}}moveOp(e){let{parent:r,fi:n,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Nh("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let u=l.splice(c,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=u.fi;return u={...u,fi:n},l=[...l,u],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(u),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let n=null;for(let s of this.childrenArray(e)){if(s.id===r)return n;n=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)+1;if(s<n.length)return n[s].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let n=this.childrenArray(r),s=n.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(n[s].id):r}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push({...n,...s})}r.sort((n,s)=>hD(n.sortKey,s.sortKey));for(let n of r)delete n.sortKey;return r}getWithSortKey(e){var r=e;let n=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)n.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:n}}}insertBeforeHelper(e,r,n){return this.insertAfterHelper(e,this.previous(e,r),n)}insertAfterHelper(e,r,n){let s=this.childrenArray(e);if(r===null){if(s.length===0)return ho(0,n,n);{let o=s[0].fi;return ho(o-n,o,n)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return ho(l,l+n,n)}else return ho(o.fi,a.fi,n)}}};var Fh;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let n=r.props,s={},o=[...e],a=!1;if(n)for(let l of Object.keys(n)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=n[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let n=r.props,s={},o={...e},a=!1;if(n)for(let l of Object.keys(n)){s[l]=o[l];let c=n[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=i})(Fh||(Fh={}));var je=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,je.prototype)}deepFreeze(){let e=0;for(;e<this.length;)kp(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,r){if(this.get(e)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,je.prototype);let r=e;return dD()||r.fillCaches(),r}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:r,id:n,data:s}=e,o=this,a={fi:r,id:n,data:s};return o=[...o,a],o.sort((c,u)=>c.fi-u.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:n}}}deleteOp(e){let{id:r}=e,n=this,s=n.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,n=[...n];let o=n.splice(s,1)[0];return{data:this.modifyArrayBy(n),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:n}=e,s=this;s=[...s];let o=s.findIndex(u=>u.id===n);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((u,h)=>u.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:n}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let n of this){if(n.id===e)return r;r=n.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let n=this;if(e===null){if(n.length===0)return ho(0,r,r);{let s=n[0].fi;return ho(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=n.find(a=>a.fi>s.fi);if(o===void 0){let a=n[n.length-1].fi;return ho(a,a+r,r)}else return ho(s.fi,o.fi,r)}}};function Uh(i){return i&&typeof i=="object"&&i instanceof wr}var wr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,n=0,s={};for(;n<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[n]],r!==void 0&&!Uh(r))return null;n+=1}r=r?Ev(r):new wr;for(let[l,c]of Object.entries(t.props)){let u=r[l];s[l]=u,c===void 0?delete r[l]:r[l]=c}for(;n>0;){if(Object.keys(r).length===0){let l=e[n-1];l&&(r=Ev(l),delete r[t.path[n-1]])}else{let l=e[n-1];if(l){let c=Ev(l);c[t.path[n-1]]=r,r=c}else{let c=new wr;c[t.path[n-1]]=r,r=c}}n-=1}let o=Object.setPrototypeOf(r,wr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},fo;(r=>{function i(n,s){return Gp(n,s)??n}r.apply=i;function t(n,s){return eA(n,s)}r.merge=t;function e(n,s){let o=0,a=s.path,l=n;for(;o<a.length&&l!==void 0;){if(l=Ur.zoomOnce(l,a[o]),l===void 0)return s;if(!Uh(l))return;o+=1}if(l===void 0)return s;if(!!Uh(l))if(s.type===0){let c={...s.props};for(let u of Object.keys(l))delete c[u];return{...s,props:c}}else if(s.type===1||s.type===4||s.type===7){let c=$w([s],l);return c?(console.log(c),c):s}else return s}r.filterOp=e})(fo||(fo={}));function $w(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=Gp(n.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=n.data),n.children){let a=$w(n.children,t);return a!==void 0?e=!0:a=n.children,{...n,id:s,data:o,children:a}}else return{...n,id:s,data:o}});if(e)return r}function Tq(i,t){if(t===void 0)return;let e=!1,r=i.map(n=>{let s=n.id,o=Gp(n.data,t[s]);return e=e||o!==void 0,o===void 0&&(o=n.data),{...n,id:s,data:o}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function Gp(i,t){if(!Uh(t))return t;if(i instanceof Sr){let e=$w(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof je)return Tq(i,t);if(Array.isArray(i)){let e=!1,r=i.map((n,s)=>{let o=Gp(n,t[s]);return e=e||o!==void 0,o===void 0&&(o=n),o});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof wr)return eA(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[n,s]of Object.entries(i)){let o=Gp(s,t[n]);r=r||o!==void 0,o===void 0&&(o=s),e[n]=o}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function eA(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Uh(t))return t;if(!Uh(i))return fo.apply(i,t);let e=new Set;for(let n of Object.keys(i))e.add(n);for(let n of Object.keys(t))e.add(n);let r=new wr;for(let n of e){let s=eA(i===void 0?void 0:i[n],t===void 0?void 0:t[n]);r[n]=s}return r}function mD(i,t){let e={cur:[],result:[],len:0};return i=Hp(i,t,e)??i,[i,e.result]}function Tv(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Mv(i){i&&(i.len-=1)}function Mq(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function gD(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Hp(s.data,t,Tv(e,o));Mv(e),r=r||l!==void 0,l===void 0&&(l=s.data);let c=gD(s.children,t,e);return c!==void 0?r=!0:c=s.children,{...s,id:o,data:l,children:c}});if(r)return n}function Cq(i,t,e){let r=!1,n=i.map(s=>{let o=s.id,a=t[o];if(a!==void 0&&typeof a=="string"&&(r=!0,o=a,e!==null))throw new Error("not supported");let l=Hp(s.data,t,Tv(e,o));return Mv(e),r=r||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(r)return Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n}function Hp(i,t,e){if(i instanceof Sr){let r=gD(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof je)return Cq(i,t,e);if(Array.isArray(i)){let r=!1,n=i.map((s,o)=>{let a=Hp(s,t,Tv(e,o));return Mv(e),r=r||a!==void 0,a===void 0&&(a=s),a});return r?(Object.setPrototypeOf(n,Object.getPrototypeOf(i)),n):void 0}else if(i&&typeof i=="object"&&!Bh(i)){let r={},n=!1;for(let[s,o]of Object.entries(i))if(s!=="name"){let a=t[s];if(typeof a=="string"){if(e!==null)throw new Error("not supported");n=!0,s=a}let l=Hp(o,t,Tv(e,s));Mv(e),n=n||l!==void 0,l===void 0&&(l=o),r[s]=l}else r[s]=o;return n?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&Mq(e),r}else return}}var Vh;(t=>{function i(e,r){let n=Ur.zoom(r,e.path);if(typeof n=="object"){let s={};for(let o of Object.keys(e.props))s[o]=n[o];return{...e,props:s}}else return{...e,props:{}}}t.replaceProps=i})(Vh||(Vh={}));var Vr;(a=>{function i(l,c){return{...l,path:l.path.slice(c)}}a.drop=i;function t(l,c){return e(l,c)?.data??l}a.applySimple=t;function e(l,c){let u=c.path;for(var h=[];;){let d;if(l instanceof wr&&c.type===0&&(d=l.runOp({...c,path:u.slice(h.length)}),d===null&&(d=void 0)),d===void 0&&h.length===u.length&&(l instanceof Sr||l instanceof je||l instanceof at?d=l.runOp(c):d=Fh.runOp(l,c)),d!==void 0)if(d!==null){let g=d.data;for(let y=h.length-1;y>=0;y--){let m=u[y],v=h[y];if(v instanceof Sr){if(typeof m=="number")throw new Error("illegal arg");g=v.modifyById(m,g)}else if(v instanceof je){if(typeof m=="number")throw new Error("illegal arg");g=v.modifyById(m,g)}else if(v instanceof at){if(typeof m=="number")throw new Error("illegal arg");g=v.modifyById(m,g)}else if(v instanceof wr){let x={...v,[m]:g};g=Object.setPrototypeOf(x,wr.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof m=="string"&&(m=parseInt(m),isNaN(m)))throw new Error("Invalid path");let x=g;g=[...v],g[m]=x}else g={...v,[m]:g};else return null}return{data:g,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[h.length],p;if(l instanceof Sr){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else if(l instanceof je){if(typeof f=="number")throw new Error("");p=l.get(f)?.data}else l!==null&&(p=l[f]);if(p!==void 0)h.push(l),l=p;else return null}}a.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}a.pathDisjoint=r;function n(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}a.pathEq=n;function s(l,c){return r(l.path,c.path)}a.commutative=s;function o(l,c){return l.type===0&&c.type===0&&n(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}a.subsumed=o})(Vr||(Vr={}));var jp;(l=>{function i(){return[]}l.empty=i;function t(c,u){let h=[];for(let d of c){let[f,...p]=d.path;f===u&&h.push({...d,path:p})}return h}l.removePrefix=t;function e(c,u){return c.map(h=>({...h,path:[u,...h.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function n(c,u){return[...c.filter(d=>!u.some(f=>Vr.subsumed(d,f))),...u]}l.compress=n;function s(c,u){return c.every(h=>u.every(d=>Vr.commutative(h,d)))}l.commutative=s;function o(c,u){for(let h of u){let d=a(c,h);d!==null&&(c=d.data)}return c}l.applyAll=o;function a(c,u){var h=c;let d=[],f=[];for(let p of u)try{if(p.type===3||p.type===5&&p.path[p.path.length-1]==="variables"){let g,y,m;if(p.type===3?(g=Ur.zoom(h,[...p.path,p.id]),m=Vr.apply(h,{...p,type:2})):(g=Ur.zoom(h,[...p.path,p.id,"value"]),m=Vr.apply(h,p)),m!==null){h=m.data;let[v,x]=mD(h,{[p.id]:g});h=v;for(let b=0;b<x.length;b++){let S=x[b],w=S.pop();if(typeof w=="number"){let E=[w];for(let P=b+1;P<x.length;P++){let M=x[P],C=M[M.length-1];if(typeof C=="number"&&Ur.equal(S,M.slice(0,M.length-1)))E.push(C),x.splice(P,1);else break}let A=Ur.zoom(h,S);y=A.map((P,M)=>E.includes(M)?p.id:P),g=A,w=S.pop()}else{if(w==="alphaOverride"||w==="alpha"){g/=100;let E=g,A=Ur.zoom(h,S.slice(0,S.length-2)),P=A.layers.map(M=>M.id===S[S.length-1]?{...M,data:{...M.data,[w]:E}}:M);Object.setPrototypeOf(P,Object.getPrototypeOf(A.layers)),A.layers=P}y=p.id}d.push({type:0,path:S,props:{[w]:g}}),f.push({type:0,path:S,props:{[w]:y}})}f.push(m.reverse),d.push(m.actual)}}else{let g=Vr.apply(h,p);g!==null&&(d.push(g.actual),h=g.data,f.push(g.reverse))}}catch(g){if(g instanceof Nh)return null;throw g}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(jp||(jp={}));var yD=Symbol(),_q=Symbol(),_v=Symbol(),Pc=class{reportOp(t,e,r=[]){let n=this;if(e===null)return;n._current=e.data;let s=r;for(;!(n instanceof Cv);){let o=n._path,a=n._current;if(o!==""&&s.splice(0,0,o),n=n._parent,n===null)return;n.update(o,a)}n.push(s,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[_v];r&&r(),delete this._children[t]}}}},rA=class extends Pc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,Fh.runOp(this._current,t),t.path)}},iA=class extends Pc{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,at.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},vD={get(i,t){if(t===_v)return()=>{i._parent=null};if(t===yD)return i._current;if(t===_q)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e[t],o=Pv(i,t,s);return o!==s?(r===void 0&&(r={},i._children=r),r[t]=o,o):s},has(i,t){return t in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},Pq={...vD,set(i,t,e){let r={type:0,props:{[t]:Qr(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},Dq={...vD,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},zh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[_v]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=Pv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}add(t,e,r,n,s){this.runOp({type:7,parent:t,fi:e,id:r,data:n,children:s})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}insertBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.add(t,n[s],o.id,o.data,o.children)}}moveAfter(t,e,r){let n=this._current.insertAfterHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}moveBefore(t,e,r){let n=this._current.insertBeforeHelper(t,e,r.length);for(let s=0;s<r.length;s++){let o=r[s];this.move(t,n[s],o)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},kh=class extends Pc{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[_v]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id,s=this._current[r].fi;t(this.data(this._current[r].id),n,s)}}find(t){let e=this.length;for(let r=0;r<e;r++){let n=this._current[r].id;if(t(this.data(n),n))return this.get(n)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,n=r===void 0?void 0:r[t];if(n!==void 0)return n;let s=e.get(t)?.data,o=Pv(this,t,s);return o!==s?(r===void 0&&(r={},this._children=r),r[t]=o,o):s}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.add(r[n],s.id,s.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let n=0;n<e.length;n++){let s=e[n];this.move(r[n],s)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function tA(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&Ur.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Cv=class extends Pc{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,n){tA(this.ts,e,t),tA(this.actual,r,t),tA(this.reverse,n,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Pv(i,t,e){return e instanceof Sr?new zh(i,t,e):e instanceof je?new kh(i,t,e):e instanceof at?new Proxy(new iA(i,t,e),Dq):e!==null&&typeof e=="object"?Bh(e)?e:new Proxy(new rA(i,t,e),Pq):e}function nA(i){let t=new Cv(i);return[Pv(t,"",i),t]}function yl(i,t){let[e,r]=nA(i);return t(e),r.result()}function Qr(i){return i instanceof zh||i instanceof kh?i._current:i!==null&&typeof i=="object"?i[yD]:i}var Ur;(n=>{function i(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}n.equal=i;function t(s,o,a){let l=r(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...o};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return o}n.removeOverridden=t;function e(s,o){if((s instanceof Sr||s instanceof zh)&&typeof o=="string")return s.data(o);if((s instanceof je||s instanceof kh)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object"&&s!==null)return s[o]}n.zoomOnce=e;function r(s,o,a=0){for(;a<o.length&&s!==void 0;)s=e(s,o[a]),a+=1;return s}n.zoom=r})(Ur||(Ur={}));function xD(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function Ut(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var Dv=class{},Wp=class extends Dv{constructor(e){super();this.id=e}},qp=class extends Dv{constructor(e){super();this.data=e}};var oA;try{oA=new TextDecoder}catch{}var qe,xl,oe=0;var CD=[],aA=CD,lA=0,Dn={},Jt,vl,hs=0,po=0,Jn,pa,vn=[],lr,bD={useRecords:!1,mapsAsObjects:!0},Xp=class{},uA=new Xp;uA.name="MessagePack 0xC1";var Gh=!1,mo=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(qe)return ID(()=>(Iv(),this?this.unpack(t,e):mo.prototype.unpack.call(bD,t,e)));xl=e>-1?e:t.length,oe=0,lA=0,po=0,vl=null,aA=CD,Jn=null,qe=t;try{lr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw qe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof mo){if(Dn=this,this.structures)return Jt=this.structures,Ov();(!Jt||Jt.length>0)&&(Jt=[])}else Dn=bD,(!Jt||Jt.length>0)&&(Jt=[]);return Ov()}unpackMultiple(t,e){let r,n=0;try{Gh=!0;let s=t.length,o=this?this.unpack(t,s):Nv.unpack(t,s);if(e){for(e(o);oe<s;)if(n=oe,e(Ov())===!1)return}else{for(r=[o];oe<s;)n=oe,r.push(Ov());return r}}catch(s){throw s.lastPosition=n,s.values=r,s}finally{Gh=!1,Iv()}}_mergeStructures(t,e){t=t||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let n=t[r],s=e[r];s&&(n&&((t.restoreStructures||(t.restoreStructures=[]))[r]=n),t[r]=s)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Ov(){try{if(!Dn.trusted&&!Gh){let t=Jt.sharedLength||0;t<Jt.length&&(Jt.length=t)}let i=Zr();if(oe==xl)Jt.restoreStructures&&SD(),Jt=null,qe=null,pa&&(pa=null);else if(oe>xl){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Gh)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Jt.restoreStructures&&SD(),Iv(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function SD(){for(let i in Jt.restoreStructures)Jt[i]=Jt.restoreStructures[i];Jt.restoreStructures=null}function Zr(){let i=qe[oe++];if(i<160)if(i<128){if(i<64)return i;{let t=Jt[i&63]||Dn.getStructures&&_D()[i&63];return t?(t.read||(t.read=hA(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,Dn.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DD()]=Zr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Zr(),Zr());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Zr();return t}else if(i<192){let t=i-160;if(po>=oe)return vl.slice(oe-hs,(oe+=t)-hs);if(po==0&&xl<140){let e=t<16?dA(t):PD(t);if(e!=null)return e}return cA(t)}else{let t;switch(i){case 192:return null;case 193:return Jn?(t=Zr(),t>0?Jn[1].slice(Jn.position1,Jn.position1+=t):Jn[0].slice(Jn.position0,Jn.position0-=t)):uA;case 194:return!1;case 195:return!0;case 196:return sA(qe[oe++]);case 197:return t=lr.getUint16(oe),oe+=2,sA(t);case 198:return t=lr.getUint32(oe),oe+=4,sA(t);case 199:return Dc(qe[oe++]);case 200:return t=lr.getUint16(oe),oe+=2,Dc(t);case 201:return t=lr.getUint32(oe),oe+=4,Dc(t);case 202:if(t=lr.getFloat32(oe),Dn.useFloat32>2){let e=Lv[(qe[oe]&127)<<1|qe[oe+1]>>7];return oe+=4,(e*t+(t>0?.5:-.5)>>0)/e}return oe+=4,t;case 203:return t=lr.getFloat64(oe),oe+=8,t;case 204:return qe[oe++];case 205:return t=lr.getUint16(oe),oe+=2,t;case 206:return t=lr.getUint32(oe),oe+=4,t;case 207:return Dn.int64AsNumber?(t=lr.getUint32(oe)*4294967296,t+=lr.getUint32(oe+4)):t=lr.getBigUint64(oe),oe+=8,t;case 208:return lr.getInt8(oe++);case 209:return t=lr.getInt16(oe),oe+=2,t;case 210:return t=lr.getInt32(oe),oe+=4,t;case 211:return Dn.int64AsNumber?(t=lr.getInt32(oe)*4294967296,t+=lr.getUint32(oe+4)):t=lr.getBigInt64(oe),oe+=8,t;case 212:if(t=qe[oe++],t==114)return MD(qe[oe++]&63);{let e=vn[t];if(e)return e.read?(oe++,e.read(Zr())):e.noBuffer?(oe++,e()):e(qe.subarray(oe,++oe));throw new Error("Unknown extension "+t)}case 213:return t=qe[oe],t==114?(oe++,MD(qe[oe++]&63,qe[oe++])):Dc(2);case 214:return Dc(4);case 215:return Dc(8);case 216:return Dc(16);case 217:return t=qe[oe++],po>=oe?vl.slice(oe-hs,(oe+=t)-hs):Iq(t);case 218:return t=lr.getUint16(oe),oe+=2,po>=oe?vl.slice(oe-hs,(oe+=t)-hs):Rq(t);case 219:return t=lr.getUint32(oe),oe+=4,po>=oe?vl.slice(oe-hs,(oe+=t)-hs):Lq(t);case 220:return t=lr.getUint16(oe),oe+=2,AD(t);case 221:return t=lr.getUint32(oe),oe+=4,AD(t);case 222:return t=lr.getUint16(oe),oe+=2,ED(t);case 223:return t=lr.getUint32(oe),oe+=4,ED(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var Oq=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function hA(i,t){function e(){if(e.count++>2){let n=i.read=new Function("r","return function(){return {"+i.map(s=>Oq.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Zr);return i.highByte===0&&(i.read=wD(t,i.read)),n()}let r={};for(let n=0,s=i.length;n<s;n++){let o=i[n];r[o]=Zr()}return r}return e.count=0,i.highByte===0?wD(t,e):e}var wD=(i,t)=>function(){let e=qe[oe++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),n=Jt[r]||_D()[r];if(!n)throw new Error("Record id is not defined for "+r);return n.read||(n.read=hA(n,i)),n.read()};function _D(){let i=ID(()=>(qe=null,Dn.getStructures()));return Jt=Dn._mergeStructures(i,Jt)}var cA=Rv,Iq=Rv,Rq=Rv,Lq=Rv;function Rv(i){let t;if(i<16&&(t=dA(i)))return t;if(i>64&&oA)return oA.decode(qe.subarray(oe,oe+=i));let e=oe+i,r=[];for(t="";oe<e;){let n=qe[oe++];if((n&128)===0)r.push(n);else if((n&224)===192){let s=qe[oe++]&63;r.push((n&31)<<6|s)}else if((n&240)===224){let s=qe[oe++]&63,o=qe[oe++]&63;r.push((n&31)<<12|s<<6|o)}else if((n&248)===240){let s=qe[oe++]&63,o=qe[oe++]&63,a=qe[oe++]&63,l=(n&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(n);r.length>=4096&&(t+=zi.apply(String,r),r.length=0)}return r.length>0&&(t+=zi.apply(String,r)),t}function AD(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Zr();return t}function ED(i){if(Dn.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[DD()]=Zr();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Zr(),Zr());return t}}var zi=String.fromCharCode;function PD(i){let t=oe,e=new Array(i);for(let r=0;r<i;r++){let n=qe[oe++];if((n&128)>0){oe=t;return}e[r]=n}return zi.apply(String,e)}function dA(i){if(i<4)if(i<2){if(i===0)return"";{let t=qe[oe++];if((t&128)>1){oe-=1;return}return zi(t)}}else{let t=qe[oe++],e=qe[oe++];if((t&128)>0||(e&128)>0){oe-=2;return}if(i<3)return zi(t,e);let r=qe[oe++];if((r&128)>0){oe-=3;return}return zi(t,e,r)}else{let t=qe[oe++],e=qe[oe++],r=qe[oe++],n=qe[oe++];if((t&128)>0||(e&128)>0||(r&128)>0||(n&128)>0){oe-=4;return}if(i<6){if(i===4)return zi(t,e,r,n);{let s=qe[oe++];if((s&128)>0){oe-=5;return}return zi(t,e,r,n,s)}}else if(i<8){let s=qe[oe++],o=qe[oe++];if((s&128)>0||(o&128)>0){oe-=6;return}if(i<7)return zi(t,e,r,n,s,o);let a=qe[oe++];if((a&128)>0){oe-=7;return}return zi(t,e,r,n,s,o,a)}else{let s=qe[oe++],o=qe[oe++],a=qe[oe++],l=qe[oe++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){oe-=8;return}if(i<10){if(i===8)return zi(t,e,r,n,s,o,a,l);{let c=qe[oe++];if((c&128)>0){oe-=9;return}return zi(t,e,r,n,s,o,a,l,c)}}else if(i<12){let c=qe[oe++],u=qe[oe++];if((c&128)>0||(u&128)>0){oe-=10;return}if(i<11)return zi(t,e,r,n,s,o,a,l,c,u);let h=qe[oe++];if((h&128)>0){oe-=11;return}return zi(t,e,r,n,s,o,a,l,c,u,h)}else{let c=qe[oe++],u=qe[oe++],h=qe[oe++],d=qe[oe++];if((c&128)>0||(u&128)>0||(h&128)>0||(d&128)>0){oe-=12;return}if(i<14){if(i===12)return zi(t,e,r,n,s,o,a,l,c,u,h,d);{let f=qe[oe++];if((f&128)>0){oe-=13;return}return zi(t,e,r,n,s,o,a,l,c,u,h,d,f)}}else{let f=qe[oe++],p=qe[oe++];if((f&128)>0||(p&128)>0){oe-=14;return}if(i<15)return zi(t,e,r,n,s,o,a,l,c,u,h,d,f,p);let g=qe[oe++];if((g&128)>0){oe-=15;return}return zi(t,e,r,n,s,o,a,l,c,u,h,d,f,p,g)}}}}}function sA(i){return Dn.copyBuffers?Uint8Array.prototype.slice.call(qe,oe,oe+=i):qe.subarray(oe,oe+=i)}function Dc(i){let t=qe[oe++];if(vn[t])return vn[t](qe.subarray(oe,oe+=i));throw new Error("Unknown extension type "+t)}var TD=new Array(4096);function DD(){let i=qe[oe++];if(i>=160&&i<192){if(i=i-160,po>=oe)return vl.slice(oe-hs,(oe+=i)-hs);if(!(po==0&&xl<180))return cA(i)}else return oe--,Zr();let t=(i<<5^(i>1?lr.getUint16(oe):i>0?qe[oe]:0))&4095,e=TD[t],r=oe,n=oe+i-3,s,o=0;if(e&&e.bytes==i){for(;r<n;){if(s=lr.getUint32(r),s!=e[o++]){r=1879048192;break}r+=4}for(n+=3;r<n;)if(s=qe[r++],s!=e[o++]){r=1879048192;break}if(r===n)return oe=r,e.string;n-=3,r=oe}for(e=[],TD[t]=e,e.bytes=i;r<n;)s=lr.getUint32(r),e.push(s),r+=4;for(n+=3;r<n;)s=qe[r++],e.push(s);let a=i<16?dA(i):PD(i);return a!=null?e.string=a:e.string=cA(i)}var MD=(i,t)=>{var e=Zr();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let n=Jt[i];return n&&n.isShared&&((Jt.restoreStructures||(Jt.restoreStructures=[]))[i]=n),Jt[i]=e,e.read=hA(e,r),e.read()},OD=typeof self=="object"?self:global;vn[0]=()=>{};vn[0].noBuffer=!0;vn[101]=()=>{let i=Zr();return(OD[i[0]]||Error)(i[1])};vn[105]=i=>{let t=lr.getUint32(oe-4);pa||(pa=new Map);let e=qe[oe],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let n={target:r};pa.set(t,n);let s=Zr();return n.used?Object.assign(r,s):(n.target=s,s)};vn[112]=i=>{let t=lr.getUint32(oe-4),e=pa.get(t);return e.used=!0,e.target};vn[115]=()=>new Set(Zr());var fA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");vn[116]=i=>{let t=i[0],e=fA[t];if(!e)throw new Error("Could not find typed array for code "+t);return new OD[e](Uint8Array.prototype.slice.call(i,1).buffer)};vn[120]=()=>{let i=Zr();return new RegExp(i[0],i[1])};vn[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=oe;oe+=t-4,Jn=[Zr(),Zr()],Jn.position0=0,Jn.position1=0;let r=oe;oe=e;try{return Zr()}finally{oe=r}};vn[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function ID(i){let t=xl,e=oe,r=lA,n=hs,s=po,o=vl,a=aA,l=pa,c=Jn,u=new Uint8Array(qe.slice(0,xl)),h=Jt,d=Jt.slice(0,Jt.length),f=Dn,p=Gh,g=i();return xl=t,oe=e,lA=r,hs=n,po=s,vl=o,aA=a,pa=l,Jn=c,qe=u,Gh=p,Jt=h,Jt.splice(0,Jt.length,...d),Dn=f,lr=new DataView(qe.buffer,qe.byteOffset,qe.byteLength),g}function Iv(){qe=null,pa=null,Jt=null}function RD(i){i.unpack?vn[i.type]=i.unpack:vn[i.type]=i}var Lv=new Array(147);for(let i=0;i<256;i++)Lv[i]=+("1e"+Math.floor(45.15-i*.30103));var Nv=new mo({useRecords:!1}),Nq=Nv.unpack,Bq=Nv.unpackMultiple,Fq=Nv.unpack,Bv={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Uq=new Float32Array(1),Zce=new Uint8Array(Uq.buffer,0,4);var Fv;try{Fv=new TextEncoder}catch{}var Uv,mA,Vv=typeof Buffer<"u",pA=Vv?Buffer.allocUnsafeSlow:Uint8Array,FD=Vv?Buffer:Uint8Array,LD=Vv?4294967296:2144337920,we,oi,pe=0,go,yo=null,Vq=/[\u0080-\uFFFF]/,Yp=Symbol("record-id"),Oc=class extends mo{constructor(t){super(t),this.offset=0;let e,r,n,s,o,a,l=0,c=FD.prototype.utf8Write?function(A,P,M){return we.utf8Write(A,P,M)}:Fv&&Fv.encodeInto?function(A,P){return Fv.encodeInto(A,we.subarray(P)).written}:!1,u=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=t.maxOwnStructures;p==null&&(p=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let g=f>32||p+f>64,y=f+64,m=f+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],x=0,b=0;this.pack=this.encode=function(A,P){if(we||(we=new pA(8192),oi=new DataView(we.buffer,0,8192),pe=0),go=we.length-10,go-pe<2048?(we=new pA(we.length),oi=new DataView(we.buffer,0,we.length),go=we.length-10,pe=0):pe=pe+7&2147483640,r=pe,a=u.structuredClone?new Map:null,u.bundleStrings?(yo=["",""],we[pe++]=214,we[pe++]=98,yo.position=pe-r,pe+=4):yo=null,n=u.structures,n){n.uninitialized&&(n=u._mergeStructures(u.getStructures()));let M=n.sharedLength||0;if(M>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let C=0;C<M;C++){let O=n[C];if(!O)continue;let L,D=n.transitions;for(let B=0,k=O.length;B<k;B++){let F=O[B];L=D[F],L||(L=D[F]=Object.create(null)),D=L}D[Yp]=C+64}l=M}h||(n.nextId=M+64)}s&&(s=!1),o=n||[];try{if(S(A),yo){oi.setUint32(yo.position+r,pe-yo.position-r);let M=yo;yo=null,S(M[0]),S(M[1])}if(u.offset=pe,a&&a.idsToInsert){pe+=a.idsToInsert.length*6,pe>go&&E(pe),u.offset=pe;let M=kq(we.subarray(r,pe),a.idsToInsert);return a=null,M}return P&VD?(we.start=r,we.end=pe,we):we.subarray(r,pe)}finally{if(n){if(b<10&&b++,x>1e4)n.transitions=null,b=0,x=0,v.length>0&&(v=[]);else if(v.length>0&&!h){for(let M=0,C=v.length;M<C;M++)v[M][Yp]=0;v=[]}if(s&&u.saveStructures){let M=n.sharedLength||f;n.length>M&&(n=n.slice(0,M));let C=we.subarray(r,pe);return u.saveStructures(n,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(A)):(l=M,C)}}P&Yq&&(pe=r)}};let S=A=>{pe>go&&(we=E(pe));var P=typeof A,M;if(P==="string"){let C=A.length;if(yo&&C>=8&&C<4096){let D=Vq.test(A);yo[D?0:1]+=A,we[pe++]=193,S(D?-C:C);return}let O;C<32?O=1:C<256?O=2:C<65536?O=3:O=5;let L=C*3;if(pe+L>go&&(we=E(pe+L)),C<64||!c){let D,B,k,F=pe+O;for(D=0;D<C;D++)B=A.charCodeAt(D),B<128?we[F++]=B:B<2048?(we[F++]=B>>6|192,we[F++]=B&63|128):(B&64512)===55296&&((k=A.charCodeAt(D+1))&64512)===56320?(B=65536+((B&1023)<<10)+(k&1023),D++,we[F++]=B>>18|240,we[F++]=B>>12&63|128,we[F++]=B>>6&63|128,we[F++]=B&63|128):(we[F++]=B>>12|224,we[F++]=B>>6&63|128,we[F++]=B&63|128);M=F-pe-O}else M=c(A,pe+O,L);M<32?we[pe++]=160|M:M<256?(O<2&&we.copyWithin(pe+2,pe+1,pe+1+M),we[pe++]=217,we[pe++]=M):M<65536?(O<3&&we.copyWithin(pe+3,pe+2,pe+2+M),we[pe++]=218,we[pe++]=M>>8,we[pe++]=M&255):(O<5&&we.copyWithin(pe+5,pe+3,pe+3+M),we[pe++]=219,oi.setUint32(pe,M),pe+=4),pe+=M}else if(P==="number")if(A>>>0===A)A<64?we[pe++]=A:A<256?(we[pe++]=204,we[pe++]=A):A<65536?(we[pe++]=205,we[pe++]=A>>8,we[pe++]=A&255):(we[pe++]=206,oi.setUint32(pe,A),pe+=4);else if(A>>0===A)A>=-32?we[pe++]=256+A:A>=-128?(we[pe++]=208,we[pe++]=A+256):A>=-32768?(we[pe++]=209,oi.setInt16(pe,A),pe+=2):(we[pe++]=210,oi.setInt32(pe,A),pe+=4);else{let C;if((C=this.useFloat32)>0&&A<4294967296&&A>=-2147483648){we[pe++]=202,oi.setFloat32(pe,A);let O;if(C<4||(O=A*Lv[(we[pe]&127)<<1|we[pe+1]>>7])>>0===O){pe+=4;return}else pe--}we[pe++]=203,oi.setFloat64(pe,A),pe+=8}else if(P==="object")if(!A)we[pe++]=192;else{if(a){let O=a.get(A);if(O){if(!O.id){let L=a.idsToInsert||(a.idsToInsert=[]);O.id=L.push(O)}we[pe++]=214,we[pe++]=112,oi.setUint32(pe,O.id),pe+=4;return}else a.set(A,{offset:pe-r})}let C=A.constructor;if(C===Object)w(A,!0);else if(C===Array){M=A.length,M<16?we[pe++]=144|M:M<65536?(we[pe++]=220,we[pe++]=M>>8,we[pe++]=M&255):(we[pe++]=221,oi.setUint32(pe,M),pe+=4);for(let O=0;O<M;O++)S(A[O])}else if(C===Map){M=A.size,M<16?we[pe++]=128|M:M<65536?(we[pe++]=222,we[pe++]=M>>8,we[pe++]=M&255):(we[pe++]=223,oi.setUint32(pe,M),pe+=4);for(let[O,L]of A)S(O),S(L)}else{for(let O=0,L=Uv.length;O<L;O++){let D=mA[O];if(A instanceof D){let B=Uv[O];if(B.write){B.type&&(we[pe++]=212,we[pe++]=B.type,we[pe++]=0),S(B.write.call(this,A));return}let k=we,F=oi,H=pe;we=null;let G;try{G=B.pack.call(this,A,X=>(we=k,k=null,pe+=X,pe>go&&E(pe),{target:we,targetView:oi,position:pe-X}),S)}finally{k&&(we=k,oi=F,pe=H,go=we.length-10)}G&&(G.length+pe>go&&E(G.length+pe),pe=zq(G,we,pe,B.type));return}}w(A,!A.hasOwnProperty)}}else if(P==="boolean")we[pe++]=A?195:194;else if(P==="bigint"){if(A<BigInt(1)<<BigInt(63)&&A>=-(BigInt(1)<<BigInt(63)))we[pe++]=211,oi.setBigInt64(pe,A);else if(A<BigInt(1)<<BigInt(64)&&A>0)we[pe++]=207,oi.setBigUint64(pe,A);else if(this.largeBigIntToFloat)we[pe++]=203,oi.setFloat64(pe,Number(A));else throw new RangeError(A+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");pe+=8}else if(P==="undefined")this.encodeUndefinedAsNil?we[pe++]=192:(we[pe++]=212,we[pe++]=0,we[pe++]=0);else if(P==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+P)},w=this.useRecords===!1?this.variableMapSize?A=>{let P=Object.keys(A),M=P.length;M<16?we[pe++]=128|M:M<65536?(we[pe++]=222,we[pe++]=M>>8,we[pe++]=M&255):(we[pe++]=223,oi.setUint32(pe,M),pe+=4);let C;for(let O=0;O<M;O++)S(C=P[O]),S(A[C])}:(A,P)=>{we[pe++]=222;let M=pe-r;pe+=2;let C=0;for(let O in A)(P||A.hasOwnProperty(O))&&(S(O),S(A[O]),C++);we[M+++r]=C>>8,we[M+r]=C&255}:A=>{let P=Object.keys(A),M,C=o.transitions||(o.transitions=Object.create(null)),O=0;for(let D=0,B=P.length;D<B;D++){let k=P[D];M=C[k],M||(M=C[k]=Object.create(null),O++),C=M}let L=C[Yp];if(L)L>=96&&g?(we[pe++]=((L-=96)&31)+96,we[pe++]=L>>5):we[pe++]=L;else{L=o.nextId,L||(L=64),L<y&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(L=o.nextOwnId,L<m||(L=y),o.nextOwnId=L+1):(L>=m&&(L=y),o.nextId=L+1);let D=P.highByte=L>=96&&g?L-96>>5:-1;C[Yp]=L,o[L-64]=P,L<y?(P.isShared=!0,o.sharedLength=L-63,s=!0,D>=0?(we[pe++]=(L&31)+96,we[pe++]=D):we[pe++]=L):(D>=0?(we[pe++]=213,we[pe++]=114,we[pe++]=(L&31)+96,we[pe++]=D):(we[pe++]=212,we[pe++]=114,we[pe++]=L),O&&(x+=b*O),v.length>=p&&(v.shift()[Yp]=0),v.push(C),S(P))}for(let D=0,B=P.length;D<B;D++)S(A[P[D]])},E=A=>{let P;if(A>16777216){if(A-r>LD)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(LD,Math.round(Math.max((A-r)*(A>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(A-r<<2,we.length-1)>>12)+1<<12;let M=new pA(P);return oi=new DataView(M.buffer,0,P),we.copy?we.copy(M,0,r,A):M.set(we.slice(r,A)),pe-=r,r=0,go=M.length-10,we=M}}useBuffer(t){we=t,oi=new DataView(we.buffer,we.byteOffset,we.byteLength),pe=0}};mA=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Xp];Uv=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:n,targetView:s,position:o}=t(6);n[o++]=214,n[o++]=255,s.setUint32(o,r)}else if(r>0&&r<17179869184){let{target:n,targetView:s,position:o}=t(10);n[o++]=215,n[o++]=255,s.setUint32(o,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:n,targetView:s,position:o}=t(3);n[o++]=212,n[o++]=255,n[o++]=255}else{let{target:n,targetView:s,position:o}=t(15);n[o++]=199,n[o++]=12,n[o++]=255,s.setUint32(o,i.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:n,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(n[s++]=212,n[s++]=115,n[s++]=0),e(r)}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=101,r[n++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(r[n++]=212,r[n++]=120,r[n++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?ND(i,16,t):BD(Vv?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==FD&&this.structuredClone?ND(i,fA.indexOf(e.name),t):BD(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function ND(i,t,e,r){let n=i.byteLength;if(n+1<256){var{target:s,position:o}=e(4+n);s[o++]=199,s[o++]=n+1}else if(n+1<65536){var{target:s,position:o}=e(5+n);s[o++]=200,s[o++]=n+1>>8,s[o++]=n+1&255}else{var{target:s,position:o,targetView:a}=e(7+n);s[o++]=201,a.setUint32(o,n+1),o+=4}s[o++]=116,s[o++]=t,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),o)}function BD(i,t){let e=i.byteLength;var r,n;if(e<256){var{target:r,position:n}=t(e+2);r[n++]=196,r[n++]=e}else if(e<65536){var{target:r,position:n}=t(e+3);r[n++]=197,r[n++]=e>>8,r[n++]=e&255}else{var{target:r,position:n,targetView:s}=t(e+5);r[n++]=198,s.setUint32(n,e),n+=4}r.set(i,n)}function zq(i,t,e,r){let n=i.length;switch(n){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:n<256?(t[e++]=199,t[e++]=n):n<65536?(t[e++]=200,t[e++]=n>>8,t[e++]=n&255):(t[e++]=201,t[e++]=n>>24,t[e++]=n>>16&255,t[e++]=n>>8&255,t[e++]=n&255)}return t[e++]=r,t.set(i,e),e+=n,e}function kq(i,t){let e,r=t.length*6,n=i.length-r;for(t.sort((s,o)=>s.offset>o.offset?1:-1);e=t.pop();){let s=e.offset,o=e.id;i.copyWithin(s+r,s,n),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=o>>24,i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=o&255,n=s}return i}function bl(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");mA.unshift(i.Class),Uv.unshift(i)}RD(i)}var UD=new Oc({useRecords:!1}),Gq=UD.pack,Hq=UD.pack;var{NEVER:jq,ALWAYS:Wq,DECIMAL_ROUND:qq,DECIMAL_FIT:Xq}=Bv,VD=512,Yq=1024;var zD=new Oc({structuredClone:!0});bl({Class:at.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,at.prototype),i}});bl({Class:je.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,je.prototype),i}});bl({Class:Sr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Sr.prototype),i}});bl({Class:Wp.prototype.constructor,type:4,write(i){return i.id},read(i){return new Wp(i)}});bl({Class:qp.prototype.constructor,type:5,write(i){return i.data},read(i){return new qp(i)}});bl({Class:wr.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,wr.prototype),i}});function Kq(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function gA(i){if(Bh(i))return i;if(Array.isArray(i))return i.map(gA);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=gA(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var zv;(r=>{function i(n){return zD.pack(n)}r.serialize=i;function t(n){return zD.unpack(n)}r.deserialize=t;function e(n){return Kq(i(gA(n))).toString()}r.checksum=e})(zv||(zv={}));var kD;(e=>{function i(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=i;function t(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=t})(kD||(kD={}));var xn={["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"]},GD;(e=>{function i(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=i;function t(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new je}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new je}}e.defaultData=t})(GD||(GD={}));var kv;(e=>{function i(r){return{type:"Property",value:[r??null,"position","x"]}}e.propertyDefaultData=i,e.valueDefaultData={type:"Literal",value:0}})(kv||(kv={}));var yA;(r=>{function i(n){return{type:"Comparison",operator:"==",lOperand:kv.propertyDefaultData(n),rOperand:{...kv.valueDefaultData}}}r.comparisonDefaultData=i;function t(n){return{type:"Distance",toObject:n??null,fromObject:n??null,distance:200}}r.distanceDefaultData=t;function e(n,s){return{type:"State",object:n??null,state:s??null}}r.stateDefaultData=e})(yA||(yA={}));var HD;(e=>{function i(r){return r.type==="Conditional"}e.is=i;function t(r){return{type:"Conditional",disabled:!1,inActions:new je,outActions:new je,condition:yA.distanceDefaultData(r)}}e.defaultData=t})(HD||(HD={}));var jD;(t=>t.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new je,drop:new je}})(jD||(jD={}));var Gv;(t=>t.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new je})(Gv||(Gv={}));var Hv;(t=>t.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(Hv||(Hv={}));var WD;(e=>{function i(r){return r.type==="MouseHover"}e.is=i;function t(){return{type:"MouseHover",disabled:!1,actions:new je}}e.defaultData=t})(WD||(WD={}));var qD;(e=>{function i(r){return r.type==="Scroll"}e.is=i;function t(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new je}}e.defaultData=t})(qD||(qD={}));var XD;(e=>{function i(r){return r.type==="Start"}e.is=i;function t(){return{type:"Start",disabled:!1,actions:new je}}e.defaultData=t})(XD||(XD={}));var YD;(e=>{function i(r){return r.type==="Collision"}e.is=i;function t(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new je}}e.defaultData=t})(YD||(YD={}));var KD;(e=>{function i(r){return r.type==="Trigger"}e.is=i;function t(r,n){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new je,triggerZone:"box",position:n.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=t})(KD||(KD={}));var jv;(o=>{o.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}o.is=t;function e(a){return typeof a=="string"?a:"custom"}o.sizeToDevice=e;function r(a){return typeof a=="string"?[...o.defaultSizes[a]]:[...a]}o.deviceToSize=r;function n(){let a={size:"mobile",operator:"<",actions:new je},l={size:"tablet",operator:"<",actions:new je},c={size:[...o.defaultSizes.custom],operator:"<>",actions:new je},u=new je;return u.push({id:_e.generateUUID(),fi:0,data:a},{id:_e.generateUUID(),fi:1,data:l},{id:_e.generateUUID(),fi:2,data:c}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:u}}o.defaultData=n;function s(){return{size:[...o.defaultSizes.custom],operator:"<>",actions:new je}}o.defaultBreakpointData=s})(jv||(jv={}));var Wv;(r=>{r.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(n){return n.type==="VariableChange"}r.is=t;function e(){return{disabled:!1,type:"VariableChange",actions:new je,variableId:"",objectId:null,property:"Position X"}}r.defaultData=e})(Wv||(Wv={}));var ds="personal camera",wl="a218fcc3-276b-49b9-b485-49037fd14f5f",JD=2960946,ai=5526619;var Fs;(f=>{function i(p,g){return p[0]===g[0]&&p[1]===g[1]}f.isEqual=i;function t(p,g,y){return[p[0]+(g[0]-p[0])*y,p[1]+(g[1]-p[1])*y]}f.lerp=t;function e(p,g){return[p[0]+g[0],p[1]+g[1]]}f.add=e;function r(p,g){return[p[0]-g[0],p[1]-g[1]]}f.sub=r;function n(p,g){return[p[0]*g[0],p[1]*g[1]]}f.multiply=n;function s(p,g){return[p[0]/g[0],p[1]/g[1]]}f.divide=s;function o(p,g){return Math.pow(g[0]-p[0],2)+Math.pow(g[1]-p[1],2)}f.distanceSquared=o;function a(p,g){return Math.sqrt(o(p,g))}f.distance=a;function l(p,g){return p[0]*g[0]+p[1]*g[1]}f.dot=l;function c(p,g){return[p[0]*g,p[1]*g]}f.scalarMultiply=c;function u(p,g,y){let m=f.sub(g,p),v=f.sub(y,p),x=f.dot(m,v)/f.dot(m,m),b=f.scalarMultiply(m,x);return f.add(p,b)}f.projectionOnto=u;function h(p,g,y){return a(p,u(p,g,y))}f.projectionOntoDistance=h;function d(p,g){return[(p[0]+g[0])*.5,(p[1]+g[1])*.5]}f.center=d})(Fs||(Fs={}));var vo;(a=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}a.isEqual=i;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}a.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}a.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}a.div=r;function n(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}a.mul=n;function s(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}a.dist=s;function o(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}a.lerp=o})(vo||(vo={}));var Kp;(e=>{function i(r,n){return r[0]===n[0]&&r[1]===n[1]&&r[2]===n[2]&&r[3]===n[3]}e.isEqual=i;function t(r,n,s){return[r[0]+(n[0]-r[0])*s,r[1]+(n[1]-r[1])*s,r[2]+(n[2]-r[2])*s,r[3]+(n[3]-r[3])*s]}e.lerp=t})(Kp||(Kp={}));var Sl;(n=>{n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}n.isEqual=t;function e(s){return s??n.identity}n.simplify=e;function r(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let u=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/u,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/u,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/u}return a}n.applyMatrix4=r})(Sl||(Sl={}));var Ci;(h=>{function i(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}h.isRGB=i,h.white={r:1,g:1,b:1},h.red={r:1,g:0,b:0},h.black={r:0,g:0,b:0};function n(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:1}}h.toRgb255a1=n;function s(d){return{r:d.r,g:d.g,b:d.b}}h.clone=s;function o(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}h.fromHex=o;function a(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}h.toHex=a;function l(d,f){return d.r===f.r&&d.g===f.g&&d.b===f.b}h.equals=l;function c(d,f){return d.r.toFixed(2)===f.r.toFixed(2)&&d.g.toFixed(2)===f.g.toFixed(2)&&d.b.toFixed(2)===f.b.toFixed(2)}h.equalsFixed=c;function u(d,f,p){return{r:d.r+(f.r-d.r)*p,g:d.g+(f.g-d.g)*p,b:d.b+(f.b-d.b)*p}}h.lerp=u})(Ci||(Ci={}));var It;(c=>{c.white={...Ci.white,a:1},c.transparent={...Ci.white,a:0};function e(u){return{r:u[0],g:u[1],b:u[2],a:u[3]}}c.from0to1=e;function r(u,h){return{...Ci.fromHex(u),a:h}}c.fromHexAndA=r;function n(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:u.a}}c.toRgb255a1=n;function s(u,h){return Ci.equals(u,h)&&u.a===h.a}c.equals=s;function o(u,h){return Ci.equalsFixed(u,h)&&u.a.toFixed(2)===h.a.toFixed(2)}c.equalsFixed=o;function a(u,h,d){return{r:u.r+(h.r-u.r)*d,g:u.g+(h.g-u.g)*d,b:u.b+(h.b-u.b)*d,a:u.a+(h.a-u.a)*d}}c.lerp=a;function l({r:u,g:h,b:d,a:f}=c.white){return`rgba(${u*255}, ${h*255}, ${d*255}, ${f})`}c.toStyle=l})(It||(It={}));var qv;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(qv||(qv={}));var QD;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(QD||(QD={}));var ZD;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(ZD||(ZD={}));var ma;(s=>(s.linear=[0,0,1,1],s.ease=[.25,.1,.25,1],s.easeIn=[.42,0,1,1],s.easeOut=[0,0,.58,1],s.easeInOut=[.42,0,.58,1]))(ma||(ma={}));function vA(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var Us;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Us||(Us={}));var Al;(n=>{n.DefaultUp=[0,1,0],n.DefaultTargetOffset=1e3,n.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:n.DefaultUp,isUpVectorFlipped:!1,targetOffset:n.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective?.zoom??1:s.orthographic?.zoom??1}n.getZoom=r})(Al||(Al={}));var xo;(e=>{function i(r,n=.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]*n,0,0]},grid:{count:[2,2,2],size:r.map(s=>s*(1+n)),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=i;function t(r,n){let s={...r};if(xA.forEach(o=>{Object.assign(s,{[o]:n[o]??r[o]})}),s.radial={...r.radial},n.radial){let o=r.radial,a=n.radial;bA.forEach(l=>{Object.assign(s.radial,{[l]:a[l]??o[l]})})}if(s.linear={...r.linear},n.linear){let o=r.linear,a=n.linear;SA.forEach(l=>{Object.assign(s.linear,{[l]:a[l]??o[l]})})}if(s.grid={...r.grid},n.grid){let o=r.grid,a=n.grid;wA.forEach(l=>{Object.assign(s.grid,{[l]:a[l]??o[l]})})}if(s.toObject={...r.toObject},n.toObject){let o=r.toObject,a=n.toObject;AA.forEach(l=>{Object.assign(s.toObject,{[l]:a[l]??o[l]})})}if(s.randomnessObject={...r.randomnessObject},n.randomnessObject){let o=r.randomnessObject,a=n.randomnessObject;EA.forEach(l=>{Object.assign(s.randomnessObject,{[l]:a[l]??o[l]})})}return s}e.merge=t})(xo||(xo={}));var Xv;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(n,s){let o=[];n.count!==void 0&&o.push({type:0,path:s,props:{count:n.count}});for(let a of t){let l=n[a];l&&Object.keys(l).length>0&&o.push({type:0,path:[...s,a],props:l})}return o}r.toOps=e})(Xv||(Xv={}));var xA=["count"],bA=["radius","start","end","position","scale","rotation"],SA=["position","scale","rotation"],wA=["count","size"],AA=["count","position","scale","rotation"],EA=["strength","scale","rotation","position","movement","seed","freqScale"];var Yv;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Yv||(Yv={}));var Kv;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:It.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:It.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:It.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Kv||(Kv={}));var Hh;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.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:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(Hh||(Hh={}));var El;(t=>t.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]})(El||(El={}));var TA;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,n){return r.castShadow===n.castShadow&&r.receiveShadow===n.receiveShadow}e.equals=t})(TA||(TA={}));var MA;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,n){return r.flatShading===n.flatShading&&r.side===n.side&&r.wireframe===n.wireframe}e.equals=t})(MA||(MA={}));var Qv;(t=>t.defaultData={...MA.defaultData,...TA.defaultData})(Qv||(Qv={}));var $D;(t=>{function i(e,r){let n=[];if("material"in e){let s=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;s&&n.push(s)}else if("materials"in e)for(let s of e.materials){let o=typeof s=="string"?r.materials[s]??r.lib.materials[s]?.asset:s;o&&n.push(o)}return n}t.getMaterialData=i})($D||($D={}));var jh;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(jh||(jh={}));var eO;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(eO||(eO={}));function rO(i){return i.type!=="displace"}var tO;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(tO||(tO={}));var Zv=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],iO=["wrapping","image","video","name","minFilter"],Hr;(n=>{function i(s,o){let{texture:a,...l}=o;if(Object.assign(s,l),a){let c=s.texture;c&&Object.assign(c,a)}}n.patch=i;function t(s,o){return s==="light"&&o?e(o):r(s)}n.defaultData=t;function e(s){let o={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(s){case"phong":return{...o,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...o,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...o,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...o,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(s){let o={alpha:1,mode:0,isMask:!1,visible:!0};switch(s){case"texture":return{...o,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...o,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:jh.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...o,type:"color",color:Ci.fromHex(ai)};case"depth":return{...o,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...o,type:"normal",cnormal:[1,1,1]};case"gradient":return{...o,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...o,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ci.fromHex(6710886),a:1},colorB:{...Ci.fromHex(6710886),a:1},colorC:{...Ci.fromHex(16777215),a:1},colorD:{...Ci.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...o,type:"fresnel",color:It.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...o,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...o,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:It.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...o,type:"outline",outlineColor:It.fromHexAndA(0,1),contourColor:It.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...o,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...o,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...o,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Ci.fromHex(0),a:1},colorB:{...Ci.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}}}})(Hr||(Hr={}));var li;(c=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=i;function t(u){let h="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,p])=>{h+=`${f}${p}`,Array.isArray(p)?p.forEach(g=>h+=`${g}`):typeof p=="object"?Object.values(p).forEach(g=>{typeof g=="number"?h+=`${g.toFixed(4)}`:h+=`${g}`}):h+=`${p}`})}),h}c.getHash=t;function e(){return{layers:new je}}c.defaultEmptyData=e;function r(u="layer1",h="layer2"){return s("phong",u,h)}c.defaultData=r;function n(u,h){return{...u,name:h}}c.withName=n;function s(u,h="layer1",d="layer2"){let f=new je;return f.push({fi:0,data:Hr.defaultData("light",u),id:h}),f.push({fi:1,data:Hr.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=s;function o(u){let h=Hr.defaultData("texture");u&&Object.assign(h.texture,{image:u});let d=new je;return d.push({fi:0,data:h,id:"layer1"}),d.push({fi:1,data:{...Hr.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Hr.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=o;function a(u,h="phong",d="layer1",f="layer2"){let p=Hr.defaultData("texture");Object.assign(p.texture,{image:u});let g=new je;return g.push({fi:0,data:p,id:d}),g.push({fi:1,data:Hr.defaultData("light",h),id:f}),{layers:g}}c.defaultTwoLayerTextureData=a;function l(u,h="phong",d="layer1",f="layer2"){let p=Hr.defaultData("video");Object.assign(p.texture,{video:u});let g=new je;return g.push({fi:0,data:p,id:d}),g.push({fi:1,data:Hr.defaultData("light",h),id:f}),{layers:g}}c.defaultTwoLayerVideoTextureData=l})(li||(li={}));var Wh;(t=>{function i(){return{points:new je,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Wh||(Wh={}));var qh;(t=>{function i(){return{points:new je,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(qh||(qh={}));var CA={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Jv;(t=>{function i(e,r){let n={...e};return _A.forEach(s=>{Object.assign(n,{[s]:r[s]??e[s]})}),n}t.merge=i})(Jv||(Jv={}));var $v={shape:CA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},_A=["depth","offset","angle","twist","startScale","endScale"];var Qp;(e=>{function i(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=i;function t(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=t})(Qp||(Qp={}));var e0;(t=>{function i(e,r){let n={...e};return Object.assign(n,r),n.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(n.extrusion={...e.extrusion},Object.assign(n.extrusion,Jv.merge(n.extrusion,r.extrusion))),n}t.merge=i})(e0||(e0={}));var Tl;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:qh.defaultData(),extrusion:$v};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Wh.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Tl||(Tl={}));var PA=["width","height","depth"];var t0;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Ci.white,near:.1,far:2e3})(t0||(t0={}));var Xh;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focusDistance:100,focalLength:20,bokehScale:5},noise:{...i,blendFunction:16}}})(Xh||(Xh={}));var DA;(t=>t.defaultData={softShadowQuality:"low"})(DA||(DA={}));var OA;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(OA||(OA={}));var IA;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(IA||(IA={}));var Ml;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ml||(Ml={}));var RA;(t=>t.defaultData={playCamera:ds,gameControlObject:null})(RA||(RA={}));var r0;(t=>t.defaultData={backgroundColor:It.fromHexAndA(JD,1),postprocessing:Xh.defaultData,fog:t0.defaultData,globalPhysics:Ml.defaultData,ambient:OA.defaultData,ao:IA.defaultData,shadow:DA.defaultData,publish:RA.defaultData})(r0||(r0={}));var i0;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(i0||(i0={}));var nO;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(nO||(nO={}));var Yh;(n=>{n.identity={...qv.identity,hiddenMatrix:Sl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}n.fromObject=t;function e(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}n.merge=e;function r(s,o){return mv({position:vo.isEqual(s.position,o.position)?void 0:o.position,rotation:vo.isEqual(s.rotation,o.rotation)?void 0:o.rotation,scale:vo.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:Sl.isEqual(s.hiddenMatrix,o.hiddenMatrix)?void 0:o.hiddenMatrix})}n.diff=r})(Yh||(Yh={}));var _i;(t=>t.defaultData={states:new je,events:new je,visible:!0,raycastLock:!1,physics:El.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Yh.identity,cloner:null})(_i||(_i={}));var n0;(t=>t.defaultData={type:"Empty",..._i.defaultData})(n0||(n0={}));var sO;(t=>t.defaultData={type:"ParticleCollider",...i0.defaultData,..._i.defaultData})(sO||(sO={}));var oO;(t=>t.defaultData={type:"Component",..._i.defaultData})(oO||(oO={}));var aO;(t=>t.defaultData={type:"Particle",..._i.defaultData,...Hh.defaultData})(aO||(aO={}));var Ic;(t=>t.defaultData={type:"Mesh",..._i.defaultData,...Qv.defaultData})(Ic||(Ic={}));var Rc;(t=>t.defaultData={..._i.defaultData,...Yh.identity,position:[0,0,Al.DefaultTargetOffset],...Al.defaultData})(Rc||(Rc={}));var s0;(e=>{function i(r){return{..._i.defaultData,...Kv.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(s0||(s0={}));var Kh;(e=>{function i(r,n,s=0){for(;s<n.length;){let o=r?r[n[s]]:void 0;if(n.length===s+1)return o;if(o)r=o.descendants,s+=1;else return}}e.resolveWithDes=i;function t(r,n,s=0){let o=i(r,n,s);if(o){let a=Object.keys(o);if(a.length===1&&a[0]==="descendants")return}return o}e.resolve=t})(Kh||(Kh={}));var bo;(s=>{s.rootOverrideProps=["physics","events"],s.compositeNonOptionalOverrideProps=["geometry"],s.compositeEntireOverrideOverrideProps=["material"];function r(o,a){return{..._i.defaultData,...a,component:o,overrides:new wr,physics:void 0,events:void 0,type:"Instance"}}s.ofComponent=r;function n(o){let a=Yh.fromObject(o.data);return r(o.id,a)}s.fromComponentData=n})(bo||(bo={}));var ga;(e=>{e.defaultData={type:"Page",..._i.defaultData,physics:{...El.defaultData,fusedBody:!1},...r0.defaultData,camera:Rc.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ga||(ga={}));var o0;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Sl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:El.defaultData,states:new je,events:new je,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Al.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",..._i.defaultData,...Ic.defaultData,geometry:Tl.defaultData("RectangleGeometry"),material:li.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",..._i.defaultData,...Ic.defaultData,geometry:Tl.defaultData("BooleanGeometry"),material:li.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",..._i.defaultData,...Ic.defaultData,geometry:Tl.defaultData("TextGeometry"),material:li.defaultTwoLayerData("phong","layer1","layer2")}))(o0||(o0={}));var ya;(n=>{function i(s,o){let a={name:o};return s.type==="Mesh"?(a.geometry={},"material"in s&&(a.material={layers:new wr}),"materials"in s&&(a.materials=s.materials.map(l=>({layers:new wr})))):Us.is(s.type)&&(a.perspective={},a.orthographic={}),a}n.newEmpty=i;function t(s,o){if(o===void 0)return s;let a={...s};return"material"in a&&"material"in o&&o.material&&(a.material=yl(a.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(o.material.layers)){let h=l.layers.data(c);h&&Hr.patch(h,u)}}).data),a.materials&&o.materials&&(a.materials=yl(a.materials,l=>{for(let c=0;c<a.materials.length;c++){let u=o.materials[c];if(typeof u!="string")for(let[h,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(h);f&&Hr.patch(f,d)}}}).data),a}function e(s,o){let a,l=[],c={orthographic:0,perspective:0,geometry:0};function u(h,d){for(let[f,p]of Object.entries(d.layers)){let{texture:g,...y}=p;if(g!==void 0&&Object.keys(g).length>0){let m={path:[...h,"layers",f,"texture"],props:g,type:0};l.push(m)}if(Object.keys(y).length>0){let m={path:[...h,"layers",f],props:y,type:0};l.push(m)}}}for(let[h,d]of Object.entries(o))if(h!=="name")if(h==="cloner")l.push(...Xv.toOps(d,["cloner"]));else if(h==="pathSnapping")l.push({path:[h],props:{slide:d.slide,offset:d.offset},type:0});else if(h==="material")u(["material"],d);else if(h==="materials")for(let[f,p]of Object.entries(d))u(["materials",f],p);else if(c[h]===0){if(h==="geometry"&&d.extrusion!==void 0){let f={path:[h,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[h],props:d,type:0};l.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},l.push(a)),a.props[h]=d;return l}n.toOps=e;function r(s,o){if(o===void 0)return s;let a={...s};if(Object.assign(a,Yh.merge(a,o)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:o.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:o.pathSnapping?.offset??a.pathSnapping?.offset??0})}),Us.is(s.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let l=o;l.orthographic?.zoom!==void 0&&(a.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(a.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(a.targetOffset=l.targetOffset)}else if(s.type==="Mesh")"geometry"in o&&Object.assign(a,{geometry:e0.merge(a.geometry,o.geometry)}),(o.material||o.materials)&&(a=t(a,o)),a.cloner&&"cloner"in o&&Object.assign(a,{cloner:xo.merge(a.cloner,o.cloner)});else if(s.type==="Empty")a.cloner&&"cloner"in o&&Object.assign(a,{cloner:xo.merge(a.cloner,o.cloner)});else if(Yv.is(s.type)){let l=o;l.intensity!==void 0&&(a.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?a.color=l.color:a.color=Ci.clone(l.color))}return a}n.patch=r})(ya||(ya={}));var Qh;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Qh||(Qh={}));var Vs;(t=>t.defaultData={orbitControls:Qh.defaultData,playPage:wl,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let n=0,s=0;return r<5?s=-30:r<10&&(s=30),r===0||r===10||r===5?n=30:(r===4||r===11||r===9)&&(n=-30),[120,[n,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})(Vs||(Vs={}));var LA;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(LA||(LA={}));var NA;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(NA||(NA={}));var va;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...LA.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:NA.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(va||(va={}));var Cl;(e=>{function i(r){return r.find(n=>n.data.type==="Page"&&n.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,n,s){r.scene.objects.traverseFrom(n,(o,a)=>{if(a.type==="Instance"){let l=Zh.getComponentData(r,a.component)?.data;l&&s(o,a,l.events)}else s(o,a,a.events)})}e.traverseModuleInstances=t})(Cl||(Cl={}));var xa;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(c=!0){let u=[],h=o0.defaultMeshObject;c&&(u.push({fi:-1,data:s0.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:h,children:[]}));let d=new Sr;return d.push({fi:1,id:wl,data:{...ga.defaultData,name:"Scene 1"},children:u}),d}l.defaultData={objects:t(),publish:Vs.defaultData,styles:va.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Sr,publish:Vs.defaultData,styles:va.defaultData()}},l.emptyDataWithPage=function(c=!0){return{objects:t(c),publish:Vs.defaultData,styles:va.defaultData()}},l.emptyData=function(){return{objects:new Sr,publish:{...Vs.defaultData},styles:va.defaultData()}};function o(c){return{...l.defaultData,objects:yn(c,Sr.prototype)}}l.withObjs=o;function a(c,u){return o([{id:c,data:u,children:[],fi:0}])}l.withObj=a})(xa||(xa={}));var Jh;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Jh||(Jh={}));var ki;(s=>{function i(o){return o.textValue!==void 0}s.isTextValue=i;function t(o){return typeof o=="number"}s.isNumber=t;function e(o){return typeof o=="boolean"}s.isBoolean=e;function r(o){return i(o)?"string":e(o)?"boolean":"number"}s.typeOfVariable=r;function n(o){return s.isTextValue(o)?Array.isArray(o.textValue)?o.textValue.map(a=>a.toString().padStart(o.padding??2,"0")).join(o.deliminator??":")+(o.suffix!==void 0?" "+o.suffix:""):o.textValue.toString():s.isBoolean(o)?o?"True":"False":s.isNumber(o)?parseFloat(o.toFixed(3)).toString():o.toString()}s.getDisplayedValue=n})(ki||(ki={}));var BA;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(BA||(BA={}));var lO;(t=>t.all=[...BA.all,"components"])(lO||(lO={}));var cO;(t=>{function i(){return{images:new at,videos:new at,colors:new at,audios:new at,particles:new at,fonts:new at,materials:new at,components:new at,variables:new at}}t.defaultData=i})(cO||(cO={}));var ba;(t=>{function i(){return{images:new at,videos:new at,colors:new at,audios:new at,particles:new at,fonts:new at,materials:new at,components:new at,variables:new at}}t.defaultData=i})(ba||(ba={}));var bn;(s=>{function i(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},yn(o,at.prototype)}s.defaultColors=i;function t(){return yn({},at.prototype)}s.defaultImages=t;function e(){return{catelogs:new at,materials:new at,images:new at,videos:new at,colors:new at,audios:new at,particles:new at,fonts:new at,variables:new je,lib:ba.defaultData()}}s.emptyData=e;function r(o){switch(o){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 a=[0,0,0];return{name:"Time",value:{textValue:a,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:a,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",o)}}s.defaultVariables=r;function n(o,a){if(a.format==="HH:mm:ss"){let l=Math.floor(o/3600),c=Math.floor((o-l*3600)/60),u=Math.round(o-l*3600-c*60);return{textValue:[l,c,u]}}else if(a.format==="mm:ss"){let l=Math.floor(o/60),c=Math.round(o-l*60);return{textValue:[l,c]}}else return a.format==="number"?o=Math.round(o):o=Math.round(o*1e3)/1e3,o}s.getFormattedTimerTime=n})(bn||(bn={}));var $h;(t=>t.list=["idle","move","jump","run"])($h||($h={}));var ed;(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 je,move:new je,jump:new je,run:new je},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:It.fromHexAndA(3728051,1)}}))(ed||(ed={}));function uO(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,n=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],s=[0,1];for(let a=2;a<10;a++)n.push(n[1]),s.push(1);let o={...Zn(Qr(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:n,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,o)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...Qr(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Sa(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function wa(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((n,s)=>{n===void 0&&(r.materials[s]=li.defaultData(),n=r.materials[s]),typeof n!="string"&&t(n)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=li.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=li.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(n=>{n.material&&typeof n.material!="string"&&Object.getPrototypeOf(n.material)!==wr.prototype&&t(n.material)})})}function Zq(i){Object.assign(i.scene.publish,{orbitControls:{...Qh.defaultData,...Qr(i.scene.publish.orbitControls)}})}function Jq(i){Object.assign(i.scene.publish.settings,{video:{...Vs.defaultData.settings.video,...Qr(i.scene.publish.settings.video)}})}function $q(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[n,s]of Object.entries(r))if((Zv.includes(n)||typeof s=="boolean")&&delete r[n],n==="texture")for(let[o,a]of Object.entries(s))(iO.includes(o)||typeof a=="boolean")&&delete s[o]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(n=>{let s=n;s.material?t(s.material):s.materials&&s.materials.forEach(o=>{t(o)})})})}function eX(i){i.scene.publish.withBackground=!0}function tX(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function rX(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(n=>n+1),r.linear.scale=r.linear.scale.map(n=>n+1))})}function iX(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function nX(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let n=Qr(i.scene.objects.data(r));n&&n.type==="Mesh"&&n.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Qr(e).booleanExclude!==!0)}})}function sX(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function oX(i){function t(r){Object.setPrototypeOf(r,wr.prototype),r.texture&&Object.setPrototypeOf(r.texture,wr.prototype)}function e(r){Object.setPrototypeOf(r,wr.prototype);for(let n in r)t(r[n])}i.scene.objects.traverse((r,n)=>{n.states.forEach(s=>{let o=s;if(o.material){let a=Qr(o.material).layers;e(a),o.material.layers=a}if(o.materials)for(let a=0;a<o.materials.length;a++){let l=o.materials[a],c=Qr(l).layers;e(c),l.layers=c}})})}function hO(i){i.layers===void 0&&Object.assign(i,li.defaultTwoLayerData("lambert"))}function FA(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let n={...Qr(t),colors:e,steps:r};Object.assign(t,n)}})}function aX(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function dO(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&FA(r)}):"material"in e&&typeof e.material!="string"&&FA(e.material)}),Object.values(i.shared.materials).forEach(t=>FA(t))}function lX(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function cX(i){i.shared.audios=yn({},at.prototype)}function uX(i){i.shared.videos=yn({},at.prototype)}function hX(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let n={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:n})}})}function dX(i){Object.entries(Qr(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(Qr(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function fX(i){i.scene.publish.settings.web.preload=!1}function fO(i){i.layers&&i.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 pO(i){i.layers&&i.layers.forEach(t=>{rO(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 pX(i){i.shared.fonts=yn({},at.prototype)}function mX(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function gX(i){let t=[];i.scene.objects.traverse((e,r)=>{let n=r;if(n.type==="TextFrame"){let s=li.defaultTwoLayerData("phong"),o=typeof n.color=="string"?i.shared.colors[n.color]:n.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=n.alpha;let a=mX(n.font);i.shared.fonts[a]===void 0&&(i.shared.fonts[a]={name:a});let l={name:n.name,..._i.defaultData,...Ic.defaultData,flatShading:!1,wireframe:!1,geometry:{...Tl.defaultData("TextGeometry"),width:n.width,height:n.height,font:a,depth:0,horizontalAlign:n.horizontalAlign,verticalAlign:n.verticalAlign,fontSize:n.fontSize*1.40625,lineHeight:n.lineHeight/1.40625,letterSpacing:n.letterSpacing-1,text:n.text,textTransform:n.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:Qr(n.states),events:Qr(n.events),visible:n.visible,raycastLock:n.raycastLock,position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix},c=Qr(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function yX(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(n=>{if(!!t[Number(n.type)])if(Object.assign(n,{type:t[Number(n.type)]}),n.type==="Audio"&&"audioEvent"in n&&(Object.assign(n,{playAudio:n.audioEvent}),delete n.audioEvent),n.type==="GameControl")Object.assign(n,{gameActions:{idle:new je,move:new je,jump:new je}});else{let s=new je;Object.assign(n,{actions:s}),(n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp")&&"url"in n&&s.push({fi:0,id:_e.generateUUID(),data:{type:"Link",url:n.url,delay:0}}),"targets"in n&&(n.targets.forEach((o,a,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(u,Zn(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(u,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...u},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new je({fi:0,id:_e.generateUUID(),data:c},{fi:1,id:_e.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete n.targets)}})})}function vX(i){i.scene.objects.traverse((t,e)=>{function r(n,s){let o=new je,a=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(c),l.interaction==="play"?h={...Zn(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")&&(h={...Zn(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:u,id:c,data:h})}}),a.forEach(l=>e.events.delete(l)),o.length){let l=e.events.find(c=>c.type===n)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):e.events.insertBefore(null,[{id:_e.generateUUID(),data:{type:n,actions:o}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function mO(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Hr.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function gO(i){Sa(i,mO),wa(i,mO)}function xX(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function bX(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function SX(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=li.defaultTwoLayerData("phong"))})}function wX(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function AX(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function EX(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function TX(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function MX(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function CX(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function _X(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=ed.defaultDataThirdPerson.navmesh)})})}function PX(i){i.scene.styles||(i.scene.styles=va.defaultData())}function yO(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function DX(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),wa(i,yO),Sa(i,yO)}function OX(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new je})})})}function IX(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function vO(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function xO(i,t){if(t<1&&(wa(i,uO),Sa(i,uO),i.schema=1),t<2&&(Zq(i),i.schema=2),t<3&&($q(i),i.schema=3),t<4&&(eX(i),i.schema=4),t<5&&(tX(i),i.schema=5),t<6&&(rX(i),i.schema=6),t<7&&(iX(i),i.schema=7),t<8&&(i.schema=8),t<9&&(dO(i),i.schema=9),t<10&&(aX(i),i.schema=10),t<11&&(lX(i),i.schema=11),t<12&&(dO(i),i.schema=12),t<13&&(cX(i),i.schema=13),t<14&&(hX(i),i.schema=14),t<15&&(dX(i),i.schema=15),t<16&&(fX(i),i.schema=16),t<17&&(wa(i,fO),Sa(i,fO),i.schema=17),t<18&&(wa(i,hO),Sa(i,hO),i.schema=18),t<19&&(Jq(i),i.schema=19),t<20&&(pX(i),gX(i),i.schema=20),t<21&&(yX(i),vX(i),i.schema=21),t<22&&(gO(i),i.schema=22),t<23&&(xX(i),i.schema=23),t<24&&(bX(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(uX(i),t<25&&(i.schema=25)),t<26&&(nX(i),i.schema=26),t<27&&(sX(i),i.schema=27),t<28&&(gO(i),i.schema=28),t<29&&(oX(i),i.schema=29),t<30&&(SX(i),i.schema=30),t<31&&(wX(i),i.schema=31),t<33&&(AX(i),i.schema=33),t<34&&(EX(i),i.schema=34),t<35&&(TX(i),i.schema=35),t<36&&(MX(i),i.schema=36),t<37&&(CX(i),i.schema=37),t<38&&(wa(i,pO),Sa(i,pO),i.schema=38),t<39&&(_X(i),i.schema=39),t<40&&(PX(i),i.schema=40),t<41&&(DX(i),i.schema=41),t<42&&(OX(i),i.schema=42),t<43&&(IX(i),i.schema=43),t<99){wa(i,vO),Sa(i,vO),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=ds);let e=Qr(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=wl,r.insertBefore(null,null,[{id:wl,data:{...ga.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:Zn(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:Zn(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ml.defaultData,...Zn(i.scene.environment,"usePhysics","gravity")},camera:Qr(i.scene.ownerCamera)??ga.defaultData.camera,name:"Scene"},children:[]}]);for(let o of e)o.id!==xa.TRASH_CAN_ID&&r.move(wl,o.fi,o.id);let n=0,s=0;i.shared.penumbraSize&&i.scene.objects.traverse((o,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=i.shared.penumbraSize[Math.min(n,2)],n+=1):a.type==="SpotLight"&&(a.penumbraSize=i.shared.penumbraSize[3+Math.min(s,1)],s+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,El.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),i.schema=99}}function bO(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function RX(i){i.scene.objects.traverse((t,e)=>{let r=e.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 LX(i){Array.isArray(Qr(i.events))&&i.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var td=180/Math.PI;function SO(i){i.rotation=i.rotation.slice(0,3).map(t=>t*td)}function wO(i){SO(i),i.type==="Page"&&SO(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*td))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*td),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*td),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=td,t.extrusion.twist*=td),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(Qr(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function NX(i){i.shared.variables=yn({},at.prototype)}function BX(i){let t=Qr(i.shared.variables);i.shared.variables=yn(Object.entries(t??{}).map(([e,r],n)=>({fi:n,id:e,data:r})),je.prototype)}var So=112;function AO(i,t){t(i.data);for(let e of i.children)AO(e,t)}function FX(i){let t=i.schema??104;t!==So&&t<105&&(AO(i.asset,wO),i.schema=105)}function UX(i){i.shared.particles=yn({},at.prototype),i.shared.lib&&(i.shared.lib.particles=ba.defaultData().particles)}function VX(i){i.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function zX(i){i.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function a0(i){let t=i.schema??0;if(t!==So){console.warn("updating from ",t,"to ",So),xO(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Vs.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(wa(i,bO),Sa(i,bO),i.schema=101),t<102&&(RX(i),i.schema=102),t<104&&(i.shared.catelogs=new at,i.shared.lib=ba.defaultData(),i.schema=104),t<105&&(NX(i),i.scene.objects.traverse((e,r)=>{wO(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))FX(e);t<106&&(BX(i),i.schema=106),t<107&&(i.shared.lib.variables=ba.defaultData().variables,i.schema=107),t<109&&(UX(i),i.schema=109),t<110&&(VX(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{LX(r)}),i.schema=111),t<112&&(zX(i),i.schema=112)}}var Zh;(l=>{l.defaultData={schema:So,scene:xa.defaultData,frames:new at().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Jh.defaultData),shared:{...bn.emptyData(),colors:bn.defaultColors()}},l.emptyDataForImports=function(){let c=xa.emptyDataWithPage();return{schema:So,scene:c,frames:new at().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Jh.defaultData),shared:{...bn.emptyData(),colors:bn.defaultColors(),images:bn.defaultImages()}}},l.emptyData=function(){return{schema:So,scene:xa.emptyDataWithPage(),frames:new at().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Jh.defaultData),shared:bn.emptyData()}},l.clipboard2dData=function(){return{schema:So,scene:xa.emptyData(),frames:new at,shared:bn.emptyData()}},l.collabHelper={...jp,updateSchema(c){return(c.schema??0)<So?yl(c,a0):(c.schema??0)-So}};function s(c){let u=l.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}l.updateSchemaDirectly=s;function o(c){return{...c,shared:{...c.shared,lib:ba.defaultData()}}}l.withoutLib=o;function a(c,u){let h=c.scene.objects.get(u);if(h&&h.data.type==="Component")return h;{let d=c.shared.lib.components[u];if(d)return d.asset}}l.getComponentData=a})(Zh||(Zh={}));var l0;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(l0||(l0={}));var EO;(t=>{function i(e){return!0}t.is=i})(EO||(EO={}));var c0;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(n,s){return{position:s?.position??n.position,rotation:s?.rotation??n.rotation,scale:s?.scale??n.scale,shear:s?.shear??n.shear}}r.merge=t;function e(n,s){return mv({position:Fs.isEqual(n.position,s.position)?void 0:s.position,rotation:n.rotation===s.rotation?void 0:s.rotation,scale:Fs.isEqual(n.scale,s.scale)?void 0:s.scale,shear:n.shear&&s.shear&&Fs.isEqual(n.shear,s.shear)?void 0:s.shear})}r.diff=e})(c0||(c0={}));var UA;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(UA||(UA={}));var u0;(t=>t.defaultData={opacity:1,fill:{color:It.fromHexAndA(ai,1),enabled:!0},stroke:{color:It.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:It.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:It.from0to1([0,0,0,1]),enabled:!1,spread:0}})(u0||(u0={}));var Aa;(s=>{function i(o,a){return{name:a}}s.newEmpty=i;function t(o,a){if(a===void 0)return o;let l={...o},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in a&&a[u]!==void 0&&Object.assign(l,{[u]:a[u]});return l}function e(o,a){if(a===void 0)return o;let l={...o};return"fill"in l&&"fill"in a&&a.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...a.fill}}),"stroke"in l&&"stroke"in a&&a.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...a.stroke}}),"layerBlur"in l&&"layerBlur"in a&&a.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...a.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in a&&a.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...a.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in a&&a.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...a.dropShadow}}),"innerShadow"in l&&"innerShadow"in a&&a.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...a.innerShadow}}),l}function r(o,a){if(a===void 0)return o;let l={...o};return Object.assign(l,c0.merge(l,a)),l=t(l,a),l=e(l,a),l}s.patch=r;function n(o,a){let l,c=[];for(let[u,h]of Object.entries(a))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=h);return c}s.toOps=n})(Aa||(Aa={}));var Zp;(t=>t.defaultData={...c0.defaultData,...UA.defaultData,states:new je,events:new je,visible:!0,raycastLock:!1})(Zp||(Zp={}));var rd;(t=>t.defaultData={...Zp.defaultData,...u0.defaultData})(rd||(rd={}));var h0;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(h0||(h0={}));var VA;(t=>t.defaultData={...rd.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(VA||(VA={}));var id;(t=>t.defaultData={...rd.defaultData,...h0.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(id||(id={}));var zA;(t=>t.defaultData={...rd.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"})(zA||(zA={}));var kA;(t=>t.defaultData={...rd.defaultData,type:"path2d",path:"",name:"Path"})(kA||(kA={}));var TO;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(TO||(TO={}));var Jp;(t=>t.defaultData={...Zp.defaultData,name:"Group",type:"group2d"})(Jp||(Jp={}));var GA;(t=>t.defaultData=()=>({...Zp.defaultData,...h0.defaultData,...u0.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:It.fromHexAndA(4737101,1),enabled:!0},stroke:{color:It.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(GA||(GA={}));var Ea;(n=>{function i(s){switch(s){case"rectangle2d":return{...id.defaultData};case"ellipse2d":return{...VA.defaultData};case"text2d":return{...zA.defaultData};case"vector2d":return{...id.defaultData};case"path2d":return{...kA.defaultData};case"frame2d":return{...GA.defaultData()};case"group2d":return{...Jp.defaultData}}}n.defaultData=i;function t(s){return"width"in s&&"height"in s?[typeof s.width=="number"?s.width*.5:0,typeof s.height=="number"?s.height*.5:0]:[0,0]}n.getPivot=t;function e(s){return s.type==="rectangle2d"||s.type==="ellipse2d"||s.type==="text2d"||s.type==="frame2d"}n.isResizeable=e;function r(s){return s.type==="rectangle2d"||s.type==="frame2d"}n.hasCorners=r})(Ea||(Ea={}));var d0;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Sr},e.emptyData=function(){return{type:"scene2d",objects:new Sr}}))(d0||(d0={}));function zs(i,t=!1){let e=i[0].index!==null,r=new Set(Object.keys(i[0].attributes)),n=new Set(Object.keys(i[0].morphAttributes)),s={},o={},a=i[0].morphTargetsRelative,l=new Ne,c=0;for(let u=0;u<i.length;++u){let h=i[u],d=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() 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 f in h.attributes){if(!r.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(t){let f;if(e)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,u),c+=f}}if(e){let u=0,h=[];for(let d=0;d<i.length;++d){let f=i[d].index;for(let p=0;p<f.count;++p)h.push(f.getX(p)+u);u+=i[d].attributes.position.count}l.setIndex(h)}for(let u in s){let h=MO(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<h;++d){let f=[];for(let g=0;g<o[u].length;++g)f.push(o[u][g][d]);let p=MO(f);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(p)}}return l}function MO(i){let t,e,r,n=-1,s=0;for(let c=0;c<i.length;++c){let u=i[c];if(t===void 0&&(t=u.array.constructor),t!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=u.itemSize),e!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=u.gpuType),n!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=u.count*e}let o=new t(s),a=new Ye(o,e,r),l=0;for(let c=0;c<i.length;++c){let u=i[c];if(u.isInterleavedBufferAttribute){let h=l/e;for(let d=0,f=u.count;d<f;d++)for(let p=0;p<e;p++){let g=u.getComponent(d,p);a.setComponent(d+h,p,g)}}else o.set(u.array,l);l+=u.count*e}return n!==void 0&&(a.gpuType=n),a}var CO=Math.pow(2,-24);var Lc=class{constructor(){}};function ps(i,t,e){return e.min.x=t[i],e.min.y=t[i+1],e.min.z=t[i+2],e.max.x=t[i+3],e.max.y=t[i+4],e.max.z=t[i+5],e}function HA(i){let t=-1,e=-1/0;for(let r=0;r<3;r++){let n=i[r+3]-i[r];n>e&&(e=n,t=r)}return t}function jA(i,t){t.set(i)}function WA(i,t,e){let r,n;for(let s=0;s<3;s++){let o=s+3;r=i[s],n=t[s],e[s]=r<n?r:n,r=i[o],n=t[o],e[o]=r>n?r:n}}function $p(i,t,e){for(let r=0;r<3;r++){let n=t[i+2*r],s=t[i+2*r+1],o=n-s,a=n+s;o<e[r]&&(e[r]=o),a>e[r+3]&&(e[r+3]=a)}}function nd(i){let t=i[3]-i[0],e=i[4]-i[1],r=i[5]-i[2];return 2*(t*e+e*r+r*t)}function HX(i,t){if(!i.index){let e=i.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n;e>65535?n=new Uint32Array(new r(4*e)):n=new Uint16Array(new r(2*e)),i.setIndex(new Ye(n,1));for(let s=0;s<e;s++)n[s]=s}}function jX(i){if(!i.groups||!i.groups.length)return[{offset:0,count:i.index.count/3}];let t=[],e=new Set;for(let n of i.groups)e.add(n.start),e.add(n.start+n.count);let r=Array.from(e.values()).sort((n,s)=>n-s);for(let n=0;n<r.length-1;n++){let s=r[n],o=r[n+1];t.push({offset:s/3,count:(o-s)/3})}return t}function XA(i,t,e,r,n=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,g=-1/0,y=-1/0,m=n!==null;for(let v=t*6,x=(t+e)*6;v<x;v+=6){let b=i[v+0],S=i[v+1],w=b-S,E=b+S;w<s&&(s=w),E>l&&(l=E),m&&b<h&&(h=b),m&&b>p&&(p=b);let A=i[v+2],P=i[v+3],M=A-P,C=A+P;M<o&&(o=M),C>c&&(c=C),m&&A<d&&(d=A),m&&A>g&&(g=A);let O=i[v+4],L=i[v+5],D=O-L,B=O+L;D<a&&(a=D),B>u&&(u=B),m&&O<f&&(f=O),m&&O>y&&(y=O)}r[0]=s,r[1]=o,r[2]=a,r[3]=l,r[4]=c,r[5]=u,m&&(n[0]=h,n[1]=d,n[2]=f,n[3]=p,n[4]=g,n[5]=y)}function WX(i,t,e,r){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=t*6,h=(t+e)*6;u<h;u+=6){let d=i[u+0];d<n&&(n=d),d>a&&(a=d);let f=i[u+2];f<s&&(s=f),f>l&&(l=f);let p=i[u+4];p<o&&(o=p),p>c&&(c=p)}r[0]=n,r[1]=s,r[2]=o,r[3]=a,r[4]=l,r[5]=c}function qX(i,t,e,r,n){let s=e,o=e+r-1,a=n.pos,l=n.axis*2;for(;;){for(;s<=o&&t[s*6+l]<a;)s++;for(;s<=o&&t[o*6+l]>=a;)o--;if(s<o){for(let c=0;c<3;c++){let u=i[s*3+c];i[s*3+c]=i[o*3+c],i[o*3+c]=u;let h=t[s*6+c*2+0];t[s*6+c*2+0]=t[o*6+c*2+0],t[o*6+c*2+0]=h;let d=t[s*6+c*2+1];t[s*6+c*2+1]=t[o*6+c*2+1],t[o*6+c*2+1]=d}s++,o--}else return s}}var Ta=32,XX=(i,t)=>i.candidate-t.candidate,_l=new Array(Ta).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),f0=new Float32Array(6);function YX(i,t,e,r,n,s){let o=-1,a=0;if(s===0)o=HA(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(s===1)o=HA(i),o!==-1&&(a=KX(e,r,n,o));else if(s===2){let l=nd(i),c=1.25*n,u=r*6,h=(r+n)*6;for(let d=0;d<3;d++){let f=t[d],y=(t[d+3]-f)/Ta;if(n<Ta/4){let m=[..._l];m.length=n;let v=0;for(let b=u;b<h;b+=6,v++){let S=m[v];S.candidate=e[b+2*d],S.count=0;let{bounds:w,leftCacheBounds:E,rightCacheBounds:A}=S;for(let P=0;P<3;P++)A[P]=1/0,A[P+3]=-1/0,E[P]=1/0,E[P+3]=-1/0,w[P]=1/0,w[P+3]=-1/0;$p(b,e,w)}m.sort(XX);let x=n;for(let b=0;b<x;b++){let S=m[b];for(;b+1<x&&m[b+1].candidate===S.candidate;)m.splice(b+1,1),x--}for(let b=u;b<h;b+=6){let S=e[b+2*d];for(let w=0;w<x;w++){let E=m[w];S>=E.candidate?$p(b,e,E.rightCacheBounds):($p(b,e,E.leftCacheBounds),E.count++)}}for(let b=0;b<x;b++){let S=m[b],w=S.count,E=n-S.count,A=S.leftCacheBounds,P=S.rightCacheBounds,M=0;w!==0&&(M=nd(A)/l);let C=0;E!==0&&(C=nd(P)/l);let O=1+1.25*(M*w+C*E);O<c&&(o=d,c=O,a=S.candidate)}}else{for(let x=0;x<Ta;x++){let b=_l[x];b.count=0,b.candidate=f+y+x*y;let S=b.bounds;for(let w=0;w<3;w++)S[w]=1/0,S[w+3]=-1/0}for(let x=u;x<h;x+=6){let w=~~((e[x+2*d]-f)/y);w>=Ta&&(w=Ta-1);let E=_l[w];E.count++,$p(x,e,E.bounds)}let m=_l[Ta-1];jA(m.bounds,m.rightCacheBounds);for(let x=Ta-2;x>=0;x--){let b=_l[x],S=_l[x+1];WA(b.bounds,S.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let x=0;x<Ta-1;x++){let b=_l[x],S=b.count,w=b.bounds,A=_l[x+1].rightCacheBounds;S!==0&&(v===0?jA(w,f0):WA(w,f0,f0)),v+=S;let P=0,M=0;v!==0&&(P=nd(f0)/l);let C=n-v;C!==0&&(M=nd(A)/l);let O=1+1.25*(P*v+M*C);O<c&&(o=d,c=O,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function KX(i,t,e,r){let n=0;for(let s=t,o=t+e;s<o;s++)n+=i[s*6+r*2];return n/e}function QX(i,t){let e=i.attributes.position,r=i.index.array,n=r.length/3,s=new Float32Array(n*6),o=e.normalized,a=e.array,l=e.offset||0,c=3;e.isInterleavedBufferAttribute&&(c=e.data.stride);let u=["getX","getY","getZ"];for(let h=0;h<n;h++){let d=h*3,f=h*6,p,g,y;o?(p=r[d+0],g=r[d+1],y=r[d+2]):(p=r[d+0]*c+l,g=r[d+1]*c+l,y=r[d+2]*c+l);for(let m=0;m<3;m++){let v,x,b;o?(v=e[u[m]](p),x=e[u[m]](g),b=e[u[m]](y)):(v=a[p+m],x=a[g+m],b=a[y+m]);let S=v;x<S&&(S=x),b<S&&(S=b);let w=v;x>w&&(w=x),b>w&&(w=b);let E=(w-S)/2,A=m*2;s[f+A+0]=S+E,s[f+A+1]=E+(Math.abs(S)+E)*CO,S<t[m]&&(t[m]=S),w>t[m+3]&&(t[m+3]=w)}}return s}function ZX(i,t){function e(m){d&&d(m/f)}function r(m,v,x,b=null,S=0){if(!p&&S>=l&&(p=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),x<=u||S>=l)return e(v+x),m.offset=v,m.count=x,m;let w=YX(m.boundingData,b,o,v,x,h);if(w.axis===-1)return e(v+x),m.offset=v,m.count=x,m;let E=qX(a,o,v,x,w);if(E===v||E===v+x)e(v+x),m.offset=v,m.count=x;else{m.splitAxis=w.axis;let A=new Lc,P=v,M=E-v;m.left=A,A.boundingData=new Float32Array(6),XA(o,P,M,A.boundingData,s),r(A,P,M,s,S+1);let C=new Lc,O=E,L=x-M;m.right=C,C.boundingData=new Float32Array(6),XA(o,O,L,C.boundingData,s),r(C,O,L,s,S+1)}return m}HX(i,t);let n=new Float32Array(6),s=new Float32Array(6),o=QX(i,n),a=i.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,f=i.index.count/3,p=!1,g=[],y=jX(i);if(y.length===1){let m=y[0],v=new Lc;v.boundingData=n,WX(o,m.offset,m.count,s),r(v,m.offset,m.count,s),g.push(v)}else for(let m of y){let v=new Lc;v.boundingData=new Float32Array(6),XA(o,m.offset,m.count,v.boundingData,s),r(v,m.offset,m.count,s),g.push(v)}return g}function DO(i,t){let e=ZX(i,t),r,n,s,o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<e.length;u++){let h=e[u],d=l(h),f=new a(32*d);r=new Float32Array(f),n=new Uint32Array(f),s=new Uint16Array(f),c(0,h),o.push(f)}return o;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function c(u,h){let d=u/4,f=u/2,p=!!h.count,g=h.boundingData;for(let y=0;y<6;y++)r[d+y]=g[y];if(p){let y=h.offset,m=h.count;return n[d+6]=y,s[f+14]=m,s[f+15]=65535,u+32}else{let y=h.left,m=h.right,v=h.splitAxis,x;if(x=c(u+32,y),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=x/4,x=c(x,m),n[d+7]=v,x}}}var On=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let r=1/0,n=-1/0;for(let s=0,o=t.length;s<o;s++){let l=t[s][e];r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}setFromPoints(t,e){let r=1/0,n=-1/0;for(let s=0,o=e.length;s<o;s++){let a=e[s],l=t.dot(a);r=l<r?l:r,n=l>n?l:n}this.min=r,this.max=n}isSeparated(t){return this.min>t.max||t.min>this.max}};On.prototype.setFromBox=function(){let i=new T;return function(e,r){let n=r.min,s=r.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){i.x=n.x*l+s.x*(1-l),i.y=n.y*c+s.y*(1-c),i.z=n.z*u+s.z*(1-u);let h=e.dot(i);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var ope=function(){let i=new On;return function(e,r){let n=e.points,s=e.satAxes,o=e.satBounds,a=r.points,l=r.satAxes,c=r.satBounds;for(let u=0;u<3;u++){let h=o[u],d=s[u];if(i.setFromPoints(d,a),h.isSeparated(i))return!1}for(let u=0;u<3;u++){let h=c[u],d=l[u];if(i.setFromPoints(d,n),h.isSeparated(i))return!1}}}();var JX=function(){let i=new T,t=new T,e=new T;return function(n,s,o){let a=n.start,l=i,c=s.start,u=t;e.subVectors(a,c),i.subVectors(n.end,n.start),t.subVectors(s.end,s.start);let h=e.dot(u),d=u.dot(l),f=u.dot(u),p=e.dot(l),y=l.dot(l)*f-d*d,m,v;y!==0?m=(h*d-p*f)/y:m=0,v=(h+m*d)/f,o.x=m,o.y=v}}(),em=function(){let i=new U,t=new T,e=new T;return function(n,s,o,a){JX(n,s,i);let l=i.x,c=i.y;if(l>=0&&l<=1&&c>=0&&c<=1){n.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),n.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?n.at(0,o):n.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=n.start:u=n.end;let h;c<0?h=s.start:h=s.end;let d=t,f=e;if(n.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),d.distanceToSquared(h)<=f.distanceToSquared(u)){o.copy(d),a.copy(h);return}else{o.copy(u),a.copy(f);return}}}}(),OO=function(){let i=new T,t=new T,e=new ii,r=new Ei;return function(s,o){let{radius:a,center:l}=s,{a:c,b:u,c:h}=o;if(r.start=c,r.end=u,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a||(r.start=c,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a)||(r.start=u,r.end=h,r.closestPointToPoint(l,!0,i).distanceTo(l)<=a))return!0;let g=o.getPlane(e);if(Math.abs(g.distanceToPoint(l))<=a){let m=g.projectPoint(l,t);if(o.containsPoint(m))return!0}return!1}}();var $X=1e-15;function sd(i){return Math.abs(i)<$X}var In=class extends Er{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new T),this.satBounds=new Array(4).fill().map(()=>new On),this.points=[this.a,this.b,this.c],this.sphere=new Or,this.plane=new ii,this.needsUpdate=!0}intersectsSphere(t){return OO(t,this)}update(){let t=this.a,e=this.b,r=this.c,n=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,n);let c=s[1],u=o[1];c.subVectors(t,e),u.setFromPoints(c,n);let h=s[2],d=o[2];h.subVectors(e,r),d.setFromPoints(h,n);let f=s[3],p=o[3];f.subVectors(r,t),p.setFromPoints(f,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};In.prototype.closestPointToSegment=function(){let i=new T,t=new T,e=new Ei;return function(n,s=null,o=null){let{start:a,end:l}=n,c=this.points,u,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[f]),em(e,n,i,t),u=i.distanceToSquared(t),u<h&&(h=u,s&&s.copy(i),o&&o.copy(t))}return this.closestPointToPoint(a,i),u=a.distanceToSquared(i),u<h&&(h=u,s&&s.copy(i),o&&o.copy(a)),this.closestPointToPoint(l,i),u=l.distanceToSquared(i),u<h&&(h=u,s&&s.copy(i),o&&o.copy(l)),Math.sqrt(h)}}();In.prototype.intersectsTriangle=function(){let i=new In,t=new Array(3),e=new Array(3),r=new On,n=new On,s=new T,o=new T,a=new T,l=new T,c=new Ei,u=new Ei,h=new Ei;return function(f,p=null,g=!1){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(i.copy(f),i.update(),f=i);let y=this.plane,m=f.plane;if(Math.abs(y.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,x=this.satAxes;e[0]=f.a,e[1]=f.b,e[2]=f.c;for(let w=0;w<4;w++){let E=v[w],A=x[w];if(r.setFromPoints(A,e),E.isSeparated(r))return!1}let b=f.satBounds,S=f.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let E=b[w],A=S[w];if(r.setFromPoints(A,t),E.isSeparated(r))return!1}for(let w=0;w<4;w++){let E=x[w];for(let A=0;A<4;A++){let P=S[A];if(s.crossVectors(E,P),r.setFromPoints(s,t),n.setFromPoints(s,e),r.isSeparated(n))return!1}}return p&&(g||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 v=this.points,x=!1,b=0;for(let D=0;D<3;D++){let B=v[D],k=v[(D+1)%3];c.start.copy(B),c.end.copy(k),c.delta(o);let F=x?u.start:u.end,H=sd(m.distanceToPoint(B));if(sd(m.normal.dot(o))&&H){u.copy(c),b=2;break}if((m.intersectLine(c,F)||H)&&!sd(F.distanceTo(k))){if(b++,x)break;x=!0}}if(b===1&&f.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(b!==2)return!1;let S=f.points,w=!1,E=0;for(let D=0;D<3;D++){let B=S[D],k=S[(D+1)%3];c.start.copy(B),c.end.copy(k),c.delta(a);let F=w?h.start:h.end,H=sd(y.distanceToPoint(B));if(sd(y.normal.dot(a))&&H){h.copy(c),E=2;break}if((y.intersectLine(c,F)||H)&&!sd(F.distanceTo(k))){if(E++,w)break;w=!0}}if(E===1&&this.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(E!==2)return!1;if(u.delta(o),h.delta(a),o.dot(a)<0){let D=h.start;h.start=h.end,h.end=D}let A=u.start.dot(o),P=u.end.dot(o),M=h.start.dot(o),C=h.end.dot(o),O=P<M,L=A<C;return A!==C&&M!==P&&O===L?!1:(p&&(l.subVectors(u.start,h.start),l.dot(o)>0?p.start.copy(u.start):p.start.copy(h.start),l.subVectors(u.end,h.end),l.dot(o)<0?p.end.copy(u.end):p.end.copy(h.end)),!0)}}}();In.prototype.distanceToPoint=function(){let i=new T;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();In.prototype.distanceToTriangle=function(){let i=new T,t=new T,e=["a","b","c"],r=new Ei,n=new Ei;return function(o,a=null,l=null){let c=a||l?r:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let d,f=e[h],p=o[f];this.closestPointToPoint(p,i),d=p.distanceToSquared(i),d<u&&(u=d,a&&a.copy(i),l&&l.copy(p));let g=this[f];o.closestPointToPoint(g,i),d=g.distanceToSquared(i),d<u&&(u=d,a&&a.copy(g),l&&l.copy(i))}for(let h=0;h<3;h++){let d=e[h],f=e[(h+1)%3];r.set(this[d],this[f]);for(let p=0;p<3;p++){let g=e[p],y=e[(p+1)%3];n.set(o[g],o[y]),em(r,n,i,t);let m=i.distanceToSquared(t);m<u&&(u=m,a&&a.copy(i),l&&l.copy(t))}}return Math.sqrt(u)}}();var Rn=class{constructor(t,e,r){this.isOrientedBox=!0,this.min=new T,this.max=new T,this.matrix=new ue,this.invMatrix=new ue,this.points=new Array(8).fill().map(()=>new T),this.satAxes=new Array(3).fill().map(()=>new T),this.satBounds=new Array(3).fill().map(()=>new On),this.alignedSatBounds=new Array(3).fill().map(()=>new On),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),r&&this.matrix.copy(r)}set(t,e,r){this.min.copy(t),this.max.copy(e),this.matrix.copy(r),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Rn.prototype.update=function(){return function(){let t=this.matrix,e=this.min,r=this.max,n=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let d=1*c|2*u|4*h,f=n[d];f.x=c?r.x:e.x,f.y=u?r.y:e.y,f.z=h?r.z:e.z,f.applyMatrix4(t)}let s=this.satBounds,o=this.satAxes,a=n[0];for(let c=0;c<3;c++){let u=o[c],h=s[c],d=1<<c,f=n[d];u.subVectors(a,f),h.setFromPoints(u,n)}let l=this.alignedSatBounds;l[0].setFromPointsField(n,"x"),l[1].setFromPointsField(n,"y"),l[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Rn.prototype.intersectsBox=function(){let i=new On;return function(e){this.needsUpdate&&this.update();let r=e.min,n=e.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(i.min=r.x,i.max=n.x,a[0].isSeparated(i)||(i.min=r.y,i.max=n.y,a[1].isSeparated(i))||(i.min=r.z,i.max=n.z,a[2].isSeparated(i)))return!1;for(let l=0;l<3;l++){let c=o[l],u=s[l];if(i.setFromBox(c,e),u.isSeparated(i))return!1}return!0}}();Rn.prototype.intersectsTriangle=function(){let i=new In,t=new Array(3),e=new On,r=new On,n=new T;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(i.copy(o),i.update(),o=i);let a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){let f=a[d],p=l[d];if(e.setFromPoints(p,t),f.isSeparated(e))return!1}let c=o.satBounds,u=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=c[d],p=u[d];if(e.setFromPoints(p,h),f.isSeparated(e))return!1}for(let d=0;d<3;d++){let f=l[d];for(let p=0;p<4;p++){let g=u[p];if(n.crossVectors(f,g),e.setFromPoints(n,t),r.setFromPoints(n,h),e.isSeparated(r))return!1}}return!0}}();Rn.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();Rn.prototype.distanceToPoint=function(){let i=new T;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Rn.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Ei),e=new Array(12).fill().map(()=>new Ei),r=new T,n=new T;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(n),this.closestPointToPoint(n,r),o.closestPointToPoint(r,n),l&&l.copy(r),c&&c.copy(n)),0;let u=a*a,h=o.min,d=o.max,f=this.points,p=1/0;for(let y=0;y<8;y++){let m=f[y];n.copy(m).clamp(h,d);let v=m.distanceToSquared(n);if(v<p&&(p=v,l&&l.copy(m),c&&c.copy(n),v<u))return Math.sqrt(v)}let g=0;for(let y=0;y<3;y++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let x=(y+1)%3,b=(y+2)%3,S=m<<x|v<<b,w=1<<y|m<<x|v<<b,E=f[S],A=f[w];t[g].set(E,A);let M=i[y],C=i[x],O=i[b],L=e[g],D=L.start,B=L.end;D[M]=h[M],D[C]=m?h[C]:d[C],D[O]=v?h[O]:d[C],B[M]=d[M],B[C]=m?h[C]:d[C],B[O]=v?h[O]:d[C],g++}for(let y=0;y<=1;y++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){n.x=y?d.x:h.x,n.y=m?d.y:h.y,n.z=v?d.z:h.z,this.closestPointToPoint(n,r);let x=n.distanceToSquared(r);if(x<p&&(p=x,l&&l.copy(r),c&&c.copy(n),x<u))return Math.sqrt(x)}for(let y=0;y<12;y++){let m=t[y];for(let v=0;v<12;v++){let x=e[v];em(m,x,r,n);let b=r.distanceToSquared(n);if(b<p&&(p=b,l&&l.copy(r),c&&c.copy(n),b<u))return Math.sqrt(b)}}return Math.sqrt(p)}}();var od=new T,ad=new T,ld=new T,m0=new U,g0=new U,y0=new U,IO=new T,RO=new T,LO=new T,v0=new T;function eY(i,t,e,r,n,s){let o;return s===ni?o=i.intersectTriangle(r,e,t,!0,n):o=i.intersectTriangle(t,e,r,s!==Bi,n),o===null?null:{distance:i.origin.distanceTo(n),point:n.clone()}}function tY(i,t,e,r,n,s,o,a,l){od.fromBufferAttribute(t,s),ad.fromBufferAttribute(t,o),ld.fromBufferAttribute(t,a);let c=eY(i,od,ad,ld,v0,l);if(c){r&&(m0.fromBufferAttribute(r,s),g0.fromBufferAttribute(r,o),y0.fromBufferAttribute(r,a),c.uv=Er.getInterpolation(v0,od,ad,ld,m0,g0,y0,new U)),n&&(m0.fromBufferAttribute(n,s),g0.fromBufferAttribute(n,o),y0.fromBufferAttribute(n,a),c.uv1=Er.getInterpolation(v0,od,ad,ld,m0,g0,y0,new U)),e&&(IO.fromBufferAttribute(e,s),RO.fromBufferAttribute(e,o),LO.fromBufferAttribute(e,a),c.normal=Er.getInterpolation(v0,od,ad,ld,IO,RO,LO,new T),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let u={a:s,b:o,c:a,normal:new T,materialIndex:0};Er.getNormal(od,ad,ld,u.normal),c.face=u,c.faceIndex=s}return c}function KA(i,t,e,r,n){let s=r*3,o=i.index.getX(s),a=i.index.getX(s+1),l=i.index.getX(s+2),{position:c,normal:u,uv:h,uv1:d}=i.attributes,f=tY(e,c,u,h,d,o,a,l,t);return f?(f.faceIndex=r,n&&n.push(f),f):null}function NO(i,t,e,r,n,s){for(let o=r,a=r+n;o<a;o++)KA(i,t,e,o,s)}function BO(i,t,e,r,n){let s=1/0,o=null;for(let a=r,l=r+n;a<l;a++){let c=KA(i,t,e,a);c&&c.distance<s&&(o=c,s=c.distance)}return o}function ms(i,t,e,r){let n=i.a,s=i.b,o=i.c,a=t,l=t+1,c=t+2;e&&(a=e.getX(t),l=e.getX(t+1),c=e.getX(t+2)),n.x=r.getX(a),n.y=r.getY(a),n.z=r.getZ(a),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),o.x=r.getX(c),o.y=r.getY(c),o.z=r.getZ(c)}function QA(i,t,e,r,n,s,o){let a=e.index,l=e.attributes.position;for(let c=i,u=t+i;c<u;c++)if(ms(o,c*3,a,l),o.needsUpdate=!0,r(o,c,n,s))return!0;return!1}var cd=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};function Ma(i,t){return t[i+15]===65535}function Nc(i,t){return t[i+6]}function ud(i,t){return t[i+14]}function hd(i){return i+8}function dd(i,t){return t[i+6]}function FO(i,t){return t[i+7]}var fd=new zt,b0=new T,iY=["x","y","z"];function S0(i,t,e,r,n){let s=i*2,o=pd,a=Pl,l=Dl;if(Ma(s,a)){let u=Nc(i,l),h=ud(s,a);NO(t,e,r,u,h,n)}else{let u=hd(i);A0(u,o,r,b0)&&S0(u,t,e,r,n);let h=dd(i,l);A0(h,o,r,b0)&&S0(h,t,e,r,n)}}function w0(i,t,e,r){let n=i*2,s=pd,o=Pl,a=Dl;if(Ma(n,o)){let c=Nc(i,a),u=ud(n,o);return BO(t,e,r,c,u)}else{let c=FO(i,a),u=iY[c],d=r.direction[u]>=0,f,p;d?(f=hd(i),p=dd(i,a)):(f=dd(i,a),p=hd(i));let y=A0(f,s,r,b0)?w0(f,t,e,r):null;if(y){let x=y.point[u];if(d?x<=s[p+c]:x>=s[p+c+3])return y}let v=A0(p,s,r,b0)?w0(p,t,e,r):null;return y&&v?y.distance<=v.distance?y:v:y||v||null}}var UO=function(){let i,t,e=[],r=new cd(()=>new zt);return function(...o){i=r.getPrimitive(),t=r.getPrimitive(),e.push(i,t);let a=n(...o);r.releasePrimitive(i),r.releasePrimitive(t),e.pop(),e.pop();let l=e.length;return l>0&&(t=e[l-1],i=e[l-2]),a};function n(s,o,a,l,c=null,u=0,h=0){function d(x){let b=x*2,S=Pl,w=Dl;for(;!Ma(b,S);)x=hd(x),b=x*2;return Nc(x,w)}function f(x){let b=x*2,S=Pl,w=Dl;for(;!Ma(b,S);)x=dd(x,w),b=x*2;return Nc(x,w)+ud(b,S)}let p=s*2,g=pd,y=Pl,m=Dl;if(Ma(p,y)){let x=Nc(s,m),b=ud(p,y);return ps(s,g,i),l(x,b,!1,h,u+s,i)}else{let x=hd(s),b=dd(s,m),S=x,w=b,E,A,P,M;if(c&&(P=i,M=t,ps(S,g,P),ps(w,g,M),E=c(P),A=c(M),A<E)){S=b,w=x;let F=E;E=A,A=F,P=M}P||(P=i,ps(S,g,P));let C=Ma(S*2,y),O=a(P,C,E,h+1,u+S),L;if(O===2){let F=d(S),G=f(S)-F;L=l(F,G,!0,h+1,u+S,P)}else L=O&&n(S,o,a,l,c,u,h+1);if(L)return!0;M=t,ps(w,g,M);let D=Ma(w*2,y),B=a(M,D,A,h+1,u+w),k;if(B===2){let F=d(w),G=f(w)-F;k=l(F,G,!0,h+1,u+w,M)}else k=B&&n(w,o,a,l,c,u,h+1);return!!k}}}(),VO=function(){let i=new In,t=new In,e=new ue,r=new Rn,n=new Rn;return function s(o,a,l,c,u=null){let h=o*2,d=pd,f=Pl,p=Dl;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,c),u=r),Ma(h,f)){let y=a,m=y.index,v=y.attributes.position,x=l.index,b=l.attributes.position,S=Nc(o,p),w=ud(h,f);if(e.copy(c).invert(),l.boundsTree)return ps(o,d,n),n.matrix.copy(e),n.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>n.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(c),A.b.applyMatrix4(c),A.c.applyMatrix4(c),A.needsUpdate=!0;for(let P=S*3,M=(w+S)*3;P<M;P+=3)if(ms(t,P,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let E=S*3,A=w+S*3;E<A;E+=3){ms(i,E,m,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let P=0,M=x.count;P<M;P+=3)if(ms(t,P,x,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let y=o+8,m=p[o+6];return ps(y,d,fd),!!(u.intersectsBox(fd)&&s(y,a,l,c,u)||(ps(m,d,fd),u.intersectsBox(fd)&&s(m,a,l,c,u)))}}}();function A0(i,t,e,r){return ps(i,t,fd),e.intersectBox(fd,r)}var ZA=[],x0,pd,Pl,Dl;function md(i){x0&&ZA.push(x0),x0=i,pd=new Float32Array(i),Pl=new Uint16Array(i),Dl=new Uint32Array(i)}function tm(){x0=null,pd=null,Pl=null,Dl=null,ZA.length&&md(ZA.pop())}var JA=Symbol("skip tree generation"),$A=new zt,eE=new zt,gd=new ue,Bc=new Rn,rm=new Rn,im=new T,E0=new T,nY=new T,sY=new T,oY=new T,zO=new zt,wo=new cd(()=>new In),Ao=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ao.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e={cloneBuffers:!0,...e};let r=t.geometry,n=t._roots,s=r.getIndex(),o;return e.cloneBuffers?o={roots:n.map(a=>a.slice()),index:s.array.slice()}:o={roots:n,index:s.array},o}static deserialize(t,e,r={}){if(typeof r=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ao.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});r={setIndex:!0,...r};let{index:n,roots:s}=t,o=new Ao(e,{...r,[JA]:!0});if(o._roots=s,r.setIndex){let a=e.getIndex();if(a===null){let l=new Ye(t.index,1,!1);e.setIndex(l)}else a.array!==n&&(a.array.set(n),a.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[JA]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[JA]||(this._roots=DO(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new zt))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,r=e.index.array,n=e.attributes.position,s,o,a,l,c=0,u=this._roots;for(let d=0,f=u.length;d<f;d++)s=u[d],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),h(0,c),c+=s.byteLength;function h(d,f,p=!1){let g=d*2;if(a[g+15]===65535){let m=o[d+6],v=a[g+14],x=1/0,b=1/0,S=1/0,w=-1/0,E=-1/0,A=-1/0;for(let P=3*m,M=3*(m+v);P<M;P++){let C=r[P],O=n.getX(C),L=n.getY(C),D=n.getZ(C);O<x&&(x=O),O>w&&(w=O),L<b&&(b=L),L>E&&(E=L),D<S&&(S=D),D>A&&(A=D)}return l[d+0]!==x||l[d+1]!==b||l[d+2]!==S||l[d+3]!==w||l[d+4]!==E||l[d+5]!==A?(l[d+0]=x,l[d+1]=b,l[d+2]=S,l[d+3]=w,l[d+4]=E,l[d+5]=A,!0):!1}else{let m=d+8,v=o[d+6],x=m+f,b=v+f,S=p,w=!1,E=!1;t?S||(w=t.has(x),E=t.has(b),S=!w&&!E):(w=!0,E=!0);let A=S||w,P=S||E,M=!1;A&&(M=h(m,f,S));let C=!1;P&&(C=h(v,f,S));let O=M||C;if(O)for(let L=0;L<3;L++){let D=m+L,B=v+L,k=l[D],F=l[D+3],H=l[B],G=l[B+3];l[d+L]=k<H?k:H,l[d+L+3]=F>G?F:G}return O}}}traverse(t,e=0){let r=this._roots[e],n=new Uint32Array(r),s=new Uint16Array(r);o(0);function o(a,l=0){let c=a*2,u=s[c+15]===65535;if(u){let h=n[a+6],d=s[c+14];t(l,u,new Float32Array(r,a*4,6),h,d)}else{let h=a+32/4,d=n[a+6],f=n[a+7];t(l,u,new Float32Array(r,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(t,e=Hn){let r=this._roots,n=this.geometry,s=[],o=e.isMaterial,a=Array.isArray(e),l=n.groups,c=o?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=a?e[l[u].materialIndex].side:c,f=s.length;if(md(r[u]),S0(0,n,d,t,s),tm(),a){let p=l[u].materialIndex;for(let g=f,y=s.length;g<y;g++)s[g].face.materialIndex=p}}return s}raycastFirst(t,e=Hn){let r=this._roots,n=this.geometry,s=e.isMaterial,o=Array.isArray(e),a=null,l=n.groups,c=s?e.side:e;for(let u=0,h=r.length;u<h;u++){let d=o?e[l[u].materialIndex].side:c;md(r[u]);let f=w0(0,n,d,t);tm(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[u].materialIndex))}return a}intersectsGeometry(t,e){let r=this.geometry,n=!1;for(let s of this._roots)if(md(s),n=VO(0,r,t,e),tm(),n)break;return n}shapecast(t,e,r){let n=this.geometry;if(t instanceof Function){if(e){let d=e;e=(f,p,g,y)=>{let m=p*3;return d(f,m,m+1,m+2,g,y)}}t={boundsTraverseOrder:r,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=wo.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:c}=t;if(l&&c){let d=l;l=(f,p,g,y,m)=>d(f,p,g,y,m)?!0:QA(f,p,n,c,g,y,s)}else l||(c?l=(d,f,p,g)=>QA(d,f,n,c,p,g,s):l=(d,f,p)=>p);let u=!1,h=0;for(let d of this._roots){if(md(d),u=UO(0,n,a,l,o,h),tm(),u)break;h+=d.byteLength}return wo.releasePrimitive(s),u}bvhcast(t,e,r){let{intersectsRanges:n,intersectsTriangles:s}=r,o=this.geometry.index,a=this.geometry.attributes.position,l=t.geometry.index,c=t.geometry.attributes.position;gd.copy(e).invert();let u=wo.getPrimitive(),h=wo.getPrimitive();if(s){let f=function(p,g,y,m,v,x,b,S){for(let w=y,E=y+m;w<E;w++){ms(h,w*3,l,c),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let A=p,P=p+g;A<P;A++)if(ms(u,A*3,o,a),u.needsUpdate=!0,s(u,h,A,w,v,x,b,S))return!0}return!1};if(n){let p=n;n=function(g,y,m,v,x,b,S,w){return p(g,y,m,v,x,b,S,w)?!0:f(g,y,m,v,x,b,S,w)}}else n=f}t.getBoundingBox(eE),eE.applyMatrix4(e);let d=this.shapecast({intersectsBounds:f=>eE.intersectsBox(f),intersectsRange:(f,p,g,y,m,v)=>($A.copy(v),$A.applyMatrix4(gd),t.shapecast({intersectsBounds:x=>$A.intersectsBox(x),intersectsRange:(x,b,S,w,E)=>n(f,p,x,b,y,m,w,E)}))});return wo.releasePrimitive(u),wo.releasePrimitive(h),d}intersectsBox(t,e){return Bc.set(t.min,t.max,e),Bc.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Bc.intersectsBox(r),intersectsTriangle:r=>Bc.intersectsTriangle(r)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,r={},n={},s=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Bc.set(t.boundingBox.min,t.boundingBox.max,e),Bc.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,c=a.index,u=t.attributes.position,h=t.index,d=wo.getPrimitive(),f=wo.getPrimitive(),p=E0,g=nY,y=null,m=null;n&&(y=sY,m=oY);let v=1/0,x=null,b=null;return gd.copy(e).invert(),rm.matrix.copy(gd),this.shapecast({boundsTraverseOrder:S=>Bc.distanceToBox(S),intersectsBounds:(S,w,E)=>E<v&&E<o?(w&&(rm.min.copy(S.min),rm.max.copy(S.max),rm.needsUpdate=!0),!0):!1,intersectsRange:(S,w)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>rm.distanceToBox(E),intersectsBounds:(E,A,P)=>P<v&&P<o,intersectsRange:(E,A)=>{for(let P=E*3,M=(E+A)*3;P<M;P+=3){ms(f,P,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let C=S*3,O=(S+w)*3;C<O;C+=3){ms(d,C,c,l),d.needsUpdate=!0;let L=d.distanceToTriangle(f,p,y);if(L<v&&(g.copy(p),m&&m.copy(y),v=L,x=C/3,b=P/3),L<s)return!0}}}});{let E=h?h.count:u.count;for(let A=0,P=E;A<P;A+=3){ms(f,A,h,u),f.a.applyMatrix4(e),f.b.applyMatrix4(e),f.c.applyMatrix4(e),f.needsUpdate=!0;for(let M=S*3,C=(S+w)*3;M<C;M+=3){ms(d,M,c,l),d.needsUpdate=!0;let O=d.distanceToTriangle(f,p,y);if(O<v&&(g.copy(p),m&&m.copy(y),v=O,x=M/3,b=A/3),O<s)return!0}}}}}),wo.releasePrimitive(d),wo.releasePrimitive(f),v===1/0?null:(r.point?r.point.copy(g):r.point=g.clone(),r.distance=v,r.faceIndex=x,n&&(n.point?n.point.copy(m):n.point=m.clone(),n.point.applyMatrix4(gd),g.applyMatrix4(gd),n.distance=g.sub(n.point).length(),n.faceIndex=b),r)}closestPointToPoint(t,e={},r=0,n=1/0){let s=r*r,o=n*n,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:u=>(im.copy(t).clamp(u.min,u.max),im.distanceToSquared(t)),intersectsBounds:(u,h,d)=>d<a&&d<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,im);let d=t.distanceToSquared(im);return d<a&&(E0.copy(im),a=d,l=h),d<s}}),a===1/0)return null;let c=Math.sqrt(a);return e.point?e.point.copy(E0):e.point=E0.clone(),e.distance=c,e.faceIndex=l,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(r=>{ps(0,new Float32Array(r),zO),t.union(zO)}),t}};var cf=qo(GO());var aY=.5*(Math.sqrt(3)-1),nm=(3-Math.sqrt(3))/6,lY=1/3,Eo=1/6,$pe=(Math.sqrt(5)-1)/4,eme=(5-Math.sqrt(5))/20,sm=i=>Math.floor(i)|0,HO=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]),rE=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 T0(i=Math.random){let t=WO(i),e=new Float64Array(t).map(n=>HO[n%12*2]),r=new Float64Array(t).map(n=>HO[n%12*2+1]);return function(s,o){let a=0,l=0,c=0,u=(s+o)*aY,h=sm(s+u),d=sm(o+u),f=(h+d)*nm,p=h-f,g=d-f,y=s-p,m=o-g,v,x;y>m?(v=1,x=0):(v=0,x=1);let b=y-v+nm,S=m-x+nm,w=y-1+2*nm,E=m-1+2*nm,A=h&255,P=d&255,M=.5-y*y-m*m;if(M>=0){let L=A+t[P],D=e[L],B=r[L];M*=M,a=M*M*(D*y+B*m)}let C=.5-b*b-S*S;if(C>=0){let L=A+v+t[P+x],D=e[L],B=r[L];C*=C,l=C*C*(D*b+B*S)}let O=.5-w*w-E*E;if(O>=0){let L=A+1+t[P+1],D=e[L],B=r[L];O*=O,c=O*O*(D*w+B*E)}return 70*(a+l+c)}}function jO(i=Math.random){let t=WO(i),e=new Float64Array(t).map(s=>rE[s%12*3]),r=new Float64Array(t).map(s=>rE[s%12*3+1]),n=new Float64Array(t).map(s=>rE[s%12*3+2]);return function(o,a,l){let c,u,h,d,f=(o+a+l)*lY,p=sm(o+f),g=sm(a+f),y=sm(l+f),m=(p+g+y)*Eo,v=p-m,x=g-m,b=y-m,S=o-v,w=a-x,E=l-b,A,P,M,C,O,L;S>=w?w>=E?(A=1,P=0,M=0,C=1,O=1,L=0):S>=E?(A=1,P=0,M=0,C=1,O=0,L=1):(A=0,P=0,M=1,C=1,O=0,L=1):w<E?(A=0,P=0,M=1,C=0,O=1,L=1):S<E?(A=0,P=1,M=0,C=0,O=1,L=1):(A=0,P=1,M=0,C=1,O=1,L=0);let D=S-A+Eo,B=w-P+Eo,k=E-M+Eo,F=S-C+2*Eo,H=w-O+2*Eo,G=E-L+2*Eo,X=S-1+3*Eo,Y=w-1+3*Eo,Z=E-1+3*Eo,le=p&255,j=g&255,K=y&255,ee=.6-S*S-w*w-E*E;if(ee<0)c=0;else{let se=le+t[j+t[K]];ee*=ee,c=ee*ee*(e[se]*S+r[se]*w+n[se]*E)}let re=.6-D*D-B*B-k*k;if(re<0)u=0;else{let se=le+A+t[j+P+t[K+M]];re*=re,u=re*re*(e[se]*D+r[se]*B+n[se]*k)}let te=.6-F*F-H*H-G*G;if(te<0)h=0;else{let se=le+C+t[j+O+t[K+L]];te*=te,h=te*te*(e[se]*F+r[se]*H+n[se]*G)}let $=.6-X*X-Y*Y-Z*Z;if($<0)d=0;else{let se=le+1+t[j+1+t[K+1]];$*=$,d=$*$*(e[se]*X+r[se]*Y+n[se]*Z)}return 32*(c+u+h+d)}}function WO(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),s=e[r];e[r]=e[n],e[n]=s}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var ks=new Er,M0=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let s=1;ks.a.fromBufferAttribute(t,n),ks.b.fromBufferAttribute(t,n+1),ks.c.fromBufferAttribute(t,n+2),s*=ks.getArea(),e[n/3]=s}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,s=-1;for(;r<=n;){let o=Math.ceil((r+n)/2);if(o===0||e[o-1]<=t&&e[o]>t){s=o;break}else t<e[o]?n=o-1:r=o+1}return s}sampleFace(t,e,r){let n=this.randomFunction(),s=this.randomFunction();return n+s>1&&(n=1-n,s=1-s),ks.a.fromBufferAttribute(this.positionAttribute,t*3),ks.b.fromBufferAttribute(this.positionAttribute,t*3+1),ks.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ks.a,n).addScaledVector(ks.b,s).addScaledVector(ks.c,1-(n+s)),ks.getNormal(r),this}};var XO=qo(iE()),cY=new ue,uY=new ue,hY=new ue,yd;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(yd||(yd={}));var vd=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new ue;this.copyPreviousMatrix=!0;this.hiddenMatrix=new ue;this.matrixWorldRigid=new ue;this.shearScale=new ue;this.shearScaleInv=new ue}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Rt&&(r=r.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===r)return!0;n=n.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(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,r=!0);for(let n of this.children)n.updateMatrixWorld(r)}updateWorldMatrix(r,n){let s=this.parent;if(r&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),n)for(let o of this.children)o.updateWorldMatrix(!1,!0)}traverseChildren(r,n=0){for(let s of this.children)yd.is(s)&&s.traverseObject(r,n+1)}traverseObject(r,n=0){if(r(this,n)!==!0)for(let o of this.children)yd.is(o)&&o.traverseObject(r,n+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,n=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:s,v:o,q:a}=(0,XO.SVD)(n),l=cY.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),c=uY.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),u=hY.copy(c).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,n){this.updateWorldMatrix(!0,!1);let s=new ue().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),s.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof ue?r.hiddenMatrix.premultiply(s):r.applyMatrix4(s),r.updateWorldMatrix(!1,!1),this.add(r),n!==void 0&&(this.children.pop(),this.children.splice(n,0,r)),this}copy(r,n=!1){return super.copy(r,n),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,n,s,o,a,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var nE=class extends vd(Rt){},dY=i=>i.type==="Mesh",zr=class extends nE{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new zr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix),n.expand(),e+=1,r=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 dY(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var Fc=new T,Uc=new T,xd=new ue,KO=[new T(-1,1,1),new T(-1,-1,1),new T(1,-1,1),new T(1,1,1),new T(-1,1,-1),new T(-1,-1,-1),new T(1,-1,-1),new T(1,1,-1)],fY=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],pY=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],YO=(i,t,e)=>{i.updateEntityBoxSize(Fc,Uc),xd.copy(t).multiply(i.matrixWorld),Uc.x===0&&Uc.y===0&&Uc.z===0?e.push(new T(Fc.x,Fc.y,Fc.z).applyMatrix4(xd)):KO.forEach(r=>{e.push(r.clone().multiply(Uc).add(Fc).applyMatrix4(xd))})},om=class extends zt{constructor(){super(...arguments);this.matrix=new ue;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let n=new ue().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,n,r)}expandByObjectSize(e,r,n=!1){let s=[];return n===!0?e.traverseEntity(o=>{if(o.visible||o.cloner&&o.data.visible){if(!("geometry"in o)){s.push(new T);return}YO(o,r,s)}}):YO(e,r,s),this.setFromPoints(s)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(xd.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Uc).multiplyScalar(.5),this.getCenter(Fc),xd.copy(this.matrix).setPosition(Fc),this.vertices=KO.map(e=>e.clone().multiply(Uc).applyMatrix4(xd))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=fY.map(([e,r])=>new Ei(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new T))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=pY.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Gs={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var oE=class extends xp{constructor(){super()}getPoints(t=12){let e=[],r,n=this.getCurveLengths(),o=n[n.length-1]/n.length;for(let a=0,l=this.curves;a<l.length;a++){let c=l[a],u=a===0?n[a]:n[a]-n[a-1],h=Math.ceil(t*u/o),d=c.getPoints(h);for(let f=0;f<d.length;f++){let p=d[f];r&&r.equals(p)||(e.push(p),r=p)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var aE=.001;function lE(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=aE}function sE(i,t){let e=new T(...i.position),r=new T(...i.controlNext.position),n=new T(...t.controlPrevious.position),s=new T(...t.position);return lE(e,r,s)&&lE(e,n,s)}function _0(i){let t=i.points.map(u=>new T(...u.data.position)),e=[i.points[0]],r=new T(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)lE(r,t[u],t[u+1])||(e.push(i.points[u]),r=t[u]);e.push(i.points[i.points.length-1]);let n=i.isClosed,s=e.length-(n?0:1),o=e.length,a=[];for(let u=0;u<o;u++){let h=e[u].data,d=new T(...h.position),f=new T(...h.controlPrevious.position),p=new T(...h.controlNext.position),g={position:d,baseRoundness:h.roundness,controlPrevious:f,controlNext:p};if(h.roundness===0||!i.isClosed&&(u===0||u===o-1)){a[u]={...g,removedLength:0};continue}let y=n&&u==0?o-1:u-1,m=n&&u==o-1?0:u+1,v=e[y].data,x=e[m].data,b=new T(...v.position),S=new T(...x.position),w=b.clone().sub(d).normalize(),E=S.clone().sub(d).normalize();Object.assign(g,{prevDir:w,nextDir:E});let A=sE(v,h),P=sE(h,x);if(!A||!P)a[u]={...g,removedLength:0};else{let M=w.clone().add(E).normalize(),C=M.clone().cross(w).length()/w.dot(M);a[u]={...g,tan:C,removedLength:h.roundness/C}}}for(let u=0;u<s;u++){let h=u,d=n&&u===o-1?0:u+1,f=a[h],p=a[d];if(f.removedLength!==0||p.removedLength!==0){let g=f.position.distanceTo(p.position);f.removedLength=Math.min(f.removedLength,g/2),p.removedLength=Math.min(p.removedLength,g/2)}}let l=[];for(let u=0;u<s;u++){let h=u,d=n&&u===o-1?0:u+1,f=a[h],p=a[d],g=null;if(!sE(e[h].data,e[d].data))f.position.distanceTo(p.position)>aE&&(g=new xc(f.position,f.controlNext,p.controlPrevious,p.position));else{let y=f.position.clone(),m=p.position.clone();(f.removedLength!==0||p.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),p.prevDir&&m.add(p.prevDir.clone().setLength(p.removedLength))),y.distanceTo(m)>aE&&(g=new xc(y,y.clone().lerp(m,.3),m.clone().lerp(y,.3),m))}l[2*u+1]=g}for(let u=0;u<o;u++){let h=a[u];if(h.removedLength===0){l[2*u]=null;continue}let d=h.position,f=h.prevDir.clone().multiplyScalar(h.removedLength).add(d),p=h.nextDir.clone().multiplyScalar(h.removedLength).add(d),g=h.tan*h.removedLength,y=h.prevDir.clone().add(h.nextDir).normalize(),m=f.clone().lerp(p,.5),v=f.distanceTo(p)/2,x=y.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(v,2))).add(m),b=y.clone().multiplyScalar(-g).add(x),S=d.distanceTo(b)/d.distanceTo(m),w=h.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),E=w.clone().lerp(b,2),A=f.clone().lerp(w,4/3),P=p.clone().lerp(E,4/3);l[2*u]=new xc(f,A,P,p)}let c=new oE;return l.forEach(u=>{u&&c.add(u)}),c}var At;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(At||(At={}));var To=i=>At.is(i),mY={type:"completeState",isfromEntity:!0},gY=["x","y","z"],cE=new T,yY=new T().set(0,1,0),bd=i=>class extends vd(i){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 om;this._recursiveBBox=new om;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let n=this.children[r];if(At.is(n))return n}entityChildrenCount(){let r=this.children.length;for(;r--;)if(At.is(this.children[r]))return r+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 r=this;for(;r.data.type!=="Instance";){let n=r.parent;if(At.is(n))r=n;else return}return r}forInstancesRec(r){this.instances.forEach(n=>{n.disposed||r(n),n.forInstancesRec(r)})}super_Entity(r,n){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=n,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,n,s=!1){if(!(this.data.states.length===0&&!s)){for(let o of this.data.states)ya.toOps(this.data,o.data).forEach(l=>{let c=Vh.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,n)});if(r!==null){let o=this.data.states.data(r);o&&(this.dataPatched=ya.patch(this.data,o),ya.toOps(this.data,o).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,n)}))}s&&this.updateTransformState(this.dataPatched,n),this.stateSelection=r,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(r,n){r.setScalar(0),n.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{To(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let n;return this.traverseEntity(s=>{s.uuid===r&&(n=s)}),n}traverseSortNextHelper(){let r=this.parent;if(r){let n=r.children,s=n.indexOf(this)+1;if(At.is(n[s]))return n[s];if(At.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&At.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let n=this;for(;r>0&&n!==null;)n=n.parent,r-=1;return n}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let n=this.parent;for(;n;){if(r===n)return!0;n=n.parent}return!1}countToAccestor(r){let n=0,s=this;for(;s!==r;){if(s===null)return-1;s=s.parent,n+=1}return n}forEachEntity(r){for(let n of this.children)To(n)&&r(n)}traverseEntityAncestors(r){this.traverseAncestors(n=>{At.is(n)&&r(n)})}traverseConcreteEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)To(o)&&o.isConcreteEntity&&o.traverseEntity(r,n+1)}traverseEntity(r,n=0){if(r(this,n)!==!0)for(let o of this.children)To(o)&&o.traverseEntity(r,n+1)}traverseVisibleEntity(r){r(this);for(let n of this.children)To(n)&&n.visible&&n.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,n=!1){return super.copy(r,n),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>To(r))}isAncestorOf(r){if(this.uuid===r)return!1;let n=!1;return this.traverseEntity(s=>{s.uuid===r&&(n=!0)}),n}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let n={position:this.position.toArray(),rotation:[this.rotation.x*_e.RAD2DEG,this.rotation.y*_e.RAD2DEG,this.rotation.z*_e.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Oh(n,r)}getTransformValues(r,n,s){return n[r].map((o,a)=>s?.shared.getVariable(o,[this.uuid,r,gY[a]])??o)}updateTransformState(r,n){let s=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,n)),s=!0),r.rotation&&(cE.fromArray(this.getTransformValues("rotation",r,n)).multiplyScalar(_e.DEG2RAD),this.rotation.setFromVector3(cE),s=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,n)),s=!0),r.hiddenMatrix!==void 0&&(s=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Sl.identity)),s&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),s}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(n=>{n.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)At.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{At.is(r)&&r.disposeRecursively()})}toState(r=[]){let n={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Oh(n,r)}updateByObjUpdateOp(r,n){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},n,!1)}updateByOp(r,n,s,o){let a=this.data;this.data=n;let l=r,c=Ut(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let h={...r.props};if(delete h.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=Ur.zoom(d,r.path.slice(2));if(f)for(let p in r.props)r.props[p]===void 0&&p in f&&(h[p]=f[p])}}l={...r,props:h,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let h=Ur.removeOverridden(r.path,r.props,u);l={...r,props:h}}}if(this.updateByPatchedOpBase(l,ya.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),s),Ut(r.path,["overrides"])){let u=[],h=[...r.path];for(u.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)u.push(h[1]),h.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=s.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(fo.apply(f.component.data,f.overrideData),s))}}else{let d=s.scene.findInstance([this.uuid,...u]);if(d){let f=Ur.zoom(d.component.data,h);if(r={...r,path:h},r.type===0){let p=r.props;if(f)for(let[g,y]of Object.entries(r.props))y===void 0&&(p===r.props&&(p={...r.props}),p[g]=f[g]);r={...r,props:p}}d.overrideData=Kh.resolve(n.overrides,u),d.updateByOp(r,Vr.applySimple(d.data,r),s,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let h;for(let d of bo.rootOverrideProps)d in r.props&&(h===void 0&&(h={}),h[d]=r.props[d]);h&&(u={...r,props:h})}else for(let h of bo.rootOverrideProps)if(Ut(r.path,[h])){u=r;break}u!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=fo.filterOp(h.overrideData,u);d&&h.updateByOp(d,Vr.applySimple(h.data,d),s,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=fo.filterOp(h.overrideData,r);if(d){let f;a===h.data&&r===d?f=n:f=Vr.applySimple(h.data,d),h.updateByOp(d,f,s,!0)}}})}}updateByPatchedOpBase(r,n,s){if(this.dataPatched=n,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Us.is(r.props.type)&&Gs.changeEntityProptotype(this,n,s);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Gs.changeEntityProptotype(this,n,s);for(let o of this.children)At.is(o)&&o.updateVisible(s.scene)}this.updateByPatchedOp(r,n,s)}updateByPatchedOp(r,n,s){if(r.path.length===0&&r.type===0&&this.updateState(r.props,s),Ut(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(n.pathSnapping),Ut(r.path,["cloner"])!==null){let o=Vr.drop(r,1);o.path.length===0&&o.type===0&&o.props.disabled===!0?this.setFromClonerState(null,s):this.cloner?this.cloner.updateState(n.cloner,s.scene):(this.setFromClonerState(n.cloner,s),this.expandCloner(s.scene)),this.updateVisible(s.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let n=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,s=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,o=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(n===null)return;let l=r.find(n);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=_0(c.geometry.path),h=(s+o)%1;s+o===1&&h===0&&(h=1);let d=u.getPointAt(h);if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ue;l.updateMatrixWorld();let p=new ue().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(p);let g={position:d.toArray(),rotation:c.rotation};if(a==="tangential"){let y=new ue().extractRotation(l.matrixWorld),m=u.getTangentAt(h).applyMatrix4(y).add(d),v=new ue().lookAt(d,m,yY),x=cE.setFromEuler(new Ht().setFromRotationMatrix(v)).multiplyScalar(_e.RAD2DEG);g={...g,rotation:x.toArray()}}this.updateTransformState(g),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(mY)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let n=!1;this.traverseEntity(s=>{if(s.data.type==="Splat")return n=!0,!0}),n&&r.reloadSplats()}updateState_Entity(r,n){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(n?.scene),this.resetBBoxNeedsUpdate()),n&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,n),this.updateVisible(n.scene)),this.updateTransformState(r,n)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof Gs.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,n){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Gs.Cloner(this,r),n.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,n.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var P0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);e.thetaLength=_e.clamp(e.thetaLength,0,360);let r=e.width/2,n=e.radiusTop??r,s=e.radiusBottom??r;return n===s?(n=r,s=r):n>s?(n=r,s=s*r/n):(n=n*r/s,s=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:n,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:h,cornerSegments:d,hollow:f}=i.parameters,p;return l===0?(p=new Ne,p.setAttribute("position",new Ie([],3))):h||f?p=new am(c,u,r,n,s,o,a,l*Math.PI/180,h,h,d,f):p=new Sc(c,u,r,n,s,o,a,l*Math.PI/180),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"CylinderGeometry"}})}};function Ol(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function QO(i){return new U(i.y,-i.x)}var am=class extends Ne{constructor(t,e,r,n,s,o,a,l,c,u,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,u=0);let p=[],g=[],y=[],m=[],v=0,x=r/2,b=new T,S=new T;f&&t==0&&(t=c),f&&e==0&&(e=u);let w=new U(t,x),E=new U(e,-x),A=null,P=null,M=null,C=null,O=w.clone().sub(E),L=0,D=0,B=0;d>0&&(L=Math.min(t,e)*(1-d),D=t-L,B=e-L);let k=w.clone();k.x-=L;let F=Math.PI-O.angle(),H=O.angle(),G=Math.tan(H/2),X=Math.tan(F/2),Y=G+X,Z=d?Y:X,le=d?Y:G;if(c=Math.min(c,(t-D)/Z,O.length()/Y),u=Math.min(u,(e-B)/le,O.length()/Y),c>0){let $=c/G;A=w.clone().sub(new U($,c)),d&&(M=A.clone(),M.x-=L-Y*c),w.sub(O.clone().setLength($))}if(u>0){let $=u/X;P=E.clone().sub(new U($,-u)),E.add(O.clone().setLength($)),d&&(C=P.clone(),C.x-=L-Y*u,k.sub(O.clone().setLength($)))}O=w.clone().sub(E);let j=O.length()<.5,K=[];for(let $=0;$<=n;$++){let se=[],Se=$/n,W=Se*l+a,Ae=new U(Math.sin(W),Math.cos(W));C&&P?(ee(se,Se,Ae,F,u,C,-1,!0),ee(se,Se,Ae,H,u,P,-1,!1)):P?(re(se,Ae,P.x,0,-1),ee(se,Se,Ae,H,u,P,-1,!1)):o||re(se,Ae,e,B,-1);let xe=QO(O).normalize();if(Ol(xe,Ae,b),!j)for(let be=0;be<=s;be++){let Ee=be/s,De=O.clone().multiplyScalar(Ee).add(E);Ol(De,Ae,S),g.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),m.push(Se,.5+S.y/r),se.push(v++)}if(M&&A?(ee(se,Se,Ae,F,c,A,1,!1),ee(se,Se,Ae,H,c,M,1,!0)):A?(ee(se,Se,Ae,F,c,A,1,!1),re(se,Ae,A.x,0,1)):o||re(se,Ae,t,D,1),d&&!j){let be=QO(O).multiplyScalar(-1).normalize();Ol(be,Ae,b);for(let Ee=0;Ee<=s;Ee++){let De=Ee/s,Pe=O.clone().multiplyScalar(-De).add(k);Ol(Pe,Ae,S),g.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),m.push(Se,.5+S.y/r),se.push(v++)}}d&&!o&&se.push(se[0]),K.push(se)}for(let $=0;$<K.length-1;$++)for(let se=0;se<K[0].length-1;se++){if(o&&d&&se==s)continue;let Se=K[$][se],W=K[$+1][se],Ae=K[$+1][se+1],xe=K[$][se+1],be=g[Ae*3+0],Ee=g[Ae*3+2];p.push(Se,W,xe),(be!=0||Ee!=0)&&p.push(W,Ae,xe)}l<Math.PI*2&&(te(-1,K[0],a),te(1,K[K.length-1],a+l)),this.setIndex(p),this.setAttribute("position",new Ie(g,3)),this.setAttribute("normal",new Ie(y,3)),this.setAttribute("uv",new Ie(m,2));function ee($,se,Se,W,Ae,xe,be,Ee){for(let De=0;De<h+1;De++){let Pe=De/h,Re=be<0?Pe:1-Pe;Ee&&(Re-=1),Re*=W;let ze=new U(Math.sin(Re),Math.cos(Re)*be),_=ze.clone().multiplyScalar(Ae).add(xe);Ol(_,Se,S),g.push(S.x,S.y,S.z),Ol(ze,Se,b),y.push(b.x,b.y,b.z),m.push(se,.5+S.y/r),$.push(v++)}}function re($,se,Se,W,Ae){let xe=new T,be=new U,Ee=[Se,W];Ae<0&&Ee.reverse();for(let De of Ee)be.set(De,x*Ae),Ol(be,se,xe),g.push(xe.x,xe.y,xe.z),y.push(0,Ae,0),m.push(.5,.5),$.push(v++)}function te($,se,Se){let W=new U(Math.sin(Se),Math.cos(Se)),Ae=new U(-Math.cos(Se),Math.sin(Se)),xe=new T,be=$<0?(Pe,Re,ze)=>p.push(Pe,Re,ze):(Pe,Re,ze)=>p.push(Pe,ze,Re),Ee=new U((t+e+D+B)/4,0);Ol(Ee,W,xe),g.push(xe.x,xe.y,xe.z),y.push(Ae.x,0,Ae.y),m.push(.5,.5);let De=v++;for(let Pe of se){let Re=g.slice(Pe*3,Pe*3+3);g.push(...Re),y.push(Ae.x,0,Ae.y);let ze=m.slice(Pe*2,Pe*2+2);m.push(...ze),v++}for(let Pe=De+1;Pe<v-1;Pe++)be(De,Pe,Pe+1);be(De,v-1,De+1)}}};var ZO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=_e.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:h}=i.parameters,d;return l===0?(d=new Ne,d.setAttribute("position",new Ie([],3))):c>0||u>0||l<360?d=new am(0,t/2,r,n,s,o,a,l*Math.PI/180,c,u,h,0,!0):d=new nl(t/2,r,n,s,o),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var JO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new mi(t,e,r,n,s,o):c=new hE(t,e,r,n,s,o,a,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},uE=Math.PI/2,hE=class extends Ne{constructor(t=1,e=1,r=1,n=1,s=1,o=1,a=0,l=4){super(),this.type="BoxGeometry";let c=this;n=Math.floor(n),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let u=[],h=[],d=[],f=[],p=0,g=0;y("z","y","x",-1,-1,r,e,t,o,s,0),y("z","y","x",1,-1,r,e,-t,o,s,1),y("x","z","y",1,1,t,r,e,n,o,2),y("x","z","y",1,-1,t,r,-e,n,o,3),y("x","y","z",1,-1,t,e,r,n,s,4),y("x","y","z",-1,-1,t,e,-r,n,s,5),a>0&&(m("z","y","x",-1,-1,1,r,e,t,o,0),m("z","y","x",1,-1,-1,r,e,t,o,1),m("z","y","x",-1,1,-1,r,e,t,o,1),m("z","y","x",1,1,1,r,e,t,o,0),m("x","y","z",-1,-1,-1,t,e,r,n,0),m("x","y","z",1,-1,1,t,e,r,n,1),m("x","y","z",-1,1,1,t,e,r,n,0),m("x","y","z",1,1,-1,t,e,r,n,1),m("y","x","z",-1,-1,1,e,t,r,s,0),m("y","x","z",1,-1,-1,e,t,r,s,1),m("y","x","z",1,1,1,e,t,r,s,1),m("y","x","z",-1,1,-1,e,t,r,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new Ie(h,3)),this.setAttribute("normal",new Ie(d,3)),this.setAttribute("uv",new Ie(f,2));function y(x,b,S,w,E,A,P,M,C,O,L){let D=(A-2*a)/C,B=(P-2*a)/O,k=A/2-a,F=P/2-a,H=M/2,G=C+1,X=O+1,Y=0,Z=0,le=new T;for(let j=0;j<X;j++){let K=j*B-F;for(let ee=0;ee<G;ee++){let re=ee*D-k;le[x]=re*w,le[b]=K*E,le[S]=H,h.push(le.x,le.y,le.z),le[x]=0,le[b]=0,le[S]=M>0?1:-1,d.push(le.x,le.y,le.z),f.push(ee/C),f.push(1-j/O),Y+=1}}for(let j=0;j<O;j++)for(let K=0;K<C;K++){let ee=p+K+G*j,re=p+K+G*(j+1),te=p+(K+1)+G*(j+1),$=p+(K+1)+G*j;u.push(ee,re,$),u.push(re,te,$),Z+=6}c.addGroup(g,Z,L),g+=Z,p+=Y}function m(x,b,S,w,E,A,P,M,C,O,L){let D=(P-2*a)/O,B=P/2-a,k=M/2-a,F=C/2,H=O+1,G=0,X=0,Y=new T,Z=new T;for(let le=0;le<l+1;le++){let j=le/l*uE,K=Math.sin(j)*a,ee=(1-Math.cos(j))*a,re=Math.sin(j),te=Math.cos(j);Y[b]=(k+K)*E,Y[S]=(F-ee)*A,Z[x]=0,Z[b]=re*Math.sign(Y[b]),Z[S]=te*Math.sign(Y[S]);for(let $=0;$<H;$++){let se=$*D-B;Y[x]=se*w,h.push(Y.x,Y.y,Y.z),d.push(Z.x,Z.y,Z.z),f.push($/O),f.push(0),G+=1}}for(let le=0;le<l;le++)for(let j=0;j<O;j++){let K=p+j+H*le,ee=p+j+H*(le+1),re=p+(j+1)+H*(le+1),te=p+(j+1)+H*le;u.push(K,ee,te),u.push(ee,re,te),X+=6}c.addGroup(g,X,L),g+=X,p+=G}function v(x,b,S){let w=new T,E=new T(t/2,e/2,r/2);E.subScalar(a);let A=[],P=x*b*S>0?(C,O,L)=>u.push(C,O,L):(C,O,L)=>u.push(C,L,O);for(let C=0;C<=l;C++){let O=[],L=uE*(1-C/l),D=Math.cos(L),B=Math.sin(L),k=0;for(let F=0;F<=C;F++){let H=Math.cos(k),G=Math.sin(k);w.x=D*H,w.y=B,w.z=D*G;let X=E.clone().addScaledVector(w,a);h.push(x*X.x,b*X.y,S*X.z),d.push(x*w.x,b*w.y,S*w.z),f.push(0,0),O.push(p++),k+=uE/C}A.push(O)}let M=A.length-1;for(let C=0;C<M;C++){let O=A[C],L=A[C+1],D=O.length-1;P(O[0],L[1],L[0]);for(let B=1;B<=D;B++)P(O[B-1],O[B],L[B]),P(O[B],L[B+1],L[B])}}}};var Il=class extends Ne{constructor(t=[],e=[],r="",n=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];u(),h(),this.setAttribute("position",new Ie(a,3)),this.setAttribute("normal",new Ie(c,3)),this.setAttribute("uv",new Ie(l,2));return;function u(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],p=new T,g=p.clone(),y=new Er,m=s*n,v=n-m,x=o+1,b=new T,S=(G,X)=>b.subVectors(G,X).normalize(),w=(G,X)=>Array(G).fill(void 0).map(X),E=w(t.length/3,(G,X)=>new T().fromArray(t,X*3).setLength(n)),A=[],P=1e6;for(let G=0;G<E.length;G++){let X=E[G],Y=[],Z,le,j,K=1e10,ee=-1;for(;(ee=e.indexOf(G,ee+1))!=-1;){let se=ee-ee%3;Z=e[se+(ee+1)%3],le=e[se+(ee+2)%3],j=X.distanceToSquared(E[Z]),K=Math.min(K,j),Y.push([Z,le,j])}K+=1e-6;let re=[],te=0,$=Y.length;for(let se=0;se<$;se++){[Z,le,j]=Y[te];let Se=A[Z]?.includes(G)==!0;j<=K&&re.push(Z+ +Se*P),te=Y.findIndex(W=>W[0]==le)}A.push(re)}let M=[];{let G=0,X=0,Y,Z,le=f==3;for(let j=0;j<=o;j++){Y=j*(j+1)/2,Z=(j+1)*(j+2)/2;for(let K=0;K<o-j;K++)[G,X]=[Y+K+j+2,Z+K+j+3],M.push(Y,Z,...le?[X,Y]:[G,Z],X,G),[Y,Z]=[G,X];M.push(Y,Z,Y+o+2)}}let C=p.clone(),O=p.clone(),L=p.clone(),D=p.clone(),B=p.clone(),k=[],F=w(E.length,()=>w(f,()=>p.clone()));for(let G=0;G<E.length;G++){p.copy(E[G]).normalize(),C.copy(p).multiplyScalar(v);let X=A[G];for(let re=0;re<X.length;re++){let te=X[re],$=X[(re+1)%f];y.setFromPointsAndIndices(E,G,te%P,$%P),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(C,F[G][re])}let Y=[],Z=[],le=[],j=new T;o==0&&[...F[G]].reduce((re,te)=>re.add(te),j).multiplyScalar(1/f);for(let re=0;re<f;re++){let te=[],$=(re-1+f)%f,se=F[G][$],Se=F[G][re];p.copy(se).sub(C),g.copy(Se).sub(C);let W=C.angleTo(p),Ae=p.angleTo(g),xe=Math.cos(W)*m;o==0?O.copy(j):O.copy(C).setLength(v+xe),Z.push(xe);let be=[O,se,Se];for(let Ee=0;Ee<2;Ee++){let De=be[Ee],Pe=be[Ee+1];D.subVectors(De,C),B.subVectors(Pe,C),L.crossVectors(D,B).normalize();for(let Re=0;Re<x;Re++){let ze=[W,Ae][Ee]*Re/x;p.copy(D).applyAxisAngle(L,ze).add(C),Y.push(p.clone()),Ee&&(S(p,C),te.push([Re==0?De:p.clone(),b.clone()]))}Ee&&(S(Pe,C),te.push([Pe,b.clone()]))}le.push(te)}k.push(le);let K=2*x,ee=2;for(let re=0;re<f;re++){let te=K*re,$=K*((re+1)%f),se=[Y[te]];for(let W=1;W<x;W++){D=Y[te+W],B=Y[$+W],se.push(D);for(let Ae=1,xe=W-ee+1;Ae<=xe;Ae++)p.lerpVectors(D,B,Ae/(xe+1)),p.sub(C).setLength(Z[re]).add(C),se.push(p.clone());se.push(B)}for(let W=0;W<x;W++)se.push(Y[W+x+te]);se.push(Y[$+x]);let Se=M.map(W=>se[W]);a.push(...Se.map(W=>[W.x,W.y,W.z]).flat()),c.push(...Se.map(W=>(S(W,C),[b.x,b.y,b.z])).flat())}}let H=[];for(let G=0;G<A.length;G++)for(let X=0;X<f;X++){let Y=A[G][X];if(Y<P){let Z=A[Y].findIndex(K=>K%P==G),le=k[G][X],j=k[Y][Z];for(let K=0;K<x;K++){let ee=le[K],re=j[x-K],te=le[K+1],$=j[x-(K+1)];[ee,re,te,te,re,$].forEach(se=>{a.push(se[0].x,se[0].y,se[0].z),c.push(se[1].x,se[1].y,se[1].z)})}H.push(le[0][0],j[x][0],le[x][0],j[0][0])}}for(;H.length;){let G,X,Y,Z;[G,X]=H.splice(0,2);let le=[G];for(;G!=X;)le.push(X),Y=H.indexOf(X),Z=Y%2,X=H.splice(Y-Z,2)[1-Z];b.subVectors(le[0],le[1]).cross(p.subVectors(le[0],le[2])).normalize();let j=b.dot(le[0])<0;j&&b.negate();for(let K=1;K<=le.length-2;K++)[le[K+ +j],le[K+1-+j],le[0]].forEach(ee=>{a.push(ee.x,ee.y,ee.z),c.push(b.x,b.y,b.z)})}}function h(){let d=new T;for(let E=0;E<a.length;E+=3){d.x=a[E+0],d.y=a[E+1],d.z=a[E+2];let A=S(d)/2/Math.PI+.5,P=w(d)/Math.PI+.5;l.push(A,1-P)}let f=new T,p=new T,g=new T,y=new T,m=new U,v=new U,x=new U,b=(E,A,P,M)=>{M<0&&E.x===1&&(l[A]=E.x-1),P.x===0&&P.z===0&&(l[A]=M/2/Math.PI+.5)};for(let E=0,A=0;E<a.length;E+=9,A+=6){f.set(a[E+0],a[E+1],a[E+2]),p.set(a[E+3],a[E+4],a[E+5]),g.set(a[E+6],a[E+7],a[E+8]),m.set(l[A+0],l[A+1]),v.set(l[A+2],l[A+3]),x.set(l[A+4],l[A+5]),y.copy(f).add(p).add(g).divideScalar(3);let P=S(y);b(m,A+0,f,P),b(v,A+2,p,P),b(x,A+4,g,P)}for(let E=0;E<l.length;E+=6){let A=l[E+0],P=l[E+2],M=l[E+4],C=Math.max(A,P,M),O=Math.min(A,P,M);C>.9&&O<.1&&(A<.2&&(l[E+0]+=1),P<.2&&(l[E+2]+=1),M<.2&&(l[E+4]+=1))}function S(E){return Math.atan2(E.z,-E.x)}function w(E){return Math.atan2(-E.y,Math.sqrt(E.x*E.x+E.z*E.z))}}}static fromJSON(t){return new Il(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var $O=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new lm(t*.5,s,o):new Gu(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"DodecahedronGeometry"}})}},lm=class extends Il{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=1/n,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-n,0,-s,n,0,s,-n,0,s,n,-s,-n,0,-s,n,0,s,-n,0,s,n,0,-n,0,-s,n,0,-s,-n,0,s,n,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,t,e,r),this.type=l}static fromJSON(t){return new lm(t.radius,t.corner,t.cornerSides)}};var cm=1e-12,Sd=class{constructor(t){this.position=new U;this.startPosition=new U;this.uuid=_e.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Sd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},wd=class extends Sd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new wd(this.parent).copy(this)}},Hs=class extends Sd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new wd(this),new wd(this))}static create(e,r){let n=new Hs(e,new U(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,s=this.controls.length;n<s;n++){let o=this.controls[n];this.position.distanceTo(o.position)<=r?o.position.copy(this.position):o.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Hs(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new U,r=new U){let[n,s]=this.computeTangents();return n&&s&&(eI(n,e),eI(s,r)),[e,r]}computeTangent(e=new U){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new U){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function eI(i,t=new U){let e=i.length();return t.set(-i.y/e,i.x/e)}var fE=i=>i,Ad=new U,D0=new U,vY=new U,xY=new U,bY=new U,SY=new U,rI=new T,iI=new T;function nI(i){let t=new U;t.addVectors(i.v0,Ad.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new U;return e.addVectors(i.v2,D0.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new on(i.v0,t,e,i.v2)}function um(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function wY(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function AY(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function pE(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-s*s)/(2*n*r))}function sI(i,t,e){return tI(i,t)&&tI(t,e)&&dE(i.position,t.position,e.position)}function dE(i,t,e){return Ad.copy(t).sub(i).cross(D0.copy(e).sub(i))===0}function oI(i,t,e,r,n){let s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=(i.y+t.y)/2,a=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(i.y-t.y)/s,c=Math.sqrt(Math.pow(e,2)-Math.pow(s/2,2))*(t.x-i.x)/s;return r.set(a+l,o+c),n.set(a-l,o-c),[r,n]}function aI(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function lI(i,t,e,r,n,s){let o=t.x-i.x,a=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),h;return pE(t,i,e)>Math.PI&&(u*=-1),um(c,a)?h=(a+c)*(r/u-.5)*8/3/(o-l):h=(o+l)*(r/u-.5)*8/3/(c-a),n.set(t.x-h*a,t.y+h*o),s.set(e.x+h*c,e.y-h*l),[n,s]}function mE(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function tI(i,t){return dE(i.position,i.controls[1].position,t.position)&&dE(i.position,t.controls[0].position,t.position)}function cI(i,t,e,r,n=.5){let s=Ad.subVectors(t,i).multiplyScalar(n).add(i),o=D0.subVectors(e,t).multiplyScalar(n).add(t),a=vY.subVectors(r,e).multiplyScalar(n).add(e),l=s,c=xY.subVectors(o,s).multiplyScalar(n).add(s),u=bY.subVectors(a,o).multiplyScalar(n).add(o),h=a,d=SY.subVectors(u,c).multiplyScalar(n).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,h.x,h.y,r.x,r.y]}function uI(i,t,e=12,r=!0){let n=iI.set(0,0,0),s,o=0,a=[];for(let l=0;l<t.length;l++){let c=fE(t[l]),u=Ad,h=Rl(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof on||c instanceof Xn||c instanceof mn){if(c.getPoint(d/h,u),n.set(u.x,u.y,0),s!==void 0&&AY(s,n))continue;s===void 0&&(s=rI),s.copy(n),i.setXYZ(o,n.x,n.y,n.z),o++}}return r&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),i}function hI(i,t,e,r=12,n=!0){let s=iI.set(0,0,0),o=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=fE(t[l]),h=Ad,d=Rl(u,r);a.push(d);for(let f=0;f<=d;f++)if(u instanceof on||u instanceof Xn||u instanceof mn){if(u.getPoint(f/d,h),s.set(h.x,h.y,0),c?.equals(s))continue;c===void 0?c=rI:(i.setXYZ(o,c.x,c.y,c.z),o++,i.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return n&&o>1&&!(i.getX(o-1)===i.getX(0)&&i.getY(o-1)===i.getY(0)&&i.getZ(o-1)===i.getZ(0))&&(i.setXYZ(o,i.getX(0),i.getY(0),i.getZ(0)),o++),a}function gE(i,t=12,e=!1){let r=[];for(let n=0,s=i.length;n<s;n++){let o=i[n],a=0;if(e&&o.roundedCurveCorner!==void 0){let l=Rl(o.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Rl(o.curveAfter,t)),r.push(a)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=Rl(i[0].roundedCurveCorner,t)*.5),r}function Rl(i,t=12){return i&&i instanceof vc?t*2:i&&(i instanceof mn||i instanceof vp)?1:i&&i instanceof Vu?t*i.points.length:t}function dI(i,t,e=12,r=!0){let n,s=0;for(let o=0;o<t.length;o++){let a=fE(t[o]),l=Rl(a,e),c=Ad;for(let u=0;u<=l;u++)if(a instanceof on||a instanceof Xn||a instanceof mn){if(a.getPoint(u/l,c),n!==void 0&&wY(n,c,cm))continue;n===void 0&&(n=D0),n.copy(c),i.push(c.x,c.y),s++}}return um(i[0],i[i.length-2],cm)&&um(i[1],i[i.length-1],cm)&&(i.pop(),i.pop()),r&&s>1&&!(um(i[s-1],i[1],cm)&&um(i[s-2],i[0],cm))&&(i.push(i[0],i[1]),s++),i}var yE=new U,EY=new U,TY=new U,MY=new U,CY=new U,_Y=new U,Yt=class extends oa{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new ii(new T(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=_e.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let s=new Yt;return s.isClosed=e.isClosed,s.points=e.points.map(o=>Hs.create(o.id,o.data)),typeof e.roundness=="number"&&(s.roundness=e.roundness),s.shapeHoles=e.shapeHoles.map(o=>Yt.createFromState(o)),r!==void 0&&n!==void 0&&s.applySize(r,n),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(s=>s.uuid===e);if(n<0){let s=r;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length,u=l.getPointIndexById(e);if(u<0)s+=c;else return u+s}}return n}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=e-r;if(a<=o.points.length-1)return o.points[a];r+=o.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,s=this.shapeHoles.length;n<s;n++){let o=this.shapeHoles[n],a=o.points.indexOf(e);if(a>=0)return r+a;r+=o.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=yE.set(e,r);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(n),a.controls[0].position.multiply(n),a.controls[1].position.multiply(n)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(e,r);this._update()}createPoint(e,r=0,n=_e.generateUUID()){let s;e instanceof U?s=e:s=new U(e,r);let o=new Hs(n,s);return o.roundness=this.roundness,o}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(s.uuid===e)return s}for(let r=0,n=this.shapeHoles.length;r<n;r++){let o=this.shapeHoles[r].getPointByUuid(e);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let s=n?this.roundedCurveDivisions:this.curveDivisions;return uI(e,n?this.roundedCurves:this.curves,r,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=gE(this.points,e,!1),this.roundedCurveDivisions=gE(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return hI(e,this.curves,r,n,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),dI(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=r?this.roundedCurveDivisions:this.curveDivisions,o=0;r&&this.points[0].roundedCurveCorner!==void 0&&(o=Rl(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let u=s[l];if(a<n+u)return[l,(a-n+1)/u];n+=u}return[0,1]}getCurveT(e,r,n){let s=this.points[e],o=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(mE(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(yE.set(n.x,n.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){mE(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let s=n.clone();e.roundedCurveBefore=s,r.roundedCurveAfter=s,e.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let s=this.points[r];if(r===0)this.moveTo(s.position.x,s.position.y);else{let o=this.points[r-1];this._applyCurveForPoint(s,o)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,s=this.points.length;n<s;n++){let o=this.points[n],a=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],c=o.roundness,u=a&&l&&sI(a,o,l);if(!o.controlsMoved()&&c>0&&!u){let h=o.curveBefore,d=o.curveAfter;if(h===void 0||d===void 0)continue;let f=o.roundedCurveBefore,p=o.roundedCurveAfter,g=h.getLength(),y=d.getLength(),m=Math.min(c,g*.499),v=Math.min(c,y*.499),x=Math.min(m,v),b=1-x/g,S=x/y,w=h.getPointAt(b,yE),E=d.getPointAt(S,EY);this._subSplitCurve(h,f,b,w,void 0),this._subSplitCurve(d,p,S,void 0,E);let A;if(this.useCubicForRoundedCorners){let P=pE(w,o.position,E)/2,M=Math.tan(P)*w.distanceTo(o.position),[C,O]=oI(w,E,M,TY,MY),L=aI(C,O,o.position),[D,B]=lI(L,w,E,M,CY,_Y);A=new on(w.clone(),D.clone(),B.clone(),E.clone())}else A=new Xn(w.clone(),o.position.clone(),E.clone());o.roundedCurveCorner=A,this.roundedCurves.splice(n+r,0,A),r++}}}}_subSplitCurve(e,r,n,s,o){if(e instanceof mn)s!==void 0&&r.v2.copy(s),o!==void 0&&r.v1.copy(o);else{let a=e,l=r,c=a.getUtoTmapping(n,0),u=cI(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),o!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new Yt(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let n=0;n<r;n++){let s=n*7,o=e.points[s+0],a=e.points[s+1],l=e.points[s+2],c=e.points[s+3],u=e.points[s+4],h=e.points[s+5],d=e.points[s+6],f=new Hs(_e.generateUUID(),new U(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(u,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let s=new Yt;return s.fromJSON(n),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(o,a)=>{a instanceof on&&a.v3.equals(o.position)&&o.controls[0].position.copy(a.v2)},s=o=>{let a=[],l,c;for(l=0,c=o.length;l<c;l++)o[l]instanceof Xn&&(o[l]=nI(o[l]));for(l=0,c=o.length;l<c;l++){let d=o[l],f=l>0?o[l-1]:null,p;d instanceof on?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof mn&&(p=this.createPoint(d.v1)),p!==void 0&&(f!==null&&n(p,f),a.push(p))}let u=o[o.length-1],h=!1;return u instanceof on?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),h=!0):u instanceof mn&&u.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=s(e.curves),e instanceof oa&&(this.shapeHoles=e.holes.map(o=>{let a=new Yt;return a.fromShape(o),a})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let s=this.getPointByUuid(e)?.controls[0];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let s=this.getPointByUuid(e)?.controls[1];s&&(r.position&&s.position.fromArray(r.position),this.needsUpdate=!0)}};var xE=Math.PI*2;function vE({x:i,y:t},e,r,n,s){return{x:i*e+n,y:t*r+s}}function PY(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),s=Math.cos(i+t),o=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:s+o*e,y:o-s*e},{x:s,y:o}]}function fI(i,t,e,r){let n=i*r-t*e<0?-1:1,s=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(s)}function DY(i,t,e,r,n,s,o,a,l,c){let u=Math.pow(n,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),p=u*h-u*f-h*d;p<0&&(p=0),p/=u*f+h*d,p=Math.sqrt(p)*(l===c?-1:1);let g=p*n/s*a,y=p*-s/n*o,m=g+(i+e)/2,v=y+(t+r)/2,x=(o-g)/n,b=(a-y)/s,S=(-o-g)/n,w=(-a-y)/s,E=fI(1,0,x,b),A=fI(x,b,S,w);return!c&&A>0&&(A-=xE),c&&A<0&&(A+=xE),{centerx:m,centery:v,ang1:E,ang2:A}}function pI({px:i,py:t,cx:e,cy:r,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(n===0||s===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];n=Math.abs(n),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(n,2)+Math.pow(u,2)/Math.pow(s,2);h>1&&(n*=Math.sqrt(h),s*=Math.sqrt(h));let d=DY(i,t,e,r,n,s,c,u,o,a),{ang1:f,ang2:p}=d,{centerx:g,centery:y}=d,m=Math.abs(p)/(xE/4);Math.abs(1-m)<1e-7&&(m=1);let v=Math.max(Math.ceil(m),1);p/=v;for(let x=0;x<v;x++)l.push(PY(f,p)),f+=p;return l.map(x=>{let{x:b,y:S}=vE(x[0],n,s,g,y),{x:w,y:E}=vE(x[1],n,s,g,y),{x:A,y:P}=vE(x[2],n,s,g,y);return{x1:b,y1:S,x2:w,y2:E,x:A,y:P}})}var jt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(jt||(jt={}));var jr;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(jr||(jr={}));function dt(i,t){if(!i)throw t||"Assertion Failed!"}var lt=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){dt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?n<s?e.t-t.t+(t.t-r.t)*(n/(n+s)):e.t-r.t+(r.t-t.t)*(s/(n+s)):0},i.edgeSign=function(t,e,r){dt(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,s=r.s-e.s;return n+s>0?(e.t-r.t)*n+(e.t-t.t)*s:0},i.transEval=function(t,e,r){dt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?n<s?e.s-t.s+(t.s-r.s)*(n/(n+s)):e.s-r.s+(r.s-t.s)*(s/(n+s)):0},i.transSign=function(t,e,r){dt(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,s=r.t-e.t;return n+s>0?(e.s-r.s)*n+(e.s-t.s)*s:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,s){var o,a,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(o=i.edgeEval(t,r,e),a=i.edgeEval(r,e,n),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,e.s)):(o=i.edgeSign(t,r,e),a=-i.edgeSign(t,n,e),o+a<0&&(o=-o,a=-a),s.s=i.interpolate(o,r.s,a,n.s)):s.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(o=i.transEval(t,r,e),a=i.transEval(r,e,n),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,e.t)):(o=i.transSign(t,r,e),a=-i.transSign(t,n,e),o+a<0&&(o=-o,a=-a),s.t=i.interpolate(o,r.t,a,n.t)):s.t=(r.t+e.t)/2},i}(),hm=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),O0=function(){function i(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(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Ed=function(){function i(){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 i}(),mI=function(){function i(){var t=new Ed,e=new hm,r=new O0(0),n=new O0(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new O0(0),r=new O0(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;dt(n,"Vertex can't be null!");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e;var o=e;do o.Org=n,o=o.Onext;while(o!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;dt(n,"Face can't be null");var s=r.prev;n.prev=s,s.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var o=e;do o.Lface=n,o=o.Lnext;while(o!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var s=t.prev,o=t.next;o.prev=s,s.next=o},i.prototype.makeEdge=function(){var t=new Ed,e=new Ed,r=new hm,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var s=new Ed;this.makeVertex_(s,e,t.Org),t.Org.anEdge=t}if(!r){var o=new hm;this.makeFace_(o,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=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 n=new hm;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new Ed;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),s=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(s,e),n.Org=t.Dst,s.Org=e.Org,n.Lface=s.Lface=t.Lface,t.Lface.anEdge=s,!r){var o=new hm;this.makeFace_(o,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,s,o,a;n=e.Lnext;do r=n,n=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)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=e);o=t.prev,a=t.next,a.prev=o,o.next=a},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,s,o,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,o=r.Org;n=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(s.Lface),a+l-2<=t&&lt.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&lt.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(n=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===o);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,s,o,a,l,c;for(s=t,s=t;(n=s.next)!==t;s=n){dt(n.prev===s),l=n.anEdge;do dt(l.Sym!==l),dt(l.Sym.Sym===l),dt(l.Lnext.Onext.Sym===l),dt(l.Onext.Sym.Lnext===l),dt(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(dt(n.prev===s&&n.anEdge===null),a=e,a=e;(o=a.next)!==e;a=o){dt(o.prev===a),l=o.anEdge;do dt(l.Sym!==l),dt(l.Sym.Sym===l),dt(l.Lnext.Onext.Sym===l),dt(l.Onext.Sym.Lnext===l),dt(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(dt(o.prev===a&&o.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)dt(l.Sym.next===c.Sym),dt(l.Sym!==l),dt(l.Sym.Sym===l),dt(l.Org!==null),dt(l.Dst!==null),dt(l.Lnext.Onext.Sym===l),dt(l.Onext.Sym.Lnext===l);dt(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),gI=function(){function i(){this.handle=null}return i}(),yI=function(){function i(){this.key=null,this.node=0}return i}(),OY=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new gI,this.handles[r]=new yI;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t<<1,o<this.size&&this.leq(r[e[o+1].handle].key,r[e[o].handle].key)&&++o,dt(o<=this.max),s=e[o].handle,o>this.size||this.leq(r[n].key,r[s].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,s,o;for(n=e[t].handle;;){if(o=t>>1,s=e[o].handle,o===0||this.leq(r[s].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=s,r[s].node=t,t=o}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,s;for(s=this.nodes.length,this.nodes.length=this.max+1,n=s;n<this.nodes.length;n++)this.nodes[n]=new gI;for(s=this.handles.length,this.handles.length=this.max+1,n=s;n<this.handles.length;n++)this.handles[n]=new yI}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;dt(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),bE=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),vI=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),IY=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new vI,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new vI;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),RY=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,s=e.eUp,o=r.eUp;if(s.Dst===n)return o.Dst===n?lt.vertLeq(s.Org,o.Org)?lt.edgeSign(o.Dst,s.Org,o.Org)<=0:lt.edgeSign(s.Dst,o.Org,s.Org)>=0:lt.edgeSign(o.Dst,n,o.Org)<=0;if(o.Dst===n)return lt.edgeSign(s.Dst,n,s.Org)>=0;var a=lt.edgeEval(s.Dst,n,s.Org),l=lt.edgeEval(o.Dst,n,o.Org);return a>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&dt(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){dt(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new bE;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case jt.ODD:return(e&1)!==0;case jt.NONZERO:return e!==0;case jt.POSITIVE:return e>0;case jt.NEGATIVE:return e<0;case jt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,s=null,o=e,a=e.eUp;o!==r;){if(o.fixUpperEdge=!1,s=i.regionBelow(o),n=s.eUp,n.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),i.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),i.finishRegion(t,o),a=s.eUp,o=s}return a},i.addRightEdges=function(t,e,r,n,s,o){var a,l,c,u,h=!0;c=r;do dt(lt.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==n);for(s===null&&(s=i.regionBelow(e).eUp.Rprev),l=e,u=s;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),h=!1,l=a,u=c;l.dirty=!0,dt(l.windingNumber-c.winding===a.windingNumber),o&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=lt.vertL1dist(e,t),s=lt.vertL1dist(r,t),o=.5*s/(n+s),a=.5*n/(n+s);t.coords[0]+=o*e.coords[0]+a*r.coords[0],t.coords[1]+=o*e.coords[1]+a*r.coords[1],t.coords[2]+=o*e.coords[2]+a*r.coords[2]},i.getIntersectData=function(t,e,r,n,s,o){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,s,o)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp;if(lt.vertLeq(n.Org,s.Org)){if(lt.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;lt.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),e.dirty=r.dirty=!0)}else{if(lt.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o;if(dt(!lt.vertEq(n.Dst,s.Dst)),lt.vertLeq(n.Dst,s.Dst)){if(lt.edgeSign(n.Dst,s.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,o=t.mesh.splitEdge(n),t.mesh.splice(s.Sym,o),o.Lface.inside=e.inside}else{if(lt.edgeSign(s.Dst,n.Dst,s.Org)>0)return!1;e.dirty=r.dirty=!0,o=t.mesh.splitEdge(s),t.mesh.splice(n.Lnext,s.Sym),o.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,s=r.eUp,o=n.Org,a=s.Org,l=n.Dst,c=s.Dst,u,h,d=new Ed,f,p;if(dt(!lt.vertEq(c,l)),dt(lt.edgeSign(l,t.event,o)<=0),dt(lt.edgeSign(c,t.event,a)>=0),dt(o!==t.event&&a!==t.event),dt(!e.fixUpperEdge&&!r.fixUpperEdge),o===a||(u=Math.min(o.t,l.t),h=Math.max(a.t,c.t),u>h))return!1;if(lt.vertLeq(o,a)){if(lt.edgeSign(c,o,a)>0)return!1}else if(lt.edgeSign(l,a,o)<0)return!1;return i.debugEvent(t),lt.intersect(l,o,c,a,d),dt(Math.min(o.t,l.t)<=d.t),dt(d.t<=Math.max(a.t,c.t)),dt(Math.min(c.s,l.s)<=d.s),dt(d.s<=Math.max(a.s,o.s)),lt.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=lt.vertLeq(o,a)?o:a,lt.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),lt.vertEq(d,o)||lt.vertEq(d,a)?(i.checkForRightSplice(t,e),!1):!lt.vertEq(l,t.event)&&lt.edgeSign(l,t.event,d)>=0||!lt.vertEq(c,t.event)&&lt.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Lnext,s.Oprev),r=e,e=i.topRightRegion(e),p=i.regionBelow(e).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,s.Onext,n.Rprev,p,!0),!0):(lt.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),lt.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(s.Sym),t.mesh.splice(s.Oprev,n),n.Org.s=d.s,n.Org.t=d.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,o,l,a,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,s;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,s=r.eUp,n.Dst!==s.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(s),r=i.regionBelow(e),s=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==s.Org)if(n.Dst!==s.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||s.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===s.Org&&n.Dst===s.Dst&&(i.addWinding(s,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,s=r.Onext,o=i.regionBelow(e),a=e.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(t,e),lt.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),e=i.topLeftRegion(t,e),s=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),o),c=!0),lt.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,o,null),c=!0),c){i.addRightEdges(t,e,r.Onext,s,s,!0);return}lt.vertLeq(l.Org,a.Org)?n=l.Oprev:n=a,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,s,o,a,l;if(n=e.eUp,lt.vertEq(n.Org,r)){dt(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!lt.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}dt(!1),e=i.topRightRegion(e),l=i.regionBelow(e),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(dt(s!==o),i.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(r.anEdge,o),lt.edgeGoesLeft(s)||(s=null),i.addRightEdges(t,e,o.Onext,a,s,!0)},i.connectLeftVertex=function(t,e){var r,n,s,o,a,l,c=new bE;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,n=i.regionBelow(r),!!n){if(o=r.eUp,a=n.eUp,lt.edgeSign(o.Dst,e,o.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(s=lt.vertLeq(a.Dst,o.Dst)?r:n,r.inside||s.fixUpperEdge){if(s===r)l=t.mesh.connect(e.anEdge.Sym,o.Lnext);else{var u=t.mesh.connect(a.Dnext,e.anEdge);l=u.Sym}s.fixUpperEdge?i.fixUpperEdge(t,s,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);dt(n!==null);var s=i.regionBelow(n),o=s.eUp,a=i.finishLeftRegions(t,s,null);a.Onext===o?i.connectRightVertex(t,n,a):i.addRightEdges(t,n,a.Onext,o,o,!0)},i.addSentinel=function(t,e,r,n){var s=new bE,o=t.mesh.makeEdge();o.Org.s=r,o.Org.t=n,o.Dst.s=e,o.Dst.t=n,t.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=t.dict.insert(s)},i.initEdgeDict=function(t){t.dict=new IY(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,s=t.bmax[0]+e,o=t.bmin[1]-r,a=t.bmax[1]+r;i.addSentinel(t,n,s,o),i.addSentinel(t,n,s,a)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(dt(e.fixUpperEdge),dt(++r===1)),dt(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,s=t.mesh.eHead;for(e=s.next;e!==s;e=r)r=e.next,n=e.Lnext,lt.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,s=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)s++;for(s+=8,e=t.pq=new OY(s,lt.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,s;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,s=r.anEdge,dt(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),t.mesh.delete(s));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!lt.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),LY=function(){function i(){this.mesh=new mI,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=jt.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 i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,s,o,a,l=[0,0,0],c=[0,0,0],u=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],p=[null,null,null],g=this.mesh.vHead;e=g.next;for(var y=0;y<3;++y)s=e.coords[y],c[y]=s,p[y]=e,l[y]=s,f[y]=e;for(e=g.next;e!==g;e=e.next)for(var m=0;m<3;++m)s=e.coords[m],s<c[m]&&(c[m]=s,p[m]=e),s>l[m]&&(l[m]=s,f[m]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=p[v],n=f[v],u[0]=r.coords[0]-n.coords[0],u[1]=r.coords[1]-n.coords[1],u[2]=r.coords[2]-n.coords[2],e=g.next;e!==g;e=e.next)h[0]=e.coords[0]-n.coords[0],h[1]=e.coords[1]-n.coords[1],h[2]=e.coords[2]-n.coords[2],d[0]=u[1]*h[2]-u[2]*h[1],d[1]=u[2]*h[0]-u[0]*h[2],d[2]=u[0]*h[1]-u[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,s=0,o=t.next;o!==t;o=o.next)if(n=o.anEdge,!(n.winding<=0))do s+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==o.anEdge);if(s<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,s=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),s=!0),r=this.sUnit,n=this.tUnit;var o=this.longAxis_(e);r[o]=0,r[(o+1)%3]=1,r[(o+2)%3]=0,n[o]=0,n[(o+1)%3]=0,n[(o+2)%3]=e[o]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,n);s&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;lt.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;lt.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var s=void 0;r.Lnext!==n;)if(lt.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(lt.edgeGoesLeft(n.Lnext)||lt.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)s=t.connect(n.Lnext,n),n=s.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(lt.edgeGoesRight(r.Lprev)||lt.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=t.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)s=t.connect(n.Lnext,n),n=s.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,s=t.eHead.next;s!==t.eHead;s=n)n=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?e:-e:r?t.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var s,o=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=o,++o}this.elementCount=o,e===jr.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*n,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*n;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],n>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){s=u.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===jr.CONNECTED_POLYGONS){s=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){n=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;s=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){o=0,n=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,o++,r=r.Lnext;while(r!==n);this.elements[u++]=s,this.elements[u++]=o,s+=o}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new mI),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,s,o){if(t===void 0&&(t=jt.ODD),e===void 0&&(e=jr.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),RY.computeInterior(this,o);var a=this.mesh;return e===jr.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),e===jr.BOUNDARY_CONTOURS?this.outputContours_(a,n):this.outputPolymesh_(a,e,r,n),!0},i}();function js(i){var t=i.windingRule,e=t===void 0?jt.ODD:t,r=i.elementType,n=r===void 0?jr.POLYGONS:r,s=i.polySize,o=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,u=c===void 0?[0,0,1]:c,h=i.contours,d=h===void 0?[]:h,f=i.strict,p=f===void 0?!0:f,g=i.debug,y=g===void 0?!1:g;if(!d&&p)throw new Error("Contours can't be empty");if(!!d){var m=new LY;i.edgeCreateCallback&&(m.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(m.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)m.addContour(l||2,d[v]);return m.tesselate(e,n,o,l,u,p),{vertices:m.vertices,vertexIndices:m.vertexIndices,vertexCount:m.vertexCount,elements:m.elements,elementCount:m.elementCount,mesh:y?m.mesh:void 0}}}var _ge=jt.ODD,Pge=jt.NONZERO,Dge=jt.POSITIVE,Oge=jt.NEGATIVE,Ige=jt.ABS_GEQ_TWO,Rge=jr.POLYGONS,Lge=jr.CONNECTED_POLYGONS,Nge=jr.BOUNDARY_CONTOURS;var I0=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*I0.eSize;this.buffer=new ArrayBuffer(r);let n=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.normals=new Float32Array(this.buffer,s*n,3*t),s+=3*t,this.uvs=new Float32Array(this.buffer,s*n,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*I0.eSize,n=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(n,o*s,3*t);o+=3*t;let l=new Float32Array(n,o*s,3*t);o+=3*t;let c=new Float32Array(n,o*s,2*t);e?(a.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=n,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let n=this.capacity;for(;e>n;)n*=2;this.realloc(n)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},dm=I0;dm.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var wI=qo(SI()),fm={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},TE={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},ME={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},EE=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),Nl=class extends Ne{constructor(e,r,n=0,s=12,o=3,a=jt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=s,this._bevelSegmentsInput=o;let c=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(C=>{let O=C.extractShapePointsToFlatArray([],s),L=[];for(let D=O.length-1;D>=1;D-=2){let B=O[D-1],k=O[D-0];L.push(B,k)}return L}),h=[],d=[];for(let C=0;C<c.length;C+=2)d.push([c[C],c[C+1]]);h.push(d);for(let C=0;C<u.length;C++){let O=u[C],L=[];for(let D=0;D<O.length;D+=2)L.push([O[D],O[D+1]]);h.push(L)}let f;e.isText?f=new eh().setFromPoints(e.points.map(O=>O.position)).getSize(new U).length()*.1:h[0].length===0?f=n:f=(0,wI.default)(h).distance,n<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(n,f,r/2),this._bevelSegments=Math.floor(o));let p;try{p=js({windingRule:a,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{p=fm}let g;try{g=js({windingRule:jt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{g=TE}if(!p)throw new Error("error generating geometry");let y=p.elementCount;if(g){p.elementCount+=g.elementCount;for(let C=0;C<g.elements.length;C++){let O=g.elements[C],L=C%2===0?p.vertexCount:0;p.elements.push(O+L)}for(let C=0;C<g.vertexIndices.length;C++){let O=g.vertexIndices[C],L=p.vertexCount;p.vertexIndices.push(O+L)}for(let C=0;C<g.vertices.length;C++){let O=g.vertices[C];p.vertices.push(O)}}let m=1/0,v=-1/0,x=1/0,b=-1/0;for(let C=0,O=p.vertexCount;C<O;C++){let L=C*2,D=p.vertices[L+0],B=p.vertices[L+1];D<m&&(m=D),D>v&&(v=D),B<x&&(x=B),B>b&&(b=B)}this._minX=m,this._minY=x,this._width=v-m,this._height=b-x,this._buffer=new dm(this._computeBufferEstimatedSize(p));let S=[],w=[];for(let C=p.elementCount-1;C>=0;C--){let O=C>=y,L=C*2,D=p.elements[L+0],B=p.elements[L+1],k=D+B,F={start:D,count:B,normals:[],continuous:[],concave:[]},H=D,G=k-1,X=D+1,Y=this._shape.roundedCurves.length;do{let ee=H-D,re=p.vertices[G*2+0],te=p.vertices[G*2+1],$=p.vertices[H*2+0],se=p.vertices[H*2+1],Se=p.vertices[X*2+0],W=p.vertices[X*2+1],Ae=$-re,xe=se-te,be=Math.sqrt(Ae*Ae+xe*xe);Ae/=be,xe/=be;let Ee=$-Se,De=se-W,Pe=Math.sqrt(Ee*Ee+De*De);Ee/=Pe,De/=Pe,F.normals[ee*2+0]=-De,F.normals[ee*2+1]=Ee,F.concave[ee]=Ae*De-xe*Ee>0;let Re=p.vertexIndices[H];if(Array.isArray(Re))F.continuous[ee]=!1;else{let[ze,_]=this._shape.getCurveIndexFromVertexId(Re-1,!0);if(_>0&&_<1)F.continuous[ee]=!0;else{let I=_===1?ze+1:ze-1;I=(I+Y)%Y;let ie=_===1?0:1,de=this._shape.roundedCurves[ze].getTangent(_),ve=this._shape.roundedCurves[I].getTangent(ie);F.continuous[ee]=de.dot(ve)>.95}}O&&(F.normals[ee*2+0]*=-1,F.normals[ee*2+1]*=-1),[G,H,X]=[H,X,X+1],X>=k&&(X-=B)}while(X!==D+1);let Z=[];Z.push({bevelI:0,angle:0,size:0,boundary:{vertices:p.vertices.slice(D*2,k*2),vertexCount:B,vertexIndices:new Array(B).fill(!0).map((ee,re)=>[re,re]),elements:[0,B],elementCount:1,mesh:null},reverseMap:[],insetPoints:p.vertices.slice(D*2,k*2)});let le=0;for(let ee=1;ee<=this._bevelSegments;ee++){let re=ee/this._bevelSegments*Math.PI/2,te=(1-Math.cos(re))*this._bevel,$=[],se=[],Se=[],W=[],Ae=0;for(let be=0;be<B;be++){let Ee=be*2,De=(be-1+B)%B*2,Pe=p.vertices[F.start*2+Ee+0],Re=p.vertices[F.start*2+Ee+1],ze=-F.normals[De+0]*te,_=-F.normals[De+1]*te,I=-F.normals[Ee+0]*te,ie=-F.normals[Ee+1]*te;if(F.concave[be]||!F.concave[be]&&O){let de=Math.atan2(_,ze),ve=Math.atan2(ie,I);ve>de&&(ve-=Math.PI*2);let fe=ve-de;if(F.continuous[be]||O){let et=de+fe/2,Ue=Math.cos(et)*te,Oe=Math.sin(et)*te;$[2*Ae+0]=Pe+Ue*(O?-1:1),$[2*Ae+1]=Re+Oe*(O?-1:1),W[Ae]=be,Ae++}else{let et=Math.max(1,Math.floor(s/4*Math.abs(fe)/Math.PI));for(let Ue=0;Ue<=et;Ue++){let Oe=de+fe*(Ue/et),Be=Math.cos(Oe)*te,xt=Math.sin(Oe)*te;$[2*Ae+0]=Pe+Be,$[2*Ae+1]=Re+xt,W[Ae]=be,Ae++}}}else $[2*Ae+0]=Pe+ze,$[2*Ae+1]=Re+_,W[Ae]=be,se[be]=Ae,Ae++,$[2*Ae+0]=Pe,$[2*Ae+1]=Re,W[Ae]=be,Ae++,$[2*Ae+0]=Pe+I,$[2*Ae+1]=Re+ie,W[Ae]=be,Se[be]=Ae,Ae++}let xe=js({windingRule:jt.POSITIVE,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[$],edgeCreateCallback:be=>{let De=be.Org.idx,Pe=W[De],Re=W[(De+1)%W.length];be.idx=[Pe,Re],be.Sym.idx=[Re,Pe]},vertexIdCallback:be=>{let Ee=be.Lprev.idx;return[Ee?Ee[1]:0,be.idx?be.idx[0]:0]}});if(!xe)throw console.log("Error"),new Error(`error generating bevel geometry for ${ee}'th loop`);if(!xe.vertexCount){let be=(ee-1)/this._bevelSegments*Math.PI/2;le=(1-Math.sin(be))*this._bevel;break}for(let be=0;be<xe.vertexIndices.length;be++){let[Ee,De]=xe.vertexIndices[be];if(Ee===De)continue;let Pe=De;De<Ee&&(Pe+=B);for(let Re=Ee;Re<Pe;Re++){let ze=Re%B,_=(Re+1)%B;if(!F.continuous[ze]||!F.continuous[_]){xe.vertexIndices[be]=[Ee,ze],xe.vertexIndices.splice(be+1,0,[_,De]),xe.vertices.splice((be+1)*2,0,xe.vertices[be*2],xe.vertices[be*2+1]);break}}}Z.push({bevelI:ee,angle:re,size:te,boundary:xe,reverseMap:W,insetPoints:$})}let j=(ee,re,te)=>{let $=0,se=ee.boundary.vertexIndices.length;for(;$<se&&te(ee.boundary.vertexIndices[re]);)re=(re+1)%se,$++;return $},K=S.length;for(let ee=1;ee<Z.length;ee++){let re=Z[ee-1],te=Z[ee],$=re.boundary.vertexIndices.length,se=te.boundary.vertexIndices.length;if(!$||!se)break;let Se=F.concave.length,W=0,Ae=EE(W,B);for(;!re.boundary.vertexIndices.filter(Ae).length||!te.boundary.vertexIndices.filter(Ae).length;)W++,Ae=EE(W,B);let xe=re.boundary.vertexIndices.findIndex(Ae),be=te.boundary.vertexIndices.findIndex(Ae);do xe=(xe+1)%$;while(Ae(re.boundary.vertexIndices[xe]));do be=(be+1)%se;while(Ae(te.boundary.vertexIndices[be]));W=(W+1)%B;let Ee=W,De=0,Pe=this._buildBevelVert(F,re,(xe-1+$)%$,void 0,De),Re=this._buildBevelVert(F,te,(be-1+se)%se,void 0,De),ze=Pe,_=Re,I,ie,de=!1;do{De=(W||Se)/Se,Ae=EE(W,B);let ve=j(re,xe,Ae),fe=j(te,be,Ae),et=de;if(de=!1,ve&&!fe){for(let Ue=0;Ue<ve;Ue++)I=this._buildBevelVert(F,re,(xe+Ue)%$,Ue/(ve-1),De),S.push(ze.topN,I.topP,_.topN),l===!1&&S.push(I.bottomP,ze.bottomN,_.bottomN),ze=I;de=!0}else if(!ve&&fe)for(let Ue=0;Ue<fe;Ue++)ie=this._buildBevelVert(F,te,(be+Ue)%se,Ue/(fe-1),De),S.push(_.topN,ze.topP,ie.topP),l===!1&&S.push(ze.bottomP,_.bottomN,ie.bottomP),_=ie;else if(ve&&fe)if(I=this._buildBevelVert(F,re,xe,0,De),ie=this._buildBevelVert(F,te,be,0,De),et?(S.push(ze.topN,ie.topP,_.topN),S.push(ze.topN,I.topP,ie.topP),l===!1&&(S.push(ie.bottomP,ze.bottomN,_.bottomN),S.push(ie.bottomP,I.bottomP,ze.bottomN))):(S.push(_.topN,ze.topN,I.topP),S.push(_.topN,I.topP,ie.topP),l===!1&&(S.push(I.bottomP,ze.bottomN,_.bottomN),S.push(I.bottomP,_.bottomN,ie.bottomP))),ze=I,_=ie,ve===fe)for(let Ue=1;Ue<ve;Ue++)I=this._buildBevelVert(F,re,(xe+Ue)%$,Ue/(ve-1),De),ie=this._buildBevelVert(F,te,(be+Ue)%se,Ue/(fe-1),De),S.push(ze.topN,I.topP,_.topN),S.push(_.topN,I.topP,ie.topP),l===!1&&(S.push(I.bottomP,ze.bottomN,_.bottomN),S.push(I.bottomP,_.bottomN,ie.bottomP)),ze=I,_=ie;else if(ve>fe){let Ue=ve/fe,Oe=0;for(let Be=1;Be<ve;Be++)I=this._buildBevelVert(F,re,(xe+Be)%$,Be/(ve-1),De),S.push(ze.topN,I.topP,_.topN),l===!1&&S.push(I.bottomP,ze.bottomN,_.bottomN),ze=I,Be>(Oe+1)*Ue&&(Oe++,ie=this._buildBevelVert(F,te,(be+Oe)%se,Oe/(fe-1),De),S.push(_.topN,I.topP,ie.topP),l===!1&&S.push(I.bottomP,_.bottomN,ie.bottomP),_=ie)}else{let Ue=fe/ve,Oe=0;for(let Be=1;Be<fe;Be++)ie=this._buildBevelVert(F,te,(be+Be)%se,Be/(fe-1),De),S.push(_.topN,I.topP,ie.topP),l===!1&&S.push(I.bottomP,_.bottomN,ie.bottomP),_=ie,Be>(Oe+1)*Ue&&(Oe++,I=this._buildBevelVert(F,re,(xe+Oe)%$,Oe/(ve-1),De),S.push(ze.topN,I.topP,_.topN),l===!1&&S.push(I.bottomP,ze.bottomN,_.bottomN),ze=I)}xe=(xe+ve)%$,be=(be+fe)%se,W=(W+1)%Se}while(W!==Ee)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(Z,F,S),O){let ee=[];for(let re=S.length-1;re>=K+2;re-=3){let te=S[re-2],$=S[re-1],se=S[re-0];ee.push(se,$,te)}S.splice(K,S.length-K,...ee)}if(O){let ee=[];for(let re=Z[Z.length-1].boundary.vertices.length-1;re>=1;re-=2){let te=Z[Z.length-1].boundary.vertices[re-1],$=Z[Z.length-1].boundary.vertices[re-0];ee.push(te,$)}w.push(ee)}if(!O){let ee=Z[Z.length-1],re;try{re=js({windingRule:Z.length>1?jt.POSITIVE:jt.ODD,elementType:jr.POLYGONS,vertexSize:2,strict:!0,contours:[ee.insetPoints,...w]})}catch{re=ME}if(!re)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let te=0;te<re.elementCount*3;te+=3){let $=this._buildSurfaceVert(re,re.elements[te+0],le),se=this._buildSurfaceVert(re,re.elements[te+1],le),Se=this._buildSurfaceVert(re,re.elements[te+2],le);S.push($.top,se.top,Se.top),l===!1&&S.push(Se.bottom,se.bottom,$.bottom)}}this.vertexCache={}}this._buffer.shrink();let E=new Ye(Uint32Array.from(S),1),A=new Ye(this._buffer.positions,3),P=new Ye(this._buffer.normals,3),M=new Ye(this._buffer.uvs,2);A.needsUpdate=!0,P.needsUpdate=!0,M.needsUpdate=!0,E.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",P),this.setAttribute("uv",M),this.setIndex(E)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);n.push(c.topP,l.topN,l.bottomN),n.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,n){let s=r.toString();if(s in this.vertexCache)return this.vertexCache[s];let o=e.vertices[r*2+0],a=e.vertices[r*2+1],l=(o-this._minX)/this._width,c=(a-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),h=u*3,d=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[h+0]=o,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-n,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[h+3]=o,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=n,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[s]=f,f}_buildBevelVert(e,r,n,s=1,o){let a=`${r.bevelI}:${n}`;if(a in this.vertexCache&&o!==0&&o!==1&&(!o||o===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[l,c]=r.boundary.vertexIndices[n],u,h,d,f;l!==c?(h=l,u=c,f=!1,d=e.continuous[h]&&e.continuous[u]):(u=l,h=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,d=e.continuous[u]||f);let p=Math.cos(r.angle),g=Math.sin(r.angle),y=n*2,m=u*2,v=h*2,x=r.boundary.vertices[y+0],b=r.boundary.vertices[y+1],S=(1-g)*this._bevel,w=(x-this._minX)/this._width,E=(b-this._minY)/this._height;this.forPathBevel&&(o!==void 0&&(w=o),E=1);let A=e.normals[m+0],P=e.normals[m+1],M=e.normals[v+0],C=e.normals[v+1];if(f){let k=M-A,F=C-P;A=A+k*(1-s),P=P+F*(1-s);let H=Math.sqrt(A*A+P*P);A/=H,P/=H}let O=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),L=O*3,D=O*2,B={i:n,fi:u,topP:O+0,topN:O+0,bottomP:O+1,bottomN:O+1,pathBevelUCoord:o};return this._buffer.positions[L+0]=x,this._buffer.positions[L+1]=b,this._buffer.positions[L+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[L+0]=A*p,this._buffer.normals[L+1]=P*p,this._buffer.normals[L+2]=g,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=E,this.forPathBevel===!1&&(this._buffer.positions[L+3]=x,this._buffer.positions[L+4]=b,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=A*p,this._buffer.normals[L+4]=P*p,this._buffer.normals[L+5]=-g,this._buffer.uvs[D+2]=E,this._buffer.uvs[D+3]=w),d||(this.forPathBevel?(O+=1,L+=3,D+=2):(O+=2,L+=6,D+=4),B.topP=O+0,B.bottomP=O+1,this._buffer.positions[L+0]=x,this._buffer.positions[L+1]=b,this._buffer.positions[L+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[L+0]=M*p,this._buffer.normals[L+1]=C*p,this._buffer.normals[L+2]=g,this._buffer.uvs[D+0]=w,this._buffer.uvs[D+1]=E,this.forPathBevel===!1&&(this._buffer.positions[L+3]=x,this._buffer.positions[L+4]=b,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=M*p,this._buffer.normals[L+4]=C*p,this._buffer.normals[L+5]=-g,this._buffer.uvs[D+2]=E,this._buffer.uvs[D+3]=w)),this.vertexCache[a]=B,B}clone(){let e=new Nl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fa(this.userData),e}};var Td=class extends Ne{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=jt.ODD;this.elementType=jr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:jt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(p=>p.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,u,h;for(let p=0,g=s.length/2;p<g;p++){let y=p*2,m=s[y+0],v=s[y+1];if(u!==void 0&&m!==u&&(l=!1),h!==void 0&&v!==h&&(c=!1),u=m,h=v,!l&&!c)break}if(!l&&!c)try{a=js({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=fm}let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ye(new Float32Array(d*3),3),this._normalAttribute=new Ye(new Float32Array(d*3),3),this._uvAttribute=new Ye(new Float32Array(d*2),2),this._indexAttribute=new Ye(new Uint32Array(f*3),1),a){let p=1/0,g=-1/0,y=1/0,m=-1/0;for(let b=0,S=d;b<S;b++){let w=b*2,E=a.vertices[w+0],A=a.vertices[w+1];E<p&&(p=E),E>g&&(g=E),A<y&&(y=A),A>m&&(m=A)}let v=g-p,x=m-y;for(let b=0,S=d;b<S;b++){let w=b*2,E=a.vertices[w+0],A=a.vertices[w+1],P=(E-p)/v,M=(A-y)/x;this._positionAttribute.setXYZ(b,E,A,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,P,M)}for(let b=0,S=f;b<S;b++){let w=b*3,E=a.elements[w+0],A=a.elements[w+1],P=a.elements[w+2];this._indexAttribute.setX(w+0,E),this._indexAttribute.setX(w+1,A),this._indexAttribute.setX(w+2,P)}}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 Td(this._shape,this._curveSegments);return e.userData=fa(this.userData),e}};var Md=class extends Nl{constructor(e,r,n=0,s=12,o=3,a=jt.ODD){super(e,r,n,s,o,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,n){let s=e[0];for(let o=0,a=s.boundary.vertexCount;o<a;o++){let l=this._buildBevelVert(r,s,o),c=this._buildBevelVert(r,s,(o+1)%a);n.push(c.topP,l.topN,l.bottomN),n.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Md(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=fa(this.userData),e}};var Ln=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:jt.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=i.shape??t?.shape,a=o?.roundness??e.roundness;o!==void 0&&(o instanceof Yt?(o.width!==r||o.height!==n)&&o.applySize(r,n):o=new Yt(r,n).fromJSON(o),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&o.update());let l=o??new Yt(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:s,roundness:a}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:s,windingRule:o}=i.parameters;i.shape.roundness=s;let a;return t<=0?a=new Td(i.shape,n,{windingRule:o}):a=new Md(i.shape,t,e,n,r,o),Object.assign(a,{userData:{...i,type:"VectorGeometry"}})}};var EI=Math.PI*2,_d=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=_e.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=t*.5,h=e*.5,d=VY(c,u,h,n*Math.PI/180,r,s);c.isClosed=!0,c.update();let f;return n===0?(f=new Ne,f.setAttribute("position",new Ie([],3))):f=Ln.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function VY(i,t,e,r,n,s){if(r>=EI)return n>30||n%4===0?(kY(i,t,e,s),Math.round(n/4)):AI(i,r,n,t,e,s);r=Math.max(r,.001);let o={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=pI({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%c.length===0?zY(i,o.x,o.y,c,n,t,e,s):AI(i,r,n,t,e,s)}function zY(i,t,e,r,n,s,o,a){let l=Math.round(n/r.length);i.addPoint(Cd(t,e));for(let c=0,u=r.length;c<u;c++){let h=r[c],d=i.points[c],f=Cd(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),i.addPoint(f)}return a>0?TI(i,s,o,a):i.addPoint(Cd(0,0)),l}function AI(i,t,e,r,n,s){let o=-t/e;for(let a=0;a<=e;a++){let l=o*a,c=Math.sin(l)*r,u=Math.cos(l)*n;i.addPoint(Cd(c,u))}return t<EI?s>0?TI(i,r,n,s):i.addPoint(Cd(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&MI(i,r,n,s)),1}function kY(i,t,e,r=0,n=0,s=0){let o=.5522847498,a=t*o,l=e*o;i.addPoint(L0(n-t,s,n-t,s-l,n-t,s+l)),i.addPoint(L0(n,s+e,n-a,s+e,n+a,s+e)),i.addPoint(L0(n+t,s,n+t,s+l,n+t,s-l)),i.addPoint(L0(n,s-e,n+a,s-e,n-a,s-e)),r>0&&MI(i,t,e,r)}function Cd(i,t){return new Hs(_e.generateUUID(),new U(i,t))}function L0(i,t,e,r,n,s){let o=Cd(i,t);return o.controls[0].position.set(e,r),o.controls[1].position.set(n,s),o}function TI(i,t,e,r){CI(i,t,e,r).forEach(s=>i.addPoint(s))}function MI(i,t,e,r){let n=CI(i,t,e,r),s=new Yt;n.forEach(o=>s.addPoint(o)),s.isClosed=!0,i.shapeHoles.push(s)}function CI(i,t,e,r){let n=r*t/100,s=n*(Math.abs(e)/Math.abs(t)),o=new U(n/t,s/e),a=i.points.map(l=>{let c=l.clone();return c.uuid=_e.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),u=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),a}var _I=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??r),s=Math.abs(e.depth??r),o=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(e,{width:r,height:n,depth:s,radius:o,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:h}=i.parameters,d=new pm(!1,t,e,r,n,s,o,a,l,c,u,h);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},CE=new lo([0,0,0],1),pm=class extends Ne{constructor(t=!0,e=1,r=1,n=1,s=1,o=1,a=1,l=1,c=1,u=1,h=1,d=1){if(super(),o===0)return;let f=t&&o===1;f&&(d=0),h>100&&(h=100),h===0&&(d=0);let p=()=>new T,g=new T,y=p(),m=p(),v=p(),x,b,S,w,E,A,P,M,C=p(),O=p(),L=p(),D=p(),B=p(),k=p(),F=p(),H=p(),G=r-2*l+.001,X=G/o,Y=Math.ceil(a*o),Z=Y+1,le=G/Y,j=-G/2,K=u+1,ee=2*Math.PI/u,re=Math.PI/2/d,te=.01,$=Math.min((1-h/100)*l,l-te),se=l-$,Se=0,W=2,Ae=d*W+W,xe=K*Ae/W,be=xe+K*Z,Ee=Math.max(0,K*(Z+Ae)),[De,Pe,Re]=[3,3,2].map(Te=>Array(Ee*Te).fill(0)),ze=[],_=s-l;function I(Te,mt){let gt=Math.PI/2;A=mt*le,M=2*Math.PI*(A%X)/X+gt,A+=j,P=Math.sin(M)*_,E=Math.cos(M)*_,t?Te.set(E,P,A):Te.set(E,A,P)}I(g,-1e-10),I(y,0),C.copy(g),I(g,1);let ie=g.distanceTo(y),de=f?0:se+$,ve=ie*Y+2*de,fe=$,et=ve-de;for(let Te=0;Te<=Y;Te++){I(m,Te),H.subVectors(m,C).normalize(),C.copy(m),k.copy(m).setComponent(+t+1,0).normalize(),F.crossVectors(H,k).normalize();let mt=Te===0,gt=Te===Y,ct=mt?3*Math.PI/2:re,tt=mt?fe:et,rt=mt?K:be,Pt=mt?0:Ee-K,Ke=H.clone().multiplyScalar(mt?-se:se).add(m),vr=H.clone().multiplyScalar(mt?-1:1).normalize();for(let J=0;J<K;J++){let Ge=J*ee;if(O.addVectors(g.copy(k).multiplyScalar(l*Math.cos(Ge)),y.copy(F).multiplyScalar(l*Math.sin(Ge))),L.copy(O).normalize(),mt||gt){f||(Se=Pt+J,[0,1,2].forEach(ce=>{De[Se*3+ce]=Ke.getComponent(ce),Pe[Se*3+ce]=vr.getComponent(ce)}),Re[Se*2]=+gt,Re[Se*2+1]=J/u),y.copy(L).multiplyScalar($),v.addVectors(m,y);for(let ce=0;ce<d;ce++){let Fe=ce*re+ct;D.addVectors(g.copy(H).multiplyScalar(se*Math.sin(Fe)),y.copy(L).multiplyScalar(se*Math.cos(Fe))),B.copy(D).normalize(),y.addVectors(v,D),D.normalize(),Se=rt+ce*K+J,[0,1,2].forEach(Ct=>{De[Se*3+Ct]=y.getComponent(Ct),Pe[Se*3+Ct]=B.getComponent(Ct)});let He=+mt+Math.sin(Fe);Re[Se*2]=(tt+se*He)/ve,Re[Se*2+1]=J/u}}y.addVectors(m,O),Se=xe+Te*K+J,[0,1,2].forEach(ce=>{De[Se*3+ce]=y.getComponent(ce),Pe[Se*3+ce]=L.getComponent(ce)}),Re[Se*2]=(de+Te*ie)/ve,Re[Se*2+1]=J/u}}let Ue=Z+2*d+W,Oe=1,[Be,xt]=[+f,Ue-1];for(let Te=Be;Te<=xt-1;Te++){let mt=f&&Te===xt-1;for(let gt=0;gt<K-1;gt++)x=Te*K+gt,b=x+1,S=(mt?gt:x)+K,w=(mt?gt+1:b)+K,Te===0?ze.push(b,w,S):Te===Ue-2?ze.push(x,b,S):ze.push(x,b,S,b,w,S)}this.setIndex(ze),this.setAttribute("position",new Ie(De,3)),this.setAttribute("normal",new Ie(Pe,3)),this.setAttribute("uv",new Ie(Re,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,n=Array.from(this.getIndex().array),s,o,a,l,c=6*(e-1)*t.radialSegments,u=e,h=u===e;for(let d=0;d<t.radialSegments;d++)s=u*r+d,o=s+1,a=(h?d:s)+r,l=(h?d+1:o)+r,n[c++]=s,n[c++]=o,n[c++]=a,n[c++]=o,n[c++]=l,n[c++]=a;return n.length=c,CE.array=n,CE.count=n.length,CE}};var PI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:s,cornerSides:o}=i.parameters,a=n===0&&s!==0?new mm(t*.5,s,o):new ju(t*.5,n);return a.scale(1,e/t,r/t),Object.assign(a,{userData:{...i,type:"IcosahedronGeometry"}})}},mm=class extends Il{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,t,e,r),this.type=a}static fromJSON(t){return new mm(t.radius,t.corner,t.cornerSides)}};var DI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new oa;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let s=new zu(n.extractPoints(r).shape,e);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...i,type:"LatheGeometry"}})}};var Mo=new ue,_E=new Rt,N0=new T,Bl=class extends gr{constructor(){super(),this.uuid=_e.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new ut().getNormalMatrix(t);for(let r=0,n=this.vertices.length;r<n;r++)this.vertices[r].applyMatrix4(t);for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];s.normal.applyMatrix3(e).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return Mo.makeRotationX(t),this.applyMatrix4(Mo),this}rotateY(t){return Mo.makeRotationY(t),this.applyMatrix4(Mo),this}rotateZ(t){return Mo.makeRotationZ(t),this.applyMatrix4(Mo),this}translate(t,e,r){return Mo.makeTranslation(t,e,r),this.applyMatrix4(Mo),this}scale(t,e,r){return Mo.makeScale(t,e,r),this.applyMatrix4(Mo),this}lookAt(t){return _E.lookAt(t),_E.updateMatrix(),this.applyMatrix4(_E.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,n=t.attributes;if(n.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=n.position,o=n.normal,a=n.color,l=n.uv,c=n.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)e.vertices.push(new T().fromBufferAttribute(s,d)),a!==void 0&&e.colors.push(new ke().fromBufferAttribute(a,d));function u(d,f,p,g){let y=a===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[p].clone()],m=o===void 0?[]:[new T().fromBufferAttribute(o,d),new T().fromBufferAttribute(o,f),new T().fromBufferAttribute(o,p)],v=new Pd(d,f,p,m,y,g);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new U().fromBufferAttribute(l,d),new U().fromBufferAttribute(l,f),new U().fromBufferAttribute(l,p)]),c!==void 0&&e.faceVertexUvs[1].push([new U().fromBufferAttribute(c,d),new U().fromBufferAttribute(c,f),new U().fromBufferAttribute(c,p)])}let h=t.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],p=f.start,g=f.count;for(let y=p,m=p+g;y<m;y+=3)r!==void 0?u(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)u(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<s.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(N0).negate(),this.translate(N0.x,N0.y,N0.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,n=new ue;return n.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(n),this}computeFaceNormals(){let t=new T,e=new T;for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,a),e.subVectors(o,a),t.cross(e),t.normalize(),s.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,n=this.vertices.length;r<n;r++)e[r]=new T;if(t){let r=new T,n=new T;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],u=this.vertices[a.c];r.subVectors(u,c),n.subVectors(l,c),r.cross(n),e[a.a].add(r),e[a.b].add(r),e[a.c].add(r)}}else{this.computeFaceNormals();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r];e[s.a].add(s.normal),e[s.b].add(s.normal),e[s.c].add(s.normal)}}for(let r=0,n=this.vertices.length;r<n;r++)e[r].normalize();for(let r=0,n=this.faces.length;r<n;r++){let s=this.faces[r],o=s.vertexNormals;o.length===3?(o[0].copy(e[s.a]),o[1].copy(e[s.b]),o[2].copy(e[s.c])):(o[0]=e[s.a].clone(),o[1]=e[s.b].clone(),o[2]=e[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],n=r.vertexNormals;n.length===3?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]);for(let s=0,o=n.vertexNormals.length;s<o;s++)n.__originalVertexNormals[s]?n.__originalVertexNormals[s].copy(n.vertexNormals[s]):n.__originalVertexNormals[s]=n.vertexNormals[s].clone()}let t=new Bl;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let s=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new T,u={a:new T,b:new T,c:new T};s.push(c),o.push(u)}}let n=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=n.faceNormals[s],c=n.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let n=this.faces[e];n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Or),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let n,s=this.vertices.length,o=this.vertices,a=t.vertices,l=this.faces,c=t.faces,u=this.colors,h=t.colors;e!==void 0&&(n=new ut().getNormalMatrix(e));for(let d=0,f=a.length;d<f;d++){let g=a[d].clone();e!==void 0&&g.applyMatrix4(e),o.push(g)}for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone());for(let d=0,f=c.length;d<f;d++){let p=c[d],g,y,m=p.vertexNormals,v=p.vertexColors,x=new Pd(p.a+s,p.b+s,p.c+s);x.normal.copy(p.normal),n!==void 0&&x.normal.applyMatrix3(n).normalize();for(let b=0,S=m.length;b<S;b++)g=m[b].clone(),n!==void 0&&g.applyMatrix3(n).normalize(),x.vertexNormals.push(g);x.color.copy(p.color);for(let b=0,S=v.length;b<S;b++)y=v[b],x.vertexColors.push(y.clone());x.materialIndex=p.materialIndex+r,l.push(x)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let g=0,y=p.length;g<y;g++){let m=p[g],v=[];for(let x=0,b=m.length;x<b;x++)v.push(m[x].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],n=[],s=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],h=Math.round(u.x*s)+"_"+Math.round(u.y*s)+"_"+Math.round(u.z*s);e[h]===void 0?(e[h]=l,r.push(this.vertices[l]),n[l]=r.length-1):n[l]=n[e[h]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=n[u.a],u.b=n[u.b],u.c=n[u.c];let h=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let u=0,h=this.faceVertexUvs.length;u<h;u++)this.faceVertexUvs[u].splice(c,1)}let a=this.vertices.length-r.length;return this.vertices=r,a}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let n=t[e];this.vertices.push(new T(n.x,n.y,n.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let n=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;n&&n.length===e&&(o=[]),s&&s.length===e&&(a=[]);for(let l=0;l<e;l++){let c=t[l]._id;o&&o.push(n[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let g in p)p[g]!==void 0&&(t[g]=p[g]);return t}let e=[];for(let p=0;p<this.vertices.length;p++){let g=this.vertices[p];e.push(g.x,g.y,g.z)}let r=[],n=[],s={},o=[],a={},l=[],c={};for(let p=0;p<this.faces.length;p++){let g=this.faces[p],y=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,x=g.normal.length()>0,b=g.vertexNormals.length>0,S=g.color.r!==1||g.color.g!==1||g.color.b!==1,w=g.vertexColors.length>0,E=0;if(E=u(E,0,0),E=u(E,1,y),E=u(E,2,m),E=u(E,3,v),E=u(E,4,x),E=u(E,5,b),E=u(E,6,S),E=u(E,7,w),r.push(E),r.push(g.a,g.b,g.c),r.push(g.materialIndex),v){let A=this.faceVertexUvs[0][p];r.push(f(A[0]),f(A[1]),f(A[2]))}if(x&&r.push(h(g.normal)),b){let A=g.vertexNormals;r.push(h(A[0]),h(A[1]),h(A[2]))}if(S&&r.push(d(g.color)),w){let A=g.vertexColors;r.push(d(A[0]),d(A[1]),d(A[2]))}}function u(p,g,y){return y?p|1<<g:p&~(1<<g)}function h(p){let g=p.x.toString()+p.y.toString()+p.z.toString();return s[g]!==void 0||(s[g]=n.length/3,n.push(p.x,p.y,p.z)),s[g]}function d(p){let g=p.r.toString()+p.g.toString()+p.b.toString();return a[g]!==void 0||(a[g]=o.length,o.push(p.getHex())),a[g]}function f(p){let g=p.x.toString()+p.y.toString();return c[g]!==void 0||(c[g]=l.length/2,l.push(p.x,p.y)),c[g]}return t.data={},t.data.vertices=e,t.data.normals=n,o.length>0&&(t.data.colors=o),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new Bl().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let n=t.faces;for(let d=0,f=n.length;d<f;d++)this.faces.push(n[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let p=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let g=0,y=p.length;g<y;g++){let m=p[g],v=[];for(let x=0,b=m.length;x<b;x++){let S=m[x];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=t.morphTargets;for(let d=0,f=s.length;d<f;d++){let p={};if(p.name=s[d].name,s[d].vertices!==void 0){p.vertices=[];for(let g=0,y=s[d].vertices.length;g<y;g++)p.vertices.push(s[d].vertices[g].clone())}if(s[d].normals!==void 0){p.normals=[];for(let g=0,y=s[d].normals.length;g<y;g++)p.normals.push(s[d].normals[g].clone())}this.morphTargets.push(p)}let o=t.morphNormals;for(let d=0,f=o.length;d<f;d++){let p={};if(o[d].vertexNormals!==void 0){p.vertexNormals=[];for(let g=0,y=o[d].vertexNormals.length;g<y;g++){let m=o[d].vertexNormals[g],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){p.faceNormals=[];for(let g=0,y=o[d].faceNormals.length;g<y;g++)p.faceNormals.push(o[d].faceNormals[g].clone())}this.morphNormals.push(p)}let a=t.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=t.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new PE().fromGeometry(this),e=new Ne,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",B0.call(new Ye(r,3),t.vertices)),t.normals.length>0){let n=new Float32Array(t.normals.length*3);e.setAttribute("normal",B0.call(new Ye(n,3),t.normals))}if(t.colors.length>0){let n=new Float32Array(t.colors.length*3);e.setAttribute("color",OI.call(new Ye(n,3),t.colors))}if(t.uvs.length>0){let n=new Float32Array(t.uvs.length*2);e.setAttribute("uv",II.call(new Ye(n,2),t.uvs))}if(t.uvs2.length>0){let n=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",II.call(new Ye(n,2),t.uvs2))}e.groups=t.groups;for(let n in t.morphTargets){let s=[],o=t.morphTargets[n];for(let a=0,l=o.length;a<l;a++){let c=o[a],u=new Ie(c.data.length*3,3);u.name=c.name,s.push(B0.call(u,c.data))}e.morphAttributes[n]=s}if(t.skinIndices.length>0){let n=new Ie(t.skinIndices.length*4,4);e.setAttribute("skinIndex",RI.call(n,t.skinIndices))}if(t.skinWeights.length>0){let n=new Ie(t.skinWeights.length*4,4);e.setAttribute("skinWeight",RI.call(n,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new Ne,r=t.geometry;if(t.isPoints||t.isLine){let n=new Ie(r.vertices.length*3,3),s=new Ie(r.colors.length*3,3);if(e.setAttribute("position",B0.call(n,r.vertices)),e.setAttribute("color",OI.call(s,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let o=new Ie(r.lineDistances.length,1);e.setAttribute("lineDistance",GY.call(o,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};Bl.prototype.isGeometry=!0;var PE=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,n,s,o=t.faces;for(n=0;n<o.length;n++){let a=o[n];a.materialIndex!==s&&(s=a.materialIndex,r!==void 0&&(r.count=n*3-r.start,e.push(r)),r={start:n*3,materialIndex:s})}r!==void 0&&(r.count=n*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,n=t.faceVertexUvs,s=n[0]&&n[0].length>0,o=n[1]&&n[1].length>0,a=t.morphTargets,l=a.length,c;if(l>0){c=[];for(let m=0;m<l;m++)c[m]={name:a[m].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,h=u.length,d;if(h>0){d=[];for(let m=0;m<h;m++)d[m]={name:u[m].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,p=t.skinWeights,g=f.length===r.length,y=p.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<e.length;m++){let v=e[m];this.vertices.push(r[v.a],r[v.b],r[v.c]);let x=v.vertexNormals;if(x.length===3)this.normals.push(x[0],x[1],x[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=n[0][m];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new U,new U,new U))}if(o===!0){let S=n[1][m];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new U,new U,new U))}for(let S=0;S<l;S++){let w=a[S].vertices;c[S].data.push(w[v.a],w[v.b],w[v.c])}for(let S=0;S<h;S++){let w=u[S].vertexNormals[m];d[S].data.push(w.a,w.b,w.c)}g&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Pd=class{constructor(t,e,r,n,s,o=0){this.a=t,this.b=e,this.c=r,this.normal=n&&n.isVector3?n:new T,this.vertexNormals=Array.isArray(n)?n:[],this.color=s&&s.isColor?s:new ke,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function GY(i){return this.array.set(i),this}function OI(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),s=new ke),t[e++]=s.r,t[e++]=s.g,t[e++]=s.b}return this}function II(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),s=new U),t[e++]=s.x,t[e++]=s.y}return this}function B0(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),s=new T),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z}return this}function RI(i){let t=this.array,e=0;for(let r=0,n=i.length;r<n;r++){let s=i[r];s===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),s=new Ze),t[e++]=s.x,t[e++]=s.y,t[e++]=s.z,t[e++]=s.w}return this}var HY=["a","b","c"];function jY(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function DE(i,t,e){let r=Math.min(i,t),n=Math.max(i,t),s=r+"_"+n;return e.get(s)}function OE(i,t,e,r,n,s){let o=Math.min(i,t),a=Math.max(i,t),l=o+"_"+a,c;if(r.has(l))c=r.get(l);else{let u=e[o],h=e[a];c={a:u,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(n),s[i].edges.push(c),s[t].edges.push(c)}function WY(i,t,e,r){let n,s,o;for(n=0,s=i.length;n<s;n++)e[n]={edges:[]};for(n=0,s=t.length;n<s;n++)o=t[n],OE(o.a,o.b,i,r,o,e),OE(o.b,o.c,i,r,o,e),OE(o.c,o.a,i,r,o,e)}function F0(i,t,e,r,n){i.push(new Pd(t,e,r,void 0,void 0,n))}function Dd(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function U0(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var V0=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Ne?t=new Bl().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new T,r,n,s,o,a,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],h=u!==void 0&&u.length>0,d=[],f=new Map;WY(l,c,d,f);let p=[],g,y,m,v,x,b,S;for(let te of Array.from(f.keys())){for(y=f.get(te),m=new T,x=3/8,b=1/8,S=y.faces.length,S!=2&&(x=.5,b=0,S!=1),m.addVectors(y.a,y.b).multiplyScalar(x),e.set(0,0,0),o=0;o<S;o++){for(v=y.faces[o],a=0;a<3&&(g=l[jY(v,HY[a])],!(g!==y.a&&g!==y.b));a++);g&&e.add(g)}e.multiplyScalar(b),m.add(e),y.newEdge=p.length,p.push(m)}let w,E,A,P,M,C,O,L=[];for(n=0,s=l.length;n<s;n++){for(C=l[n],M=d[n].edges,r=M.length,r==3?w=3/16:r>3&&(w=3/(8*r)),E=1-r*Number(w),A=w,r<=2&&(r==2?(E=3/4,A=1/8):r==1||r==0),O=C.clone().multiplyScalar(E),e.set(0,0,0),o=0;o<r;o++)P=M[o],g=P.a!==C?P.a:P.b,e.add(g);e.multiplyScalar(Number(A)),O.add(e),L.push(O)}let D=L.concat(p),B=L.length,k,F,H,G=[],X=[],Y,Z,le,j,K=new U,ee=new U,re=new U;for(n=0,s=c.length;n<s;n++)v=c[n],k=Number(DE(v.a,v.b,f).newEdge)+B,F=Number(DE(v.b,v.c,f).newEdge)+B,H=Number(DE(v.c,v.a,f).newEdge)+B,F0(G,k,F,H,v.materialIndex),F0(G,v.a,k,H,v.materialIndex),F0(G,v.b,F,k,v.materialIndex),F0(G,v.c,H,F,v.materialIndex),h&&(Y=u[n],Z=Y[0],le=Y[1],j=Y[2],K.set(Dd(Z.x,le.x),Dd(Z.y,le.y)),ee.set(Dd(le.x,j.x),Dd(le.y,j.y)),re.set(Dd(Z.x,j.x),Dd(Z.y,j.y)),U0(X,K,ee,re),U0(X,Z,K,re),U0(X,le,ee,K),U0(X,j,re,ee));t.vertices=D,t.faces=G,h&&(t.faceVertexUvs[0]=X)}};var Pi=new T,LI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ne().copy(new mi(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Pi),r={width:Pi.x,height:Pi.y,depth:Pi.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,s=i.geometry??new Ne().copy(new mi(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(Pi)):Pi.set(o.width,o.height,o.depth),(t!==Pi.x||e!==Pi.y||r!==Pi.z)&&s.scale(Pi.x===0?1:t/Pi.x,Pi.y===0?1:e/Pi.y,Pi.z===0?1:r/Pi.z);let a=s.originalGeometry;try{n>0?(a===void 0||o?.subdivisions!==n)&&(a===void 0&&(a=s),s=new V0(n).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals())}catch{a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()}return a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Ju(e).load(i,n=>{let s=this.normalizeInputs({geometry:n});n.boundingBox.getSize(Pi);let o=100/Pi.x;Object.assign(s.parameters,{width:100,height:Pi.y*o,depth:Pi.z*o}),t(this.build(s))})}};var z0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=i.parameters,l=i.shape,c=t*.5,u=e*.5,h=0,d=0,f=2*Math.PI/r;for(let g=0;g<r;g++){let y=f*g,m=h+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(m,v))}l.isClosed=!0;for(let g=0,y=l.points.length;g<y;g++)l.points[g].roundness=n;l.roundness=n,l.update();let p=Ln.create({shape:l,parameters:{roundness:n,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"PolygonGeometry"}})}};var NI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=i.parameters,c=new RE(t*.5,e,n,s,o,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function gm(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function IE(i,t,e,r,n,s){let o=t.clone().sub(i),a=e.clone().sub(i),l=o.angleTo(a);if(o.normalize(),a.normalize(),r===n){let c=o.add(a).normalize();s.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(i),s.addScaledVector(o,n/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function qY(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var RE=class extends Ne{constructor(t=.5,e=1,r=4,n=1,s=!1,o=0,a=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),a=Math.floor(a);let l=[],c=[],u=[],h=[],d=0,f=e/2,p=Math.PI/r,g=t*Math.cos(Math.PI/r),y=2*Math.PI/r,m=(r-2)*Math.PI/r,v=Math.PI-m,x=new T(0,-f,0),b=new T(0,f,0),S=new U(t,-f),w=new U(g,-f),E=new U(0,b.y).sub(w),A=new U(0,b.y).sub(S),P=new U(E.y,-E.x).normalize(),M=new U(A.y,-A.x).normalize(),O=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-E.angle())/2)-1e-8;o=Math.min(o,O);let L;{let X=new T(P.x,P.y,0),Y=new T(Math.cos(y)*X.x,X.y,Math.sin(y)*X.x);L=X.angleTo(Y)}let D=o/Math.tan((Math.PI-E.angle())/2),B=o/Math.tan((Math.PI-L)/2),k=new T;if(!s){c.push(x.x,x.y,x.z),u.push(0,-1,0),h.push(0,0);let X=d++,Y=[],Z=S.clone(),le=D/Math.cos(Math.PI/r);Z.x-=le;for(let j=0;j<r;j++){let K=j/r*Math.PI*2+p,ee=new U(Math.sin(K),Math.cos(K));gm(Z,ee,k),c.push(k.x,k.y,k.z),u.push(0,-1,0),h.push(0,0),Y.push(d++)}for(let j=0;j<Y.length;j++)l.push(Y[j],X,Y[(j+1)%Y.length])}let F=[];{let X=new T,Y=new T,Z=new T,le=new T,j=new T,K=new T;for(let ee=0;ee<r;ee++){let re=ee/r*Math.PI*2+p,te=(ee+.5)/r*Math.PI*2+p,$=(ee+1)/r*Math.PI*2+p,se=new U(Math.sin(re),Math.cos(re)),Se=new U(Math.sin(te),Math.cos(te)),W=new U(Math.sin($),Math.cos($));gm(S,se,Y),gm(S,W,Z),gm(P,Se,X),IE(b,Y,Z,B,B,le),c.push(le.x,le.y,le.z),IE(Y,b,Z,B,D,j),c.push(j.x,j.y,j.z),IE(Z,Y,b,D,B,K),c.push(K.x,K.y,K.z),u.push(X.x,X.y,X.z),u.push(X.x,X.y,X.z),u.push(X.x,X.y,X.z),h.push(0,0),h.push(0,0),h.push(0,0);let Ae=d++,xe=d++,be=d++;if(l.push(Ae,xe,be),o>0){{let Pe=Y.clone().add(Z).multiplyScalar(.5),Re=b.clone().sub(Pe).normalize(),_=x.clone().sub(Pe).normalize().add(Re).normalize().multiplyScalar(-1),I=K.clone().sub(j);H(Pe,I,_,E.angle())}let Ee,De;{let Pe=new T;gm(M,W,Pe);let Re=K.clone().add(le).multiplyScalar(.5);Re=qY(Re,Z,b);let ze=K.clone().sub(le);[Ee,De]=H(Re,ze,Pe,L,le.y)}{let Pe=Ee,Re=Pe.clone().setY(0).normalize(),ze=new T(0,-1,0),_=Re.clone().cross(ze);G(Pe,Re,ze,_)}F.concat(De);{let Pe=E.angle(),Re=Math.PI-Pe,ze=b.clone();ze.y-=o/Math.sin(Pe-Math.PI/2);let _=new T,I=[];for(let de=0;de<a;de++){let ve=[],fe=Math.PI/2-Re*de/a,et=Math.cos(fe),Ue=Math.sin(fe),Oe=te;for(let Be=0;Be<=de;Be++){let xt=Math.cos(Oe),Te=Math.sin(Oe);X.x=et*Te,X.y=Ue,X.z=et*xt,_.copy(ze).addScaledVector(X,o),c.push(_.x,_.y,_.z),u.push(X.x,X.y,X.z),h.push(0,0),ve.push(d++),Oe+=Math.PI*2/de/r}I.push(ve)}De.reverse(),I.push(De);let ie=I.length-1;for(let de=0;de<ie;de++){let ve=I[de],fe=I[de+1],et=ve.length-1;l.push(fe[1],ve[0],fe[0]);for(let Ue=1;Ue<=et;Ue++)l.push(ve[Ue],ve[Ue-1],fe[Ue]),l.push(fe[Ue+1],ve[Ue],fe[Ue])}}}}}this.setIndex(l),this.setAttribute("position",new Ie(c,3)),this.setAttribute("normal",new Ie(u,3)),this.setAttribute("uv",new Ie(h,2));function H(X,Y,Z,le,j){let K=-le/2,ee=(Math.PI-le)/2,re=Y.clone().normalize().cross(Z);X.addScaledVector(Z,-o/Math.sin(ee));let te=new T,$=new T,se=1,Se=d,W=[];for(let Ae=0;Ae<=a;Ae++){let xe=K+Ae/a*le;$.set(0,0,0),$.addScaledVector(re,Math.sin(xe)),$.addScaledVector(Z,Math.cos(xe));for(let be=0;be<=se;be++){let Ee=be/se-.5;if(te.copy(X),te.addScaledVector(Y,Ee),te.addScaledVector($,o),j!=null){let De=Math.max(0,te.y-j);te.addScaledVector(Y,-De/Y.y)}c.push(te.x,te.y,te.z),u.push($.x,$.y,$.z),h.push(0,0),be===0&&W.push(d),d++}}for(let Ae=0;Ae<a;Ae++)for(let xe=0;xe<se;xe++){let be=Se+xe+(se+1)*Ae,Ee=be+(se+1),De=Ee+1,Pe=be+1;l.push(be,Ee,Pe),l.push(Ee,De,Pe)}return[X.clone().addScaledVector(Y,.5),W]}function G(X,Y,Z,le){let j=Math.PI/2,K=A.angle()-j,ee=[],re=new T,te=new T;for(let se=0;se<=a;se++){let Se=[],W=se/a;for(let Ae=0;Ae<=se;Ae++){let be=((se?Ae/se:0)-.5)*v,Ee=Math.cos(be),De=Math.sin(be),Pe=Math.atan(Math.tan(K)*Ee),Re=(j+Pe)*W,ze=Math.cos(Re),_=Math.sin(Re);re.set(0,0,0),re.addScaledVector(Y,_*Ee),re.addScaledVector(Z,ze),re.addScaledVector(le,_*De),te.copy(X).addScaledVector(re,o),c.push(te.x,te.y,te.z),u.push(re.x,re.y,re.z),h.push(0,0),Se.push(d++)}ee.push(Se)}let $=ee.length-1;for(let se=0;se<$;se++){let Se=ee[se],W=ee[se+1],Ae=Se.length-1;l.push(Se[0],W[1],W[0]);for(let xe=1;xe<=Ae;xe++)l.push(Se[xe-1],Se[xe],W[xe]),l.push(Se[xe],W[xe+1],W[xe])}}}};var Od=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},h={x:c.x,y:c.y};function d(b,S,w){return S>e&&w>r?Math.min(b*e/S,b*r/w):S>e?b*e/S:w>r?b*r/w:b}let f=[];f[0]=n[0]===0?0:d(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:d(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:d(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:d(n[3],n[3]+n[0],n[3]+n[2]);let p=u.x,g=h.x,y=h.y,m=u.y;t.addPoint(t.createPoint(p,y)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(p,m)),t.isClosed=!0;let v=!0;for(let b=0,S=t.points.length;b<S;b++)t.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=s!==1,t.update();let x=Ln.create({shape:t,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...i,type:"RectangleGeometry"}})}};var BI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=_e.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new Ne,u.setAttribute("position",new Ie([],3))):u=new Ls(.5*t,n,s,o,a,l,c*_e.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};var FI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,s=new sn(t,e,r,n);return s.scale(1,1,1),Object.assign(s,{userData:{...i,type:"PlaneGeometry"}})}};var UI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:s,cornerSegments:o}=i.parameters,a=new LE(t,e,r,n,s,o);return Object.assign(a,{userData:{...i,type:"BackdropGeometry"}})}},LE=class extends Ne{constructor(t=1,e=1,r=1,n=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],u=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),n=Math.min(180-u,n),n*=Math.PI/180;let h=[],d=Math.PI/2,f=(te=0,$=0,se=0)=>new T(te,$,se),p=f(),g=f(),[y,m,v]=[e/2,t/2,r/2],x=-m,b=+m,[S,w,E]=[f(x,-y,+v),f(x,-y,-v),f(x,+y,-v)],A=(te,$=!1)=>Math.sin(te-Math.PI/(1+ +$)),P=(te,$=!1)=>Math.cos(te-Math.PI/(1+ +$));E.y=Math.sin(n)*e-y;let M=Math.cos(n)*e-v,C=S.z-u;n<=d?(E.z=Math.min(M,C),E.z==C&&(E.y-=(M-C)/Math.tan(d-n))):w.z=Math.min(w.z-M-v,S.z-u),p.subVectors(S,w),g.subVectors(E,w);let O=Math.min(p.length(),g.length())*s/100,L=O*Math.tan(n/2),D=O/Math.cos(n/2),B=p.clone().normalize().add(g.normalize()).setLength(D).add(w);p.set(0,A(n,!0),P(n,!0)),h.push([E,p.clone()]);let k=(Math.PI-n)/o;for(let te=0;te<=o;te++){let $=d+n+te*k;p.set(0,Math.sin($)*L,Math.cos($)*L),p.add(B),g.set(0,A($),P($)),h.push([p.clone(),g.clone()])}h.push([S,f(0,1,0)]);let F=Math.sin(k/2)*L*2,H=h.length-1,G=h[0][0].distanceTo(h[1][0]),X=h[H-1][0].distanceTo(h[H][0]),Y=G+F*o+X;h[0].push(1);for(let te=0;te<=o;te++)h[te+1].push(1-(G+te*F)/Y);h[H].push(0);let[Z,le,j]=h[0],K,ee,re;for(let te=1;te<h.length;te++)[K,ee,re]=h[te],a.push(x,Z.y,Z.z,x,K.y,K.z,b,Z.y,Z.z,b,Z.y,Z.z,x,K.y,K.z,b,K.y,K.z),l.push(0,le.y,le.z,0,ee.y,ee.z,0,le.y,le.z,0,le.y,le.z,0,ee.y,ee.z,0,ee.y,ee.z),c.push(0,j,0,re,1,j,1,j,0,re,1,re),[Z,le,j]=[K,ee,re];this.setAttribute("position",new Ie(a,3)),this.setAttribute("normal",new Ie(l,3)),this.setAttribute("uv",new Ie(c,2))}};var k0=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,h=t*.5,d=e*.5,f=0,p=0,g=o*Math.PI/360/n,y=Math.PI/2*3*-1,m=h*r/100,v=d*r/100;if(n===3&&r===50){g=2*Math.PI/n;for(let b=0;b<n;b++){let S=g*b,w=f+Math.sin(S)*h,E=p+Math.cos(S)*d;u.addPoint(u.createPoint(w,E))}}else for(let b=0;b<n;b++){let S=f+Math.cos(y)*h,w=p+Math.sin(y)*d;u.addPoint(u.createPoint(S,w)),y+=g,S=f+Math.cos(y)*m,w=p+Math.sin(y)*v,b<=n,u.addPoint(u.createPoint(S,w)),y+=g}u.isClosed=!0;for(let b=0,S=u.points.length;b<S;b++)u.points[b].roundness=s;u.roundness=s,u.update();let x=Ln.create({shape:u,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(x,{userData:{...i,type:"StarGeometry"}})}};var VI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new sn(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var zI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:s})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=i.parameters,c=XY(t,e,r,t*.5,o,s,0,0,n,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function XY(i,t,e,r,n,s,o,a,l,c,u){[t,e]=[e,t],o=t/2;let h=_e.clamp(n/360,0,1);if(h===0){let d=new Ne;return d.setAttribute("position",new Ie([],3)),d}return h===1&&(c=0),new pm(!0,i,t,e,r,h,s,o,a,l,c,u)}var kI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:s,q:o}=i.parameters,a=t*.5;a!==e&&(a-=e);let l=new qu(a,e,r,n,s,o);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var GI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Yt?i.shape:new Yt,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=i.parameters,l=i.shape,c=t*.5,u=e*.5;a?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=Ln.create({shape:l,parameters:{roundness:r,depth:n,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...i,type:"TriangleGeometry"}})}};function HI(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var NE=class{add(t,e,r){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(n){this[n]=this[n]||[],e&&this[n][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},BE=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},ye=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ye.version}static addUnaryOp(t){return ye.max_unop_len=Math.max(t.length,ye.max_unop_len),ye.unary_ops[t]=1,ye}static addBinaryOp(t,e,r){return ye.max_binop_len=Math.max(t.length,ye.max_binop_len),ye.binary_ops[t]=e,r?ye.right_associative.add(t):ye.right_associative.delete(t),ye}static addIdentifierChar(t){return ye.additional_identifier_chars.add(t),ye}static addLiteral(t,e){return ye.literals[t]=e,ye}static removeUnaryOp(t){return delete ye.unary_ops[t],t.length===ye.max_unop_len&&(ye.max_unop_len=ye.getMaxKeyLen(ye.unary_ops)),ye}static removeAllUnaryOps(){return ye.unary_ops={},ye.max_unop_len=0,ye}static removeIdentifierChar(t){return ye.additional_identifier_chars.delete(t),ye}static removeBinaryOp(t){return delete ye.binary_ops[t],t.length===ye.max_binop_len&&(ye.max_binop_len=ye.getMaxKeyLen(ye.binary_ops)),ye.right_associative.delete(t),ye}static removeAllBinaryOps(){return ye.binary_ops={},ye.max_binop_len=0,ye}static removeLiteral(t){return delete ye.literals[t],ye}static removeAllLiterals(){return ye.literals={},ye}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new ye(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return ye.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ye.binary_ops[String.fromCharCode(t)]||ye.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return ye.isIdentifierStart(t)||ye.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(ye.hooks[t]){let r={context:this,node:e};return ye.hooks.run(t,r),r.node}return e}searchHook(t){if(ye.hooks[t]){let e={context:this};return ye.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===ye.SPACE_CODE||t===ye.TAB_CODE||t===ye.LF_CODE||t===ye.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:ye.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index<this.expr.length;)if(r=this.code,r===ye.SEMCOL_CODE||r===ye.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())e.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,ye.max_binop_len),e=t.length;for(;e>0;){if(ye.binary_ops.hasOwnProperty(t)&&(!ye.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ye.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,n,s,o,a,l,c;if(o=this.gobbleToken(),!o||(e=this.gobbleBinaryOp(),!e))return o;for(s={value:e,prec:ye.binaryPrecedence(e),right_a:ye.right_associative.has(e)},a=this.gobbleToken(),a||this.throwError("Expected expression after "+e),n=[o,s,a];e=this.gobbleBinaryOp();){if(r=ye.binaryPrecedence(e),r===0){this.index-=e.length;break}s={value:e,prec:r,right_a:ye.right_associative.has(e)},c=e;let u=h=>s.right_a&&h.right_a?r>h.prec:r<=h.prec;for(;n.length>2&&u(n[n.length-2]);)a=n.pop(),e=n.pop().value,o=n.pop(),t={type:ye.BINARY_EXP,operator:e,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),n.push(s,t)}for(l=n.length-1,t=n[l];l>1;)t={type:ye.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,ye.isDecimalDigit(t)||t===ye.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===ye.SQUOTE_CODE||t===ye.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===ye.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,ye.max_unop_len),r=e.length;r>0;){if(ye.unary_ops.hasOwnProperty(e)&&(!ye.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ye.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ye.UNARY_EXP,operator:e,argument:s,prefix:!0})}e=e.substr(0,--r)}ye.isIdentifierStart(t)?(n=this.gobbleIdentifier(),ye.literals.hasOwnProperty(n.name)?n={type:ye.LITERAL,value:ye.literals[n.name],raw:n.name}:n.name===ye.this_str&&(n={type:ye.THIS_EXP})):t===ye.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===ye.PERIOD_CODE||e===ye.OBRACK_CODE||e===ye.OPAREN_CODE||e===ye.QUMARK_CODE;){let r;if(e===ye.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ye.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===ye.OBRACK_CODE?(t={type:ye.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==ye.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===ye.OPAREN_CODE?t={type:ye.CALL_EXP,arguments:this.gobbleArguments(ye.CPAREN_CODE),callee:t}:(e===ye.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:ye.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;ye.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===ye.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);ye.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));ye.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);ye.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,ye.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===ye.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===ye.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ye.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===r){n=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":t+=`
3801
3801
  `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=s}else t+=s}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:ye.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(ye.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,ye.isIdentifierPart(t));)this.index++;return{type:ye.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===t){r=!0,this.index++,t===ye.CPAREN_CODE&&n&&n>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(s===ye.COMMA_CODE){if(this.index++,n++,n!==e.length){if(t===ye.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ye.CBRACK_CODE)for(let o=e.length;o<n;o++)e.push(null)}}else if(e.length!==n&&n!==0)this.throwError("Expected comma");else{let o=this.gobbleExpression();(!o||o.type===ye.COMPOUND)&&this.throwError("Expected comma"),e.push(o)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(ye.CPAREN_CODE);if(this.code===ye.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:ye.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ye.ARRAY_EXP,elements:this.gobbleArguments(ye.CBRACK_CODE)}}},YY=new NE;Object.assign(ye,{hooks:YY,plugins:new BE(ye),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"});ye.max_unop_len=ye.getMaxKeyLen(ye.unary_ops);ye.max_binop_len=ye.getMaxKeyLen(ye.binary_ops);var Vc=i=>new ye(i).parse(),KY=Object.getOwnPropertyNames(ye);KY.forEach(i=>{Vc[i]===void 0&&i!=="prototype"&&(Vc[i]=ye[i])});Vc.Jsep=ye;var QY="ConditionalExpression",ZY={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let r=e.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),e.node={type:QY,test:r,consequent:n,alternate:s},r.operator&&i.binary_ops[r.operator]<=.9){let o=r;for(;o.right.operator&&i.binary_ops[o.right.operator]<=.9;)o=o.right;e.node.test=o.right,o.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};Vc.plugins.register(ZY);var JY=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],$Y=["0","1","2","3","4","5","6","7","8","9","."],e9=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function t9(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}Vc.addBinaryOp("^",11,!0);function G0(i,t,e="number"){let r="";for(let o=0;o<i.length;o++){let a=i[o];if("id"in a){let l=i[o-1];if(o>0&&"id"in l){console.error("Two variables in a row",i);return}let c=t.getVariable(a.id),u=ki.getDisplayedValue(c);e==="number"&&ki.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?u=parseFloat(u).toString():e==="boolean"&&ki.isBoolean(c)?u=c?"true":"false":e==="boolean"&&ki.isTextValue(c)&&!Array.isArray(c.textValue)&&(u='"'+u+'"'),r+=u;continue}else if(e==="string"){a.name!=='"'&&a.name!=="+"&&(r+=a.name),a.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+a.name);continue}if(a.name==="and"){r+="&&";continue}if(a.name==="or"){r+="||";continue}if(a.name==="True"){r+="true";continue}if(a.name==="False"){r+="false";continue}if(e==="boolean"&&!t9(a.name)&&!$Y.includes(a.name)&&!JY.includes(a.name)&&!e9.includes(a.name.replace(/\($/g,""))){r+='"'+a.name+'"';continue}r+=a.name}if(e==="string")return r;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let n;try{n=Vc(r)}catch(o){console.error(r,o);return}let s;try{s=qt(n)}catch(o){console.error(r,n,o)}return s}function qt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(qt(i.left)===qt(i.right));case"!=":return Number(qt(i.left)!==qt(i.right));case">":return Number(qt(i.left)>qt(i.right));case">=":return Number(qt(i.left)>=qt(i.right));case"<":return Number(qt(i.left)<qt(i.right));case"<=":return Number(qt(i.left)<=qt(i.right));case"+":return qt(i.left)+qt(i.right);case"-":return qt(i.left)-qt(i.right);case"*":return qt(i.left)*qt(i.right);case"/":return qt(i.left)/qt(i.right);case"%":return qt(i.left)%qt(i.right);case"&&":return qt(i.left)&&qt(i.right);case"||":return qt(i.left)||qt(i.right);case"^":return Math.pow(qt(i.left),qt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-qt(i.argument);case"!":return Number(!qt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=qt(i.arguments[0])}catch(r){console.warn(r)}if(i.arguments.length>=2)try{e=qt(i.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(qt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var r9=new ue,i9=new ue;function n9(i,t,e){let r=[new T,new T,new T],n=[new T,new T,new T];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((s,o)=>{let a=n[o],l=_e.lerp(s.length(),a.length(),e);s.lerp(a,e).setLength(l)}),new ue().makeBasis(r[0],r[1],r[2])}var jI=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),s=Math.abs(e.depth??0),o=t?.shapeData??_d.create({parameters:CA}).userData.shape;return{path:i.path??qh.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:s,extrusion:{...$v,...e.extrusion}}),shapeData:o}}static build(i){if(i.path.points.length>=2){let e=new FE(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ne,{userData:{...i,type:"PathGeometry"}})}},FE=class extends Ne{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)||!HI(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:n,offset:s}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),s=Math.max(0,Math.min(s,1));let o=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(s*o),l=this.inputs.path.isClosed?Math.ceil((n+s)*o):Math.ceil(Math.min(1,n+s)*o),c=Math.min(Math.max(2,l-a+1),o+2),u=[],h=[];for(let G=0;G<c;G++){let X=this.inputs.path.isClosed?(G+a)%e.length:Math.min(G+a,e.length-1);u.push(e[X].clone()),h.push(r[X].clone())}let d=(G,X,Y)=>{u[G]=u[G].clone().lerp(u[X],Y),h[G]=n9(h[G],h[X],Y)},f=0,p=s*o%1;(!this.inputs.path.isClosed||n<=1)&&(p||s===0)&&(f=p,d(0,1,f));let g=0,y=(s+n)*o%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&s+n<1)&&y&&(g=y,d(u.length-1,u.length-2,1-g)),n===0){let G=u.length-1;u[G].copy(u[0]),h[G].copy(h[0])}this._applyPathModifiers(h,f,g);let{bevel:m,bevelSides:v}=this.inputs.parameters.extrusion,x=m>0?this.inputs.parameters.extrusion.capType:"flat",b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:w,vertices:E}=this._computeShapePoints(b),A=0,P;x==="round"&&(P=new Nl(this.inputs.shapeData,2*m,m,b,v,void 0,!0),A=P.getAttribute("position").count);let M=0,C=0;w.sort((G,X)=>G.start-X.start),w.forEach(G=>{G.verticesStart=M,G.verticesCount=G.continuous.reduce((X,Y,Z)=>X+(Z===0||!Y?2:1),0),C+=G.verticesCount,M=C});let O=C*c,L,D=0;if(this._isOpenEnded()&&x==="flat"){try{L=js({windingRule:jt.ODD,elementType:jr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{L=ME}D=L.vertexCount}let B=O+2*D+A*2,k=O+2*D,F={positions:new Float32Array(B*3),normals:new Float32Array(B*3),uvs:new Float32Array(B*2)},H=[];if(w.forEach(G=>{this._extrudeRegion(G,E,h,u,F,H,this._isGeometryClosed()&&!this._isOpenEnded())}),L&&(this._closeEnd(L,O,H,F,h[0],u[0],!1),this._closeEnd(L,O+D,H,F,h[h.length-1],u[u.length-1],!0)),P){F.positions.set(P.getAttribute("position").array,k*3),F.normals.set(P.getAttribute("normal").array,k*3),F.uvs.set(P.getAttribute("uv").array,k*2);for(let Z=k;Z<k+A;Z++)F.uvs[Z*2+1]=1e-4;let G=H.length;H.push(...P.getIndex().array.map(Z=>Z+k)),k+=A,F.positions.set(P.getAttribute("position").array,k*3),F.normals.set(P.getAttribute("normal").array,k*3),F.uvs.set(P.getAttribute("uv").array,k*2);let X=H.length;H.push(...P.getIndex().array.map(Z=>Z+k)),this.setAttribute("position",new Ye(F.positions,3)),this.setAttribute("normal",new Ye(F.normals,3)),this.setAttribute("uv",new Ye(F.uvs,2)),this.setIndex(H);let Y=r9;Y.copy(h[h.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(Y,k,B),Y.copy(h[0]).setPosition(u[0]).multiply(i9.makeScale(1,1,-1)),this.applyMatrix4OnRange(Y,k-A,k),this.reverseIndicesOnRange(G,X)}else this.setAttribute("position",new Ye(F.positions,3)),this.setAttribute("normal",new Ye(F.normals,3)),this.setAttribute("uv",new Ye(F.uvs,2)),this.setIndex(H)}_extractPathPoints(){let r=_0(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let n=[r[0]];return r.forEach(o=>{n[n.length-1].distanceToSquared(o)>.001&&n.push(o)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],n=e.length,s=this.inputs.path.isClosed,o=new T,a=new T,l=new T,c=new T,u=new T(0,1,0);for(let y=0;y<n;y++){let m=e[y],v;y===0?v=s?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let x;y===n-1?x=s?e[1]:m.clone().multiplyScalar(2).sub(e[y-1]):x=e[y+1];let b=m.clone().sub(v).normalize(),S=x.clone().sub(m).normalize(),w=b.clone().add(S).normalize();l.copy(w),y===0&&(w.equals(u)||w.clone().negate().equals(u))&&u.set(0,0,1);let E=u.clone().cross(w).normalize(),A=w.clone().cross(E).normalize();u.copy(A),c.copy(E),y===0&&(o.copy(A),a.copy(w));let P=new ue().makeBasis(E,A,w);r.push(P)}let h=s?a:l,d=s?o:new T(0,1,0),f=h.clone().cross(c).normalize(),p=Math.acos(d.dot(f));if(isNaN(p))return r;let g=d.clone().cross(f);h.dot(g)>0&&(p*=-1);for(let y=1;y<r.length;y++){let m=new ue().makeRotationZ(p*y/r.length);r[y].multiply(m)}return r}_applyPathModifiers(e,r,n){let s=e.length,{angle:o,twist:a,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new ue,h=new ue;return e.forEach((d,f)=>{let p=f===0?0:f===s-1?1:(f-r)/(s-(n===0?0:1)-(r+(1-n)));u.makeRotationZ(_e.lerp(o,o+a,p)*_e.DEG2RAD);let g=_e.lerp(l,c,p);h.makeScale(g,g,g),d.multiply(u).multiply(h)}),e}_computeShapePoints(e=12,r=jt.ODD){let n=this.inputs.shapeData,s=n.extractShapePointsToFlatArray([],e),o=n.shapeHoles.map(g=>{let y=g.extractShapePointsToFlatArray([],e),m=[];for(let v=y.length-1;v>=1;v-=2){let x=y[v-1],b=y[v-0];m.push(x,b)}return m}),a;try{a=js({windingRule:r,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]})}catch{a=fm}let l;try{l=js({windingRule:jt.ODD,elementType:jr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]})}catch{l=TE}if(!a)throw new Error("error generating geometry");let c=a.elementCount;if(l){a.elementCount+=l.elementCount;for(let g=0;g<l.elements.length;g++){let y=l.elements[g],m=g%2===0?a.vertexCount:0;a.elements.push(y+m)}for(let g=0;g<l.vertexIndices.length;g++){let y=l.vertexIndices[g],m=a.vertexCount;a.vertexIndices.push(y+m)}for(let g=0;g<l.vertices.length;g++){let y=l.vertices[g];a.vertices.push(y)}}let u=1/0,h=-1/0,d=1/0,f=-1/0;for(let g=0,y=a.vertexCount;g<y;g++){let m=g*2,v=a.vertices[m+0],x=a.vertices[m+1];v<u&&(u=v),v>h&&(h=v),x<d&&(d=x),x>f&&(f=x)}let p=[];for(let g=a.elementCount-1;g>=0;g--){let y=g>=c,m=g*2,v=a.elements[m+0],x=a.elements[m+1],b=v+x,S={start:v,count:x,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};p.push(S);let w=v,E=b-1,A=v+1,P=n.roundedCurves.length;do{let M=w-v,C=a.vertices[E*2+0],O=a.vertices[E*2+1],L=a.vertices[w*2+0],D=a.vertices[w*2+1],B=a.vertices[A*2+0],k=a.vertices[A*2+1],F=L-C,H=D-O,G=Math.sqrt(F*F+H*H);F/=G,H/=G;let X=L-B,Y=D-k,Z=Math.sqrt(X*X+Y*Y);X/=Z,Y/=Z,S.normals[M*2+0]=-Y,S.normals[M*2+1]=X;let le=a.vertexIndices[w];if(Array.isArray(le))S.continuous[M]=!1;else{let[j,K]=n.getCurveIndexFromVertexId(le-1,!0);if(K>0&&K<1)S.continuous[M]=!0;else{let ee=K===1?j+1:j-1;ee=(ee+P)%P;let re=K===1?0:1,te=n.roundedCurves[j].getTangent(K),$=n.roundedCurves[ee].getTangent(re);S.continuous[M]=te.dot($)>.95}}y&&(S.normals[M*2+0]*=-1,S.normals[M*2+1]*=-1),[E,w,A]=[w,A,A+1],A>=b&&(A-=x)}while(A!==v+1)}return{regions:[s,...o],infos:p,vertices:a.vertices}}_insertVertex(e,r,n,s,o){let a=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=s.x,e.normals[l+1]=s.y,e.normals[l+2]=s.z,e.uvs[a+0]=o.x,e.uvs[a+1]=o.y}_extrudeRegion(e,r,n,s,o,a,l){let c=new T,u=new T,h=new T,d=new T,f=new U;n.forEach((g,y)=>{let m=s[y],v=e.verticesStart*n.length+e.verticesCount*y;for(let x=0;x<e.count;x++){let b=(e.start+x)*2;if(c.set(r[b+0],r[b+1],0),h.copy(c).applyMatrix4(g).add(m),e.continuous[x])d.set(e.normals[x*2+0],e.normals[x*2+1],0);else{let S=x===0?(e.start+e.count-1)*2:b-2;u.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(g).normalize(),f.set(x===0?1:x/e.count,y/(n.length-1)),this._insertVertex(o,v,h,d,f),v++,!e.continuous[x]||x===0){if(x===0)d.set(e.normals[x*2+0],e.normals[x*2+1],0),f.set(0,y/(n.length-1));else{let S=x===e.count-1?e.start*2:b+2;u.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(g).normalize(),this._insertVertex(o,v,h,d,f),v++}}});let p=n.length-1;for(let g=0;g<p;g++){let y=e.verticesStart*n.length+e.verticesCount*g,m=e.verticesStart*n.length+e.verticesCount*(g+1),v=0;for(let x=0;x<e.count;x++){(!e.continuous[x]||x===0)&&v++;let b=x===e.count-1?0:v+1,S=y+v,w=y+b,E=m+b,A=m+v;e.isHole?a.push(S,E,w,S,A,E):a.push(S,w,E,S,E,A),v++}}}_closeEnd(e,r,n,s,o,a,l){let c=e.vertexCount,u=new T(0,0,l?-1:1).applyMatrix4(o),h=new T,d=new U;for(let p=0;p<c;p++){let g=2*p;h.set(e.vertices[g+0],e.vertices[g+1],0).applyMatrix4(o).add(a),this._insertVertex(s,r+p,h,u,d)}let f=e.elements;for(let p=0;p<e.elementCount;p++){let g=3*p,y=f[g+0]+r,m=f[g+(l?1:2)]+r,v=f[g+(l?2:1)]+r;n.push(y,m,v)}}applyMatrix4OnRange(e,r,n){let s=e.elements,o=new ut().getNormalMatrix(e).elements,a,l,c,u,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let f=h.array,p=d.array,g=h.itemSize;for(let y=r*g,m=n*g;y<m;y+=g){if(y===r)debugger;a=f[y+0],l=f[y+1],c=f[y+2],u=1/(s[3]*a+s[7]*l+s[11]*c+s[15]),f[y+0]=(s[0]*a+s[4]*l+s[8]*c+s[12])*u,f[y+1]=(s[1]*a+s[5]*l+s[9]*c+s[13])*u,f[y+2]=(s[2]*a+s[6]*l+s[10]*c+s[14])*u,a=p[y+0],l=p[y+1],c=p[y+2],p[y+0]=o[0]*a+o[3]*l+o[6]*c,p[y+1]=o[1]*a+o[4]*l+o[7]*c,p[y+2]=o[2]*a+o[5]*l+o[8]*c}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let n=this.index;if(n){for(let s=e;s<r;s+=3){let o=n.getX(s),a=n.getX(s+1),l=n.getX(s+2);n.setXYZ(s,l,a,o)}n.needsUpdate=!0}}};function WI(){let i=new Ne;return i.setAttribute("position",new Ye(new Float32Array([]),3)),i.setIndex(new Ye(new Uint16Array([]),1)),i}var o9=WI().attributes,a9=12,l9=1,Id=class extends Ne{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,o9),this.userData={parameters:e,type:"TextGeometry"};let n=r.getFont(e.font);n?.isLoaded?(this.font=n,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let n=r.getFont(e);n&&(this.font=n,await n.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:c,textTransform:u}=e,h=ki.getDisplayedValue(c),d=u===2?h.toUpperCase():u===3?h.toLowerCase():h,f=c9(e,r,d),{shapes:p,charWidths:g,charCoords:y}=r.generateShapes(f,e),m=(typeof n=="number"?n:1)*.5,v=(typeof s=="number"?s:1)*.5,x=p.map(w=>new Yt().fromShape(w,!0));this.vectorShapes=x;let b=x.map(w=>Ln.create({shape:w,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?jt.NONZERO:jt.ODD,subdivisions:this.isLowResolution&&o>0?l9:a9}})),S=b.length?zs(b):WI();S.translate(-m,v,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([w,E])=>{this.setAttribute(w,E)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=yn(new Ne,Id.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,n])=>{this.setAttribute(r,n)}),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 c9(i,t,e){let r=[""],n="";for(let s of e)n+=s,s===" "||s===`
3802
3802
  `?(r[r.length-1]+=n,n="",s===`
3803
- `&&r.push("")):t.getTextWidth(r[r.length-1]+n,i)>i.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+n,i)>i.width&&(n.length===1?(r[r.length-1]+=n,n=""):(r[r.length-1]+=n.slice(0,-1),n=n[n.length-1],r.push(""))));return r[r.length-1]+=n,r}var XI,j0=new Promise(i=>{XI=i}),qI=!1;var H0;function YI(){if(qI)return;if(H0)return H0;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.88/build",n=import("./process.js"),[s,o]=await Promise.all([n,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});XI(l),qI=!0}return H0=i(),H0}var u9=["font"];function Ca(i,t,e,r){let n,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let c of o){let u=s;for(let h of c)u=u[h];for(n in u){let h=u[n];vA(h)&&!u9.includes(n)&&(u[n]=t.getVariable(h,[r.uuid,"geometry",...c,n]),vA(u[n])&&(u[n]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let c=Yt.createFromState(s.shape,s.width,s.height);a.shape=c}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),a.geometry=new Ju().parse(s);else if(s.type==="SubdivGeometry"){let c=new ci(s,e);return c.data=i,c}else{if(s.type==="TextGeometry")return new Id(s,t);if(s.type==="UIGeometry")return Od.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=UE(a)}catch(c){console.error(c)}if(!l){let c=Yt.createFromState(Wh.defaultData(),100,100);a.shape=c,l=UE(a)}return l}var h9=new ue;function ym(i,t,e,r){let n=i.position.array,s=i.normal.array,o=h9.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=n.length;u<h;u+=3)n[u]*=t,n[u+1]*=e,n[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var W0=new zt,Rd=new T,ht;j0.then(i=>{ht=i});var KI=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),QI=new Uint32Array([0,1,2,3]),ZI=new Uint8Array([4]),ci=class extends Ne{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked,s=vo.div(r,n);this.subdividedGeometry&&ym(this.subdividedGeometry.attributes,...s),this.originalGeometry&&ym(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Rd.fromArray(s));let a=Rd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=ci.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mi(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ci.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Or,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;W0.setFromBufferAttribute(r),W0.getCenter(n),e.boundingSphere.radius=n.distanceTo(W0.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),W0.getSize(Rd);let s={width:Rd.x,height:Rd.y,depth:Rd.z};return this.userData.parameters=s,s}static build(e,r,n,s){let o,a,l,c=e?.phongAngle??35;n===!1&&(c=-1),r&&(ht.free_bvh(r),ht.free_subdivision_surface(r));try{o=ci.allocate(e,s)}catch(u){console.error(u,e),o=ci.allocate({positionWASM:KI,indexWASM:QI,verticesPerFaceWASM:ZI},s)}if(ht.set_destination_refinement_level(o,0),a=ci.buildLevel(o,!0,c),e.subdivisions>0)try{ht.set_destination_refinement_level(o,e.subdivisions),l=ci.buildLevel(o,!1,c)}catch{try{ht.set_destination_refinement_level(o,e.subdivisions-1),l=ci.buildLevel(o,!1,c)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,n){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?r.geometry:Ca(e,n,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=zc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:c}=GE(a,u,s,h),{positions:a,indices:l,verticesPerFace:c}}static allocate(e,r){let n,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(n=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(n=KI,s=QI,o=ZI);let c=n.length,u=s.length,h=o.length,d=n.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,g=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,m=ht._malloc(p),v=new Float32Array(ht.HEAPF32.buffer,m,d),x=new Uint32Array(ht.HEAPU32.buffer,m+g,f);v.set(n,0),v.set(a,n.length),v.set(l,n.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(w=>w!==1)&&(b=new ue().makeScale(...e.scaleBaked)),r&&(b?b.premultiply(r):b=r);let S=b?ht.alloc_subdivision_surface2(m,c,m+g,u,m+g+s.length*Uint32Array.BYTES_PER_ELEMENT,h,b.elements):ht.alloc_subdivision_surface(m,c,m+g,u,m+g+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return ht._free(m),S}static buildLevel(e,r,n,s,o){let a=o?ht.get_mesh_data2(e,r?ht.Level.CONTROL:ht.Level.REFINED,n,o.elements):ht.get_mesh_data(e,r?ht.Level.CONTROL:ht.Level.REFINED,n),l=8,c=ht.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=ht.HEAPU32[c[h]>>2],f=ht.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let p=ht.HEAPU32[c[h]>>2],g=ht.HEAPF32.subarray(p>>2,(p>>2)+u[h]);h++;let y=ht.HEAPU32[c[h]>>2],m=ht.HEAPU32.subarray(y>>2,(y>>2)+u[h]);h++;let v=ht.HEAPU32[c[h]>>2],x=ht.HEAPU32.subarray(v>>2,(v>>2)+u[h]);if(h++,s===void 0){let b=new Ne;if(b.setIndex(new lo(x,1)),b.setAttribute("position",new Ie(f,3)),b.setAttribute("normal",new Ie(g,3)),r){b.setAttribute("faceMap",new lo(m,1));let S=new Float32Array(g.length/3*4).fill(0);b.setAttribute("color",new Ye(S,4))}return ht.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(g),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,ht.free_mesh_data(a)}static freeSubdivPointer(e){ht.free_bvh(e),ht.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let s=ht.get_wireframe_data_for_base_level(e),o=4,a=ht.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=ht.HEAPU32[a[c]>>2],h=ht.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=ht.HEAPU32[a[c]>>2],f=ht.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let p=new Ne;p.setAttribute("position",new Ie(h,3));let g=new Float32Array(h.length);for(let y=0,m=h.length;y<m;)g[y++]=n.r,g[y++]=n.g,g[y++]=n.b;return p.setAttribute("color",new Ye(g,3)),p.setIndex(new lo(f,1)),ht.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,ht.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,n){let s=r===0;s||ht.set_destination_refinement_level(e,r);let o=n?ht.get_topological_data2(e,s?ht.Level.CONTROL:ht.Level.REFINED,n.elements):ht.get_topological_data(e,s?ht.Level.CONTROL:ht.Level.REFINED),a=6,l=ht.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=ht.HEAPU32[l[u]>>2],d=new Float32Array(ht.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=ht.HEAPU32[l[u]>>2],p=new Uint32Array(ht.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let g=ht.HEAPU32[l[u]>>2],y=new Uint8Array(ht.HEAPU32.subarray(g>>2,(g>>2)+c[u]));return ht.free_topological_data(o),{positions:d,indices:p,verticesPerFace:y}}};var JI=["getX","getY","getZ"];function zc(i,t){let e={},r=t?t.count:i.count,n=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,h="";for(let d=0;d<3;d++)h+=`${~~(i[JI[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[JI[d]](u));e[h]=n,s.push(n),n++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var q0=new T,VE=new T,zE=new T,kE=new T;function GE(i,t,e,r){let n=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,p)=>Math.floor(p/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]);i.length=0;let h=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),n.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),n.push(h++);return s.push(h),{indices:n,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){q0.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),VE.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),zE.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),kE.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),VE.sub(q0).normalize(),zE.sub(q0).normalize(),kE.sub(q0).normalize();let l=VE.cross(zE).dot(kE);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(n.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),u++),i[h+2]===o&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=c[0];c[0]=c[1],c[1]=h}l.reverse(),n.push(...l,...c),s.push(u,u)}return{indices:n,verticesPerFace:s}}var gs={};iM(gs,{calcBoolean:()=>p9,calcBooleanTopological:()=>f9,freeMeshSet:()=>v9,getMeshSet:()=>m9,hasOpenEdges:()=>g9,transformMeshSet:()=>y9});var $I,eR=new Promise(i=>{$I=i});var X0;function tR(){if(X0)return X0;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.0.88/build",n=import("./boolean.js"),[s,o]=await Promise.all([n,fetch(`${e}/boolean.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});$I(l)}return X0=i(),X0}var Lt,Ld;eR.then(i=>Lt=i);function d9(i,t,e){let r,n;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?n=i.getClosedTorusIndicesForBooleanOrSubdiv():n=i.getIndex();let{positions:s,triIndices:o}=zc(i.getAttribute("position"),n),a;if(t&&e){let{indices:l,verticesPerFace:c}=GE(s,o,i);a=c.length,r=[];for(let u=0,h=0;u<a;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let c=0,u=0;u<r.length;)r[u++]=3,a++,r[u++]=o[c++],r[u++]=o[c++],r[u++]=o[c++]}return{positions:s,faceIndices:r,nFaces:a}}function rR(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,n=Number.isInteger(i[0])?e:r,s=Lt._malloc(n);return(Number.isInteger(i[0])?new Uint32Array(Lt.HEAPU32.buffer,s,t):new Float32Array(Lt.HEAPF32.buffer,s,t)).set(i,0),s}function iR(i){switch(i){case 0:return Lt.OP.UNION;case 1:return Lt.OP.INTERSECTION;case 2:return Lt.OP.A_MINUS_B;case 3:return Lt.OP.B_MINUS_A;case 4:return Lt.OP.SYMMETRIC_DIFFERENCE;case 5:return Lt.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function f9(i,t){Ld===void 0&&(Ld=Lt.init_csg());let e=rR(i),r=Lt.csg_calc_topological(Ld,e,i.length,iR(t));Lt._free(e);let n=6,s=Lt.HEAPU32.subarray(r>>2,(r>>2)+n),o=s.subarray(3,3+3),a=0,l=Lt.HEAPU32[s[a]>>2],c=new Float32Array(Lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=Lt.HEAPU32[s[a]>>2],h=new Uint32Array(Lt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=Lt.HEAPU32[s[a]>>2],f=new Uint8Array(Lt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return Lt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function p9(i,t,e,r){Ld===void 0&&(Ld=Lt.init_csg());let n=rR(i),s=Lt.csg_calc(Ld,n,i.length,r,iR(t));Lt._free(n);let o=5,a=Lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=Lt.HEAPU32[a[c]>>2],h=Lt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Lt.HEAPU32[a[c]>>2],f=Lt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=l[c];e.setAttribute("position",new Ie(h,3)),e.setAttribute("normal",new Ie(f,3));let g=Lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Or),e.boundingSphere.center.set(g[0],g[1],g[2]),e.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,e.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},Lt.free_mesh_data(s),p}function m9(i,t,e){if(Lt===void 0)return-1;let r,n,s;if(t&&i.userData.positions!==void 0){let m=i.userData;s=m.verticesPerFace.length,r=m.positions,n=Array(m.verticesPerFace.reduce((v,x)=>v+x,0)+s);for(let v=0,x=0,b=0;v<m.verticesPerFace.length;v++){n[b++]=m.verticesPerFace[v];for(let S=0;S<m.verticesPerFace[v];S++)n[b++]=m.indices[x++]}}else({positions:r,faceIndices:n,nFaces:s}=d9(i,t,e));let o=r.length,a=n.length,l=r.length,c=n.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Lt._malloc(u),p=new Float32Array(Lt.HEAPF32.buffer,f,l),g=new Uint32Array(Lt.HEAPU32.buffer,f+h,c);p.set(r,0),g.set(n,0);let y=Lt.get_csg_mesh(f,o,f+h,a,s);return Lt._free(f),y}function g9(i){return Lt.has_open_edges(i)}function y9(i,t){Lt.transform_csg_mesh(i,t.elements)}function v9(i){Lt.free_csg_mesh(i)}var x9={ConeGeometry:ZO,CubeGeometry:JO,CylinderGeometry:P0,DodecahedronGeometry:$O,EllipseGeometry:_d,HelixGeometry:_I,IcosahedronGeometry:PI,LatheGeometry:DI,NonParametricGeometry:LI,PolygonGeometry:z0,PyramidGeometry:NI,RectangleGeometry:Od,SphereGeometry:BI,PlaneGeometry:FI,BackdropGeometry:UI,StarGeometry:k0,TextFrameGeometry:VI,TorusGeometry:zI,TorusKnotGeometry:kI,TriangleGeometry:GI,PathGeometry:jI,VectorGeometry:Ln},UE=i=>x9[i.type].create(i);function Nd(i){return i!==null&&"booleanOp"in i}var Bd=class extends bd(tr){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!Nd(this.parent)&&this.visible,Nd(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(gs.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Nd(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Bd&&(e.freeBooleanPointer(),Nd(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let n=super.updateTransformState(e,r);return n&&Nd(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}onVariableUpdate(e=!1){super.onVariableUpdate(e),Nd(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Y0=new zt;function vm(i,t=0,e=i.count,r,n){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>c&&(c=f),p>u&&(u=p)}Y0.min.set(s,o,a),Y0.max.set(l,c,u),Y0.getCenter(r),Y0.getSize(n).multiplyScalar(.5)}var b9=new Ne,S9=new jn,yr=class extends Bd{constructor(t,e){super(b9,S9),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?vm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var _a=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(_a.uuidContext===null)throw new Error("plz startContext");_a.uuidContext===_a.globalContext?this.uuid="_gid"+_a.uuidContext.nodeContextUuid++:this.uuid="_uid"+_a.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===_a.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e??this.getType(t,e);let n=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,s,o){return""}generate(t,e,r,n,s){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},cr=_a;cr.globalContext={nodeContextUuid:0},cr.uuidContext=_a.globalContext;var xm=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var HE=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Di=new HE;var st=class extends cr{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,n,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=_e.generateUUID()),n=e.getUUID(n??this.getUUID(),!o);let a=e.getNodeData(n),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,n)):super.build(e,r,n);if(o)return a.name=a.name||super.build(e,r,n),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let c=this.getTemp(e,n);if(c)return e.format(c,l,r);{c=super.generate(e,r,n,a.output,s);let u=this.generate(e,l,n);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,s??this.getType(e),o,this.getLabel()).name}};var ur=class extends st{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var Wr=class extends ur{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof U?e:new U(e,r)}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,r,n,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var Qi=class extends ur{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof T?e:new T(e,r,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,n,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var Ar=class extends ke{constructor(e,r,n,s){super(e,r,n);this.isColorA=!0;this.a=s}setRGBA(e,r,n,s){super.setRGB(e,r,n),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Nn=class extends ur{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ar?e:new Ar(e.r,e.g,e.b,e.a)}generateReadonly(e,r,n,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var w9=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,nR=/[a-z_0-9]+/gi,Me=class extends st{constructor(e,r,n,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,n,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,s,o){let a,l=0,c=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 u=[];for(;a=nR.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,g=f;if(this.keywords[f]||this.useKeywords&&p&&Di.containsKeyword(f)){let y=this.keywords[f];if(!y){let m=Di.getKeywordData(f);m.cache&&(y=e.keywords[f]),y=y||Di.getKeyword(f,e),m.cache&&(e.keywords[f]=y)}g=y.build(e)}f!==g&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+g+c.substring(d.index+f.length+l),l+=g.length-f.length),this.getIncludeByName(g)===void 0&&Di.contains(g)&&e.include(Di.get(g))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,n,s){if(this.src=e||"",this.includes=r??[],this.extensions=n??{},this.keywords=s??{},this.isMethod){let o=w9.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(nR);if(a){let l=0;for(;l<a.length;){let c=a[l++],u;c==="in"||c==="out"||c==="inout"?u=a[l++]:(u=c,c="");let h=a[l++];this.inputs.push({name:h,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var A9=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,jE=class extends st{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||jE.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,s,o){this.src=e||"";let a,l,c="",u=A9.exec(e);this.useDefine=o??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],a=u[2],c=u[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="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),r)}generate(e,r,n,s,o){return e.format(this.name,this.getType(e),r)}},Xt=jE;Xt.PI="PI",Xt.PI2="PI2",Xt.RECIPROCAL_PI="RECIPROCAL_PI",Xt.RECIPROCAL_PI2="RECIPROCAL_PI2",Xt.LOG2="LOG2",Xt.EPSILON="EPSILON";var E9=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3803
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+n,i)>i.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+n,i)>i.width&&(n.length===1?(r[r.length-1]+=n,n=""):(r[r.length-1]+=n.slice(0,-1),n=n[n.length-1],r.push(""))));return r[r.length-1]+=n,r}var XI,j0=new Promise(i=>{XI=i}),qI=!1;var H0;function YI(){if(qI)return;if(H0)return H0;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.89/build",n=import("./process.js"),[s,o]=await Promise.all([n,fetch(`${e}/process.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});XI(l),qI=!0}return H0=i(),H0}var u9=["font"];function Ca(i,t,e,r){let n,s,o;i.type==="PathGeometry"?(s=JSON.parse(JSON.stringify(i)),o=[[],["extrusion"]]):(s={...i},o=[[]]);for(let c of o){let u=s;for(let h of c)u=u[h];for(n in u){let h=u[n];vA(h)&&!u9.includes(n)&&(u[n]=t.getVariable(h,[r.uuid,"geometry",...c,n]),vA(u[n])&&(u[n]=1))}}let a={parameters:s,type:s.type};if(s.type==="PathGeometry")a.path=s.path;else if(s.type==="VectorGeometry"){let c=Yt.createFromState(s.shape,s.width,s.height);a.shape=c}else if(s.type==="NonParametricGeometry")s.data.groups&&s.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),a.geometry=new Ju().parse(s);else if(s.type==="SubdivGeometry"){let c=new ci(s,e);return c.data=i,c}else{if(s.type==="TextGeometry")return new Id(s,t);if(s.type==="UIGeometry")return Od.create({parameters:{width:s.width,height:s.height,cornerRadius:s.cornerRadius,cornerType:s.cornerType}})}let l;try{l=UE(a)}catch(c){console.error(c)}if(!l){let c=Yt.createFromState(Wh.defaultData(),100,100);a.shape=c,l=UE(a)}return l}var h9=new ue;function ym(i,t,e,r){let n=i.position.array,s=i.normal.array,o=h9.makeScale(t,e,r).invert().elements,a,l,c;for(var u=0,h=n.length;u<h;u+=3)n[u]*=t,n[u+1]*=e,n[u+2]*=r,a=s[u],l=s[u+1],c=s[u+2],s[u]=o[0]*a+o[4]*l+o[8]*c,s[u+1]=o[1]*a+o[5]*l+o[9]*c,s[u+2]=o[2]*a+o[6]*l+o[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var W0=new zt,Rd=new T,ht;j0.then(i=>{ht=i});var KI=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),QI=new Uint32Array([0,1,2,3]),ZI=new Uint8Array([4]),ci=class extends Ne{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked,s=vo.div(r,n);this.subdividedGeometry&&ym(this.subdividedGeometry.attributes,...s),this.originalGeometry&&ym(this.originalGeometry.attributes,...s),this.data=e;let o=this.userData.parameters;this.userData.parameters={width:o.width*s[0],height:o.height*s[1],depth:o.depth*s[2]},this.originalGeometry.boundingSphere.center.multiply(Rd.fromArray(s));let a=Rd.set(o.width,o.height,o.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=ci.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new mi(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let s=this.subdividedGeometry??this.originalGeometry;Object.assign(this,s),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ci.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Or,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;W0.setFromBufferAttribute(r),W0.getCenter(n),e.boundingSphere.radius=n.distanceTo(W0.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),W0.getSize(Rd);let s={width:Rd.x,height:Rd.y,depth:Rd.z};return this.userData.parameters=s,s}static build(e,r,n,s){let o,a,l,c=e?.phongAngle??35;n===!1&&(c=-1),r&&(ht.free_bvh(r),ht.free_subdivision_surface(r));try{o=ci.allocate(e,s)}catch(u){console.error(u,e),o=ci.allocate({positionWASM:KI,indexWASM:QI,verticesPerFaceWASM:ZI},s)}if(ht.set_destination_refinement_level(o,0),a=ci.buildLevel(o,!0,c),e.subdivisions>0)try{ht.set_destination_refinement_level(o,e.subdivisions),l=ci.buildLevel(o,!1,c)}catch{try{ht.set_destination_refinement_level(o,e.subdivisions-1),l=ci.buildLevel(o,!1,c)}catch{l=null}}else l=null;return{subdivPointer:o,originalGeometry:a,subdividedGeometry:l}}static primitiveToQuads(e,r,n){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let s=e.shape!==void 0||e.path!==void 0?r.geometry:Ca(e,n,!1),o;e.type==="TorusGeometry"&&e.arc===Math.PI*2?o=s.getClosedTorusIndicesForBooleanOrSubdiv():o=s.getIndex();let a,l,c,u;({positions:a,triIndices:u}=zc(s.getAttribute("position"),o));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;h=[d,f]}return{indices:l,verticesPerFace:c}=GE(a,u,s,h),{positions:a,indices:l,verticesPerFace:c}}static allocate(e,r){let n,s,o,a=[],l=[];e.positionWASM&&e.positionWASM.length>0?(n=e.positionWASM,s=e.indexWASM,o=e.verticesPerFaceWASM):(n=KI,s=QI,o=ZI);let c=n.length,u=s.length,h=o.length,d=n.length+a.length+l.length,f=s.length+o.length,p=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,g=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,m=ht._malloc(p),v=new Float32Array(ht.HEAPF32.buffer,m,d),x=new Uint32Array(ht.HEAPU32.buffer,m+g,f);v.set(n,0),v.set(a,n.length),v.set(l,n.length+a.length),x.set(s,0),x.set(o,s.length);let b;e?.scaleBaked?.some(w=>w!==1)&&(b=new ue().makeScale(...e.scaleBaked)),r&&(b?b.premultiply(r):b=r);let S=b?ht.alloc_subdivision_surface2(m,c,m+g,u,m+g+s.length*Uint32Array.BYTES_PER_ELEMENT,h,b.elements):ht.alloc_subdivision_surface(m,c,m+g,u,m+g+s.length*Uint32Array.BYTES_PER_ELEMENT,h);return ht._free(m),S}static buildLevel(e,r,n,s,o){let a=o?ht.get_mesh_data2(e,r?ht.Level.CONTROL:ht.Level.REFINED,n,o.elements):ht.get_mesh_data(e,r?ht.Level.CONTROL:ht.Level.REFINED,n),l=8,c=ht.HEAPU32.subarray(a>>2,(a>>2)+l),u=c.subarray(4,4+4),h=0,d=ht.HEAPU32[c[h]>>2],f=ht.HEAPF32.subarray(d>>2,(d>>2)+u[h]);h++;let p=ht.HEAPU32[c[h]>>2],g=ht.HEAPF32.subarray(p>>2,(p>>2)+u[h]);h++;let y=ht.HEAPU32[c[h]>>2],m=ht.HEAPU32.subarray(y>>2,(y>>2)+u[h]);h++;let v=ht.HEAPU32[c[h]>>2],x=ht.HEAPU32.subarray(v>>2,(v>>2)+u[h]);if(h++,s===void 0){let b=new Ne;if(b.setIndex(new lo(x,1)),b.setAttribute("position",new Ie(f,3)),b.setAttribute("normal",new Ie(g,3)),r){b.setAttribute("faceMap",new lo(m,1));let S=new Float32Array(g.length/3*4).fill(0);b.setAttribute("color",new Ye(S,4))}return ht.free_mesh_data(a),b.userData.type="SubdivGeometry",b}s.getAttribute("position").copyArray(f),s.getAttribute("normal").copyArray(g),s.attributes.position.needsUpdate=!0,s.attributes.normal.needsUpdate=!0,ht.free_mesh_data(a)}static freeSubdivPointer(e){ht.free_bvh(e),ht.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let s=ht.get_wireframe_data_for_base_level(e),o=4,a=ht.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+2),c=0,u=ht.HEAPU32[a[c]>>2],h=ht.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=ht.HEAPU32[a[c]>>2],f=ht.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let p=new Ne;p.setAttribute("position",new Ie(h,3));let g=new Float32Array(h.length);for(let y=0,m=h.length;y<m;)g[y++]=n.r,g[y++]=n.g,g[y++]=n.b;return p.setAttribute("color",new Ye(g,3)),p.setIndex(new lo(f,1)),ht.free_wireframe_data_for_base_level(s),p}r.getAttribute("position").copyArray(h),r.attributes.position.needsUpdate=!0,ht.free_wireframe_data_for_base_level(s)}static updateCollabMesh(e,r,n){let s=r===0;s||ht.set_destination_refinement_level(e,r);let o=n?ht.get_topological_data2(e,s?ht.Level.CONTROL:ht.Level.REFINED,n.elements):ht.get_topological_data(e,s?ht.Level.CONTROL:ht.Level.REFINED),a=6,l=ht.HEAPU32.subarray(o>>2,(o>>2)+a),c=l.subarray(3,3+3),u=0,h=ht.HEAPU32[l[u]>>2],d=new Float32Array(ht.HEAPF32.subarray(h>>2,(h>>2)+c[u]));u++;let f=ht.HEAPU32[l[u]>>2],p=new Uint32Array(ht.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let g=ht.HEAPU32[l[u]>>2],y=new Uint8Array(ht.HEAPU32.subarray(g>>2,(g>>2)+c[u]));return ht.free_topological_data(o),{positions:d,indices:p,verticesPerFace:y}}};var JI=["getX","getY","getZ"];function zc(i,t){let e={},r=t?t.count:i.count,n=0,s=[],o=[],a=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,h="";for(let d=0;d<3;d++)h+=`${~~(i[JI[d]](u)*a)},`;if(h in e)s.push(e[h]);else{for(let d=0;d<3;d++)o.push(i[JI[d]](u));e[h]=n,s.push(n),n++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var q0=new T,VE=new T,zE=new T,kE=new T;function GE(i,t,e,r){let n=[],s=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,p)=>Math.floor(p/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]);i.length=0;let h=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),n.push(h++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),n.push(h++);return s.push(h),{indices:n,verticesPerFace:s}}let o=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[a]*3+2]===o||i[t[a]*3+2]===0)&&l++,(i[t[a+1]*3+2]===o||i[t[a+1]*3+2]===0)&&l++,(i[t[a+2]*3+2]===o||i[t[a+2]*3+2]===0)&&l++,l===3)break}if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){q0.set(i[t[a]*3],i[t[a]*3+1],i[t[a]*3+2]),VE.set(i[t[a+1]*3],i[t[a+1]*3+1],i[t[a+1]*3+2]),zE.set(i[t[a+4]*3],i[t[a+4]*3+1],i[t[a+4]*3+2]),kE.set(i[t[a+5]*3],i[t[a+5]*3+1],i[t[a+5]*3+2]),VE.sub(q0).normalize(),zE.sub(q0).normalize(),kE.sub(q0).normalize();let l=VE.cross(zE).dot(kE);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3):(n.push(t[a],t[a+1],t[a+4],t[a+5]),s.push(4),a+=6)}else n.push(t[a],t[a+1],t[a+2]),s.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let h=0,d=0;h<i.length;h+=3,d++)i[h+2]===0&&(l.push(d),u++),i[h+2]===o&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let h=c[0];c[0]=c[1],c[1]=h}l.reverse(),n.push(...l,...c),s.push(u,u)}return{indices:n,verticesPerFace:s}}var gs={};iM(gs,{calcBoolean:()=>p9,calcBooleanTopological:()=>f9,freeMeshSet:()=>v9,getMeshSet:()=>m9,hasOpenEdges:()=>g9,transformMeshSet:()=>y9});var $I,eR=new Promise(i=>{$I=i});var X0;function tR(){if(X0)return X0;async function i(){let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@1.0.89/build",n=import("./boolean.js"),[s,o]=await Promise.all([n,fetch(`${e}/boolean.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});$I(l)}return X0=i(),X0}var Lt,Ld;eR.then(i=>Lt=i);function d9(i,t,e){let r,n;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?n=i.getClosedTorusIndicesForBooleanOrSubdiv():n=i.getIndex();let{positions:s,triIndices:o}=zc(i.getAttribute("position"),n),a;if(t&&e){let{indices:l,verticesPerFace:c}=GE(s,o,i);a=c.length,r=[];for(let u=0,h=0;u<a;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[h++])}}else{let l=o.length;r=Array(l+l/3),a=0;for(let c=0,u=0;u<r.length;)r[u++]=3,a++,r[u++]=o[c++],r[u++]=o[c++],r[u++]=o[c++]}return{positions:s,faceIndices:r,nFaces:a}}function rR(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,n=Number.isInteger(i[0])?e:r,s=Lt._malloc(n);return(Number.isInteger(i[0])?new Uint32Array(Lt.HEAPU32.buffer,s,t):new Float32Array(Lt.HEAPF32.buffer,s,t)).set(i,0),s}function iR(i){switch(i){case 0:return Lt.OP.UNION;case 1:return Lt.OP.INTERSECTION;case 2:return Lt.OP.A_MINUS_B;case 3:return Lt.OP.B_MINUS_A;case 4:return Lt.OP.SYMMETRIC_DIFFERENCE;case 5:return Lt.OP.ALL;default:throw new Error("Unknown boolean operation "+i)}}function f9(i,t){Ld===void 0&&(Ld=Lt.init_csg());let e=rR(i),r=Lt.csg_calc_topological(Ld,e,i.length,iR(t));Lt._free(e);let n=6,s=Lt.HEAPU32.subarray(r>>2,(r>>2)+n),o=s.subarray(3,3+3),a=0,l=Lt.HEAPU32[s[a]>>2],c=new Float32Array(Lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let u=Lt.HEAPU32[s[a]>>2],h=new Uint32Array(Lt.HEAPU32.subarray(u>>2,(u>>2)+o[a]));a++;let d=Lt.HEAPU32[s[a]>>2],f=new Uint8Array(Lt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return Lt.free_mesh_data(r),{positions:c,indices:h,verticesPerFace:f}}function p9(i,t,e,r){Ld===void 0&&(Ld=Lt.init_csg());let n=rR(i),s=Lt.csg_calc(Ld,n,i.length,r,iR(t));Lt._free(n);let o=5,a=Lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,u=Lt.HEAPU32[a[c]>>2],h=Lt.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Lt.HEAPU32[a[c]>>2],f=Lt.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=l[c];e.setAttribute("position",new Ie(h,3)),e.setAttribute("normal",new Ie(f,3));let g=Lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Or),e.boundingSphere.center.set(g[0],g[1],g[2]),e.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,e.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},Lt.free_mesh_data(s),p}function m9(i,t,e){if(Lt===void 0)return-1;let r,n,s;if(t&&i.userData.positions!==void 0){let m=i.userData;s=m.verticesPerFace.length,r=m.positions,n=Array(m.verticesPerFace.reduce((v,x)=>v+x,0)+s);for(let v=0,x=0,b=0;v<m.verticesPerFace.length;v++){n[b++]=m.verticesPerFace[v];for(let S=0;S<m.verticesPerFace[v];S++)n[b++]=m.indices[x++]}}else({positions:r,faceIndices:n,nFaces:s}=d9(i,t,e));let o=r.length,a=n.length,l=r.length,c=n.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Lt._malloc(u),p=new Float32Array(Lt.HEAPF32.buffer,f,l),g=new Uint32Array(Lt.HEAPU32.buffer,f+h,c);p.set(r,0),g.set(n,0);let y=Lt.get_csg_mesh(f,o,f+h,a,s);return Lt._free(f),y}function g9(i){return Lt.has_open_edges(i)}function y9(i,t){Lt.transform_csg_mesh(i,t.elements)}function v9(i){Lt.free_csg_mesh(i)}var x9={ConeGeometry:ZO,CubeGeometry:JO,CylinderGeometry:P0,DodecahedronGeometry:$O,EllipseGeometry:_d,HelixGeometry:_I,IcosahedronGeometry:PI,LatheGeometry:DI,NonParametricGeometry:LI,PolygonGeometry:z0,PyramidGeometry:NI,RectangleGeometry:Od,SphereGeometry:BI,PlaneGeometry:FI,BackdropGeometry:UI,StarGeometry:k0,TextFrameGeometry:VI,TorusGeometry:zI,TorusKnotGeometry:kI,TriangleGeometry:GI,PathGeometry:jI,VectorGeometry:Ln},UE=i=>x9[i.type].create(i);function Nd(i){return i!==null&&"booleanOp"in i}var Bd=class extends bd(tr){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new ue}updateVisible(e){super.updateVisible(e),this.visible=!Nd(this.parent)&&this.visible,Nd(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(gs.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Nd(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Bd&&(e.freeBooleanPointer(),Nd(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let n=super.updateTransformState(e,r);return n&&Nd(this.parent)&&this.invalidateDownstreamBooleanData(!0),n}onVariableUpdate(e=!1){super.onVariableUpdate(e),Nd(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Y0=new zt;function vm(i,t=0,e=i.count,r,n){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=t;h<e;h++){let d=i.getX(h),f=i.getY(h),p=i.getZ(h);d<s&&(s=d),f<o&&(o=f),p<a&&(a=p),d>l&&(l=d),f>c&&(c=f),p>u&&(u=p)}Y0.min.set(s,o,a),Y0.max.set(l,c,u),Y0.getCenter(r),Y0.getSize(n).multiplyScalar(.5)}var b9=new Ne,S9=new jn,yr=class extends Bd{constructor(t,e){super(b9,S9),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?vm(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var _a=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(_a.uuidContext===null)throw new Error("plz startContext");_a.uuidContext===_a.globalContext?this.uuid="_gid"+_a.uuidContext.nodeContextUuid++:this.uuid="_uid"+_a.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===_a.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let n={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),n}build(t,e,r){e=e??this.getType(t,e);let n=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,n,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,n,s,o){return""}generate(t,e,r,n,s){return""}parse(t,e,r,n){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let n=t.getTypeLength(r);(n>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=n,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},cr=_a;cr.globalContext={nodeContextUuid:0},cr.uuidContext=_a.globalContext;var xm=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var HE=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},Di=new HE;var st=class extends cr{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,n,s){if(r=r??this.getType(e),this.getShared(e,r)){let o=this.getUnique(e,r);o&&this.uuid===void 0&&(this.uuid=_e.generateUUID()),n=e.getUUID(n??this.getUUID(),!o);let a=e.getNodeData(n),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,n)):super.build(e,r,n);if(o)return a.name=a.name||super.build(e,r,n),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,n);n=this.getUUID(!1);let c=this.getTemp(e,n);if(c)return e.format(c,l,r);{c=super.generate(e,r,n,a.output,s);let u=this.generate(e,l,n);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,n)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let n=e.getVars()[r];return n?n.name:void 0}generate(e,r,n,s,o){return this.getShared(e,r)||console.error("TempNode is not shared"),n=n??this.uuid,e.getTempVar(n,s??this.getType(e),o,this.getLabel()).name}};var ur=class extends st{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,n,s,o,a){n=e.getUUID(n??this.getUUID()),s=s??this.getType(e);let l=e.getNodeData(n);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,n,s,o,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(s,this,o,a,this.getLabel())),e.format(l.vertex.name,s,r)):(l.fragment||(l.fragment=e.createFragmentUniform(s,this,o,a,this.getLabel())),e.format(l.fragment.name,s,r))}};var Wr=class extends ur{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof U?e:new U(e,r)}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,r,n,s,o,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",s,r)}};var Qi=class extends ur{constructor(e=0,r,n){super("v3");this.nodeType="Vector3";this.value=e instanceof T?e:new T(e,r,n)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,n,s,o,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,r)}};var Ar=class extends ke{constructor(e,r,n,s){super(e,r,n);this.isColorA=!0;this.a=s}setRGBA(e,r,n,s){super.setRGB(e,r,n),this.a=s}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let s,o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="rgba"?parseFloat(s[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=o==="hsla"?parseFloat(s[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Nn=class extends ur{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ar?e:new Ar(e.r,e.g,e.b,e.a)}generateReadonly(e,r,n,s,o,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,r)}};var w9=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,nR=/[a-z_0-9]+/gi,Me=class extends st{constructor(e,r,n,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(e,r,n,s)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,n,s,o){let a,l=0,c=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 u=[];for(;a=nR.exec(this.src);)u.push(a);for(let h=0;h<u.length;h++){let d=u[h],f=d[0],p=this.isMethod?!this.getInputByName(f):!0,g=f;if(this.keywords[f]||this.useKeywords&&p&&Di.containsKeyword(f)){let y=this.keywords[f];if(!y){let m=Di.getKeywordData(f);m.cache&&(y=e.keywords[f]),y=y||Di.getKeyword(f,e),m.cache&&(e.keywords[f]=y)}g=y.build(e)}f!==g&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+g+c.substring(d.index+f.length+l),l+=g.length-f.length),this.getIncludeByName(g)===void 0&&Di.contains(g)&&e.include(Di.get(g))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,n,s){if(this.src=e||"",this.includes=r??[],this.extensions=n??{},this.keywords=s??{},this.isMethod){let o=w9.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(nR);if(a){let l=0;for(;l<a.length;){let c=a[l++],u;c==="in"||c==="out"||c==="inout"?u=a[l++]:(u=c,c="");let h=a[l++];this.inputs.push({name:h,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var A9=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,jE=class extends st{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||jE.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,n,s,o){this.src=e||"";let a,l,c="",u=A9.exec(e);this.useDefine=o??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],a=u[2],c=u[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="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),r)}generate(e,r,n,s,o){return e.format(this.name,this.getType(e),r)}},Xt=jE;Xt.PI="PI",Xt.PI2="PI2",Xt.RECIPROCAL_PI="RECIPROCAL_PI",Xt.RECIPROCAL_PI2="RECIPROCAL_PI2",Xt.LOG2="LOG2",Xt.EPSILON="EPSILON";var E9=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3804
3804
  )*?)}`,"gim"),T9=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Fd=class extends st{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,n,s,o){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=E9.exec(e);if(r){let n=r[2],s;for(;s=T9.exec(n);)this.inputs.push({type:s[1],name:s[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ud=class extends st{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let n=this.index>0?this.index+1:"",s=e.isShader("vertex")?"uv"+n:"vUv"+n;return e.format(s,this.getType(e),r)}};Di.addKeyword("uv",function(){return new Ud});Di.addKeyword("uv2",function(){return new Ud(1)});var kc=class extends st{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??kc.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case an:return["Linear"];case Ot:return["sRGB"];default:return[]}}generate(e,r){let n=this.input.build(e,"v4"),s=this.getType(e),o=kc.Nodes[this.method],a=e.include(o);if(a===kc.LINEAR_TO_LINEAR)return e.format(n,s,r);if(o.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(a+"( "+n+", "+l+" )",s,r)}else return e.format(a+"( "+n+" )",s,r)}fromEncoding(e){let r=kc.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=kc.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},Sn=kc;Sn.Nodes={LinearToLinear:new Me(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3805
3805
  `)),sRGBToLinear:new Me(["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(`
3806
3806
  `)),LinearTosRGB:new Me(["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(`
@@ -5619,7 +5619,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
5619
5619
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
5620
5620
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
5621
5621
  return displaced_position;
5622
- }`,[e,r])}}();var $e={normalRenderTarget:new wn,normalRenderTargetDepth:new wn,transmissionRenderTarget:new wn,aspectRatio:new Wr,transmissionSize:new Wr(2048,2048),transmissionRenderTargetDepth:new wn,aoRenderTarget:new wn,aoEnabled:new Jr,pixelRatioNode:new Ve(1),resolution:new Wr,penumbraSize:new qs(5,.5),frameIndex:new Bt(0),transmissionLod:new Bt(2)};for(let i of Object.values($e))i.isRenderGlobal=!0;var $0={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.88/build/ui.wasm"};var Pa=class extends cr{constructor(){super("basic");this.nodeType="Basic";this.color=new ir(ai),this.shadingAlpha=new Ve(1),this.shadingBlend=new Bt(0),this.previousModelViewMatrix=new Zi,this.previouseProjectionMatrix=new Zi}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:$e.frameIndex}),e.mergeUniform({resolution:$e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ns.merge([Le.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
5622
+ }`,[e,r])}}();var $e={normalRenderTarget:new wn,normalRenderTargetDepth:new wn,transmissionRenderTarget:new wn,aspectRatio:new Wr,transmissionSize:new Wr(2048,2048),transmissionRenderTargetDepth:new wn,aoRenderTarget:new wn,aoEnabled:new Jr,pixelRatioNode:new Ve(1),resolution:new Wr,penumbraSize:new qs(5,.5),frameIndex:new Bt(0),transmissionLod:new Bt(2)};for(let i of Object.values($e))i.isRenderGlobal=!0;var $0={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.89/build/ui.wasm"};var Pa=class extends cr{constructor(){super("basic");this.nodeType="Basic";this.color=new ir(ai),this.shadingAlpha=new Ve(1),this.shadingBlend=new Bt(0),this.previousModelViewMatrix=new Zi,this.previouseProjectionMatrix=new Zi}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let n=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:$e.frameIndex}),e.mergeUniform({resolution:$e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ns.merge([Le.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
5623
5623
  `));let s=["#include <beginnormal_vertex>",`
5624
5624
  #if !defined( USE_LAYER_DISPLACE )
5625
5625
  #include <defaultnormal_vertex>
@@ -7999,7 +7999,7 @@ void main() {
7999
7999
  gVelocity = vec4(0.0); // so it is ignored by TAA
8000
8000
  }`,s={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new U},viewport:{type:"v2",value:new U},basisViewport:{type:"v2",value:new U},debugColor:{type:"v3",value:new ke},covariancesTextureSize:{type:"v2",value:new U(1024,1024)},centersColorsTextureSize:{type:"v2",value:new U(1024,1024)},orthoZoom:{type:"f",value:-1}};return new ot({uniforms:s,vertexShader:r,fragmentShader:n,transparent:!0,alphaTest:1,blending:Za,depthTest:!0,depthWrite:!1,side:Bi})}static buildGeomtery(e){let r=new Ne;r.setIndex([0,1,2,0,2,3]);let n=new Float32Array(4*3),s=new Ye(n,3);r.setAttribute("position",s),s.setXYZ(0,-1,-1,0),s.setXYZ(1,-1,1,0),s.setXYZ(2,1,1,0),s.setXYZ(3,1,-1,0),s.needsUpdate=!0;let o=new Tp().copy(r),a=new Uint32Array(e),l=new co(a,1,!1);return l.setUsage(o_),o.setAttribute("splatIndex",l),o.instanceCount=e,o}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(s=>s.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,r=0,n=0;for(let s of this.splatBuffers){let o=s.nsplats;this.colors.subarray(e,e+o*4).set(s.colorsA),e+=o*4,this.centers.subarray(r,r+o*3).set(s.decoded.xyz.denormDequant().data),r+=o*3,this.covariances.subarray(n,n+o*6).set(new Float32Array(s.precomputedCovarianceBufferData)),n+=o*6}}allocateAndStoreLocalSplatDataInTextures(){let n=this.splatCount,s=new U(4096,1024);for(;s.x*s.y*2<n*6;)s.y*=2;let o=new U(4096,1024);for(;o.x*o.y*4<n*4;)o.y*=2;let a,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(s.x*s.y*2);for(let p=0;p<this.covariances.length;p++)l[p]=u_.toHalfFloat(this.covariances[p]);a=new si(l,s.x,s.y,rh,sa)}else l=new Float32Array(s.x*s.y*2),l.set(this.covariances),a=new si(l,s.x,s.y,rh,ar);a.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=a,this.material.uniforms.covariancesTextureSize.value.copy(s);let c=new Uint32Array(o.x*o.y*4);for(let p=0;p<n;p++){let g=p*4,y=p*3,m=p*4;c[m]=ZN(this.colors[g],this.colors[g+1],this.colors[g+2],this.colors[g+3]),c[m+1]=ib(this.centers[y]),c[m+2]=ib(this.centers[y+1]),c[m+3]=ib(this.centers[y+2])}let u=new si(c,o.x,o.y,Uy,is);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(o);let h=256*4,d=new Float32Array(256*16);for(let p=0;p<this.meshMatrixWorlds.length;p++)d.set(this.meshMatrixWorlds[p].elements,p*16);let f=new si(d,h,1,Yr,ar);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:a,size:s},centerColors:{data:c,texture:u,size:o},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,n,s){this.splatCount>0&&(nb.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(nb),this.material.uniforms.basisViewport.value.set(2/nb.x,2/nb.y),this.material.uniforms.focal.value.set(r,n),this.material.uniforms.orthoZoom.value=s,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var $N,$1=new Promise(i=>{$N=i}),JN=!1;var ob;function eT(){if(JN)return;if(ob)return ob;async function i(){let e=await import("./gaussian-splat-compression.js");$N(e),JN=!0}return ob=i(),ob}var eB;$1.then(i=>eB=i);var Wm=class{constructor(t={}){Xo(this,"updateView",function(){let t=new ue,e=[],r=new T(0,0,-1),n=new T(0,0,-1),s=new T,o=new T;return function(a=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!a){n.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(n.dot(r)<=.95&&(d=!0),o.copy(l.position).sub(s).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,s.copy(l.position),r.copy(n),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let h={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=h:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(h))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new ue().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new U;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new T().fromArray(t.position)),t.orientation&&(t.orientation=new Qe().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(o=>{o.data.type==="Splat"&&e.push(o)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(o=>o.matrixWorld),this.meshMatrixWorldsOld=e.map(o=>o.matrixWorld.clone()),this.cropsArray=e.map(o=>o.data.crops.map(a=>a.data));let r=e.map(o=>new eB.GSplineBuffer(new Uint8Array(o.data.buffer).buffer)),n=0,s=[0];for(let o of r)n+=o.getSplatCount(),s.push(n);return this.setupSplatMesh(r,n,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,s,this.meshMatrixWorlds),this.setupSortWorker(n),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((n,s)=>{this.cropsArray[r][s]===void 0?(t=!0,this.cropsArray[r][s]=n.data):Object.entries(n.data).forEach(([o,a])=>{Array.isArray(a)&&a.some((l,c)=>l!==this.cropsArray[r][s][o][c])?(t=!0,this.cropsArray[r][s][o]=a):a!==this.cropsArray[r][s]?.[o]&&(t=!0,this.cropsArray[r][s][o]=a)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new T,n=new Qe,s=!1,o=1,a,l){this.splatMesh=Jl.buildMesh(t,e,s,o,a,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(n),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,h)=>this.update(c,h)}setupSortWorker(t){this.sortWorker=QN(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var Fx=new jn;Fx.wireframe=!0;var tB=new T,ql=class extends Ai{constructor(e,r){super();this.data=e;this.sharedAssets=r;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 rb;this.invisibleObjects=new As("jflkdsafjasdifjaslk",{...n0.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new fr("fdasfa",{...ga.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=YN(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=XN(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),n=this.entityIdentityToEntity[r];n&&(e.uuid=n.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof fr&&(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 r=this.find(e);if(r===void 0)return;let n=[],s=r;for(;s!==this;){let o=s;s=s.parent;let a=s.children.indexOf(o);n.splice(0,0,a)}return{entity:r,sortKey:n}}getAllSorted(e){let r=[];for(let n of e){let s=this.getWithSortKey(n.id);s!==void 0&&r.push(s)}return r.sort((n,s)=>yv(n.sortKey,s.sortKey)),r.map(n=>n.entity)}nonExistOrDescendantOf(e,r){let n=this.find(e);if(n===void 0)return!0;for(;n;){if(n.uuid===r)return!0;n=n.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===ds)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof fr&&r.uiScene){let n=r.uiScene.find(e);if(n)return n}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof fr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(n=>{r===void 0&&n instanceof Cr&&(r=n.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof fr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.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(r=>{this.toExpandCloner.add(r)})}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,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let n=e.parent===null?this:this.find(e.parent);if(n===void 0)throw new Error("unexpected");let s=this.createObject(e.id,e.data,e.children,n,e.localIndex,r);s.updateVisible(this),s.resetBBoxNeedsUpdate(),ln(s)&&Mn(s.parent)&&(s.invalidateUpstreamBooleanData(),s.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(s),this.markToExpandCloner(s),this.markPenumbraSizeDirty(),s.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markToExpandCloner(n),n.resetBBoxNeedsUpdate(),this.unregisterObject(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),this.markNeedsRecomputeInstancesForChildren(n),this.markPenumbraSizeDirty(),n.parent.remove(n),Mn(n.parent)&&(n.parent.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ln(n)&&(n.freeBooleanPointer(),s instanceof Un&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n instanceof Ql&&n.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),this.pathConstraints.removeDependencies(n.uuid),n.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let n=this.find(e.id);if(n===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(n);let s=n.parent;this.markNeedsRecomputeInstancesForAncessors(s),n.cloner?.resetOnMove(),this.markToExpandCloner(n);let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");o.add(n),this.markNeedsRecomputeInstancesForAncessors(o),this.markToExpandCloner(n),n.invalidateClonerTransform(n),n.updateVisible(this),n.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;o.children.splice(a,0,o.children.pop()),ln(n)&&(n.invalidateUpstreamBooleanData(),Mn(n.parent)?n.parent.invalidateDownstreamBooleanData().recomputeBoolean():s instanceof Un&&s.invalidateDownstreamBooleanData().recomputeBoolean()),n.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 r of this.children)r instanceof fr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,n,s){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:a}=r.props;r={...r,props:a},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let o=this.find(e);if(o)try{jN(o,r,n,{scene:this,shared:s}),o instanceof dr&&o.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}updateEntity2DByOp(e,r,n,s,o,a=[]){e.updateEntityByOp(r,n,s,o),this.traverseEntity(l=>{(l instanceof Cr||l instanceof fr)&&(a.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,n,s,o)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let n=Object.entries(r.data.lib.components).map((s,o)=>({data:s[1].asset.data,children:s[1].asset.children,id:s[0],fi:o}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(n,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(s=>{s instanceof Tr&&s.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){At.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{At.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,n,s,o,a,l){if(e){let c=s.find(e);c&&c!==s&&o.forInstancesRec(u=>{u.data=yl(u.data,h=>{let d=h.events.data(l.id),f=u.goUp(a);if(f){let p=[...gv(f.identity),e].join("-"),g=this.entityIdentityToEntity[p];if(g){let y=g.uuid,m=Ur.zoom(d,r);m[n]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,n,s,o,a){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",n,s,o,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Js&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,n)=>{r.data.events.forEach(s=>{if(s.data.type==="GameControl"){let o=!1;if(r.forInstancesRec(a=>{a.data=yl(a.data,l=>{a.isInstanceRoot||(l.events.delete(s.id),o=!0)}).data}),o===!1)for(let a of $h.list)this.rewriteActions(s.data.gameActions[a],["gameActions",a],e,r,n,s)}else s.data.type==="Conditional"?(s.data.condition.type==="Distance"?(this.relativeizeInner(s.data.condition.fromObject,["condition"],"fromObject",e,r,n,s),this.relativeizeInner(s.data.condition.toObject,["condition"],"toObject",e,r,n,s)):s.data.condition.type==="State"?this.relativeizeInner(s.data.condition.object,["condition"],"object",e,r,n,s):s.data.condition.type==="Comparison"&&(s.data.condition.lOperand.type==="Property"&&this.relativeizeInner(s.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,n,s),s.data.condition.rOperand.type==="Property"&&this.relativeizeInner(s.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,n,s)),this.rewriteActions(s.data.inActions,["inActions"],e,r,n,s),this.rewriteActions(s.data.outActions,["outActions"],e,r,n,s)):"actions"in s.data&&this.rewriteActions(s.data.actions,["actions"],e,r,n,s)})}),!0})}expandInstances(e,r,n){let s=new Set;this.traverseEntity(o=>{if(o instanceof Js&&o.isInstanceRoot)return o.expandInstanceChildren({scene:this,shared:e,pendingDeletes:s}),r||o.resetBBoxNeedsUpdate(),n&&o.traverseEntity(a=>{n.addClip(a)}),!0});for(let o of s)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),Yx(o)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(n=>{n instanceof Js&&n.isInstanceRoot&&(n.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let n=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[n]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[n]),r.dispose()})}clearScene(){for(let e of this.children)At.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let n=[],s=o=>{for(let a of o.children){let l=a.cloner;if(At.is(a)&&!a.raycastLock&&(a.visible||l?.object.data.visible))if(r===!0&&a.isInstanceRoot){let c=[];if(e.intersectObject(a,!0,c),c.length){let u=c[0];u.object=a,u.point.applyMatrix4(u.object.matrixWorld);let h=a.matrixWorld.clone().invert();u.point.applyMatrix4(h),n.push(u)}}else(ln(a)||Nm(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,n),jm(a,e,n)),s(a)}};return s(this.activePage),n}raycastWithClones(e){let r=[],n=s=>{for(let o of s.children){let a=o.cloner;At.is(o)&&(o.visible||a?.object.data.visible)&&((ln(o)||Nm(o)&&this.enableHelpers&&o.objectHelper.visible)&&(e.intersectObject(o,!1,r),jm(o,e,r,!0)),n(o))}};return n(this),r}forEachEntity(e){for(let r of this.children)At.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)At.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)At.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(n=>{if(n instanceof dr&&n.data.type==="Mesh"&&n.data.geometry.type==="TextGeometry"&&n.data.geometry.font===e){let s=n.geometry,o=n.data.geometry;s.updateFont(e,r).then(()=>{s.update(o);let a=n.invalidateDownstreamBooleanData();Mn(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)yd.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)At.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,n){let s=0;for(let o of e)this.createObject(o.id,o.data,o.children,r,s,n),s+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,n,s,o,a){let l={scene:this,shared:a},c=tb(e,r,l);return c&&(this.entityByUuid[e]=c,s.add(c),s.children.splice(o,0,s.children.pop()),n.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(n,c,a)),c.updateState(r,l),c instanceof dr&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let h=u.dataPatched;if(u instanceof dr&&h.bones&&h.boneInverses){let d=h.bones.map(g=>this.find(g)),f=h.boneInverses.map(g=>new ue().fromArray(g)),p=new rl(d,f);u.bind(p,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let s=0,o=e.length;s<o;++s){let{id:a,recursive:l}=e[s],c=this.find(a),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let n=new zt;return n.setFromPoints(r),n.getCenter(tB),tB}copyMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e);n?r.copy(n.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let n=this.find(e)?.parent;n?r.copy(n.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof yr)if(Array.isArray(r.material))for(let n=0;n<r.material.length;n++)r.material[n]instanceof Fn&&e(r.material[n]);else r.material instanceof Fn&&e(r.material)})}updateViewPlaneSize(e,r,n=!1){this.traverseConcreteEntity(s=>{s instanceof Tr&&s.setViewplaneSize(e,r,n)})}initializeSplatViewer(){this.splatViewer=new Wm({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var qm=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},rB=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return IQ(Math.atan2(r,e))},iB=(i,t,e)=>{let r={x:0,y:0};return e=ab(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},ab=i=>i*(Math.PI/180),IQ=i=>i*(180/Math.PI),nB=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,tT=new Map,rT=i=>{tT.has(i)&&clearTimeout(tT.get(i)),tT.set(i,setTimeout(i,100))},Rf=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s<r.length;s+=1)n=r[s],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},iT=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let s=0;s<r.length;s+=1)n=r[s],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var lb=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),nT=()=>{if(typeof window>"u")return;let i=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:i,y:t}},cb=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},ub=(i,t,e)=>{let r=oB(i);for(let n in r)if(r.hasOwnProperty(n))if(typeof t=="string")r[n]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";r[n]=s.slice(0,-2)}return r},sB=(i,t)=>{let e=oB(i);for(let r in e)e.hasOwnProperty(r)&&(e[r]=t);return e},oB=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},hb=(i,t)=>{for(let e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},aB=(i,t)=>{let e={};for(let r in i)i.hasOwnProperty(r)&&t.hasOwnProperty(r)?e[r]=t[r]:i.hasOwnProperty(r)&&(e[r]=i[r]);return e},Xm=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},lB=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(cB="ontouchstart"in window,uB=!!window.PointerEvent,hB=!!window.MSPointerEvent);var cB,uB,hB,Ym={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"}},Lf,Km={};uB?Lf=Ym.pointer:hB?Lf=Ym.MSPointer:cB?(Lf=Ym.touch,Km=Ym.mouse):Lf=Ym.mouse;function ru(){}ru.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)n=r[s],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};ru.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};ru.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<r.length;s+=1)n=r[s],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(o){o.call(e,{type:n,target:e},t)})};ru.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=aB(t.options,i))};ru.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Rf(i,Lf[t],e._domHandlers_[t]),Km[t]&&Rf(i,Km[t],e._domHandlers_[t]),e};ru.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},iT(i,Lf[t],e._domHandlers_[t]),Km[t]&&iT(i,Km[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Nf=ru;function Oi(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,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=Oi.id,Oi.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}Oi.prototype=new Nf;Oi.constructor=Oi;Oi.id=0;Oi.prototype.buildEl=function(i){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)};Oi.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=sB("borderRadius","50%"),e=ub("transition","opacity",i),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)"},hb(r.el,e),this.options.shape==="circle"&&hb(r.back,t),hb(r.front,t),this.applyStyles(r),this};Oi.prototype.applyStyles=function(i){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};Oi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Oi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Oi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Oi.prototype.show=function(i){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 i=="function"&&i.call(this)},t.options.fadeTime)),t};Oi.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};Oi.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=ub("transition",["top","left"],r);var s={front:{}};s.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};Oi.prototype.restCallback=function(){var i=this,t={};t.front=ub("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};Oi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Oi.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,s,o;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?s="left":s="right"),i.lockX||(t>0?o="up":o="down"),i.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var c={};this.direction={x:s,y:o,angle:n},i.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return i;(!c.x||!c.y)&&this.trigger("plain",i),c.x||this.trigger("plain:"+s,i),c.y||this.trigger("plain:"+o,i),c.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var dB=Oi;function hi(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=hi.id,hi.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}hi.prototype=new Nf;hi.constructor=hi;hi.id=0;hi.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};hi.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};hi.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};hi.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},s=e.options,o={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-o.x,y:i.y-o.y};else if(i.top||i.right||i.bottom||i.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=i.top,a.style.right=i.right,a.style.bottom=i.bottom,a.style.left=i.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),n=i,i={x:l.left+r.x,y:l.top+r.y}}var c=new dB(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:i,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(cb(c.ui.el,n),cb(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};hi.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};hi.prototype.bindNipple=function(i){var t=this,e,r=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};hi.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var s=i.force||i.pressure||i.webkitForce||0;s!==n&&(t.trigger("pressure",s),r.trigger("pressure "+t.identifier+":pressure",s),n=s)}.bind(r),100)};hi.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=lb(i),t.updateBox();var n=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(r.touches).findIndex(function(l){return l.identifier===o})<0){var a=[i[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return Xm(i,n),t.manager.bindDocument(),!1};hi.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),s=i.force||i.pressure||i.webkitForce||0,o={x:i.pageX,y:i.pageY},a=t.getOrCreate(n,o);a.identifier!==n&&t.manager.removeIdentifier(a.identifier),a.identifier=n;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),s>0&&t.pressureFn(i,u,u.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(a))>=0&&t.idles.splice(r,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")l(a);else{var c=qm(o,a.position);if(c<=e.catchDistance)l(a);else{a.destroy(),t.processOnStart(i);return}}return a};hi.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};hi.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),s=t.manager.scroll;if(!nB(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var o=n.el.getBoundingClientRect();n.position={x:s.x+o.left,y:s.y+o.top}}n.identifier=r;var a=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var c=qm(l,n.position),u=rB(l,n.position),h=ab(u),d=c/a,f={distance:c,position:l},p,g;if(n.options.shape==="circle"?(p=Math.min(c,a),g=iB(n.position,p,u)):(g=lB(l,n.position,a),p=qm(g,n.position)),e.follow){if(c>a){let x=l.x-g.x,b=l.y-g.y;n.position.x+=x,n.position.y+=b,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",c=qm(l,n.position)}}else l=g,c=p;var y=l.x-n.position.x,m=l.y-n.position.y;n.frontPosition={x:y,y:m},e.dataOnly||cb(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:d,pressure:i.force||i.pressure||i.webkitForce||0,distance:c,angle:{radian:h,degree:u},vector:{x:y/a,y:-m/a},raw:f,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:ab(180-u),degree:180-u},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};hi.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),s=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};hi.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};hi.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)i.pressureIntervals.hasOwnProperty(t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off()};var fB=hi;function qi(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=nT(),t.config(i),t.prepareCollections();var e=function(){var n;t.collections.forEach(function(s){s.forEach(function(o){n=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+n.left,y:t.scroll.y+n.top}})})};if(typeof window>"u")return t.collections;Rf(window,"resize",function(){rT(e)});var r=function(){t.scroll=nT()};return Rf(window,"scroll",function(){rT(r)}),t.collections}qi.prototype=new Nf;qi.constructor=qi;qi.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};qi.prototype.create=function(i){return this.createCollection(i)};qi.prototype.createCollection=function(i){var t=this,e=new fB(t,i);return t.bindCollection(e),t.collections.push(e),e};qi.prototype.bindCollection=function(i){var t=this,e,r=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};qi.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};qi.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};qi.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.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]};qi.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};qi.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};qi.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};qi.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};qi.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=lb(t);var s=function(a,l,c){c.ids.indexOf(l)>=0&&(c[n](a),a._found_=!0)},o=function(a){r=e.getIdentifier(a),Xm(e.collections,s.bind(null,a,r)),a._found_||e.removeIdentifier(r)};return Xm(t,o),!1};qi.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.off()};qi.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};var pB=qi;var mB=new pB,gB={create:function(i){return mB.create(i)},factory:mB};var yB=new Map,Qm=new Map,Fo=class{constructor(t,e,r,n){this.data=e;let{audio:s,volume:o,delay:a,loop:l}=e;if(!s)throw new Error("Missing property");let c=typeof s=="string"?n.getAudio(s).src:s.data;this.audioPlayer=new Ia({src:c,volume:o,delay:a,loop:l}),Qm.has(r.uuid)?Qm.get(r.uuid).push(this):Qm.set(r.uuid,[this]),yB.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},Bf=class{constructor(t){this.data=t}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=yB.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Qm.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let t=[...Qm.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Zm=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new Fo(t,e,r,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Bf(e);else throw new Error("Missing property")}dispatchBasic(){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(t){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fo&&(t==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Jm=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.delay=0;this.emission=t.emission,t.delay!==void 0&&(this.delay=t.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(t=0){if(t){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(Gt(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(Gt(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(t){if(Gt(this.shared,this.condition)===!1||!this.particleSystem)return!1;t==="start"?this.particleSystem.start():this.particleSystem.stop()}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};var RQ="text/plain",LQ="us-ascii",vB=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),NQ=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:r,data:n,hash:s}=e.groups,o=r.split(";");s=t?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),u=[...o.map(h=>{let[d,f=""]=h.split("=").map(p=>p.trim());return d==="charset"&&(f=f.toLowerCase(),f===LQ)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&u.push("base64"),(u.length>0||l&&l!==RQ)&&u.unshift(l),`data:${u.join(";")},${a?n.trim():n}${s?`#${s}`:""}`};function sT(i,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},i=i.trim(),/^data:/i.test(i))return NQ(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let n=new URL(i);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&n.protocol==="https:"&&(n.protocol="http:"),t.forceHttps&&n.protocol==="http:"&&(n.protocol="https:"),t.stripAuthentication&&(n.username="",n.password=""),t.stripHash?n.hash="":t.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let u=o.exec(n.pathname);if(!u)break;let h=u[0],d=u.index,f=n.pathname.slice(a,d);l+=f.replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}let c=n.pathname.slice(a,n.pathname.length);l+=c.replace(/\/{2,}/g,"/"),n.pathname=l}if(n.pathname)try{n.pathname=decodeURI(n.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let o=n.pathname.split("/"),a=o[o.length-1];vB(a,t.removeDirectoryIndex)&&(o=o.slice(0,-1),n.pathname=o.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let o of[...n.searchParams.keys()])vB(o,t.removeQueryParameters)&&n.searchParams.delete(o);if(t.removeQueryParameters===!0&&(n.search=""),t.sortQueryParameters){n.searchParams.sort();try{n.search=decodeURIComponent(n.search)}catch{}}t.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,""));let s=i;return i=n.toString(),!t.removeSingleSlash&&n.pathname==="/"&&!s.endsWith("/")&&n.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||n.pathname==="/")&&n.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var fb=class{constructor({url:t,context:e},r,n,s){this.controlsManager=r;this.shared=n;this.condition=s;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:sT(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(Gt(this.shared,this.condition)===!1)return!1;Rh?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(nt[0]),eD())}};var $m=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,n=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let s of e.cloner.children)n?(s.playModeVisible=!1,s.rigidBody&&e.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0)):this.clone===void 0||this.clone===s?(s.playModeVisible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),r.removeRigidBody(s.rigidBody),s.rigidBody=void 0)):s.playModeVisible===void 0&&(s.playModeVisible=!0);(n||this.clone===void 0||this.clone===!1)&&(e.visible=!1,e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0))}else e.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(e.rigidBody.collider(0).handle),r.removeRigidBody(e.rigidBody),e.rigidBody=void 0),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(s=>s.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}dispatch(t){if(Gt(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(Gt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};var eg=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.shared=r;this.eventManager=n;this.condition=s;this.shared=r}dispatch(){if(Gt(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),Ff(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}};var EB={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},cT={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},BQ=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],mb={CSS:{},springs:{}};function $s(i,t,e){return Math.min(Math.max(i,t),e)}function tg(i,t){return i.indexOf(t)>-1}function oT(i,t){return i.apply(null,t)}var ft={arr:function(i){return Array.isArray(i)},obj:function(i){return tg(Object.prototype.toString.call(i),"Object")},pth:function(i){return ft.obj(i)&&i.hasOwnProperty("totalLength")},svg:function(i){return i instanceof SVGElement},inp:function(i){return i instanceof HTMLInputElement},dom:function(i){return!("isNode"in i)&&(i.nodeType||ft.svg(i))},str:function(i){return typeof i=="string"},fnc:function(i){return typeof i=="function"},und:function(i){return typeof i>"u"},hex:function(i){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(i)},rgb:function(i){return/^rgb/.test(i)},hsl:function(i){return/^hsl/.test(i)},col:function(i){return ft.hex(i)||ft.rgb(i)||ft.hsl(i)},key:function(i){return!EB.hasOwnProperty(i)&&!cT.hasOwnProperty(i)&&i!=="targets"&&i!=="keyframes"}};function TB(i){var t=/\(([^)]+)\)/.exec(i);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function MB(i,t){var e=TB(i),r=$s(ft.und(e[0])?1:e[0],.1,100),n=$s(ft.und(e[1])?100:e[1],.1,100),s=$s(ft.und(e[2])?10:e[2],.1,100),o=$s(ft.und(e[3])?0:e[3],.1,100),a=Math.sqrt(n/r),l=s/(2*Math.sqrt(n*r)),c=l<1?a*Math.sqrt(1-l*l):0,u=1,h=l<1?(l*a+-o)/c:-o+a;function d(p){var g=t?t*p/1e3:p;return l<1?g=Math.exp(-g*l*a)*(u*Math.cos(c*g)+h*Math.sin(c*g)):g=(u+h*g)*Math.exp(-g*a),p===0||p===1?p:1-g}function f(){var p=mb.springs[i];if(p)return p;for(var g=1/6,y=0,m=0;;)if(y+=g,d(y)===1){if(m++,m>=16)break}else m=0;var v=y*g*1e3;return mb.springs[i]=v,v}return t?d:f}function FQ(i){return i===void 0&&(i=10),function(t){return Math.ceil($s(t,1e-6,1)*i)*(1/i)}}var UQ=function(){var i=11,t=1/(i-1);function e(u,h){return 1-3*h+3*u}function r(u,h){return 3*h-6*u}function n(u){return 3*u}function s(u,h,d){return((e(h,d)*u+r(h,d))*u+n(h))*u}function o(u,h,d){return 3*e(h,d)*u*u+2*r(h,d)*u+n(h)}function a(u,h,d,f,p){var g,y,m=0;do y=h+(d-h)/2,g=s(y,f,p)-u,g>0?d=y:h=y;while(Math.abs(g)>1e-7&&++m<10);return y}function l(u,h,d,f){for(var p=0;p<4;++p){var g=o(h,d,f);if(g===0)return h;var y=s(h,d,f)-u;h-=y/g}return h}function c(u,h,d,f){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var p=new Float32Array(i);if(u!==h||d!==f)for(var g=0;g<i;++g)p[g]=s(g*t,u,d);function y(m){for(var v=0,x=1,b=i-1;x!==b&&p[x]<=m;++x)v+=t;--x;var S=(m-p[x])/(p[x+1]-p[x]),w=v+S*t,E=o(w,u,d);return E>=.001?l(m,w,u,d):E===0?w:a(m,v,v+t,u,d)}return function(m){return u===h&&d===f||m===0||m===1?m:s(y(m),h,f)}}return c}(),CB=function(){var i={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 n,s=4;r<((n=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((n*3-2)/22-r,2)}},Elastic:function(r,n){r===void 0&&(r=1),n===void 0&&(n=.5);var s=$s(r,1,10),o=$s(n,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},e=["Quad","Cubic","Quart","Quint","Expo"];return e.forEach(function(r,n){t[r]=function(){return function(s){return Math.pow(s,n+2)}}}),Object.keys(t).forEach(function(r){var n=t[r];i["easeIn"+r]=n,i["easeOut"+r]=function(s,o){return function(a){return 1-n(s,o)(1-a)}},i["easeInOut"+r]=function(s,o){return function(a){return a<.5?n(s,o)(a*2)/2:1-n(s,o)(a*-2+2)/2}}}),i}();function uT(i,t){if(ft.fnc(i))return i;var e=i.split("(")[0],r=CB[e],n=TB(i);switch(e){case"spring":return MB(i,t);case"cubicBezier":return oT(UQ,n);case"steps":return oT(FQ,n);default:return oT(r,n)}}function _B(i){try{var t=document.querySelectorAll(i);return t}catch{return}}function gb(i,t){for(var e=i.length,r=arguments.length>=2?arguments[1]:void 0,n=[],s=0;s<e;s++)if(s in i){var o=i[s];t.call(r,o,s,i)&&n.push(o)}return n}function yb(i){return i.reduce(function(t,e){return t.concat(ft.arr(e)?yb(e):e)},[])}function xB(i){return ft.arr(i)?i:(ft.str(i)&&(i=_B(i)||i),i instanceof NodeList||i instanceof HTMLCollection?[].slice.call(i):[i])}function hT(i,t){return i.some(function(e){return e===t})}function dT(i){var t={};for(var e in i)t[e]=i[e];return t}function aT(i,t){var e=dT(i);for(var r in i)e[r]=t.hasOwnProperty(r)?t[r]:i[r];return e}function vb(i,t){var e=dT(i);for(var r in t)e[r]=ft.und(i[r])?t[r]:i[r];return e}function VQ(i){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(i);return t?"rgba("+t[1]+",1)":i}function zQ(i){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e=i.replace(t,function(a,l,c,u){return l+l+c+c+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),n=parseInt(r[1],16),s=parseInt(r[2],16),o=parseInt(r[3],16);return"rgba("+n+","+s+","+o+",1)"}function kQ(i){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(i)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(i),e=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,n=parseInt(t[3],10)/100,s=t[4]||1;function o(d,f,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?d+(f-d)*6*p:p<1/2?f:p<2/3?d+(f-d)*(2/3-p)*6:d}var a,l,c;if(r==0)a=l=c=n;else{var u=n<.5?n*(1+r):n+r-n*r,h=2*n-u;a=o(h,u,e+1/3),l=o(h,u,e),c=o(h,u,e-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function GQ(i){if(ft.rgb(i))return VQ(i);if(ft.hex(i))return zQ(i);if(ft.hsl(i))return kQ(i)}function Ba(i){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(i);if(t)return t[1]}function HQ(i){if(tg(i,"translate")||i==="perspective")return"px";if(tg(i,"rotate")||tg(i,"skew"))return"deg"}function lT(i,t){return ft.fnc(i)?i(t.target,t.id,t.total):i}function Uo(i,t){return i.getAttribute(t)}function fT(i,t,e){var r=Ba(t);if(hT([e,"deg","rad","turn"],r))return t;var n=mb.CSS[t+e];if(!ft.und(n))return n;var s=100,o=document.createElement(i.tagName),a=i.parentNode&&i.parentNode!==document?i.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+e;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(t);return mb.CSS[t+e]=c,c}function PB(i,t,e){if(t in i.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=i.style[t]||getComputedStyle(i).getPropertyValue(r)||"0";return e?fT(i,n,e):n}}function pT(i,t){if(ft.dom(i)&&!ft.inp(i)&&(Uo(i,t)||ft.svg(i)&&i[t]))return"attribute";if(ft.dom(i)&&hT(BQ,t))return"transform";if(ft.dom(i)&&t!=="transform"&&PB(i,t))return"css";if(i[t]!=null)return"object"}function DB(i){if(!!ft.dom(i)){for(var t=i.style.transform||"",e=/(\w+)\(([^)]*)\)/g,r=new Map,n;n=e.exec(t);)r.set(n[1],n[2]);return r}}function jQ(i,t,e,r){var n=tg(t,"scale")?1:0+HQ(t),s=DB(i).get(t)||n;return e&&(e.transforms.list.set(t,s),e.transforms.last=t),r?fT(i,s,r):s}function mT(i,t,e,r){switch(pT(i,t)){case"transform":return jQ(i,t,r,e);case"css":return PB(i,t,e);case"attribute":return Uo(i,t);default:return i[t]||0}}function gT(i,t){var e=/^(\*=|\+=|-=)/.exec(i);if(!e)return i;var r=Ba(i)||0,n=parseFloat(t),s=parseFloat(i.replace(e[0],""));switch(e[0][0]){case"+":return n+s+r;case"-":return n-s+r;case"*":return n*s+r}}function OB(i,t){if(ft.col(i))return GQ(i);if(/\s/g.test(i))return i;var e=Ba(i),r=e?i.substr(0,i.length-e.length):i;return t?r+t:r}function yT(i,t){return Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))}function WQ(i){return Math.PI*2*Uo(i,"r")}function qQ(i){return Uo(i,"width")*2+Uo(i,"height")*2}function XQ(i){return yT({x:Uo(i,"x1"),y:Uo(i,"y1")},{x:Uo(i,"x2"),y:Uo(i,"y2")})}function IB(i){for(var t=i.points,e=0,r,n=0;n<t.numberOfItems;n++){var s=t.getItem(n);n>0&&(e+=yT(r,s)),r=s}return e}function YQ(i){var t=i.points;return IB(i)+yT(t.getItem(t.numberOfItems-1),t.getItem(0))}function RB(i){if(i.getTotalLength)return i.getTotalLength();switch(i.tagName.toLowerCase()){case"circle":return WQ(i);case"rect":return qQ(i);case"line":return XQ(i);case"polyline":return IB(i);case"polygon":return YQ(i)}}function KQ(i){var t=RB(i);return i.setAttribute("stroke-dasharray",t),t}function QQ(i){for(var t=i.parentNode;ft.svg(t)&&ft.svg(t.parentNode);)t=t.parentNode;return t}function LB(i,t){var e=t||{},r=e.el||QQ(i),n=r.getBoundingClientRect(),s=Uo(r,"viewBox"),o=n.width,a=n.height,l=e.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function ZQ(i,t){var e=ft.str(i)?_B(i)[0]:i,r=t||100;return function(n){return{property:n,el:e,svg:LB(e),totalLength:RB(e)*(r/100)}}}function JQ(i,t){function e(a){a===void 0&&(a=0);var l=t+a>=1?t+a:0;return i.el.getPointAtLength(l)}var r=LB(i.el,i.svg),n=e(),s=e(-1),o=e(1);switch(i.property){case"x":return(n.x-r.x)*r.w;case"y":return(n.y-r.y)*r.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function bB(i,t){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=OB(ft.pth(i)?i.totalLength:i,t)+"";return{original:r,numbers:r.match(e)?r.match(e).map(Number):[0],strings:ft.str(i)||t?r.split(e):[]}}function NB(i){var t=i?yb(ft.arr(i)?i.map(xB):xB(i)):[];return gb(t,function(e,r,n){return n.indexOf(e)===r})}function BB(i){var t=NB(i);return t.map(function(e,r){return{target:e,id:r,total:t.length,transforms:{list:DB(e)}}})}function $Q(i,t){var e=dT(t);if(/^spring/.test(e.easing)&&(e.duration=MB(e.easing)),ft.arr(i)){var r=i.length,n=r===2&&!ft.obj(i[0]);n?i={value:i}:ft.fnc(t.duration)||(e.duration=t.duration/r)}var s=ft.arr(i)?i:[i];return s.map(function(o,a){var l=ft.obj(o)&&!ft.pth(o)?o:{value:o};return ft.und(l.delay)&&(l.delay=a?0:t.delay),ft.und(l.endDelay)&&(l.endDelay=a===s.length-1?t.endDelay:0),l}).map(function(o){return vb(o,e)})}function eZ(i){for(var t=gb(yb(i.map(function(s){return Object.keys(s)})),function(s){return ft.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),e={},r=function(s){var o=t[s];e[o]=i.map(function(a){var l={};for(var c in a)ft.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},n=0;n<t.length;n++)r(n);return e}function tZ(i,t){var e=[],r=t.keyframes;r&&(t=vb(eZ(r),t));for(var n in t)ft.key(n)&&e.push({name:n,tweens:$Q(t[n],i)});return e}function rZ(i,t){var e={};for(var r in i){var n=lT(i[r],t);ft.arr(n)&&(n=n.map(function(s){return lT(s,t)}),n.length===1&&(n=n[0])),e[r]=n}return e.duration=parseFloat(e.duration),e.delay=parseFloat(e.delay),e}function iZ(i,t){var e;return i.tweens.map(function(r){var n=rZ(r,t),s=n.value,o=ft.arr(s)?s[1]:s,a=Ba(o),l=mT(t.target,i.name,a,t),c=e?e.to.original:l,u=ft.arr(s)?s[0]:c,h=Ba(u)||Ba(l),d=a||h;return ft.und(o)&&(o=c),n.from=bB(u,d),n.to=bB(gT(o,u),d),n.start=e?e.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=uT(n.easing,n.duration),n.isPath=ft.pth(s),n.isColor=ft.col(n.from.original),n.isColor&&(n.round=1),e=n,n})}var FB={css:function(i,t,e){return i.style[t]=e},attribute:function(i,t,e){return i.setAttribute(t,e)},object:function(i,t,e){return i[t]=e},transform:function(i,t,e,r,n){if(r.list.set(t,e),t===r.last||n){var s="";r.list.forEach(function(o,a){s+=a+"("+o+") "}),i.style.transform=s}}};function UB(i,t){var e=BB(i);e.forEach(function(r){for(var n in t){var s=lT(t[n],r),o=r.target,a=Ba(s),l=mT(o,n,a,r),c=a||Ba(l),u=gT(OB(s,c),l),h=pT(o,n);FB[h](o,n,u,r.transforms,!0)}})}function nZ(i,t){var e=pT(i.target,t.name);if(e){var r=iZ(t,i),n=r[r.length-1];return{type:e,property:t.name,animatable:i,tweens:r,duration:n.end,delay:r[0].delay,endDelay:n.endDelay}}}function sZ(i,t){return gb(yb(i.map(function(e){return t.map(function(r){return nZ(e,r)})})),function(e){return!ft.und(e)})}function VB(i,t){var e=i.length,r=function(s){return s.timelineOffset?s.timelineOffset:0},n={};return n.duration=e?Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+l+s.duration*(s.loop??1)})):t.duration,n.delay=e?Math.min.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0;return r(s)+o+a+s.delay})):t.delay,n.endDelay=e?n.duration-Math.max.apply(Math,i.map(function(s){let o=s.startOnceDelay??0,a=s.pingPongDelayCorrection??0,l=s.pingPongEndDelayCorrection??0;return r(s)+o+a+s.duration*(s.loop??1)-s.endDelay-l})):t.endDelay,n}var SB=0;function oZ(i){var t=aT(EB,i),e=aT(cT,i),r=tZ(e,i),n=BB(i.targets),s=sZ(n,r),o=VB(s,e),a=SB;return SB++,vb(t,{id:a,children:[],animatables:n,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay,startOnceDelay:e.startOnceDelay,pingPongDelayCorrection:e.pingPongDelayCorrection,pingPongEndDelayCorrection:e.pingPongEndDelayCorrection})}var Ts=[],wB=[],pb,aZ=function(){function i(){pb=requestAnimationFrame(t)}function t(e){var r=Ts.length;if(r){for(var n=0;n<r;){var s=Ts[n];s.paused?(Ts.splice(n,1),r-=1):(s.tick(e),n++)}i()}else pb=cancelAnimationFrame(pb)}return i}();function lZ(i){document.hidden?(Ts.forEach(function(t){return t.pause(i.timeStamp)}),wB=Ts.slice(0),di.running=Ts=[]):wB.forEach(function(t){return t.play(i.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",lZ);function di(i){i===void 0&&(i={});var t=0,e=0,r=0,n,s,o=0,a=null;function l(E){var A=window.Promise&&new Promise(function(P){return a=P});return E.finished=A,A}var c=oZ(i),u=l(c);function h(){var E=c.direction;E!=="alternate"&&(c.direction=E!=="normal"?"normal":"reverse"),c.reversed=!c.reversed,s.forEach(function(A){(A.loop===1||A.loop%2===0)&&(A.reversed=c.reversed)})}function d(){c.direction="normal",c.reversed=!1,s.forEach(function(E){return E.reversed=!1})}function f(E){return c.reversed?c.duration-E:E}function p(){t=0,e=f(c.currentTime)*(1/di.speed)}function g(E,A,P=!1){A&&(c.reversed?A.seek(A.duration*A.loop-(E-A.timelineOffset-A.pingPongDelayCorrection),P):A.seek(E-A.timelineOffset-A.startOnceDelay-A.pingPongDelayCorrection,P))}function y(E,A=!1){if(c.reversed)for(var M=o;M--;)g(E,s[M],A);else for(var P=0;P<o;P++)g(E,s[P],A)}function m(E){var A=0,P=c.animations,M=P.length;for(c.direction!=="alternate"&&c.parent?.direction==="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1&&(c.parent?.reversed&&c.direction==="alternate"?E=c.duration-c.delay+c.endDelay-E:E=c.duration+c.delay-c.endDelay-E):S(!1,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)&&(c.parent?.reversed&&c.direction==="alternate"?E=c.duration-c.delay+c.endDelay-E:E=c.duration+c.delay-c.endDelay-E);A<M;){var C=P[A],O=C.animatable,L=C.tweens,D=L.length-1,B=L[D];D&&(B=gb(L,function(se){return E<se.end})[0]||B);let $;c.parent?.reversed&&c.direction==="alternate"?$=$s(E-B.start-B.endDelay,0,B.duration)/B.duration:$=$s(E-B.start-B.delay,0,B.duration)/B.duration;for(var k=isNaN($)?1:B.easing($),F=B.to.strings,H=B.round,G=[],X=B.to.numbers.length,Y=void 0,Z=0;Z<X;Z++){var le=void 0;let se,Se;c.direction!=="alternate"?c.parent?.rewind===!1&&c.reversePlayback===!0&&c.rewind===!1?(se=B.to.numbers[Z],Se=B.from.numbers[Z]||0):(Se=B.to.numbers[Z],se=B.from.numbers[Z]||0):S(!0,c.parent?.rewind,c.rewind,c.parent?.reversePlayback,c.reversePlayback)?(se=B.to.numbers[Z],Se=B.from.numbers[Z]||0):(Se=B.to.numbers[Z],se=B.from.numbers[Z]||0),B.isPath?le=JQ(B.value,k*Se):le=se+k*(Se-se),H&&(B.isColor&&Z>2||(le=Math.round(le*H)/H)),G.push(le)}var j=F.length;if(!j)Y=G[0];else{Y=F[0];for(var K=0;K<j;K++){var ee=F[K],re=F[K+1],te=G[K];isNaN(te)||(re?Y+=te+re:Y+=te+" ")}}FB[C.type](O.target,C.property,Y,O.transforms),C.currentValue=Y,A++}}function v(E){c[E]&&!c.passThrough&&c[E](c)}function x(){c.remaining&&c.remaining!==!0&&c.remaining--}let b={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(E,A,P,M,C){return b[E<<4|A<<3|P<<2|M<<1|C]}function w(E,A=!1){var P=c.duration;let M=c.delay,C=P-c.endDelay;c.parent?.reversed&&c.direction==="alternate"&&(M=c.endDelay,C=P-c.delay);var O=f(E);if(c.progress=$s(O/P*100,0,100),A||(c.reversePlayback=O<c.currentTime),o&&y(O,A),!c.began&&c.currentTime>=0&&(c.began=!0,v("begin")),!c.loopBegan&&c.currentTime>0&&(c.loopBegan=!0,v("loopBegin")),(c.reversed||O>=0)&&O<=M&&c.currentTime!==0&&(m(0),v("change")),(O>=C&&c.currentTime!==P+c.pingPongDelayCorrection||!P)&&(m(P),v("change")),O>M&&O<C?(c.changeBegan||(c.changeBegan=!0,c.changeCompleted=!1,v("changeBegin")),m(O),v("change")):c.changeBegan?(c.changeCompleted=!0,c.changeBegan=!1,v("change"),o&&v("timelineChangeComplete")):c.began&&O>C&&v("changeComplete"),c.currentTime=$s(O,0,P+c.pingPongDelayCorrection),c.began&&v("update"),E>=P)if(x(),!c.remaining)c.paused=!0,c.completed||(c.completed=!0,v("loopComplete"),v("complete"),!c.passThrough&&"Promise"in window&&(a(),u=l(c)));else{o?t+=c.duration/di.speed:t+=c.duration;for(let L of s)L.setStartTime(0),L.remaining=L.loop;v("loopComplete"),c.loopBegan=!1,c.direction==="alternate"?h():o&&d()}}return c.reset=function(){var E=c.direction;c.passThrough=!1,c.currentTime=0,c.progress=0,c.paused=!0,c.began=!1,c.loopBegan=!1,c.changeBegan=!1,c.completed=!1,c.changeCompleted=!1,c.reversePlayback=!1,c.reversed=E==="reverse",c.remaining=c.loop,s=c.children,o=s.length;for(var A=o;A--;)c.children[A].reset();m(c.reversed?c.duration:0)},c.setStartTime=function(E){t=E},c.set=function(E,A){return UB(E,A),c},c.tick=function(E){r=E,t||(t=r),w((r+(e-t))*di.speed)},c.seek=function(E,A=!1){w(E-t,A)},c.pause=function(E){c.paused=!0,o&&(n=E??performance.now())},c.play=function(E){!c.paused||(c.completed&&c.reset(),c.paused=!1,Ts.push(c),o&&n!==void 0&&(t+=(E??performance.now())-n),pb||aZ())},c.reverse=function(){h(),c.completed=!c.reversed,p()},c.restart=function(){c.reset(),c.play()},c.reset(),c.autoplay&&c.play(),c}function AB(i,t){for(var e=t.length;e--;)hT(i,t[e].animatable.target)&&t.splice(e,1)}function cZ(i){for(var t=NB(i),e=Ts.length;e--;){var r=Ts[e],n=r.animations,s=r.children;AB(t,n);for(var o=s.length;o--;){var a=s[o],l=a.animations;AB(t,l),!l.length&&!a.children.length&&s.splice(o,1)}!n.length&&!s.length&&r.pause()}}function uZ(i,t){t===void 0&&(t={});var e=t.direction||"normal",r=t.easing?uT(t.easing):null,n=t.grid,s=t.axis,o=t.from||0,a=o==="first",l=o==="center",c=o==="last",u=ft.arr(i),h=parseFloat(u?i[0]:i),d=u?parseFloat(i[1]):0,f=Ba(u?i[1]:i)||0,p=t.start||0+(u?h:0),g=[],y=0;return function(m,v,x){if(a&&(o=0),l&&(o=(x-1)/2),c&&(o=x-1),!g.length){for(var b=0;b<x;b++){if(!n)g.push(Math.abs(o-b));else{var S=l?(n[0]-1)/2:o%n[0],w=l?(n[1]-1)/2:Math.floor(o/n[0]),E=b%n[0],A=Math.floor(b/n[0]),P=S-E,M=w-A,C=Math.sqrt(P*P+M*M);s==="x"&&(C=-P),s==="y"&&(C=-M),g.push(C)}y=Math.max.apply(Math,g)}r&&(g=g.map(function(L){return r(L/y)*y})),e==="reverse"&&(g=g.map(function(L){return s?L<0?L*-1:-L:Math.abs(y-L)}))}var O=u?(d-h)/y:h;return p+O*(Math.round(g[v]*100)/100)+f}}function hZ(i){i===void 0&&(i={});var t=di(i);return t.duration=0,t.add=function(e,r){var n=Ts.indexOf(t),s=t.children;n>-1&&Ts.splice(n,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=vb(e,aT(cT,i));l.targets=l.targets||i.targets;var c=t.duration;l.autoplay=!1,l.timelineOffset=ft.und(r)?c:gT(r,c),o(t);var u=di(l);o(u),s.push(u),u.parent=t;var h=VB(s,i);return t.delay=h.delay,t.endDelay=h.endDelay,t.duration=h.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}di.version="3.2.0";di.speed=1;di.running=Ts;di.remove=cZ;di.get=mT;di.set=UB;di.convertPx=fT;di.path=ZQ;di.setDashoffset=KQ;di.stagger=uZ;di.timeline=hZ;di.easing=uT;di.penner=CB;di.random=function(i,t){return Math.floor(Math.random()*(t-i+1))+i};var xb=di;var zB=new T,kB=new T,GB=new Qe;function jB(i,t,e,r){if(r===0)return e.copy(i);if(r===1)return e.copy(t);let n=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(n>=1)return e.copy(i);let s=1-n*n;if(s<=Number.EPSILON){let u=1-r;return e.w=u*i.w+r*t.w,e.x=u*i.x+r*t.x,e.y=u*i.y+r*t.y,e.z=u*i.z+r*t.z,e.normalize(),e}let o=Math.sqrt(s),a=Math.atan2(o,n),l=Math.sin((1-r)*a)/o,c=Math.sin(r*a)/o;return e.w=i.w*l+t.w*c,e.x=i.x*l+t.x*c,e.y=i.y*l+t.y*c,e.z=i.z*l+t.z*c,e}function $r(i,t,e,r,n,s){let o=e[i]?e[i]:void 0,a=r[i];if(a==null)return;let l=o!=null?typeof o=="string"?Number(n.getVariable(o)??0):o:t[i],c=typeof a=="string"?Number(n.getVariable(a)??0):a;if(l!==c)return{update:u=>{let h=_e.lerp(l,c,u);s?t[i]=Math.trunc(h):t[i]=h},start:()=>{t[i]=l},end:()=>{t[i]=c}}}function ig(i,t,e,r,n,s){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let l=t[i],c=[...o??l].map(h=>typeof h=="string"?Number(n.getVariable(h)??0):h),u=[...a].map(h=>typeof h=="string"?Number(n.getVariable(h)??0):h);if(!(c.length!==u.length||Fp(c,u)))return{update:h=>{c.forEach((d,f)=>{let p=_e.lerp(d,u[f],h);t[i][f]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[i],c)},end:()=>{Object.assign(t[i],u)}}}function rg(i,t,e){return t.forEach((r,n)=>{i.setComponent(n,typeof r=="string"?Number(e.getVariable(r)??0):r)}),i}function vT(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=s?rg(new T,s,n):a.clone(),c=rg(new T,o,n);if(!l.equals(c))return{update:u=>{a.lerpVectors(l,c,u)},start:()=>{a.copy(l)},end:()=>{a.copy(c)}}}function HB(i,t,e){return t.forEach((r,n)=>{i.setComponent(n,typeof r=="string"?Number(e.getVariable(r)??0):r)}),i}function Uf(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=!(a instanceof U),c=a instanceof U?a:new U().fromArray(a),u=s?HB(new U,s,n):c.clone(),h=HB(new U,o,n);if(!u.equals(h))return{update:d=>{c.lerpVectors(u,h,d),l&&(t[i]=c.toArray())},start:()=>{c.copy(u),l&&(t[i]=c.toArray())},end:()=>{c.copy(h),l&&(t[i]=c.toArray())}}}function WB(i,t,e,r){let n=e[i]?e[i]:void 0,s=r[i];if(!s)return;let o=t[i],a=n?new ue().fromArray(n):o.clone(),l=new T,c=new Qe,u=new T;a.decompose(l,c,u);let h=new ue().fromArray(s),d=new T,f=new Qe,p=new T;if(h.decompose(d,f,p),!a.equals(h))return{update:g=>{GB.slerpQuaternions(c,f,g),zB.lerpVectors(l,d,g),kB.lerpVectors(u,p,g),o.compose(zB,GB,kB)},start:()=>{o.compose(l,c,u)},end:()=>{o.compose(d,f,p)}}}function qB(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=s?typeof s=="string"?n.getColor(s).clone():new ke().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?n.getColor(o).clone():new ke().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return t[i]=u,{update:h=>{u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function ng(i,t,e,r,n){let s=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],l=new Ar(a.r,a.g,a.b,a.a),c=s?typeof s=="string"?n.getColor(s).clone():new Ar(s.r,s.g,s.b,s.a):l.clone(),u=typeof o=="string"?n.getColor(o).clone():new Ar(o.r,o.g,o.b,o.a);if(!c.equals(u))return{update:h=>{l.lerpColors(c,u,h);let d=_e.lerp(c.a,u.a,h);l.a=d,t[i]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(u)}}}function Vo(i,t,e,r,n){if(typeof t[i]=="number")return $r(i,t,e??{},r,n);if(Array.isArray(t[i]))return ig(i,t,e??{},r,n)}function XB(i,t,e,r){let n=[],s=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,o=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(o!==void 0){let a=s??i.zoom,l=o;a!==l&&n.push({update:c=>{i.zoom=_e.lerp(a,l,c),i.updateProjectionMatrix()},start:()=>{i.zoom=a,i.updateProjectionMatrix()},end:()=>{i.zoom=l,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let a=$r("targetOffset",i,t,e,r);a&&n.push(a)}return n}function dZ(i,t,e,r){if(e.scaleBaked===void 0)return;let n=(t.scaleBaked??i.data.geometry.scaleBaked).map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a),s=e.scaleBaked.map(a=>typeof a=="string"?Number(r.getVariable(a)??0):a);if(vo.isEqual(n,s))return;let o=[];return o.push({update:a=>{i.updateGeometryInteractions({scaleBaked:[_e.lerp(n[0],s[0],a),_e.lerp(n[1],s[1],a),_e.lerp(n[2],s[2],a)]},r),i.invalidateDownstreamBooleanData()},start:()=>{i.updateGeometryInteractions({scaleBaked:n},r),i.invalidateDownstreamBooleanData()},end:()=>{i.updateGeometryInteractions({scaleBaked:s},r),i.invalidateDownstreamBooleanData()}}),o}function fZ(i,t,e,r){if(!e.extrusion)return;let n=i.extrusion,s=t.extrusion??{},o=e.extrusion,a=[];return _A.forEach(l=>{let c=Vo(l,n,s,o,r);c&&a.push(c)}),a}function YB(i,t,e,r){let n=[];if(!("geometry"in e))return n;let s=i.geometry.userData.parameters,o="geometry"in t?t.geometry:{},a=e.geometry;if(i instanceof Ks){let l=dZ(i,o,a,r);l&&n.push(...l)}else{let l={};if(Object.assign(l,Zn(s,PA)),PA.forEach(c=>{let u=Vo(c,l,o,a,r);u&&n.push(u)}),i instanceof Ql){Object.assign(l,{extrusion:{...s.extrusion}});let c=fZ(l,o,a,r);c&&n.push(...c)}n.length&&n.push({update:c=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()},start:c=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()},end:c=>{i.updateGeometryInteractions(l,r),i.updateGeometryGroupsIfNeeded()}})}return n}function KB(i,t,e,r){let n=[];if(e.intensity!==void 0){let s=$r("intensity",i,t,e,r);s&&n.push(s)}if(e.color!==void 0){let s=qB("color",i,t,e,r);s&&n.push(s)}return n}function ZB(i,t,e,r){let n=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return n;let s="materials"in t&&t.materials?t.materials:[],o=e.materials;i.material.forEach((a,l)=>{if(!o[l])return;let c=s[l]??{},u=o[l];typeof c=="string"||typeof u=="string"||n.push(...QB(a,c,u,r))})}else{if(!("material"in e&&e.material))return n;let s="material"in t&&t.material?t.material:{},o=e.material;if(typeof s=="string"||typeof o=="string")return n;n.push(...QB(i.material,s,o,r))}return n}function QB(i,t,e,r){let n=[],s=qc(e,r)||!!t.layers&&qc(t,r);n.push(wZ(i,s));for(let o of i.layers){let a=t.layers?.data(o.uuid),l=e.layers.data(o.uuid);if(!l||o.type!=="light"&&(!(o.visible??!0)||!(l.visible??!0)))continue;let c=o.getNames().filter(u=>!Zv.some(h=>u.includes(h)));for(let u of c)try{let h=o.getValue(u),d;if(u==="colors")d=bZ(o,a,l,u);else if(Array.isArray(h))u==="steps"&&(d=xZ(o,a,l,u));else if(typeof h=="number")d=pZ(o,a,l,u,r);else{if(typeof h=="boolean")continue;h instanceof U?d=mZ(o,a,l,u):h instanceof T?d=gZ(o,a,l,u,r):h instanceof Ar?d=vZ(o,a,l,u,r):h instanceof ke?d=yZ(o,a,l,u,r):"isTexture"in h&&(d=SZ(o,a,l,u))}d&&(Array.isArray(d)?n.push(...d):n.push(d))}catch(h){console.error(`lerpMaterial: unexpected material layer for ${u}`,h)}}return n}function pZ(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:i.getValue(r),o=e[r],a=typeof s=="string"?Number(n.getVariable(s)??0):s,l=typeof o=="string"?Number(n.getVariable(o)??0):o;if(a!==l)return{update:c=>{i.setValue(r,_e.lerp(a,l,c))},start:()=>{i.setValue(r,a)},end:()=>{i.setValue(r,l)}}}function mZ(i,t,e,r){if(!i.hasValue(r)||!(r in e))return;let n=i.getValue(r),s=t?new U().fromArray(t[r]):n.clone(),o=new U().fromArray(e[r]);if(!s.equals(o))return{update:a=>{n.lerpVectors(s,o,a)},start:()=>{n.copy(s)},end:()=>{n.copy(o)}}}function gZ(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=i.getValue(r),o=t?t[r]:void 0,a=e[r],l=o?rg(new T,o,n):s.clone(),c=rg(new T,a,n);if(!l.equals(c))return{update:u=>{s.lerpVectors(l,c,u)},start:()=>{s.copy(l)},end:()=>{s.copy(c)}}}function yZ(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=i.getValue(r),l=s?typeof s=="string"?n.getColor(s).clone():new ke().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?n.getColor(o).clone():new ke().setRGB(o.r,o.g,o.b);if(l.equals(c))return;let u=a.clone();return{update:h=>{i.getValue(r)!==u&&i.setValue(r,u),u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function vZ(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let s=t?t[r]:void 0,o=e[r],a=i.getValue(r),l=s?typeof s=="string"?n.getColor(s).clone():new ke().setRGB(s.r,s.g,s.b):a.clone(),c=typeof o=="string"?n.getColor(o).clone():new Ar(o.r,o.g,o.b,o.a);if(l.equals(c))return;let u=a.clone();return{update:h=>{i.getValue(r)!==u&&i.setValue(r,u),u.lerpColors(l,c,h)},start:()=>{u.copy(l)},end:()=>{u.copy(c)}}}function xZ(i,t,e,r="steps"){if(!i.hasValue(r)||!(r in e))return;let n=[],s=i.getValue(r),o=t?t[r]:s,a=e[r];for(let l=0;l<s.length;++l){let c=o[l],u=a[l];c!==u&&n.push({update:h=>{s[l]=_e.lerp(c,u,h)},start:()=>{s[l]=c},end:()=>{s[l]=u}})}return n.length?n:void 0}function bZ(i,t,e,r="colors"){if(!i.hasValue(r)||!(r in e))return;let n=[],s=i.getValue(r),o=t?t[r]:s.map(l=>l.toArray()),a=e[r];for(let l=0;l<s.length;++l){let c=[...o[l]],u=[...a[l]];Kp.isEqual(c,u)||n.push({update:h=>{s[l].fromArray(Kp.lerp(c,u,h))},start:()=>{s[l].fromArray(c)},end:()=>{s[l].fromArray(u)}})}return n.length?n:void 0}function SZ(i,t,e,r="texture"){if(!i.hasValue(r)||!(r in e))return;let n=i.getNode("rotation"),s=t?.[r]?.rotation??0,o=e[r]?.rotation??0;if(n&&s!==o)return{update:y=>{n.value=_e.lerp(s,o,y)*_e.DEG2RAD},start:()=>{n.value=s*_e.DEG2RAD},end:()=>{n.value=o*_e.DEG2RAD}};let a=i.getNode("mat");if(!a)return;let l=t?t[r]:a,c=e[r],u=[...l.repeat],h=[...l.offset],d=[...c.repeat],f=[...c.offset],p=l.rotation??0,g=c.rotation??0;if(!Fs.isEqual(u,d)||!Fs.isEqual(h,f)||p!==g)return{update:y=>{a.repeat=Fs.lerp(u,d,y),a.offset=Fs.lerp(h,f,y),a.rotation=_e.lerp(p,g,y),a.updateMatrix()},start:()=>{a.repeat=[...u],a.offset=[...h],a.rotation=p,a.updateMatrix()},end:()=>{a.repeat=[...d],a.offset=[...f],a.rotation=g,a.updateMatrix()}}}function wZ(i,t){return{update:()=>{i.transparent=t}}}var xT=new T,JB=new Ht;function $B(i,t,e,r,n){let s=[],o,a,l,c,u,h,d,f;if(i instanceof nr?(o=Uf("position",i,t,e,n),o&&s.push(o),l=$r("rotation",i,t,e,n),l&&s.push(l),c=Uf("shear",i,t,e,n),c&&s.push(c)):(f={slide:t.pathSnapping?.slide??i.updatedPathSnapping?.slide??i.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??i.updatedPathSnapping?.offset??i.dataPatched.pathSnapping?.offset??0},h=$r("slide",f,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),h&&s.push(h),d=$r("offset",f,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),d&&s.push(d),!h&&!d&&(o=vT("position",i,t,e,n),o&&s.push(o),a=vT("scale",i,t,e,n),a&&s.push(a),l=AZ(i,t,e,r,n),l&&s.push(l),u=WB("hiddenMatrix",i,t,e),u&&s.push(u))),o||a||l||u||h||d){let p=i instanceof nr?()=>{i.updateWorldMatrix(!0)}:()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldSVD()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),ln(i)&&Mn(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,f))};s.push({update:p,start:p,end:p})}return s}function AZ(i,t,e,r,n){let s=t?.rotation?t.rotation.map(u=>(typeof u=="string"?Number(n.getVariable(u)??0):u)*_e.DEG2RAD):void 0,o=e.rotation?.map(u=>(typeof u=="string"?Number(n.getVariable(u)??0):u)*_e.DEG2RAD);if(!o)return;let a=s?new T().fromArray(s):new T().setFromEuler(i.rotation),l=new T().fromArray(o);if(a.equals(l))return;let c=xT.subVectors(l,a);if(r&&c.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new Qe().setFromEuler(JB.setFromVector3(a)),h=new Qe().setFromEuler(JB.setFromVector3(l));return{update:d=>{jB(u,h,i.quaternion,d)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}else return{update:u=>{xT.lerpVectors(a,l,u),i.rotation.setFromVector3(xT)},start:()=>{i.rotation.setFromVector3(a)},end:()=>{i.rotation.setFromVector3(l)}}}function e3(i,t,e,r){let n=[];if(!("cloner"in e)||!i.cloner)return n;let s=i.cloner,o="cloner"in t?t.cloner:{},a=e.cloner;xA.forEach(f=>{let p;f==="count"?p=$r("count",s.parameters,o,a,r,!0):p=Vo(f,s.parameters,o??{},a,r),p&&n.push(p)});let l=EZ(s,o,a,r);l?.length&&n.push(...l);let c=TZ(s,o,a,r);c?.length&&n.push(...c);let u=MZ(s,o,a,r);u?.length&&n.push(...u);let h=CZ(s,o,a,r);h?.length&&n.push(...h);let d=_Z(s,o,a,r);return d?.length&&n.push(...d),n.length&&n.push({update:()=>{s.update()}}),n}function EZ(i,t,e,r){if(i.parameters.type!=="radial")return;let n=t.radial,s=e.radial;if(!s)return;let o=i.parameters.radial,a=[];return bA.forEach(l=>{let c=Vo(l,o,n??{},s,r);c&&a.push(c)}),a}function TZ(i,t,e,r){if(i.parameters.type!=="linear")return;let n=t.linear,s=e.linear;if(!s)return;let o=[],a=i.parameters.linear;return SA.forEach(l=>{let c=Vo(l,a,n??{},s,r);c&&o.push(c)}),o}function MZ(i,t,e,r){if(i.parameters.type!=="grid")return;let n=t.grid,s=e.grid;if(!s)return;let o=[],a=i.parameters.grid;return wA.forEach(l=>{let c;l==="count"?c=ig(l,a,n??{},s,r,!0):c=Vo(l,a,n??{},s,r),c&&o.push(c)}),o}function CZ(i,t,e,r){if(i.parameters.type!=="toObject")return;let n=t.toObject,s=e.toObject;if(!s)return;let o=[],a=i.parameters.toObject;return AA.forEach(l=>{let c;l==="count"?c=$r(l,a,n??{},s,r,!0):c=Vo(l,a,n??{},s,r),c&&o.push(c)}),o}function _Z(i,t,e,r){if(!i.parameters.randomness)return;let n=t.randomnessObject,s=e.randomnessObject;if(!s)return;let o=[],a=i.parameters.randomnessObject;return EA.forEach(l=>{let c=Vo(l,a,n??{},s,r);c&&o.push(c)}),o}function PZ(i,t){return{update:()=>{i instanceof Mr&&(i.fill.enabled=t)}}}function DZ(i,t){return{update:()=>{i instanceof Mr&&(i.stroke.enabled=t)}}}function OZ(i,t){return{update:()=>{i instanceof Mr&&(i.dropShadow.enabled=t)}}}function IZ(i,t){return{update:()=>{i instanceof Mr&&(i.innerShadow.enabled=t)}}}function RZ(i,t){return{update:()=>{i instanceof Mr&&(i.backgroundBlur.enabled=t)}}}function LZ(i,t){return{update:()=>{i instanceof Mr&&(i.layerBlur.enabled=t)}}}function t3(i,t,e,r,n){let s=[],o,a,l,c,u,h,d,f,p,g,y,m,v,x,b;if("width"in i&&(o=$r("width",i,t,e,n),o&&s.push(o)),"height"in i&&(a=$r("height",i,t,e,n),a&&s.push(a)),i instanceof Mr||i instanceof $i){let S={...t.fill},w={...e.fill};S.enabled!==void 0&&S.enabled!==w.enabled&&(s.push(PZ(i,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),l=ng("color",i.fill,S,w,n),l&&s.push(l)}if(i instanceof Mr){let S={...t.stroke},w={...e.stroke};(S.enabled||w.enabled)&&(s.push(DZ(i,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),c=ng("color",i.stroke,S,w,n),c&&s.push(c),u=$r("thickness",i.stroke,S,w,n),u&&s.push(u)}if(i instanceof Mr){let S={...t.dropShadow},w={...e.dropShadow};(S.enabled||w.enabled)&&(s.push(OZ(i,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),h=ng("color",i.dropShadow,S,w,n),h&&s.push(h),d=$r("blurRadius",i.dropShadow,S,w,n),d&&s.push(d),p=$r("spread",i.dropShadow,S,w,n),p&&s.push(p),f=Uf("offset",i.dropShadow,S,w,n),f&&s.push(f)}if(i instanceof Mr){let S={...t.innerShadow},w={...e.innerShadow};(S.enabled||w.enabled)&&(s.push(IZ(i,!0)),S.enabled||Object.assign(S,{enabled:!0,color:{...S.color,a:0}}),w.enabled||Object.assign(w,{enabled:!0,color:{...w.color,a:0}})),g=ng("color",i.innerShadow,S,w,n),g&&s.push(g),y=$r("blurRadius",i.innerShadow,S,w,n),y&&s.push(y),v=$r("spread",i.innerShadow,S,w,n),v&&s.push(v),m=Uf("offset",i.innerShadow,S,w,n),m&&s.push(m)}if(i instanceof Mr||i instanceof $i){let S={...t.backgroundBlur},w={...e.backgroundBlur};(S.enabled||w.enabled)&&(s.push(RZ(i,!0)),S.enabled||Object.assign(S,{enabled:!0,radius:0}),w.enabled||Object.assign(w,{enabled:!0,radius:0})),x=$r("radius",i.backgroundBlur,S,w,n),x&&s.push(x)}if(i instanceof Mr){let S={...t.layerBlur},w={...e.layerBlur};(S.enabled||w.enabled)&&(s.push(LZ(i,!0)),S.enabled||Object.assign(S,{enabled:!0,radius:0}),w.enabled||Object.assign(w,{enabled:!0,radius:0})),b=$r("radius",i.layerBlur,S,w,n),b&&s.push(b)}if(i instanceof $i||i instanceof Es){let S=ig("cornerRadius",i,t,e,n);S&&s.push(S)}return s}function bT(i,t,e,r,n){let s=[];return i.data.visible&&s.push(...$B(i,t,e,n,r)),i instanceof nr?s.push(...t3(i,t,e,n,r)):(i.data.visible&&s.push(...e3(i,t,e,r)),ln(i)?(i instanceof dr&&i.data.visible&&s.push(...YB(i,t,e,r)),i.data.visible&&s.push(...ZB(i,t,e,r))):dL(i)?i.data.visible&&s.push(...KB(i,t,e,r)):hL(i)&&s.push(...XB(i,t,e,r))),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var r3=new T;function Ff(i,t,e=!1){let r=[],n=s=>{let o=s.data;delete s.states,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let a of o.states){let l={...a.data};s.states||(s.states={}),s.states[a.id]=Aa.patch(o,l)}n3(i.scene,s,null,t,o.events.find(a=>a.data.type==="Follow"||a.data.type==="LookAt")!==void 0),i3(i)};i.scene.traverse2D(n),i.traverseChildren(s=>{if(e&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(r3,!0),s.rigidBody?.setAngvel(r3,!0)),!At.is(s))return;let o=s.uuid,a=s.data;if(delete s.states,s.uuid===ds)return;let l=!1;r.some(c=>i.scene.find(o)?.isDescendantOf(c))?l=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&r.push(o),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let c of a.states){let u={...c.data};i.data.globalPhysics.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete u.position,c.data.rotation!==void 0&&delete u.rotation,c.data.hiddenMatrix!==void 0&&delete u.hiddenMatrix),s.states||(s.states={}),s.states[c.id]=ya.patch(a,u)}n3(i.scene,s,null,t,a.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),i3(i),s instanceof Cr&&s.frame&&(s.frame.traverse(c=>n(c)),s.uiCanvas?.applySize())}),i.frame&&(i.frame.traverse(s=>n(s)),i.uiCanvas?.applySize())}function i3(i){i.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let n of Object.values(e.data.gameActions))r.push(...n);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let n of r)if(n.data.type==="Create"&&n.data.hideBase==="Yes"){let s=i.scene.find(n.data.object);s&&(s.visible=!1)}}})}function n3(i,t,e,r,n=!1){if(t instanceof dr&&t.removeInteractionGeometry(r),t instanceof nr?t.changeSelectedState(e,{shared:r},n):t.changeSelectedState(e,{scene:i,shared:r},n),t instanceof dr&&t.updateGeometryGroupsIfNeeded(),t instanceof Tr&&t.updateCameraState(t.dataPatched,{scene:i,shared:r}),!(t instanceof nr)){if(t.cloner)for(let s of t.cloner.children)s.playModeVisible=void 0;t.updateVisible()}}function wT(i){let t;if(i.easing===5){let{control1:e,control2:r}=i;t=`cubicBezier(
8001
8001
  ${e[0]}, ${e[1]}, ${r[0]}, ${r[1]}
8002
- )`}else if(i.easing===6){let{mass:e,stiffness:r,damping:n,velocity:s}=i;t=`spring( ${e}, ${r}, ${n}, ${s} )`}else{let e;switch(i.easing){case 0:e=ma.linear;break;case 1:e=ma.ease;break;case 2:e=ma.easeIn;break;case 3:e=ma.easeOut;break;case 4:e=ma.easeInOut;break;default:e=ma.linear}let[r,n,s,o]=e;t=`cubicBezier( ${r}, ${n}, ${s}, ${o} )`}return{duration:Math.max(i.duration,1e-4),easing:t}}function ST(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.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,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var NZ={type:"beginState"},BZ={type:"completeState",isfromEntity:!1},Sb=class{constructor(t,e,r,n,s,o){this.object=t;this.data=n;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.requestRender()),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object instanceof nr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof Tr&&e.dispatchEvent(NZ)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object instanceof nr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof Tr&&e.dispatchEvent(BZ)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=bT(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=bb(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=bb(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=bb(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...ST(n),...wT(n),change:this.onChange},this.callback=bT(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},sg=class extends gr{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;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())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,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?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=bb(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:n=!1}={}){try{let s=ST(this.data.tweens[0].data);n&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=xb.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let c=this.data.tweens[l],u=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Tr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new Sb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let c=this.data.tweens[l],u=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Tr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new Sb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Gt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=ST(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.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 nr?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(Gt(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 bb(i,t){let e,r;if(typeof t=="string"?(e=t,r=i.states?.[e]):t===null&&(e=null,r=i.data),!(e===void 0||r===void 0))return{id:e,data:r}}var FZ={type:"beginState"},s3={type:"completeState",isfromEntity:!1},o3={type:"requestRender"},og=class extends gr{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new T;this.posEnd=new T;this.qStart=new Qe;this.qEnd=new Qe;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 r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=xb({targets:n,t:1,...wT(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(FZ));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,n.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(o3),n.t===1&&s.dispatchEvent(s3)}})}switchCamera(e){let r=this.page.activeCamera,n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),r.dispatchEvent({type:"cameraChange",camera:n})}play(){if(Gt(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(Gt(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(s3),this.page.activeCamera.dispatchEvent(o3))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var ag=class extends gr{constructor(e,r,n,s,o){super();this.page=r;this.animationControls=n;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let c=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=c?.getClip()?.duration??1;let u=c?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/u*this.duration,this.rightFrameTime=this.data.crop[1]/u*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Gt(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 r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([n,s])=>{let o=n.split("/")[1];this.threeAnimAction!==s&&o===r&&s.isRunning()&&(e?s.fadeOut(.2):s.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=_e.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(Gt(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 n=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===n&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&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()}};var lg=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.eventManager=r;this.shared=n;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Gt(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(r=>r.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 t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Ff(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var cg=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Gt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=G0(this.data.expression,this.shared,ki.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var ug=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.timeoutId=null}dispatchInner(){if(Gt(this.shared,this.condition)===!1)return!1;let t=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,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="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"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="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 e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function Gt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=G0(t.expression,i,"boolean");return t.negate?!e:!!e}function _r(i,t,e,r,n,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?xn[i.type].includes("Audio")&&o.Audio.push(new Zm(c,u,s,r,l)):u.type==="Video"&&!(s instanceof nr)?xn[i.type].includes("Video")&&o.Video.push(new hg(c,u,s,r,l)):u.type==="Particles"?xn[i.type].includes("Particles")&&o.Particles.push(new Jm(u,e,r,l)):u.type==="Link"?xn[i.type].includes("Link")&&o.Link.push(new fb(u,n.controlsManager,r,l)):u.type==="Create"?xn[i.type].includes("Create")&&o.Create.push(new dg(u,e,n.controlsManager,r,l)):u.type==="Destroy"?xn[i.type].includes("Destroy")&&o.Destroy.push(new $m(u,e,n.controlsManager,r,l)):u.type==="Reset"?xn[i.type].includes("Reset")&&o.Reset.push(new eg(u,e,r,n,l)):u.type==="Transition"?xn[i.type].includes("Transition")&&o.Transition.push(new sg(u,e,r,l)):u.type==="SwitchCamera"?xn[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new og(u,e,r,l)):u.type==="SceneTransition"?xn[i.type].includes("SceneTransition")&&o.SceneTransition.push(new lg(u,e,n,r,l)):u.type==="Animation"?xn[i.type].includes("Animation")&&o.Animation.push(new ag(u,e,n.animationControls,r,l)):u.type==="SetVariable"?xn[i.type].includes("SetVariable")&&o.SetVariable.push(new cg(u,e,r,l)):u.type==="DynamicVariablePlay"?xn[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new ug(u,e,r,l)):u.type==="Conditional"&&xn[i.type].includes("Conditional")&&(u.ifActions.forEach(a({expression:u.condition,negate:!1})),u.elseActions.forEach(a({expression:u.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function pr(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Zm||e instanceof hg||e instanceof Jm||e instanceof ag||e instanceof sg||e instanceof dg||e instanceof $m||e instanceof og||e instanceof lg||e instanceof eg||e instanceof cg||e instanceof ug)&&e.dispose()})})}function a3(i,t){let e;if("material"in i){let r=i.material;Array.isArray(r)?e=i.material[0].layers.find(n=>n.uuid===t):e=i.material.layers.find(n=>n.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var l3=new Map,fg=new Map,Fa=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:n,loop:s,volume:o,delay:a}=e;if(this.object=r,n===void 0)throw new Error("Missing property");let l=a3(r,n);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,Rh&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),fg.has(r.uuid)?fg.get(r.uuid).push(this):fg.set(r.uuid,[this]),l3.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(n=>{}).catch(n=>{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)}},Vf=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=l3.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=fg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...fg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},hg=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new Fa(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Vf(e);else throw new Error("Missing property")}dispatchBasic(){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var c3=(()=>{let i,t,e,r;function n(a){!i&&!u3()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,c=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,h=c.length,d=0;for(;d<h;){let f=c[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,c.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,r())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){u3()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):n()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),n})();function u3(){return!!document&&document.hidden}var h3=new Qe,UZ=new T,VZ=new T,dg=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=_e.generateUUID();this.dispatch=()=>{if(Gt(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(Gt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Qw(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 t=new zr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,n=this.page.scene.find(r);n&&(n.updateMatrixWorldSVD(),t.hiddenMatrix.copy(n.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),c3(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Wi)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof zr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Wi)return;t instanceof zr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new T().fromArray(this.data.velocity),n=e.dataPatched;if(!(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(UZ,h3,VZ),r.applyQuaternion(h3),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");c3(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var MT=200,AT=.02,ET=.3,zZ=65,XHe=new T,d3=new T,f3=new T,kZ=new T,_n=new T,zn=new T,$l=new T,TT=new ue,p3=new ue,GZ=new ue,YHe=new ue,eo=new Qe,Ua=new Qe,zo=new Ht(0,0,0,"YXZ"),HZ=new T(1,0,0),to=new T(0,1,0),jZ=new T(0,0,1),m3=new T(1,1,1),KHe=new Or,WZ=1,qZ=.025,XZ=16e-6,g3=12,YZ=20,Xi=new Ei,Ms=new zt,KZ={type:"requestRender"},QZ={type:"updateMatrix"},y3=Math.PI/6,wb=class extends gr{constructor(e,r,n,s,o,a,l,c,u){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=c;this.sharedAssets=u;this.enableDamping=!0;this.hiddenMatrix0=new ue;this.target0=new T;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=MT;this.euler0=new Ht(0,0,0,"YXZ");this.position0Cam=new T;this.quat0Cam=new Qe;this.scale0Cam=new T;this.hiddenMatrix0Cam=new ue;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Ei(new T(0,-40,0),new T(0,40,0)),matrix:new ue,position:new T,rotation:new Qe};this.euler=new Ht(0,0,0,"YXZ");this.eulerDelta=new T;this.lastPosition=new T;this.lastCameraQuaternion=new Qe;this.lastCameraPosition=new T;this.PI_2=Math.PI/2;this.prevMouse=new U;this.velocityTarget=new T;this.velocity=new T;this.directionXZ=new T;this.rotVelocityStick=new T;this.rotVelocityTarget=new T;this.rotVelocity=new T;this.rotDirection=new T;this.nonColliderRotOffset=new ue;this.nonColliderPosOffset=new ue;this.firstPointerId=-1;this.rot=new T;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 ue;this.objectToTarget=new T;this.objectToTarget0=new T;this.objectToCamXZ=new T;this.objectToCamXZ0=new T;this.targetToCamera=new T;this.targetToCamera0=new T;this.cameraPolarAxis0=new T;this.targetPos=new T;this.targetQuat=new Qe;this.lerpFactorPos=new T().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Qe;this.objXZQuatInv=new Qe;this.objXZRotMat=new ue;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new T;this.pushedVelocity=new T;this.groundYRotation=0;this.objectRealQuat=new Qe;this.colliderWorldQuat=new Qe;this.groundNormal=new T;this.groundTilt=new Qe;this.groundTiltInv=new Qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new T;this.quaternion=new Qe;this.scale=new T;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Mi&&(!Zw||Jw>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Zw&&Jw<15.5&&!Mi?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?wb.isLocked=!0:wb.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let s=e.axes[n];r===0?n===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(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(),d=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,d,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 y=new T(0,0,-1).applyQuaternion(this.camera.quaternion),m=new T().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(y.y)<1e-6?(m.y=0,y.y=0,x=m.projectOnVector(y)):m.y/y.y>0?x=y.multiplyScalar(m.y/y.y):x=y.multiplyScalar(m.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let b=new Ht().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof Tr&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*WZ,this.speedOrbit=(n.speedRotate??100)*qZ,this.mouseOrbitSensitivity=(n.speedRotate??100)*XZ,this.keyAssignments=n.keyAssignments.map(y=>{let m=[y[0],y[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}),n.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Ml.defaultData.gravity)*g3,this.usePhysics=this.gloabalPhysics.usePhysics??Ml.defaultData.usePhysics,this.jumpPower=n.jumpPower*YZ,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??ed.defaultDataThirdPerson.orientWith,this.slopeThresh=zZ*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*AT/this.pixelsPerMeter,this.stepThresh=n.collider.height*ET/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*AT/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*ET/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*AT/this.pixelsPerMeter,this.stepThresh=n.collider.height*ET/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let f=new T().fromArray(n.collider.position),p=new Qe().setFromEuler(new Ht().fromArray([...n.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,m3),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=n.runMultiplier??2;let g=n.navmesh.destinationHelperRadius*2;if(g>0){let y=new je;y.push({fi:0,data:{...Hr.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Hr.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let m=new Oa({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new tr(P0.create({parameters:{width:g,height:g/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=n.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 r=new Ht().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Tr?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},$h.list.forEach(n=>{this.actions[n]=_r({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,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"),pr(this.actions.idle),pr(this.actions.move),pr(this.actions.run),pr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return _n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,n){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 s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let c=zn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*g3),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(u){this.onObject=!0,this.groundNormal.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),u.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=u.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(_n,Ua,zn),this.groundVelocity.subVectors(_n,d.prevT),this.object.getWorldPosition(zn).add(this.collider.position).sub(_n),this.groundYRotation=zo.setFromQuaternion(Ua).y-d.prevR.y,$l.copy(zn).applyAxisAngle(to,this.groundYRotation),this.groundVelocity.add($l.sub(zn)).divideScalar(s);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*o),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 c=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 u=_n.subVectors(this.path[1],this.position),h=zn.subVectors(this.path[1],this.path[0]);u.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),c.opacity=c.userData.opacity0}else c.opacity-=.05*c.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)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):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 l=kZ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=zn.copy(l);c.y=0,l.set(0,l.y,c.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let c=_n;this.camera.getWorldDirection(c);let u=$l.copy(to).multiplyScalar(c.dot(to));c.sub(u);let h=zn.copy(this.directionXZ);h.x*=-1,this.rot.y=c.angleTo(h)*(c.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(zo.setFromVector3(this.rot),this.moveMode==="walk"&&(zo.x=0),l.applyEuler(zo),a&&(Ua.setFromUnitVectors(to,this.groundNormal),l.applyQuaternion(Ua)),n){let c=zo.set(0,this.vrEulerYOffset*y3,0);n.applyEuler(c),l.x+=n.x,l.z+=n.z,this.nonColliderPosOffset.elements[13]+=n.y*s}if(this.usePhysics===!0){let c=zn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=$l.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),_n.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=At.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let p;u instanceof zr&&(p=u);let g=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(g)for(let y of g)y.data.target==="character"&&(y.dispatch(p),f.dispatchEvent(Ab));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),c.copy(d.normal1).applyQuaternion(u.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let u=c.dot(l);u<0&&l.addScaledVector(c,-u),l.add(this.pushedVelocity)}else l.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(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(to,this.euler.y-this.euler0.y);let c=zn.copy(this.objectToCamXZ).normalize(),u=$l.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(_n.copy(c).multiplyScalar(u.dot(c))).cross(c).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+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=_e.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=_e.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=_e.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(zo.copy(r),zo.y=0):(zo.copy(this.euler),zo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(zo)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*y3),eo.setFromAxisAngle(HZ,this.rot.x),Ua.setFromAxisAngle(to,this.rot.y),Ua.multiply(eo),eo.setFromAxisAngle(jZ,this.rot.z),Ua.multiply(eo),this.quaternion.copy(Ua),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let c=zn.copy(l).multiplyScalar(s/this.pixelsPerMeter),u=null;this.didHit=!1;let h=new T;for(let d=0;d<5;d++){let f=c.length(),p=$l.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let g=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(g!==this.lastHitObj&&d===0){this.lastHitObj=g;let x=this.sharedGameControlGlobals.entityToCollisionEvents[g?.uuid];if(x){for(let b of x)if(b.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,w;if(g.cloner){for(let E of g.cloner.children)if(E.rigidBody===S){w=E;break}}b.dispatch(w),g.dispatchEvent(Ab)}}}let y=d3.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),m=f3.copy(p).multiplyScalar(u.toi).dot(y),v=u.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(v=u.toi*(m-this.offset)/m,h.addScaledVector(p,v)),c.copy(p).multiplyScalar(f-v),Math.acos(-y.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),b=$l.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let S=x.add(b);S.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);w!==null&&w.toi===0&&(y.y=0,y.normalize())}c.addScaledVector(y,-c.dot(y))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(c);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(_n.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(eo.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let c=this.onObject?1:5,u=l.multiplyScalar(s/c);for(let h=0;h<c;h++)this.position.add(u),this.collisionAdjustment(s/c)}else this.position.addScaledVector(l,s);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 c=this.objectToTarget.add(this.position),u=this.targetToCamera.add(c);TT.lookAt(u,c,to).setPosition(u),TT.decompose(this.targetPos,this.targetQuat,_n),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=_e.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=_e.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(QZ),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(KZ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=eo.setFromAxisAngle(to,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?_e.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 r;this.cameraXAxis==="Limit"?r=_e.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=_e.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=_n.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let s=Ua.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){to.angleTo(e)*180/Math.PI<15||to.angleTo(e)*180/Math.PI>85?eo.identity():eo.setFromUnitVectors(to,e),this.groundTilt.slerp(eo,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=f3.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=TT.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(_n,eo,zn).compose(_n,eo,m3);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ms.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=p3.copy(a).invert(),c=GZ.copy(p3).multiply(n);Xi.copy(this.collider.segment),Xi.start.applyMatrix4(c),Xi.end.applyMatrix4(c);let u=d3.copy(this.position).applyMatrix4(l);Ms.expandByPoint(Xi.start),Ms.expandByPoint(Xi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Xi.end)},intersectsBounds:h=>h.intersectsBox(Ms),intersectsTriangle:h=>{let d=_n,f=zn,p=h.closestPointToSegment(Xi,d,f);if(p<this.collider.radius){let g=this.collider.radius-p,y=f.sub(d).normalize(),m=$l.copy(u);m.addScaledVector(y,g);let v=m.applyMatrix4(a).sub(this.position);r.add(v),Xi.start.addScaledVector(y,g),Xi.end.addScaledVector(y,g)}}})}),Ms.makeEmpty(),Xi.copy(this.collider.segment),Xi.start.applyMatrix4(n),Xi.end.applyMatrix4(n),Ms.expandByPoint(Xi.start),Ms.expandByPoint(Xi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Xi.end)},intersectsBounds:o=>o.intersectsBox(Ms),intersectsTriangle:o=>{let a=_n,l=zn,c=o.closestPointToSegment(Xi,a,l);if(c<this.collider.radius){let u=this.collider.radius-c,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,u),Xi.start.addScaledVector(h,u),Xi.end.addScaledVector(h,u)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}},pg=wb;pg.isLocked=!1;var v3=qo(iE());function ro(i,t){let e=new Ne;if(!i.getAttribute("position"))return e.setAttribute("position",new Ie([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=zc(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Ie(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var ZZ=new ue,JZ=new ue,ko=[[0,0,0],[0,0,0],[0,0,0]];function CT(i){let t=i.elements;ko[0][0]=t[0],ko[0][1]=t[4],ko[0][2]=t[8],ko[1][0]=t[1],ko[1][1]=t[5],ko[1][2]=t[9],ko[2][0]=t[2],ko[2][1]=t[6],ko[2][2]=t[10];let{u:e,v:r}=(0,v3.SVD)(ko),n=ZZ.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=JZ.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 n.multiply(s.transpose())}var Eb=class extends $u{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(n=>{n.visible&&this.intersectObject(n,e,r)}),r}createRaycastLineHelper(){let t=new os({color:65280,linewidth:10}),e=new T(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new T(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),n=this.camera.far-this.camera.near,s=new T().addVectors(e,r.multiplyScalar(n)),o=new Ne;return o.setFromPoints([e,s]),new yc(o,t)}};var x3=i=>i instanceof As||i instanceof Js;function $Z(i,t){return i.distance-t.distance}function b3(i,t,e){if(!(!To(t)||!t.visible)){ln(t)&&t.raycast(i,e);for(let r of t.children)b3(i,r,e)}}function zf(i,t,e,r=!1){if(!r&&!e.some(s=>kf(i,s)!==void 0))return[];let n=[];return t.children.forEach(s=>b3(i,s,n)),n.sort($Z),n}function mg(i){let t=[];if(i.length){let e=i[0].object;To(e)&&t.push(e);let r=e.parent;for(;r;)x3(r)&&t.push(r),r=r.parent}return t}function io(i,t,e,r){let n=i.frame;if(n){let s=t[0]*n.width,o=(1-t[1])*n.height;for(let a of e){let l=a===n.uuid?n:n.find(a);if(l?.intersects(s,o))return r(l),!0}}return!1}function kf(i,t){if(ln(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(x3(t))return S3(i,t)}function S3(i,t){if(!(!To(t)||!t.visible)){if(ln(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let r=S3(i,e);if(r)return r}}}function eJ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}function tJ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var Tb=class{constructor(t,e,r,n,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=n;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new Eb;this._useWindowEvents=!1;this.pointerWorld={x:0,y:0};this.pointerScreen={x:0,y:0};this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}get domRect(){return this._domRect}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.pointerWorld=eJ(e,r,this._domRect),this.pointerScreen=tJ(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var kr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var _T=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],w3=i=>_T.find(([t,e])=>e===i)?.[0],Go=i=>_T.find(([t])=>t===i)?.[1],rJ=(i,t)=>{let e=w3(i);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Mb=class extends kr{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[w3(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:n}=this.eventContext;n.dispatchEvent(r)};let{page:r}=this.eventContext;r.traverseEntity(n=>{if(!!n.data?.events.length){for(let[s,o]of _T)if(n.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(n):this.objectsPerEvents.set(s,[n]);let a={id:n.uuid,name:n.name},l=rJ(o,a),c=this.splineEvents[s];c?c[n.uuid]=l:this.splineEvents[s]={[n.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var PT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=_r(e,e.actions,n,s,o,r)}disconnect(){pr(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(n=>n.playing)||this.actions.Transition.forEach(n=>{this.alreadyPlayedNonTogglingActions.has(n)===!1&&n.play()}),this.actions.SwitchCamera.some(n=>n.playing)||this.actions.SwitchCamera.forEach(n=>{n.play()}),this.actions.Animation.forEach(n=>{n.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,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.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},Cb=class extends kr{constructor(e,r,n){super(e);this.useForRaycastProperty=n;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=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=zf(r,n,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(n)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext,a=(l,c)=>{if(!l.data?.events.length)return;let u=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let h of u){let d=this.eventsPerObjects[h];l.data.events.filter(({data:f})=>f.type===h&&f.disabled!==!0).forEach(({id:f,data:p})=>{try{let g=new PT(f,p,l,s,o,r);g.actions.Video.length&&(this.hasVideoAction=!0),(p.type==="MouseDown"||p.type==="MouseUp"||p.type==="MousePress")&&(p.mode==="Canvas"||p.mode==="Window")?this.canvasMouseEvents.push(g):d[l.uuid]?d[l.uuid].some(y=>y.id===g.id)||d[l.uuid].push(g):d[l.uuid]=[g]}catch(g){!1&&console.log(g)}}),d[l.uuid]?.length&&this.objectsPerTypes[h].push(l instanceof nr&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress")?c:l)}};s.traverseEntity(l=>{(l instanceof Cr||l instanceof fr)&&l.frame?.traverse(c=>{a(c,l)}),a(l)})}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(([r,n])=>{n.forEach(s=>{s.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(r=>{Object.values(r).forEach(n=>{n.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,n])=>{n.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:n,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof nr));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&io(s,[o.x,o.y],Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}))){if(r||this.useForRaycastProperty){let c;if(this.sceneInterects===null?c=zf(n,s,l,this.useForRaycastProperty):(c=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&c.length&&(this.eventContext.sharedAssets.raycastProperty={x:c[0].point.x,y:c[0].point.y,z:c[0].point.z,objX:c[0].object.matrixWorld.elements[12],objY:c[0].object.matrixWorld.elements[13],objZ:c[0].object.matrixWorld.elements[14]}),r){let u=[c[0]?.uv?.x??0,c[0]?.uv?.y??0];mg(c).forEach(h=>{h instanceof Cr&&io(h,u,Object.keys(this.eventsPerObjects[e]),d=>{this.handleObjectMouseEventDispatch(d,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}r||l.forEach(c=>{let u=kf(n,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof Cr&&io(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let r="MousePress",n=this.objectsPerTypes[r],s=n.filter(a=>!(a instanceof nr)),o=[];if(!!n.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=io(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=zf(l,c,s);o=mg(d),d.forEach(f=>{f.object instanceof Cr&&io(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)})})}else s.forEach(d=>{let f=kf(l,d);f&&(o.push(d),d instanceof Cr&&io(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{o.includes(a)||this.handleObjectMouseEventDispatchRelease(a,r)}),o.length&&o.forEach(a=>{this.handleObjectMouseEventDispatch(a,r)}),this._prevObjects=o}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatchRelease()})}handleKeyEvent(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(n?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(n)})})}};var iJ=new T,nJ=new T;var _b=class{constructor(t,e,r,n,s){this.actionsIn=_r(t,t.inActions,r,n,s,e),this.actionsOut=_r(t,t.outActions,r,n,s,e)}disconnect(){pr(this.actionsIn),pr(this.actionsOut)}};var DT=class extends _b{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=iJ.setFromMatrixPosition(this.objects[0].matrixWorld),r=nJ.setFromMatrixPosition(this.objects[1].matrixWorld),n=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==n){this.stage=n;let s=n==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Particles.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch())}};let{distance:l,fromObject:c,toObject:u}=r.condition;this.distance=l;for(let h of[c,u]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}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)})}},OT=class extends _b{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(n=>n.dispatchConditional()),this.actionsOut.Particles.forEach(n=>n.dispatchConditional()),this.actionsOut.Video.forEach(n=>n.dispatchConditional()),this.actionsOut.Link.forEach(n=>n.dispatch()),this.actionsOut.Create.forEach(n=>n.dispatch()),this.actionsOut.Destroy.forEach(n=>n.dispatch()),this.actionsOut.Reset.forEach(n=>n.dispatch()),this.actionsIn.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(n=>n.play()),this.actionsOut.Animation.forEach(n=>n.play()),this.actionsIn.SwitchCamera.forEach(n=>n.pause()),this.actionsOut.SwitchCamera.forEach(n=>n.play()),this.actionsOut.SceneTransition.forEach(n=>n.dispatch()),this.actionsOut.SetVariable.forEach(n=>n.checkConditions()),this.actionsOut.SetVariable.forEach(n=>n.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(n=>n.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(n=>n.dispatchConditional()),this.actionsIn.Particles.forEach(n=>n.dispatchConditional()),this.actionsIn.Video.forEach(n=>n.dispatchConditional()),this.actionsIn.Link.forEach(n=>n.dispatch()),this.actionsIn.Create.forEach(n=>n.dispatch()),this.actionsIn.Destroy.forEach(n=>n.dispatch()),this.actionsIn.Reset.forEach(n=>n.dispatch()),this.actionsOut.Transition.forEach(n=>n.pause()),this.actionsOut.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(n=>n.play()),this.actionsIn.Animation.forEach(n=>n.play()),this.actionsOut.SwitchCamera.forEach(n=>n.pause()),this.actionsIn.SwitchCamera.forEach(n=>n.play()),this.actionsIn.SceneTransition.forEach(n=>n.dispatch()),this.actionsIn.SetVariable.forEach(n=>n.checkConditions()),this.actionsIn.SetVariable.forEach(n=>n.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(n=>n.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let c=s.find(l.object)??s.scene.find2D(l.object);if(!c)throw new Error("Missing property");if(this.toObject=c,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){cs(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),cs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),cs(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),cs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Pb=class extends kr{constructor(e,r){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let c;l.condition.type==="Comparison"||(l.condition.type==="Distance"?c=new DT(a,l,o,n,s,r):l.condition.type==="State"&&(c=new OT(a,l,o,n,s,r))),c&&(this.eventsPerConditions[l.condition.type].push(c),(c.actionsIn.Video.length||c.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(c){!1&&console.log(c)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var gg=new T,ec=new T,nu=new T,A3=new ii,sJ=.01,sr=new T,Ii=new T,E3=new T,su=new Qe,IT=new Ht,oJ=new ue,RT=new ut,Gf=new T,Ho=new T,Hf=.2;function LT(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var aJ=function(){let i=new ue;return(t,e,r)=>{let n=t.obj;i.copy(n.hiddenMatrix),n.parent!==null&&i.premultiply(n.parent.matrixWorld),i.invert(),n.position.copy(e),t.reference==="global"&&LT(n.position,t.limits),n.position.applyMatrix4(i),t.reference==="parent"?LT(n.position,t.limits):t.reference==="local"&&(su.copy(t.quat0).invert(),n.position.sub(t.position0),n.position.applyQuaternion(su),LT(n.position,t.limits),su.invert(),n.position.applyQuaternion(su),n.position.add(t.position0)),i.multiply(r??n.matrixWorld).decompose(sr,n.quaternion,Ii),n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n instanceof yr&&Mn(n.parent)&&n.invalidateDownstreamBooleanData(!0)}}(),NT=class{constructor(t,e,r,n,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=_r(e,e.dragDropActions.drag,r,n,s,this.object),this.actionsDrop=_r(e,e.dragDropActions.drop,r,n,s,this.object);let a=[];this.data.objects.forEach(l=>{let c=r.find(l);!c||c.data.visible!==!1&&(a.push(c),o[c.uuid]&&o[c.uuid].forEach(u=>{let h=r.find(u);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let c=r.find(l);!c||c.data.visible!==!1&&(this.dropDestIds.push(c.uuid),o[c.uuid]&&o[c.uuid].forEach(u=>{let h=r.find(u);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new T().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new T().setFromMatrixPosition(l.matrixWorld),pointStart:new T,pointEnd:new T,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new T().copy(l.position),quat0:new Qe().copy(l.quaternion),snapped:!1,orientationMatrix:new ue,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){pr(this.actionsDrag),pr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Db=class extends kr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(nt.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:c,pointStart:u}of o.dragItems){if(l===s[0].object||l===s[0].object.object||At.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(sr,su,Ii),IT.setFromQuaternion(su),h.prevR===void 0?(h.prevR=IT.clone(),h.prevT=sr.clone()):(h.prevR.copy(IT),h.prevT.copy(sr)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&l.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}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(nt.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(nt.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||At.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof As)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===l.object.uuid||n.scene.find(c).isAncestorOf(l.object.uuid))))[0]),a){let l=E3.copy(a.face.normal).applyMatrix3(RT.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){sr.copy(l).applyMatrix3(RT.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;sr.x>Hf?Ii.x=-c.recursiveBBox.min.x:sr.x<-Hf&&(Ii.x=-c.recursiveBBox.max.x),sr.y>Hf?Ii.y=-c.recursiveBBox.min.y:sr.y<-Hf&&(Ii.y=-c.recursiveBBox.max.y),sr.z>Hf?Ii.z=-c.recursiveBBox.min.z:sr.z<-Hf&&(Ii.z=-c.recursiveBBox.max.z),Ii.applyMatrix3(RT.invert())}else Ii.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Ii)}this.activeEvent.data.autoOrient&&(sr.set(0,1,0).cross(l),sr.length()<1e-4&&sr.set(-1,0,0).cross(l),Ii.crossVectors(E3,sr),o.orientationMatrix.makeBasis(sr,Ii,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(n=>n.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let n={};e.page.traverseEntity(s=>{s.component&&(n[s.component.uuid]?n[s.component.uuid].push(s.uuid):n[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new NT(s,o.data,e.page,e.sharedAssets,r,n))})})}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(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,n,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(ec),ec.negate();let l=su.identity();switch(s==="parent"?oJ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(sr,l,Ii):s==="local"&&e.matrixWorld.decompose(sr,l,Ii),n){case"x":sr.set(1,0,0).applyQuaternion(l),Gf.copy(ec).cross(sr),Ho.copy(sr).cross(Gf);break;case"y":sr.set(0,1,0).applyQuaternion(l),Gf.copy(ec).cross(sr),Ho.copy(sr).cross(Gf);break;case"z":sr.set(0,0,1).applyQuaternion(l),Gf.copy(ec).cross(sr),Ho.copy(sr).cross(Gf);break;case"xy":Ho.set(0,0,1).applyQuaternion(l);break;case"yz":Ho.set(1,0,0).applyQuaternion(l);break;case"xz":Ho.set(0,1,0).applyQuaternion(l);break;case"adaptive":ec.angleTo(Ii.set(0,1,0))>Math.PI/6?(sr.crossVectors(Ii.set(0,1,0),ec),Ho.crossVectors(sr,Ii)):Ho.set(0,1,0);break;default:Ho.copy(ec);break}nu.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:nu;if(A3.setFromNormalAndCoplanarPoint(Ho,c),!!a.ray.intersectPlane(A3,r)&&(n==="x"||n==="y"||n==="z")){let u=Ii.subVectors(r,c).dot(sr);r.copy(c).addScaledVector(sr,u)}}updateDragItem(e,r=!1){nu.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?gg.subVectors(e.fromPosition,nu).divideScalar(e.currentDampingFactor):e.reset==="original"?(gg.subVectors(e.obj.userData.worldPosition0,nu).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):gg.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(nu).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?gg.length()<sJ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&aJ(e,gg.add(nu),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var jf=new T,BT=new T,Va=new T,za=new T,T3=new ii,lJ=.01,cJ={type:"requestRender"},uJ=function(){let i=new T,t=new T;return(e,r,n)=>n>0?(i.subVectors(e,r),i.length()<=n?e:t.copy(r).add(i.normalize().multiplyScalar(n))):r}(),M3=function(){let i=new ue;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof yr&&Mn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),FT=class{constructor(t,e,r,n,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new T;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Gv.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=_r(t,t.actions,r,n,s,e)}},Ob=class extends kr{constructor(e,r){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(nt.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!n.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new FT(o.data,s,n,e.sharedAssets,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let s=n.target,o=this.onTargetChange(n);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let n of this.events)n.paused=!0,n.isReset=!1,pr(n.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(c=>{c.dispatchThrottled()})});let{plane:n,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Va),e.isReset)za.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(za);else{let{getCamera:l,raycaster:c}=this.eventContext;if(n==="custom"?(l().getWorldDirection(BT),BT.negate(),jf.copy(BT)):n==="xy"?jf.set(0,0,1):n==="xz"?jf.set(0,1,0):n==="yz"&&jf.set(1,0,0),T3.setFromNormalAndCoplanarPoint(jf,Va),!c.ray.intersectPlane(T3,za))return}if(!e.isReset){if(za.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)za.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&&(za.x=Va.x),e.data.enabledTranslation[1]===!1&&(za.y=Va.y),e.data.enabledTranslation[2]===!1&&(za.z=Va.z);let a=uJ(Va,za,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=jf.subVectors(a,Va).divideScalar(e.currentDampingFactor);Va.add(l),r&&M3(e.object,Va),e.paused=l.length()<lJ}else M3(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(cJ)}};var yg=new T,Ib=new T,vg=new ue,Wf=new Qe,tc=new Qe,xg=new T,bg=new T,ou=new T,ka=new T,UT=new ii,hJ=1e-6,dJ={type:"requestRender"},fJ={type:"changeRotation"},C3=function(){let i=new ue;return function(e,r){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),r.premultiply(CT(i).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof yr&&Mn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),VT=class{constructor(t,e,r){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Hv.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},Rb=class extends kr{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(nt.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{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=e=>{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=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:n})=>{if(!r||!n)return;let s=Go(r);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(n=>{let s=n.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!r.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new VT(s.data,n,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?r.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),l=n.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(n),o=n.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let[n,s]of this.pairOfUserEventListeners)n.removeEventListener("userEvent",s);for(let n of this.events)n.paused=!0,n.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:r,axis:n,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:c}=e.data,{getCamera:u,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(xg),!e.isReset)if(e.target)e.target.getWorldPosition(bg);else{if(o==="custom"?(u().getWorldDirection(Ib),Ib.negate(),UT.setFromNormalAndCoplanarPoint(Ib,xg)):(o==="xy"?yg.set(0,0,1):o==="xz"?yg.set(0,1,0):o==="yz"&&yg.set(1,0,0),UT.setFromNormalAndCoplanarPoint(yg,xg)),!h.ray.intersectPlane(UT,bg))return;s>0&&(o==="custom"||o===void 0)&&bg.addScaledVector(Ib,s)}if(e.isReset||(f?r==="target"?ou.copy(f.up).applyMatrix4(vg.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(n==="x"?(ka.set(0,0,1),l[2]===!1&&ka.set(0,1,0)):n==="y"?(ka.set(1,0,0),l[0]===!1&&ka.set(0,0,1)):(ka.set(0,1,0),l[1]===!1&&ka.set(1,0,0)),ou.copy(ka).applyQuaternion(e.worldQuaternion0).normalize()):ou.set(0,1,0):o==="custom"?ou.set(0,1,0):ou.copy(yg)),e.isReset)tc.copy(e.worldQuaternion0);else if(xg.distanceTo(bg)>a&&c&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)tc.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;pJ(vg,bg,xg,ou,n,ka),tc.setFromRotationMatrix(vg),Wf.setFromUnitVectors(ka.applyQuaternion(tc),ou),l.some(p=>p===!1)&&r!=="target"&&tc.premultiply(Wf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Wf.setFromRotationMatrix(CT(d.matrixWorld)),Wf.slerp(tc,1/e.currentDampingFactor),C3(d,vg.makeRotationFromQuaternion(Wf)),e.paused=8*(1-Wf.dot(tc))<hJ):(C3(d,vg.makeRotationFromQuaternion(tc)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(dJ),d.dispatchEvent(fJ)}},Cs=new T,Ri=new T,fi=new T;function pJ(i,t,e,r,n,s){let o=i.elements;fi.subVectors(t,e),fi.lengthSq()===0&&(fi.z=1),fi.normalize(),Ri.crossVectors(r,fi),Ri.lengthSq()===0&&(Math.abs(r.z)===1?fi.x+=1e-4:fi.z+=1e-4,fi.normalize(),Ri.crossVectors(r,fi)),Ri.normalize(),Cs.crossVectors(fi,Ri),n==="x"?s.z===1?[Ri,Cs,fi]=[fi,Ri,Cs]:(Ri.negate(),[Ri,fi]=[fi,Ri]):n==="y"?s.x===1?[Ri,Cs,fi]=[Cs,fi,Ri]:(Ri.negate(),[Cs,fi]=[fi,Cs]):s.x===1&&(Ri.negate(),[Ri,Cs]=[Cs,Ri]),o[0]=Ri.x,o[4]=Cs.x,o[8]=fi.x,o[1]=Ri.y,o[5]=Cs.y,o[9]=fi.y,o[2]=Ri.z,o[6]=Cs.z,o[10]=fi.z}var zT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=_r(e,e.actions,n,s,o,r)}disconnect(){pr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),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()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),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())}},Lb=class extends kr{constructor(e,r){super(e);this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{nt.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{page:n,sharedAssets:s}=this.eventContext,o=(a,l)=>{if(!(!a.visible||!a.data?.events.length)){for(let{id:c,data:u}of a.data.events)if(!u.disabled&&u.type==="MouseHover")try{let h=new zT(c,u,a,n,s,r);this.eventsPerObjects[a.uuid]?this.eventsPerObjects[a.uuid].push(h):this.eventsPerObjects[a.uuid]=[h]}catch(h){!1&&console.log(h)}this.eventsPerObjects[a.uuid]?.length&&this.objects.push(a instanceof nr?l:a)}};n.traverseEntity(a=>{(a instanceof Cr||a instanceof fr)&&a.frame?.traverse(l=>{o(l,a)}),o(a)})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(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(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(n=>{n.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:n,raycaster:s,page:o,pointerScreen:a}=this.eventContext,l=!1;if(o.uiCanvas&&(l=io(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),n&&!l){let c=zf(s,o,this.objects);r=mg(c),c.forEach(u=>{u.object instanceof Cr&&io(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)})})}else this.objects.forEach(c=>{let u=kf(s,c);u&&(r.push(c),c instanceof Cr&&io(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(n=>{r.includes(n)||(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(n=>{n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var kT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=_r(e,e.actions,n,s,o,r)}connect(){this.scrollCounter=0}disconnect(){pr(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(r)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},GT=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=_r(e,e.actions,n,s,a,r)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,r=document.documentElement,n=window.pageYOffset||r.scrollTop||e.scrollTop,s=r.clientTop||e.clientTop||0,o=Math.round(t.top+n-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,c=this.data.enterAnchor,u=c==="top"?a:c==="bottom"?a-l:a-l*.5;this.scrollStart=o-u}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){pr(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:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,n=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(n)),this.actions.Animation.forEach(s=>s.seek(n)),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(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},Nb=class extends kr{constructor(e,r){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,n])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),n.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{page:n,sharedAssets:s,domElement:o,isExport:a}=this.eventContext,l=c=>{if(!!c.data?.events.length){for(let{id:u,data:h}of c.data.events)if(!h.disabled&&h.type==="Scroll")if(h.trigger==="load"||!a){let d=new kT(u,h,c,n,s,r);this.wheelEventsPerObject.has(c)?this.wheelEventsPerObject.get(c)?.push(d):this.wheelEventsPerObject.set(c,[d])}else{let d=new GT(u,h,c,n,s,o,r);this.scrollEventsPerObject.has(c)?this.scrollEventsPerObject.get(c)?.push(d):this.scrollEventsPerObject.set(c,[d])}}};n.traverseEntity(c=>{(c instanceof Cr||c instanceof fr)&&c.frame?.traverse(u=>{l(u)}),l(c)}),this.intersectionObserver=new IntersectionObserver(c=>{let u=c[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.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,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var HT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=_r(e,e.actions,n,s,o,r)}disconnect(){pr(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),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.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Fo?e.interaction.audioPlayer.play():e.interaction instanceof Bf&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof Fa?e.interaction.play(r==="autoplay"):e.interaction instanceof Vf&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),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.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Fo?e.interaction.audioPlayer.play():e.interaction instanceof Bf&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Fa?e.interaction.play():e.interaction instanceof Vf&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},Bb=class extends kr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.actions.Audio.forEach(s=>{s.interaction instanceof Fo&&s.interaction.audioPlayer.play()}),n.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Fa&&s.interaction.play(o==="autoplay")}),n.actions.Particles.forEach(s=>{s.dispatchBasic()})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&s==="Start"&&(r instanceof nr||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext,n=s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new HT(o,a,s,r,e,this.eventManager);(l.actions.Transition.length||l.actions.Animation.length||l.actions.SwitchCamera.length||l.actions.Create.length||l.actions.Destroy.length||l.actions.SceneTransition.length||l.actions.Reset.length||l.actions.SetVariable.length||l.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Particles.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}};if(r.traverseEntity(s=>{(s instanceof Cr||s instanceof fr)&&s.frame?.traverse(o=>{n(o)}),n(s)}),[...this.eventsAfterPerObject.values()].some(s=>s.length)){if(this.eventManager.activateCount===0){let{domElement:s,isExport:o}=this.eventContext,a=o?document:s;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(([l,c])=>{l.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>a.dispatch()),s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onMouseDown),n.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(n=>n.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var Fb=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=_r(e,e.actions,n,s,o,r),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){pr(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var Ub=class extends kr{constructor(e,r,n,s,o){super(e);this.sharedVariables=r;this.eventManager=n;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let r=new Date,n=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:c,property:u,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(c),f=Wv.propertyPaths[u];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h===null?this.propertiesToWatch[l].prevValue=d instanceof T?d.clone():d:(d instanceof T?!d.equals(h):h!==d)&&(s.push({objId:c,property:u}),d instanceof T?this.propertiesToWatch[l].prevValue.copy(d):this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:c,prevValue:u}=this.variablesToWatch[l],h=this.shared.getVariable(c);h!==u&&(n.push(c),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:c,expectedTime:u,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],g=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?g=1:d.dynamicVariableType==="counter"?g=d.updateInterval:d.dynamicVariableType==="random"&&(g=d.isStatic?1/0:d.updateInterval),u===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+g;continue}if(!((this.shared.getDynamicVariablePlayState(c)==="Stopped"||this.shared.getDynamicVariablePlayState(c)==="Restarted")&&(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+g,d.dynamicVariableType==="counter"&&this.shared.getVariable(c)!==p&&(this.shared.updateVariable(c,p),this.eventManager.requestRender()),(d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(c,bn.getFormattedTimerTime(p,d)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(c)==="Restarted"&&this.shared.setDynamicVariablePlayState(c,"Playing"),this.shared.getDynamicVariablePlayState(c)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(c)==="Paused"){this.dynamicVars[l].deltaToExpectedTime===void 0&&(this.dynamicVars[l].deltaToExpectedTime=Math.max(this.dynamicVars[l].expectedTime-e,0)),this.dynamicVars[l].last=e-(g-this.dynamicVars[l].deltaToExpectedTime),this.dynamicVars[l].expectedTime=e+this.dynamicVars[l].deltaToExpectedTime;continue}else this.dynamicVars[l].deltaToExpectedTime=void 0;if(e>=u)if(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=g,d.dynamicVariableType==="random"){let y=d.min+Math.random()*(d.max-d.min),m=d.decimals;y=Math.round(y*Math.pow(10,m))/Math.pow(10,m),this.shared.updateVariable(c,y),n.push(c),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let y=this.shared.getVariable(c),m=this.shared.getDynamicVariableToggleIsForward(c)??!0,v=this.shared.getVariable(c)+d.increment*(m?1:-1);d.hasEnd&&(v=d.increment>0?_e.clamp(v,p,d.endValue):_e.clamp(v,d.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(c,void 0),d.repeat?v===d.endValue&&(v=p):(v===p||v===d.endValue)&&this.shared.setDynamicVariablePlayState(c,"Paused")),v!==y&&(n.push(c),this.shared.updateVariable(c,v),this.eventManager.requestRender())}else if(d.dynamicVariableType==="time")this.shared.updateVariable(c,d1(r,d)),n.push(c),this.eventManager.requestRender();else{let y=ki.isTextValue(d.endValue)?_3(d.endValue.textValue):d.endValue,m=this.shared.getDynamicVariableToggleIsForward(c)??!0,v=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1)*(m?1:-1);v=Math.max(v,0),d.hasEnd&&(v=d.dynamicVariableType==="stopwatch"?_e.clamp(v,p,y):_e.clamp(v,y,p),v===p&&this.shared.setDynamicVariableToggleIsForward(c,void 0),d.repeat?Math.abs(v-y)<(d.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(d.format==="number3decimal"?1e-4:.1)||Math.abs(v-y)<(d.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(c,"Paused")),v!==f&&(n.push(c),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(c,bn.getFormattedTimerTime(v,d)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(n.includes(l.data.variableId)||s.find(c=>c.objId===l.data.objectId&&c.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new jT(a.uuid,l.data,a,e.page,e.sharedAssets,n))})}),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:l})=>{if(!("dynamicVariableType"in l)){this.events.find(u=>u.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let c;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let u;if(ki.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?u=h[2]+h[1]*60+h[0]*3600:u=h[1]+h[0]*60}else u=l.value;c=u,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:u,startValue:c})}else l.dynamicVariableType==="time"&&this.shared.updateVariable(a,d1(new Date,l)),l.dynamicVariableType==="counter"&&(c=ki.isTextValue(l.value)?_3(l.value.textValue):l.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:c})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].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())}},jT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=_r(e,e.actions,n,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch())}dispose(){pr(this.actions)}};function _3(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var D3=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.0.88/build/",mJ=!1?D3:"https://unpkg.com/@splinetool/navmesh-wasm@1.0.88/build/",gJ=`
8002
+ )`}else if(i.easing===6){let{mass:e,stiffness:r,damping:n,velocity:s}=i;t=`spring( ${e}, ${r}, ${n}, ${s} )`}else{let e;switch(i.easing){case 0:e=ma.linear;break;case 1:e=ma.ease;break;case 2:e=ma.easeIn;break;case 3:e=ma.easeOut;break;case 4:e=ma.easeInOut;break;default:e=ma.linear}let[r,n,s,o]=e;t=`cubicBezier( ${r}, ${n}, ${s}, ${o} )`}return{duration:Math.max(i.duration,1e-4),easing:t}}function ST(i){let t={delay:0,loop:i.repeat===-1?!0:i.repeat+1};if(i.repeat===0)t.direction="normal",t.rewind=!1;else switch(i.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,i.delayDirection){case"start-once":t.startOnceDelay=i.delay;break;case"start":t.delay=i.delay;break;case"end":t.endDelay=i.delay;break;case"start-end":case void 0:t.delay=i.delay,t.endDelay=i.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,i.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):i.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):i.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var NZ={type:"beginState"},BZ={type:"completeState",isfromEntity:!1},Sb=class{constructor(t,e,r,n,s,o){this.object=t;this.data=n;this.sharedAssets=s;this.allowSlerp=o;this.targets={t:0};this.firstLoop=!0;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.requestRender()),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let t=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"beginState",state:t}),this.object instanceof nr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof Tr&&e.dispatchEvent(NZ)})};this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let t=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=t,this.object.dispatchEvent({type:"completeState",state:t}),this.object instanceof nr||this.object.traverseEntity(e=>{e!==this.object&&e instanceof Tr&&e.dispatchEvent(BZ)})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=bT(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))};if(e===void 0){let a=bb(this.object,this.object.currentState===r?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=bb(this.object,e);if(!a)throw new Error("Missing property");this.from=a}if(r===void 0)throw new Error("Missing property");{let a=bb(this.object,r);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=e===void 0||r===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...ST(n),...wT(n),change:this.onChange},this.callback=bT(this.object,e===void 0?{}:this.from.data,r===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},sg=class extends gr{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;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())};if(!e.object)throw new Error("Missing property");let o=this.page.scene.find(e.object)??this.page.uiCanvas?.find(e.object)??this.page.scene.find2DInUIObjects(e.object);if(!o)throw new Error("Missing property");if(!o.states)throw new Error("Missing property");if(this.object=o,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?.paused===!1}get changeBegan(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=bb(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:r=!1,isRebuild:n=!1}={}){try{let s=ST(this.data.tweens[0].data);n&&typeof s.loop=="number"&&s.loop--,this.timeline?.pause(),this.timeline=xb.timeline({autoplay:!1,...s,...s.loop===!0||s.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let o=this.tweens.findIndex(a=>a?.changeBegan);if(r===!0&&(this.timelineNeedsRebuild=!0),e){let a=o===-1?0:o;for(let l=a;l<this.data.tweens.length-1;l++){let c=this.data.tweens[l],u=this.data.tweens[l+1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Tr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new Sb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,u.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.delay:0))}this.timeline.duration+=s.endDelay}else{let a=o===-1?this.data.tweens.length-1:o+1;for(let l=a;l>0;l--){let c=this.data.tweens[l],u=this.data.tweens[l-1],h;l===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.changeBegan===!0)?(h=void 0,this.object instanceof Tr&&(this.object.wasMovedByUser=!1)):h=c.data.state===void 0?this.currentState:c.data.state;let d=new Sb(this.object,h,u.data.state===void 0?this.currentState:u.data.state,c.data,this.shared,this.data.allowSlerp??!1);o!==-1&&l===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[l-1]=d,this.timeline.add(d.params,this.timeline.duration+(l===a?s.endDelay:0))}this.timeline.duration+=s.delay}}catch(s){s instanceof Error&&console.error(s.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(Gt(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=ST(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(r){r instanceof Error&&console.error(r.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 nr?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(Gt(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 bb(i,t){let e,r;if(typeof t=="string"?(e=t,r=i.states?.[e]):t===null&&(e=null,r=i.data),!(e===void 0||r===void 0))return{id:e,data:r}}var FZ={type:"beginState"},s3={type:"completeState",isfromEntity:!1},o3={type:"requestRender"},og=class extends gr{constructor(e,r,n,s){super();this.data=e;this.page=r;this.shared=n;this.condition=s;this.toggleIsForward=!1;this.useToggle=!1;this.posStart=new T;this.posEnd=new T;this.qStart=new Qe;this.qEnd=new Qe;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 r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");let n={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=xb({targets:n,t:1,...wT(this.data),update:()=>{n.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(FZ));let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,n.t),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,n.t),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*n.t,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(o3),n.t===1&&s.dispatchEvent(s3)}})}switchCamera(e){let r=this.page.activeCamera,n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),r.dispatchEvent({type:"cameraChange",camera:n})}play(){if(Gt(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(Gt(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(s3),this.page.activeCamera.dispatchEvent(o3))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var ag=class extends gr{constructor(e,r,n,s,o){super();this.page=r;this.animationControls=n;this.shared=s;this.condition=o;this.startOnceDelay=0;this.toggleIsForward=!1;let a=e.object,l=r.scene.find(e.object);l&&Array.isArray(l.identity)&&(a=l.identity[0]),this.data={...e,object:a};let c=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=c?.getClip()?.duration??1;let u=c?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/u*this.duration,this.rightFrameTime=this.data.crop[1]/u*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(Gt(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 r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([n,s])=>{let o=n.split("/")[1];this.threeAnimAction!==s&&o===r&&s.isRunning()&&(e?s.fadeOut(.2):s.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=_e.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(Gt(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 n=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([s,o])=>{let a=s.split("/")[1];this.threeAnimAction!==o&&a===n&&o.isRunning()&&(r?o.fadeOut(.2):o.stop())}),r&&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()}};var lg=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.eventManager=r;this.shared=n;this.condition=s;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(Gt(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(r=>r.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 t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),Ff(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};var cg=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=Gt(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let t=this.shared.getVariable(this.data.variableId),e=G0(this.data.expression,this.shared,ki.typeOfVariable(t));e!==void 0&&this.shared.updateVariable(this.data.variableId,typeof e=="string"?{textValue:e}:e)}dispose(){}};var ug=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.timeoutId=null}dispatchInner(){if(Gt(this.shared,this.condition)===!1)return!1;let t=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,t==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&t!=="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"&&t!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&t!=="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 e=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);t==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,e===void 0?!1:!e):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!e),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let t=this.data.delay,e=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&e==="Playing"&&(t=this.data.pauseDelay),t!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},t)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function Gt(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=G0(t.expression,i,"boolean");return t.negate?!e:!!e}function _r(i,t,e,r,n,s){let o={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},a=l=>({id:c,data:u})=>{try{u.type==="Audio"?xn[i.type].includes("Audio")&&o.Audio.push(new Zm(c,u,s,r,l)):u.type==="Video"&&!(s instanceof nr)?xn[i.type].includes("Video")&&o.Video.push(new hg(c,u,s,r,l)):u.type==="Particles"?xn[i.type].includes("Particles")&&o.Particles.push(new Jm(u,e,r,l)):u.type==="Link"?xn[i.type].includes("Link")&&o.Link.push(new fb(u,n.controlsManager,r,l)):u.type==="Create"?xn[i.type].includes("Create")&&o.Create.push(new dg(u,e,n.controlsManager,r,l)):u.type==="Destroy"?xn[i.type].includes("Destroy")&&o.Destroy.push(new $m(u,e,n.controlsManager,r,l)):u.type==="Reset"?xn[i.type].includes("Reset")&&o.Reset.push(new eg(u,e,r,n,l)):u.type==="Transition"?xn[i.type].includes("Transition")&&o.Transition.push(new sg(u,e,r,l)):u.type==="SwitchCamera"?xn[i.type].includes("SwitchCamera")&&o.SwitchCamera.push(new og(u,e,r,l)):u.type==="SceneTransition"?xn[i.type].includes("SceneTransition")&&o.SceneTransition.push(new lg(u,e,n,r,l)):u.type==="Animation"?xn[i.type].includes("Animation")&&o.Animation.push(new ag(u,e,n.animationControls,r,l)):u.type==="SetVariable"?xn[i.type].includes("SetVariable")&&o.SetVariable.push(new cg(u,e,r,l)):u.type==="DynamicVariablePlay"?xn[i.type].includes("DynamicVariablePlay")&&o.DynamicVariablePlay.push(new ug(u,e,r,l)):u.type==="Conditional"&&xn[i.type].includes("Conditional")&&(u.ifActions.forEach(a({expression:u.condition,negate:!1})),u.elseActions.forEach(a({expression:u.condition,negate:!0})))}catch(h){!1&&console.log(h)}};return t.forEach(a()),o}function pr(i){Object.values(i).forEach(t=>{t.forEach(e=>{(e instanceof Zm||e instanceof hg||e instanceof Jm||e instanceof ag||e instanceof sg||e instanceof dg||e instanceof $m||e instanceof og||e instanceof lg||e instanceof eg||e instanceof cg||e instanceof ug)&&e.dispose()})})}function a3(i,t){let e;if("material"in i){let r=i.material;Array.isArray(r)?e=i.material[0].layers.find(n=>n.uuid===t):e=i.material.layers.find(n=>n.uuid===t)}if(!!e)return e.color.texture.image.img instanceof HTMLVideoElement?e.color.texture.image.img:void 0}var l3=new Map,fg=new Map,Fa=class{constructor(t,e,r){this.data=e;this.delay=0;this.status="stopped";let{layerId:n,loop:s,volume:o,delay:a}=e;if(this.object=r,n===void 0)throw new Error("Missing property");let l=a3(r,n);l&&(this.videoElement=l,this.videoElement.loop=s===1/0,Rh&&(this.videoElement.autoplay=!0),o!==void 0&&(this.videoElement.volume=o)),a!==void 0&&(this.delay=a),fg.has(r.uuid)?fg.get(r.uuid).push(this):fg.set(r.uuid,[this]),l3.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(n=>{}).catch(n=>{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)}},Vf=class{constructor(t){this.data=t}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=l3.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=fg.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...fg.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},hg=class{constructor(t,e,r,n,s){this.data=e;this.shared=n;this.condition=s;if(e.interaction==="play")this.interaction=new Fa(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new Vf(e);else throw new Error("Missing property")}dispatchBasic(){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fa?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(Gt(this.shared,this.condition)===!1)return!1;this.interaction instanceof Fa?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};var c3=(()=>{let i,t,e,r;function n(a){!i&&!u3()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(i=requestAnimationFrame(s)),a&&(t=a,r=a.requestRender)}function s(a){let l=e?a-e:0,c=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,h=c.length,d=0;for(;d<h;){let f=c[d];f.userData.createdTime===void 0&&(f.userData.createdTime=a),f.userData.lifetime===void 0&&f.userData.quantity===void 0||f.userData.lifetime&&a-f.userData.createdTime<f.userData.lifetime||f.userData.quantity&&u[f.userData.actionId]<=f.userData.quantity?(f.userData.velocity&&(f.position.addScaledVector(f.userData.velocity,l/1e3),f.updateMatrix(),r()),d++):(u[f.userData.actionId]>f.userData.quantity&&u[f.userData.actionId]--,c.splice(d,1),f.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&f.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(f.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(f.rigidBody)):(f.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(p=>p.bvhGeometry!==void 0)),h--,r())}i=d>0?requestAnimationFrame(s):void 0,e=d>0?a:void 0}function o(){u3()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):n()}return typeof document<"u"&&document.addEventListener("visibilitychange",o),n})();function u3(){return!!document&&document.hidden}var h3=new Qe,UZ=new T,VZ=new T,dg=class{constructor(t,e,r,n,s){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=s;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=_e.generateUUID();this.dispatch=()=>{if(Gt(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(Gt(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=Qw(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 t=new zr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,n=this.page.scene.find(r);n&&(n.updateMatrixWorldSVD(),t.hiddenMatrix.copy(n.matrixWorldRigid))}t.position.fromArray(this.data.position),t.rotation.fromArray(this.data.rotation),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),c3(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldSVD();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Wi)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof zr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Wi)return;t instanceof zr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new T().fromArray(this.data.velocity),n=e.dataPatched;if(!(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(UZ,h3,VZ),r.applyQuaternion(h3),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(s=>s!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let o=this.page.scene.find(this.data.object);if(!o)throw new Error("Missing Property");if(this.object=o,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");c3(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}};var MT=200,AT=.02,ET=.3,zZ=65,XHe=new T,d3=new T,f3=new T,kZ=new T,_n=new T,zn=new T,$l=new T,TT=new ue,p3=new ue,GZ=new ue,YHe=new ue,eo=new Qe,Ua=new Qe,zo=new Ht(0,0,0,"YXZ"),HZ=new T(1,0,0),to=new T(0,1,0),jZ=new T(0,0,1),m3=new T(1,1,1),KHe=new Or,WZ=1,qZ=.025,XZ=16e-6,g3=12,YZ=20,Xi=new Ei,Ms=new zt,KZ={type:"requestRender"},QZ={type:"updateMatrix"},y3=Math.PI/6,wb=class extends gr{constructor(e,r,n,s,o,a,l,c,u){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=s;this.controlsManager=o;this.cameraFollow=a;this.camera=l;this.page=c;this.sharedAssets=u;this.enableDamping=!0;this.hiddenMatrix0=new ue;this.target0=new T;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=MT;this.euler0=new Ht(0,0,0,"YXZ");this.position0Cam=new T;this.quat0Cam=new Qe;this.scale0Cam=new T;this.hiddenMatrix0Cam=new ue;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new Ei(new T(0,-40,0),new T(0,40,0)),matrix:new ue,position:new T,rotation:new Qe};this.euler=new Ht(0,0,0,"YXZ");this.eulerDelta=new T;this.lastPosition=new T;this.lastCameraQuaternion=new Qe;this.lastCameraPosition=new T;this.PI_2=Math.PI/2;this.prevMouse=new U;this.velocityTarget=new T;this.velocity=new T;this.directionXZ=new T;this.rotVelocityStick=new T;this.rotVelocityTarget=new T;this.rotVelocity=new T;this.rotDirection=new T;this.nonColliderRotOffset=new ue;this.nonColliderPosOffset=new ue;this.firstPointerId=-1;this.rot=new T;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 ue;this.objectToTarget=new T;this.objectToTarget0=new T;this.objectToCamXZ=new T;this.objectToCamXZ0=new T;this.targetToCamera=new T;this.targetToCamera0=new T;this.cameraPolarAxis0=new T;this.targetPos=new T;this.targetQuat=new Qe;this.lerpFactorPos=new T().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Qe;this.objXZQuatInv=new Qe;this.objXZRotMat=new ue;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new T;this.pushedVelocity=new T;this.groundYRotation=0;this.objectRealQuat=new Qe;this.colliderWorldQuat=new Qe;this.groundNormal=new T;this.groundTilt=new Qe;this.groundTiltInv=new Qe;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new T;this.quaternion=new Qe;this.scale=new T;this.initialAction=!0;this.onPointerDown=e=>{e.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Mi&&(!Zw||Jw>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Zw&&Jw<15.5&&!Mi?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?wb.isLocked=!0:wb.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let s=e.axes[n];r===0?n===2?this.movementState.movePosX=s:this.movementState.movePosZ=s:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(s)>=.3&&(this.vrEulerYOffset+=s<0?1:-1),this.movementState.rotPosY=s):this.moveMode==="fly"&&(this.movementState.moveNegY=s))}};this.sharedGameControlGlobals=o.sharedGameControlGlobals,e===l&&(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(),d=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,d,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 y=new T(0,0,-1).applyQuaternion(this.camera.quaternion),m=new T().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v,x;Math.abs(y.y)<1e-6?(m.y=0,y.y=0,x=m.projectOnVector(y)):m.y/y.y>0?x=y.multiplyScalar(m.y/y.y):x=y.multiplyScalar(m.length()),this.targetToCamera0.copy(x).negate(),v=this.camera.position.clone().add(x),this.objectToTarget0.subVectors(v,this.position);let b=new Ht().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-b.x,b.x=0,b.z=0,b.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(b)}if(this.object instanceof Tr&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*WZ,this.speedOrbit=(n.speedRotate??100)*qZ,this.mouseOrbitSensitivity=(n.speedRotate??100)*XZ,this.keyAssignments=n.keyAssignments.map(y=>{let m=[y[0],y[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}),n.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Ml.defaultData.gravity)*g3,this.usePhysics=this.gloabalPhysics.usePhysics??Ml.defaultData.usePhysics,this.jumpPower=n.jumpPower*YZ,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??ed.defaultDataThirdPerson.orientWith,this.slopeThresh=zZ*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*AT/this.pixelsPerMeter,this.stepThresh=n.collider.height*ET/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*AT/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*ET/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*AT/this.pixelsPerMeter,this.stepThresh=n.collider.height*ET/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let f=new T().fromArray(n.collider.position),p=new Qe().setFromEuler(new Ht().fromArray([...n.collider.rotation,"XYZ"]));this.collider.position.copy(f).multiply(this.scale),this.collider.rotation.copy(p),this.collider.matrix.compose(f,p,m3),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=n.runMultiplier??2;let g=n.navmesh.destinationHelperRadius*2;if(g>0){let y=new je;y.push({fi:0,data:{...Hr.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Hr.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let m=new Oa({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new tr(P0.create({parameters:{width:g,height:g/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=n.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 r=new Ht().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Tr?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},$h.list.forEach(n=>{this.actions[n]=_r({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,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"),pr(this.actions.idle),pr(this.actions.move),pr(this.actions.run),pr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return _n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,r,n){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 s=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let o=s*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let c=zn.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*g3),1)*(this.gravity>0?1:-1):this.velocity.y)*s,0).divideScalar(this.pixelsPerMeter),u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(u){this.onObject=!0,this.groundNormal.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),u.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=u.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(_n,Ua,zn),this.groundVelocity.subVectors(_n,d.prevT),this.object.getWorldPosition(zn).add(this.collider.position).sub(_n),this.groundYRotation=zo.setFromQuaternion(Ua).y-d.prevR.y,$l.copy(zn).applyAxisAngle(to,this.groundYRotation),this.groundVelocity.add($l.sub(zn)).divideScalar(s);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*o),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 c=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 u=_n.subVectors(this.path[1],this.position),h=zn.subVectors(this.path[1],this.path[0]);u.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),c.opacity=c.userData.opacity0}else c.opacity-=.05*c.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)**o),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**o),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**o)):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 l=kZ.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let c=zn.copy(l);c.y=0,l.set(0,l.y,c.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let c=_n;this.camera.getWorldDirection(c);let u=$l.copy(to).multiplyScalar(c.dot(to));c.sub(u);let h=zn.copy(this.directionXZ);h.x*=-1,this.rot.y=c.angleTo(h)*(c.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(zo.setFromVector3(this.rot),this.moveMode==="walk"&&(zo.x=0),l.applyEuler(zo),a&&(Ua.setFromUnitVectors(to,this.groundNormal),l.applyQuaternion(Ua)),n){let c=zo.set(0,this.vrEulerYOffset*y3,0);n.applyEuler(c),l.x+=n.x,l.z+=n.z,this.nonColliderPosOffset.elements[13]+=n.y*s}if(this.usePhysics===!0){let c=zn;this.pushedVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=$l.setFromMatrixPosition(u.matrixWorld).sub(u.prevT).divideScalar(s).divideScalar(this.pixelsPerMeter),d=u.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),_n.copy(l).divideScalar(this.pixelsPerMeter),s,!1);h.multiplyScalar(this.pixelsPerMeter);let f=At.is(u)?u:u.object;if(d!==null&&this.lastHitObj!==f){let p;u instanceof zr&&(p=u);let g=this.sharedGameControlGlobals.entityToCollisionEvents[f.uuid];if(g)for(let y of g)y.data.target==="character"&&(y.dispatch(p),f.dispatchEvent(Ab));this.lastHitObj=f}if(d!==null){this.pushedVelocity.copy(h),c.copy(d.normal1).applyQuaternion(u.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let u=c.dot(l);u<0&&l.addScaledVector(c,-u),l.add(this.pushedVelocity)}else l.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(s),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**o):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**o),this.euler.x+=this.rotVelocity.x*s,this.euler.y+=this.rotVelocity.y*s+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*s),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(to,this.euler.y-this.euler0.y);let c=zn.copy(this.objectToCamXZ).normalize(),u=$l.copy(l).multiplyScalar(s);u.y=0;let h=u.sub(_n.copy(c).multiplyScalar(u.dot(c))).cross(c).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*s+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=_e.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=_e.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=_e.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(r?(zo.copy(r),zo.y=0):(zo.copy(this.euler),zo.y=0),this.nonColliderRotOffset.makeRotationFromEuler(zo)),r&&(this.moveMode==="walk"?(this.rot.y=r.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(r),this.rot.y+=this.vrEulerYOffset*y3),eo.setFromAxisAngle(HZ,this.rot.x),Ua.setFromAxisAngle(to,this.rot.y),Ua.multiply(eo),eo.setFromAxisAngle(jZ,this.rot.z),Ua.multiply(eo),this.quaternion.copy(Ua),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let c=zn.copy(l).multiplyScalar(s/this.pixelsPerMeter),u=null;this.didHit=!1;let h=new T;for(let d=0;d<5;d++){let f=c.length(),p=$l.copy(c).normalize();if(u=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,p,this.object.rigidBody?.collider(0).shape,f,!1,24,void 0,void 0,this.object.rigidBody),u!==null){this.didHit=!0;let g=this.sharedGameControlGlobals.colliderToEntity.get(u.collider.handle);if(g!==this.lastHitObj&&d===0){this.lastHitObj=g;let x=this.sharedGameControlGlobals.entityToCollisionEvents[g?.uuid];if(x){for(let b of x)if(b.data.target==="character"){let S=(this.sharedGameControlGlobals.rapierWorld?.getCollider(u.collider.handle))._parent,w;if(g.cloner){for(let E of g.cloner.children)if(E.rigidBody===S){w=E;break}}b.dispatch(w),g.dispatchEvent(Ab)}}}let y=d3.set(u.normal2.x,u.normal2.y,u.normal2.z).applyQuaternion(this.colliderWorldQuat),m=f3.copy(p).multiplyScalar(u.toi).dot(y),v=u.toi;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(v=u.toi*(m-this.offset)/m,h.addScaledVector(p,v)),c.copy(p).multiplyScalar(f-v),Math.acos(-y.y)>this.slopeThresh){let x=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),b=$l.copy(u.witness2).applyQuaternion(this.colliderWorldQuat);b.y=0;let S=x.add(b);S.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(S,this.colliderWorldQuat,c,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);w!==null&&w.toi===0&&(y.y=0,y.normalize())}c.addScaledVector(y,-c.dot(y))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(c);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(_n.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(eo.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let c=this.onObject?1:5,u=l.multiplyScalar(s/c);for(let h=0;h<c;h++)this.position.add(u),this.collisionAdjustment(s/c)}else this.position.addScaledVector(l,s);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 c=this.objectToTarget.add(this.position),u=this.targetToCamera.add(c);TT.lookAt(u,c,to).setPosition(u),TT.decompose(this.targetPos,this.targetQuat,_n),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**o),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=_e.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=_e.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(QZ),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(KZ),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=eo.setFromAxisAngle(to,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?_e.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 r;this.cameraXAxis==="Limit"?r=_e.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=_e.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=_n.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let s=Ua.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}groundTiltAdjustment(e){to.angleTo(e)*180/Math.PI<15||to.angleTo(e)*180/Math.PI>85?eo.identity():eo.setFromUnitVectors(to,e),this.groundTilt.slerp(eo,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=f3.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=TT.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(_n,eo,zn).compose(_n,eo,m3);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;Ms.makeEmpty(),o.updateMatrixWorldSVD();let a=o.matrixWorldRigid,l=p3.copy(a).invert(),c=GZ.copy(p3).multiply(n);Xi.copy(this.collider.segment),Xi.start.applyMatrix4(c),Xi.end.applyMatrix4(c);let u=d3.copy(this.position).applyMatrix4(l);Ms.expandByPoint(Xi.start),Ms.expandByPoint(Xi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),o.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(Xi.end)},intersectsBounds:h=>h.intersectsBox(Ms),intersectsTriangle:h=>{let d=_n,f=zn,p=h.closestPointToSegment(Xi,d,f);if(p<this.collider.radius){let g=this.collider.radius-p,y=f.sub(d).normalize(),m=$l.copy(u);m.addScaledVector(y,g);let v=m.applyMatrix4(a).sub(this.position);r.add(v),Xi.start.addScaledVector(y,g),Xi.end.addScaledVector(y,g)}}})}),Ms.makeEmpty(),Xi.copy(this.collider.segment),Xi.start.applyMatrix4(n),Xi.end.applyMatrix4(n),Ms.expandByPoint(Xi.start),Ms.expandByPoint(Xi.end),Ms.min.addScalar(-this.collider.radius),Ms.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(o){return o.distanceToPoint(Xi.end)},intersectsBounds:o=>o.intersectsBox(Ms),intersectsTriangle:o=>{let a=_n,l=zn,c=o.closestPointToSegment(Xi,a,l);if(c<this.collider.radius){let u=this.collider.radius-c,h=l.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),r.addScaledVector(h,u),Xi.start.addScaledVector(h,u),Xi.end.addScaledVector(h,u)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(s),this.position.add(r)}},pg=wb;pg.isLocked=!1;var v3=qo(iE());function ro(i,t){let e=new Ne;if(!i.getAttribute("position"))return e.setAttribute("position",new Ie([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=zc(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Ie(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var ZZ=new ue,JZ=new ue,ko=[[0,0,0],[0,0,0],[0,0,0]];function CT(i){let t=i.elements;ko[0][0]=t[0],ko[0][1]=t[4],ko[0][2]=t[8],ko[1][0]=t[1],ko[1][1]=t[5],ko[1][2]=t[9],ko[2][0]=t[2],ko[2][1]=t[6],ko[2][2]=t[10];let{u:e,v:r}=(0,v3.SVD)(ko),n=ZZ.set(e[0][0],e[0][1],e[0][2],0,e[1][0],e[1][1],e[1][2],0,e[2][0],e[2][1],e[2][2],0,0,0,0,1),s=JZ.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 n.multiply(s.transpose())}var Eb=class extends $u{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(t,e){e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):e.isPerspectiveCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(e),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(t,e=!0,r=[]){return t.forEach(n=>{n.visible&&this.intersectObject(n,e,r)}),r}createRaycastLineHelper(){let t=new os({color:65280,linewidth:10}),e=new T(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),r=new T(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),n=this.camera.far-this.camera.near,s=new T().addVectors(e,r.multiplyScalar(n)),o=new Ne;return o.setFromPoints([e,s]),new yc(o,t)}};var x3=i=>i instanceof As||i instanceof Js;function $Z(i,t){return i.distance-t.distance}function b3(i,t,e){if(!(!To(t)||!t.visible)){ln(t)&&t.raycast(i,e);for(let r of t.children)b3(i,r,e)}}function zf(i,t,e,r=!1){if(!r&&!e.some(s=>kf(i,s)!==void 0))return[];let n=[];return t.children.forEach(s=>b3(i,s,n)),n.sort($Z),n}function mg(i){let t=[];if(i.length){let e=i[0].object;To(e)&&t.push(e);let r=e.parent;for(;r;)x3(r)&&t.push(r),r=r.parent}return t}function io(i,t,e,r){let n=i.frame;if(n){let s=t[0]*n.width,o=(1-t[1])*n.height;for(let a of e){let l=a===n.uuid?n:n.find(a);if(l?.intersects(s,o))return r(l),!0}}return!1}function kf(i,t){if(ln(t)){if(t.visible){let e=[];return t.raycast(i,e),e.length?e[0]:void 0}}else if(x3(t))return S3(i,t)}function S3(i,t){if(!(!To(t)||!t.visible)){if(ln(t)){let e=[];if(t.raycast(i,e),e.length)return e[0]}for(let e of t.children){let r=S3(i,e);if(r)return r}}}function eJ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width*2-1,y:-((t-(e.top+window.scrollY))/e.height)*2+1}}function tJ(i,t,e){return{x:(i-(e.left+window.scrollX))/e.width,y:1-(t-(e.top+window.scrollY))/e.height}}var Tb=class{constructor(t,e,r,n,s,o,a,l){this.renderer=t;this.publish=e;this.scene=r;this.getCamera=n;this.sharedAssets=s;this.requestRender=o;this.isExport=a;this.frame=l;this.raycaster=new Eb;this._useWindowEvents=!1;this.pointerWorld={x:0,y:0};this.pointerScreen={x:0,y:0};this._useWindowEvents=e.mouseEventTarget==="window",this.domElement=t.domElement,this.eventElement=this._useWindowEvents?window:t.domElement,this._domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(t){this._useWindowEvents=t,this.eventElement=t?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}set domRect(t){this._domRect=t}get domRect(){return this._domRect}updateRaycaster(t){let{pageX:e,pageY:r}=t.touches?.length>0?t.touches[0]:t;this.pointerWorld=eJ(e,r,this._domRect),this.pointerScreen=tJ(e,r,this._domRect),this.raycaster.setFromCamera(this.pointerWorld,this.getCamera())}};var kr=class{constructor(t){this.eventContext=t;this.domEventsNeeded=new Set;this.hasVideoAction=!1}connect(){}disconnect(){}};var _T=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],w3=i=>_T.find(([t,e])=>e===i)?.[0],Go=i=>_T.find(([t])=>t===i)?.[1],rJ=(i,t)=>{let e=w3(i);if(e){let r=new CustomEvent(e,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Mb=class extends kr{constructor(e){super(e);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=e=>{if(!e.eventName||!e.target||e.eventName==="Scroll")return;let r=this.splineEvents[w3(e.eventName)]?.[e.target.uuid];if(!r)return;e.eventName==="Scroll"&&e.deltaY!==void 0&&Object.assign(r,{deltaY:e.deltaY});let{domElement:n}=this.eventContext;n.dispatchEvent(r)};let{page:r}=this.eventContext;r.traverseEntity(n=>{if(!!n.data?.events.length){for(let[s,o]of _T)if(n.data.events.some(a=>a.data.type===o&&!a.data.disabled)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(n):this.objectsPerEvents.set(s,[n]);let a={id:n.uuid,name:n.name},l=rJ(o,a),c=this.splineEvents[s];c?c[n.uuid]=l:this.splineEvents[s]={[n.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(r=>{r.removeEventListener("beginEvent",this.onBeginEvent)})})}};var PT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.alreadyPlayedNonTogglingActions=new Set;if(this.useToggle=e.runMode==="Toggle",(e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress")&&!e.key)throw new Error("Missing property");this.actions=_r(e,e.actions,n,s,o,r)}disconnect(){pr(this.actions)}dispatchHeld(t){this.actions.Create.forEach(e=>{t&&e.dispatchThrottled.cancel(),e.dispatchThrottled()})}dispatch(t=!1){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()}),this.actions.SwitchCamera.forEach(e=>{e.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStart())):(this.actions.Transition.some(n=>n.playing)||this.actions.Transition.forEach(n=>{this.alreadyPlayedNonTogglingActions.has(n)===!1&&n.play()}),this.actions.SwitchCamera.some(n=>n.playing)||this.actions.SwitchCamera.forEach(n=>{n.play()}),this.actions.Animation.forEach(n=>{n.play()})),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),t===!1&&this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,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.Create.forEach(t=>t.dispatchStop()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},Cb=class extends kr{constructor(e,r,n){super(e);this.useForRaycastProperty=n;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=e=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=zf(r,n,[],!0);this.sceneInterects=s,s.length&&(this.eventContext.sharedAssets.raycastProperty={x:s[0].point.x,y:s[0].point.y,z:s[0].point.z,objX:s[0].object.matrixWorld.elements[12],objY:s[0].object.matrixWorld.elements[13],objZ:s[0].object.matrixWorld.elements[14]})}};this.onCanvasMouseDown=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{(r.data.type==="MouseDown"||r.data.type==="MousePress")&&(this.onCanvasRaycast(e),r.dispatch())})};this.onCanvasMouseUp=e=>{(e.target===this.eventContext.domElement||e.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(r=>{r.data.type==="MouseUp"?(this.onCanvasRaycast(e),r.dispatch()):r.data.type==="MousePress"&&r.dispatchRelease()})};this.onMouseDown=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseDown"))};this.onMouseUp=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseEvent("MouseUp"))};this.onMousePressDown=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent())};this.onMousePressRelease=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMousePressEvent(!0))};this.onKeyDown=e=>{this.heldKeys[e.key]||(this.handleKeyEvent(e,"KeyDown"),this.handleKeyEventHeld(e,"KeyDown",!0)),this.heldKeys[e.key]=!0};this.onKeyUp=e=>{this.handleKeyEvent(e,"KeyUp"),this.handleKeyEventHeld(e,"KeyUp",!0)};this.onKeyPressDown=e=>{this.heldKeysPress[e.key]?this.handleKeyEventHeld(e,"KeyPress"):(this.handleKeyEvent(e,"KeyPress"),this.handleKeyEventHeld(e,"KeyPress",!0)),this.heldKeysPress[e.key]=!0};this.onKeyPressUp=e=>{this.handleKeyEvent(e,"KeyPress",!0)};this.releaseHeldKey=e=>{delete this.heldKeys[e.key]};this.releaseHeldKeyPress=e=>{delete this.heldKeysPress[e.key]};this._onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&(s==="MouseDown"||s==="MouseUp"||s==="MousePress"?(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent(n)})):(s==="KeyDown"||s==="KeyUp"||s==="KeyPress")&&(r.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[r.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{page:s,sharedAssets:o}=this.eventContext,a=(l,c)=>{if(!l.data?.events.length)return;let u=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let h of u){let d=this.eventsPerObjects[h];l.data.events.filter(({data:f})=>f.type===h&&f.disabled!==!0).forEach(({id:f,data:p})=>{try{let g=new PT(f,p,l,s,o,r);g.actions.Video.length&&(this.hasVideoAction=!0),(p.type==="MouseDown"||p.type==="MouseUp"||p.type==="MousePress")&&(p.mode==="Canvas"||p.mode==="Window")?this.canvasMouseEvents.push(g):d[l.uuid]?d[l.uuid].some(y=>y.id===g.id)||d[l.uuid].push(g):d[l.uuid]=[g]}catch(g){!1&&console.log(g)}}),d[l.uuid]?.length&&this.objectsPerTypes[h].push(l instanceof nr&&(h==="MouseDown"||h==="MouseUp"||h==="MousePress")?c:l)}};s.traverseEntity(l=>{(l instanceof Cr||l instanceof fr)&&l.frame?.traverse(c=>{a(c,l)}),a(l)})}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(([r,n])=>{n.forEach(s=>{s.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(r=>{Object.values(r).forEach(n=>{n.forEach(s=>{s.disconnect()})})}),this.canvasMouseEvents.forEach(r=>{r.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([r,n])=>{n.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:r,raycaster:n,page:s,pointerScreen:o}=this.eventContext,a=this.objectsPerTypes[e],l=a.filter(c=>!(c instanceof nr));if(!(!a.length&&!this.useForRaycastProperty)&&!(s.uiCanvas&&io(s,[o.x,o.y],Object.keys(this.eventsPerObjects[e]),u=>{this.handleObjectMouseEventDispatch(u,e)}))){if(r||this.useForRaycastProperty){let c;if(this.sceneInterects===null?c=zf(n,s,l,this.useForRaycastProperty):(c=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&c.length&&(this.eventContext.sharedAssets.raycastProperty={x:c[0].point.x,y:c[0].point.y,z:c[0].point.z,objX:c[0].object.matrixWorld.elements[12],objY:c[0].object.matrixWorld.elements[13],objZ:c[0].object.matrixWorld.elements[14]}),r){let u=[c[0]?.uv?.x??0,c[0]?.uv?.y??0];mg(c).forEach(h=>{h instanceof Cr&&io(h,u,Object.keys(this.eventsPerObjects[e]),d=>{this.handleObjectMouseEventDispatch(d,e)}),this.eventsPerObjects[e][h.uuid]&&this.handleObjectMouseEventDispatch(h,e)})}}r||l.forEach(c=>{let u=kf(n,c);u&&(this.handleObjectMouseEventDispatch(c,e),c instanceof Cr&&io(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects[e]),h=>{this.handleObjectMouseEventDispatch(h,e)}))})}}handleMousePressEvent(e=!1){let r="MousePress",n=this.objectsPerTypes[r],s=n.filter(a=>!(a instanceof nr)),o=[];if(!!n.length){if(!e){let{stopRaycast:a,raycaster:l,page:c,pointerScreen:u}=this.eventContext,h=!1;if(c.uiCanvas&&(h=io(c,[u.x,u.y],Object.keys(this.eventsPerObjects[r]),d=>{o.push(d)})),a&&!h){let d=zf(l,c,s);o=mg(d),d.forEach(f=>{f.object instanceof Cr&&io(f.object,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)})})}else s.forEach(d=>{let f=kf(l,d);f&&(o.push(d),d instanceof Cr&&io(d,[f?.uv?.x??0,f?.uv?.y??0],Object.keys(this.eventsPerObjects[r]),p=>{o.push(p)}))})}this._prevObjects.length&&this._prevObjects.forEach(a=>{o.includes(a)||this.handleObjectMouseEventDispatchRelease(a,r)}),o.length&&o.forEach(a=>{this.handleObjectMouseEventDispatch(a,r)}),this._prevObjects=o}}handleObjectMouseEventDispatch(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatch()})}handleObjectMouseEventDispatchRelease(e,r){e.dispatchEvent({type:"beginEvent",eventName:r}),this.eventsPerObjects[r]?.[e.uuid]?.forEach(n=>{n.dispatchRelease()})}handleKeyEvent(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{let o=this.eventsPerObjects[r][s.uuid];o.some(({data:a})=>"key"in a&&a.key===e.key)&&s.dispatchEvent({type:"beginEvent",eventName:r}),o.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(n?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,r,n=!1){this.objectsPerTypes[r].forEach(s=>{this.eventsPerObjects[r][s.uuid].forEach(a=>{"key"in a.data&&a.data.key===e.key&&a.dispatchHeld(n)})})}};var iJ=new T,nJ=new T;var _b=class{constructor(t,e,r,n,s){this.actionsIn=_r(t,t.inActions,r,n,s,e),this.actionsOut=_r(t,t.outActions,r,n,s,e)}disconnect(){pr(this.actionsIn),pr(this.actionsOut)}};var DT=class extends _b{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrixWorld=()=>{for(let s of this.objects)if(!s.visible)return;let e=iJ.setFromMatrixPosition(this.objects[0].matrixWorld),r=nJ.setFromMatrixPosition(this.objects[1].matrixWorld),n=e.distanceTo(r)<=this.distance?"in":"out";if(this.stage!==n){this.stage=n;let s=n==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Particles.forEach(o=>o.dispatchConditional()),s.Video.forEach(o=>o.dispatchConditional()),s.Link.forEach(o=>o.dispatch()),s.Create.forEach(o=>o.dispatch()),s.Destroy.forEach(o=>o.dispatch()),s.Reset.forEach(o=>o.dispatch()),s.Transition.forEach(o=>{o.object.currentTransitionEvent!==this&&(o.object.currentTransitionEvent=this),o.init()}),s.Transition.forEach(o=>o.play()),s.Animation.forEach(o=>o.play()),s.SwitchCamera.forEach(o=>o.play()),s.SceneTransition.forEach(o=>o.dispatch()),s.SetVariable.forEach(o=>o.checkConditions()),s.SetVariable.forEach(o=>o.dispatch()),s.DynamicVariablePlay.forEach(o=>o.dispatch())}};let{distance:l,fromObject:c,toObject:u}=r.condition;this.distance=l;for(let h of[c,u]){if(!h)throw new Error("Missing property");let d=s.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}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)})}},OT=class extends _b{constructor(e,r,n,s,o,a){super(r,n,s,o,a);this.id=e;this.data=r;this.object=n;this.onBegin=({target:e,state:r})=>{this.toState!==r&&(this.actionsOut.Audio.forEach(n=>n.dispatchConditional()),this.actionsOut.Particles.forEach(n=>n.dispatchConditional()),this.actionsOut.Video.forEach(n=>n.dispatchConditional()),this.actionsOut.Link.forEach(n=>n.dispatch()),this.actionsOut.Create.forEach(n=>n.dispatch()),this.actionsOut.Destroy.forEach(n=>n.dispatch()),this.actionsOut.Reset.forEach(n=>n.dispatch()),this.actionsIn.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(n=>n.play()),this.actionsOut.Animation.forEach(n=>n.play()),this.actionsIn.SwitchCamera.forEach(n=>n.pause()),this.actionsOut.SwitchCamera.forEach(n=>n.play()),this.actionsOut.SceneTransition.forEach(n=>n.dispatch()),this.actionsOut.SetVariable.forEach(n=>n.checkConditions()),this.actionsOut.SetVariable.forEach(n=>n.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(n=>n.dispatch()))};this.onComplete=({target:e,state:r})=>{this.toState===r&&(this.actionsIn.Audio.forEach(n=>n.dispatchConditional()),this.actionsIn.Particles.forEach(n=>n.dispatchConditional()),this.actionsIn.Video.forEach(n=>n.dispatchConditional()),this.actionsIn.Link.forEach(n=>n.dispatch()),this.actionsIn.Create.forEach(n=>n.dispatch()),this.actionsIn.Destroy.forEach(n=>n.dispatch()),this.actionsIn.Reset.forEach(n=>n.dispatch()),this.actionsOut.Transition.forEach(n=>n.pause()),this.actionsOut.Transition.forEach(n=>n.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(n=>n.play()),this.actionsIn.Animation.forEach(n=>n.play()),this.actionsOut.SwitchCamera.forEach(n=>n.pause()),this.actionsIn.SwitchCamera.forEach(n=>n.play()),this.actionsIn.SceneTransition.forEach(n=>n.dispatch()),this.actionsIn.SetVariable.forEach(n=>n.checkConditions()),this.actionsIn.SetVariable.forEach(n=>n.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(n=>n.dispatch()))};let{condition:l}=r;if(!l.object)throw new Error("Missing property");let c=s.find(l.object)??s.scene.find2D(l.object);if(!c)throw new Error("Missing property");if(this.toObject=c,l.state&&!this.toObject.states?.[l.state])throw new Error("Missing property");this.toState=l.state}connect(){cs(this.actionsOut).forEach(e=>{this.actionsOut[e]?.length&&this.toObject.addEventListener("beginState",this.onBegin)}),cs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.addEventListener("completeState",this.onComplete)})}disconnect(){super.disconnect(),cs(this.actionsOut).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("beginState",this.onBegin)}),cs(this.actionsIn).forEach(e=>{this.actionsIn[e]?.length&&this.toObject.removeEventListener("completeState",this.onComplete)})}},Pb=class extends kr{constructor(e,r){super(e);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};this.hasVideoAction=!1;let{page:n,sharedAssets:s}=this.eventContext;n.traverseEntity(o=>{if(!!o.data?.events.length){for(let{id:a,data:l}of o.data.events)if(!l.disabled&&l.type==="Conditional")try{let c;l.condition.type==="Comparison"||(l.condition.type==="Distance"?c=new DT(a,l,o,n,s,r):l.condition.type==="State"&&(c=new OT(a,l,o,n,s,r))),c&&(this.eventsPerConditions[l.condition.type].push(c),(c.actionsIn.Video.length||c.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch(c){!1&&console.log(c)}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(r=>r.disconnect()))}};var gg=new T,ec=new T,nu=new T,A3=new ii,sJ=.01,sr=new T,Ii=new T,E3=new T,su=new Qe,IT=new Ht,oJ=new ue,RT=new ut,Gf=new T,Ho=new T,Hf=.2;function LT(i,t){!t||(t[0]<t[1]&&(i.x=Math.min(Math.max(i.x,t[0]),t[1])),t[2]<t[3]&&(i.y=Math.min(Math.max(i.y,t[2]),t[3])),t[4]<t[5]&&(i.z=Math.min(Math.max(i.z,t[4]),t[5])))}var aJ=function(){let i=new ue;return(t,e,r)=>{let n=t.obj;i.copy(n.hiddenMatrix),n.parent!==null&&i.premultiply(n.parent.matrixWorld),i.invert(),n.position.copy(e),t.reference==="global"&&LT(n.position,t.limits),n.position.applyMatrix4(i),t.reference==="parent"?LT(n.position,t.limits):t.reference==="local"&&(su.copy(t.quat0).invert(),n.position.sub(t.position0),n.position.applyQuaternion(su),LT(n.position,t.limits),su.invert(),n.position.applyQuaternion(su),n.position.add(t.position0)),i.multiply(r??n.matrixWorld).decompose(sr,n.quaternion,Ii),n.updateMatrix(),n.hasNonUniformScale&&(n.updateMatrixWorld(),n.updateMatrixWorldSVD()),n instanceof yr&&Mn(n.parent)&&n.invalidateDownstreamBooleanData(!0)}}(),NT=class{constructor(t,e,r,n,s,o){this.object=t;this.data=e;this.dropDestIds=[];this.activeIdx=null;this.wasDragEventTriggered=!1;this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=_r(e,e.dragDropActions.drag,r,n,s,this.object),this.actionsDrop=_r(e,e.dragDropActions.drop,r,n,s,this.object);let a=[];this.data.objects.forEach(l=>{let c=r.find(l);!c||c.data.visible!==!1&&(a.push(c),o[c.uuid]&&o[c.uuid].forEach(u=>{let h=r.find(u);!h||h.data.visible!==!1&&a.push(h)}))}),this.data.dropDestinations.forEach(l=>{let c=r.find(l);!c||c.data.visible!==!1&&(this.dropDestIds.push(c.uuid),o[c.uuid]&&o[c.uuid].forEach(u=>{let h=r.find(u);!h||h.data.visible!==!1&&this.dropDestIds.push(h.uuid)}))}),this.dragItems=a.map(l=>(this.data.planeMode==="locked"&&(l.userData.lockedPlane=!0),l.userData.worldPosition0=new T().setFromMatrixPosition(l.matrixWorld),{obj:l,fromPosition:new T().setFromMatrixPosition(l.matrixWorld),pointStart:new T,pointEnd:new T,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new T().copy(l.position),quat0:new Qe().copy(l.quaternion),snapped:!1,orientationMatrix:new ue,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){pr(this.actionsDrag),pr(this.actionsDrop),this.dragItems.forEach(t=>{t.fromPosition.copy(t.obj.userData.worldPosition0),t.pointStart.copy(t.fromPosition),t.pointEnd.copy(t.pointStart),t.obj.recursiveBBoxNeedsUpdate=!0,t.obj.userData.lockedPlane=void 0,t.obj.position.copy(t.position0),t.obj.quaternion.copy(t.quat0),t.obj.updateMatrix()})}},Db=class extends kr{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.lastDropDestination=null;this.dragTimeout=null;this.onPointerDown=e=>{if(nt.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(this.lastDropDestination=null,s.length===0){this.activeEvent=null;return}for(let o of this.events){let a=0;for(let{obj:l,pointEnd:c,pointStart:u}of o.dragItems){if(l===s[0].object||l===s[0].object.object||At.is(l)&&l.isAncestorOf(s[0].object.uuid)){if(o.activeIdx=a,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let h=o.activeDragItem.obj;l.hasNonUniformScale&&l.updateMatrixWorldSVD(),(h.hasNonUniformScale?h.matrixWorldRigid:h.matrixWorld).decompose(sr,su,Ii),IT.setFromQuaternion(su),h.prevR===void 0?(h.prevR=IT.clone(),h.prevT=sr.clone()):(h.prevR.copy(IT),h.prevT.copy(sr)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(l,u,o.data.plane,o.data.referenceFrame),c.copy(u),(this.eventManager.controlsManager.usePhysics&&l.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}a++}}this.activeEvent=null};this.onPointerMove=e=>{if(nt.length>1)return;this.eventContext.updateRaycaster(e);let{raycaster:r,page:n}=this.eventContext,s=n.raycastWithClones(r);if(nt.length===0){let o=!1;for(let a of this.events){for(let{obj:l}of a.dragItems)if(l===s[0]?.object||l===s[0]?.object?.object||At.is(l)&&l.isAncestorOf(s[0]?.object.uuid)){switch(o=!0,a.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let a;if(this.activeEvent.data.drop&&(a=s.filter(l=>o.obj!==l.object&&!o.obj.isAncestorOf(l.object.uuid)&&!(l.object instanceof As)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(c=>c===l.object.uuid||n.scene.find(c).isAncestorOf(l.object.uuid))))[0]),a){let l=E3.copy(a.face.normal).applyMatrix3(RT.getNormalMatrix(a.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(a.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(a.point),this.activeEvent.data.snapSurfaceMode==="bbox"){sr.copy(l).applyMatrix3(RT.setFromMatrix4(o.obj.matrixWorld).transpose());let c=o.obj;sr.x>Hf?Ii.x=-c.recursiveBBox.min.x:sr.x<-Hf&&(Ii.x=-c.recursiveBBox.max.x),sr.y>Hf?Ii.y=-c.recursiveBBox.min.y:sr.y<-Hf&&(Ii.y=-c.recursiveBBox.max.y),sr.z>Hf?Ii.z=-c.recursiveBBox.min.z:sr.z<-Hf&&(Ii.z=-c.recursiveBBox.max.z),Ii.applyMatrix3(RT.invert())}else Ii.copy(l).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(Ii)}this.activeEvent.data.autoOrient&&(sr.set(0,1,0).cross(l),sr.length()<1e-4&&sr.set(-1,0,0).cross(l),Ii.crossVectors(E3,sr),o.orientationMatrix.makeBasis(sr,Ii,l)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==a.object&&(this.lastDropDestination=a.object,this.activeEvent.actionsDrop.Transition.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Animation.forEach(c=>{c.play()}),this.activeEvent.actionsDrop.Audio.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Particles.forEach(c=>{c.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(c=>{c.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(l=>{l.stop()}),this.activeEvent.actionsDrop.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.Particles.forEach(l=>{l.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(l=>{l.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(l=>l.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(l=>l.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.play()}),this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("start")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(l=>{l.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(l=>{l.stop(),l.object.currentState!==null&&l.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(l=>{l.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}};this.onPointerUp=e=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let r=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!r)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&r&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Particles.forEach(n=>{n.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(n=>n.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(n=>n.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let n={};e.page.traverseEntity(s=>{s.component&&(n[s.component.uuid]?n[s.component.uuid].push(s.uuid):n[s.component.uuid]=[s.uuid])}),e.page.traverseEntity(s=>{s.data?.events.filter(o=>o.data.type==="DragDrop"&&!o.data.disabled).forEach(o=>{this.events.push(new NT(s,o.data,e.page,e.sharedAssets,r,n))})})}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(r=>r.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let r of e.dragItems)r.paused||this.updateDragItem(r,!0)}calcPlaneIntersectPos(e,r,n,s){let{getCamera:o,raycaster:a}=this.eventContext;o().getWorldDirection(ec),ec.negate();let l=su.identity();switch(s==="parent"?oJ.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(sr,l,Ii):s==="local"&&e.matrixWorld.decompose(sr,l,Ii),n){case"x":sr.set(1,0,0).applyQuaternion(l),Gf.copy(ec).cross(sr),Ho.copy(sr).cross(Gf);break;case"y":sr.set(0,1,0).applyQuaternion(l),Gf.copy(ec).cross(sr),Ho.copy(sr).cross(Gf);break;case"z":sr.set(0,0,1).applyQuaternion(l),Gf.copy(ec).cross(sr),Ho.copy(sr).cross(Gf);break;case"xy":Ho.set(0,0,1).applyQuaternion(l);break;case"yz":Ho.set(1,0,0).applyQuaternion(l);break;case"xz":Ho.set(0,1,0).applyQuaternion(l);break;case"adaptive":ec.angleTo(Ii.set(0,1,0))>Math.PI/6?(sr.crossVectors(Ii.set(0,1,0),ec),Ho.crossVectors(sr,Ii)):Ho.set(0,1,0);break;default:Ho.copy(ec);break}nu.setFromMatrixPosition(e.matrixWorld);let c=e.userData.lockedPlane?e.userData.worldPosition0:nu;if(A3.setFromNormalAndCoplanarPoint(Ho,c),!!a.ray.intersectPlane(A3,r)&&(n==="x"||n==="y"||n==="z")){let u=Ii.subVectors(r,c).dot(sr);r.copy(c).addScaledVector(sr,u)}}updateDragItem(e,r=!1){nu.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?gg.subVectors(e.fromPosition,nu).divideScalar(e.currentDampingFactor):e.reset==="original"?(gg.subVectors(e.obj.userData.worldPosition0,nu).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):gg.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(nu).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?gg.length()<sJ:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||r)&&aJ(e,gg.add(nu),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}};var jf=new T,BT=new T,Va=new T,za=new T,T3=new ii,lJ=.01,cJ={type:"requestRender"},uJ=function(){let i=new T,t=new T;return(e,r,n)=>n>0?(i.subVectors(e,r),i.length()<=n?e:t.copy(r).add(i.normalize().multiplyScalar(n))):r}(),M3=function(){let i=new ue;return(t,e)=>{t.position.copy(e),t.parent!==null&&(i.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(i)),i.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(i),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof yr&&Mn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),FT=class{constructor(t,e,r,n,s){this.data=t;this.object=e;this.paused=!1;this.currentDampingFactor=1;this.snapComplete=!1;this.isReset=!1;this.worldPosition0=new T;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Gv.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=_r(t,t.actions,r,n,s,e)}},Ob=class extends kr{constructor(e,r){super(e);this.events=[];this.pairOfEventListeners=[];this.onMouseMove=e=>{if(!(nt.length>1)){this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))};this.onTargetChange=e=>()=>{this.updateSingleEvent(e)};let{page:n}=this.eventContext;n.traverseEntity(s=>{let o=s.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);o&&(!n.data.globalPhysics.usePhysics||s.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new FT(o.data,s,n,e.sharedAssets,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events)if(n.target!==void 0){let s=n.target,o=this.onTargetChange(n);this.pairOfEventListeners.push([s,o]),s.addEventListener("requestRender",o)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let n of this.events)n.paused=!0,n.isReset=!1,pr(n.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,r=!1){this.events.forEach(l=>{l.actions.Create.forEach(c=>{c.dispatchThrottled()})});let{plane:n,limitDistance:s,limitDistanceEnabled:o}=e.data;if(e.object.getWorldPosition(Va),e.isReset)za.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(za);else{let{getCamera:l,raycaster:c}=this.eventContext;if(n==="custom"?(l().getWorldDirection(BT),BT.negate(),jf.copy(BT)):n==="xy"?jf.set(0,0,1):n==="xz"?jf.set(0,1,0):n==="yz"&&jf.set(1,0,0),T3.setFromNormalAndCoplanarPoint(jf,Va),!c.ray.intersectPlane(T3,za))return}if(!e.isReset){if(za.distanceTo(e.worldPosition0)>s&&o&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)za.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&&(za.x=Va.x),e.data.enabledTranslation[1]===!1&&(za.y=Va.y),e.data.enabledTranslation[2]===!1&&(za.z=Va.z);let a=uJ(Va,za,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let l=jf.subVectors(a,Va).divideScalar(e.currentDampingFactor);Va.add(l),r&&M3(e.object,Va),e.paused=l.length()<lJ}else M3(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(cJ)}};var yg=new T,Ib=new T,vg=new ue,Wf=new Qe,tc=new Qe,xg=new T,bg=new T,ou=new T,ka=new T,UT=new ii,hJ=1e-6,dJ={type:"requestRender"},fJ={type:"changeRotation"},C3=function(){let i=new ue;return function(e,r){e.parent!==null?i.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix):i.copy(e.hiddenMatrix),r.premultiply(CT(i).invert()),e.rotation.setFromRotationMatrix(r),e.updateMatrix(),e instanceof yr&&Mn(e.parent)&&e.invalidateDownstreamBooleanData(!0)}}(),VT=class{constructor(t,e,r){this.object=e;this.paused=!1;this.currentDampingFactor=1;this.isReset=!1;this.worldQuaternion0=new Qe;this.timeoutId=null;this.delayFinished=!0;this.wasOutside=!1;this.data={...Hv.defaultData,...t,...t.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},t.target===void 0||t.target==="cursor"||(this.target=r.find(t.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},Rb=class extends kr{constructor(e){super(e);this.events=[];this.pairOfEventListeners=[];this.pairOfUserEventListeners=[];this.onMouseMove=e=>{if(!(nt.length>1)){this._lastMouseEvent=e,this.eventContext.updateRaycaster(e);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}};this.onMouseEnter=e=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)};this.onMouseLeave=e=>{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=e=>{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=e=>()=>{this.updateSingleEvent(e)};this.createUserEventListener=e=>({eventName:r,target:n})=>{if(!r||!n)return;let s=Go(r);s&&s==="LookAt"&&this.updateSingleEvent(e)};let{page:r}=this.eventContext;r.traverseEntity(n=>{let s=n.data?.events.find(o=>o.data.type==="LookAt"&&!o.data.disabled);s&&(!r.data.globalPhysics.usePhysics||n.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new VT(s.data,n,r))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),r.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?r.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let n of this.events){if(n.target!==void 0){let a=this.onTargetChange(n),l=n.target;this.pairOfEventListeners.push([l,a]),l.addEventListener("requestRender",a)}let s=this.createUserEventListener(n),o=n.object;this.pairOfUserEventListeners.push([o,s]),o.addEventListener("userEvent",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:r}=this.eventContext;this.domEventsNeeded.clear(),Mi&&e.removeEventListener("pointerdown",this.onMouseMove),r.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),r.removeEventListener("scroll",this.onScroll);for(let[n,s]of this.pairOfEventListeners)n.removeEventListener("requestRender",s);for(let[n,s]of this.pairOfUserEventListeners)n.removeEventListener("userEvent",s);for(let n of this.events)n.paused=!0,n.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:r,axis:n,distance:s,plane:o,limitDistance:a,enabledRotation:l,limitDistanceEnabled:c}=e.data,{getCamera:u,raycaster:h}=this.eventContext,{object:d,target:f}=e;if(d.getWorldPosition(xg),!e.isReset)if(e.target)e.target.getWorldPosition(bg);else{if(o==="custom"?(u().getWorldDirection(Ib),Ib.negate(),UT.setFromNormalAndCoplanarPoint(Ib,xg)):(o==="xy"?yg.set(0,0,1):o==="xz"?yg.set(0,1,0):o==="yz"&&yg.set(1,0,0),UT.setFromNormalAndCoplanarPoint(yg,xg)),!h.ray.intersectPlane(UT,bg))return;s>0&&(o==="custom"||o===void 0)&&bg.addScaledVector(Ib,s)}if(e.isReset||(f?r==="target"?ou.copy(f.up).applyMatrix4(vg.extractRotation(f.matrixWorld)).normalize():l.some(p=>p===!1)?(n==="x"?(ka.set(0,0,1),l[2]===!1&&ka.set(0,1,0)):n==="y"?(ka.set(1,0,0),l[0]===!1&&ka.set(0,0,1)):(ka.set(0,1,0),l[1]===!1&&ka.set(1,0,0)),ou.copy(ka).applyQuaternion(e.worldQuaternion0).normalize()):ou.set(0,1,0):o==="custom"?ou.set(0,1,0):ou.copy(yg)),e.isReset)tc.copy(e.worldQuaternion0);else if(xg.distanceTo(bg)>a&&c&&f)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)tc.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;pJ(vg,bg,xg,ou,n,ka),tc.setFromRotationMatrix(vg),Wf.setFromUnitVectors(ka.applyQuaternion(tc),ou),l.some(p=>p===!1)&&r!=="target"&&tc.premultiply(Wf).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),Wf.setFromRotationMatrix(CT(d.matrixWorld)),Wf.slerp(tc,1/e.currentDampingFactor),C3(d,vg.makeRotationFromQuaternion(Wf)),e.paused=8*(1-Wf.dot(tc))<hJ):(C3(d,vg.makeRotationFromQuaternion(tc)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(dJ),d.dispatchEvent(fJ)}},Cs=new T,Ri=new T,fi=new T;function pJ(i,t,e,r,n,s){let o=i.elements;fi.subVectors(t,e),fi.lengthSq()===0&&(fi.z=1),fi.normalize(),Ri.crossVectors(r,fi),Ri.lengthSq()===0&&(Math.abs(r.z)===1?fi.x+=1e-4:fi.z+=1e-4,fi.normalize(),Ri.crossVectors(r,fi)),Ri.normalize(),Cs.crossVectors(fi,Ri),n==="x"?s.z===1?[Ri,Cs,fi]=[fi,Ri,Cs]:(Ri.negate(),[Ri,fi]=[fi,Ri]):n==="y"?s.x===1?[Ri,Cs,fi]=[Cs,fi,Ri]:(Ri.negate(),[Cs,fi]=[fi,Cs]):s.x===1&&(Ri.negate(),[Ri,Cs]=[Cs,Ri]),o[0]=Ri.x,o[4]=Cs.x,o[8]=fi.x,o[1]=Ri.y,o[5]=Cs.y,o[9]=fi.y,o[2]=Ri.z,o[6]=Cs.z,o[10]=fi.z}var zT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.entered=!1;this.actions=_r(e,e.actions,n,s,o,r)}disconnect(){pr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.play()),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()))}dispatchLeave(){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Particles.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent()))}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Particles.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),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())}},Lb=class extends kr{constructor(e,r){super(e);this.eventsPerObjects={};this.objects=[];this.objects2D=[];this._prevObjects=[];this.onMouseDown=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onMouseUp=e=>{nt.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=e=>{nt.length>1||(this.eventContext.updateRaycaster(e),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&s==="MouseHover"&&(r.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[r.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{page:n,sharedAssets:s}=this.eventContext,o=(a,l)=>{if(!(!a.visible||!a.data?.events.length)){for(let{id:c,data:u}of a.data.events)if(!u.disabled&&u.type==="MouseHover")try{let h=new zT(c,u,a,n,s,r);this.eventsPerObjects[a.uuid]?this.eventsPerObjects[a.uuid].push(h):this.eventsPerObjects[a.uuid]=[h]}catch(h){!1&&console.log(h)}this.eventsPerObjects[a.uuid]?.length&&this.objects.push(a instanceof nr?l:a)}};n.traverseEntity(a=>{(a instanceof Cr||a instanceof fr)&&a.frame?.traverse(l=>{o(l,a)}),o(a)})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(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(r=>{r.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Mi&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(r=>{r.forEach(n=>{n.disconnect()})}),this.objects.forEach(r=>{r.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let r=[];if(!e){let{stopRaycast:n,raycaster:s,page:o,pointerScreen:a}=this.eventContext,l=!1;if(o.uiCanvas&&(l=io(o,[a.x,a.y],Object.keys(this.eventsPerObjects),c=>{r.push(c)})),n&&!l){let c=zf(s,o,this.objects);r=mg(c),c.forEach(u=>{u.object instanceof Cr&&io(u.object,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)})})}else this.objects.forEach(c=>{let u=kf(s,c);u&&(r.push(c),c instanceof Cr&&io(c,[u?.uv?.x??0,u?.uv?.y??0],Object.keys(this.eventsPerObjects),h=>{r.push(h)}))})}this._prevObjects.length&&this._prevObjects.forEach(n=>{r.includes(n)||(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchLeave()))}),r.length&&r.forEach(n=>{n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=r}};var kT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.scrollCounter=0;this.actions=_r(e,e.actions,n,s,o,r)}connect(){this.scrollCounter=0}disconnect(){pr(this.actions)}dispatch(t){this.actions.Transition.forEach(n=>{n.object.currentTransitionEvent!==this&&(n.object.currentTransitionEvent=this,n.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let r=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(n=>n.seek(r)),this.actions.Animation.forEach(n=>n.seek(e)),this.actions.Create.forEach(n=>n.dispatchThrottled()),this.actions.SetVariable.forEach(n=>n.checkConditions()),this.actions.SetVariable.forEach(n=>n.dispatch()),this.actions.DynamicVariablePlay.forEach(n=>n.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},GT=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.object=r;this.domElement=o;this.eventManager=a;this.scrollStart=0;this.scrollEnd=0;this.actions=_r(e,e.actions,n,s,a,r)}computeScrollBounds(){let t=this.domElement.getBoundingClientRect(),e=document.body,r=document.documentElement,n=window.pageYOffset||r.scrollTop||e.scrollTop,s=r.clientTop||e.clientTop||0,o=Math.round(t.top+n-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,l=t.height,c=this.data.enterAnchor,u=c==="top"?a:c==="bottom"?a-l:a-l*.5;this.scrollStart=o-u}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=t,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){pr(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:t,y:e}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let r=this.scrollEnd-this.scrollStart,n=Math.min(1,Math.max(0,(e-this.scrollStart)/r));this.actions.Transition.forEach(s=>s.seek(n)),this.actions.Animation.forEach(s=>s.seek(n)),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(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>{e.playFromCurrent()}),this.actions.Animation.forEach(e=>{e.playFromCurrent()})),this.actions.Create.forEach(e=>e.dispatchThrottled()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}},Nb=class extends kr{constructor(e,r){super(e);this.wheelEventsPerObject=new Map;this.scrollEventsPerObject=new Map;this.isInview=!0;this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.handleResize())})};this.onScroll=e=>{if(!this.isInview)return;let r={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([n,s])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:r}),s.forEach(o=>o.dispatch(r))})};this.onWheel=e=>{!this.isInview||e.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([r,n])=>{r.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:e.deltaY}),n.forEach(s=>s.dispatch(e.deltaY))})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&s==="Scroll"&&(r.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{page:n,sharedAssets:s,domElement:o,isExport:a}=this.eventContext,l=c=>{if(!!c.data?.events.length){for(let{id:u,data:h}of c.data.events)if(!h.disabled&&h.type==="Scroll")if(h.trigger==="load"||!a){let d=new kT(u,h,c,n,s,r);this.wheelEventsPerObject.has(c)?this.wheelEventsPerObject.get(c)?.push(d):this.wheelEventsPerObject.set(c,[d])}else{let d=new GT(u,h,c,n,s,o,r);this.scrollEventsPerObject.has(c)?this.scrollEventsPerObject.get(c)?.push(d):this.scrollEventsPerObject.set(c,[d])}}};n.traverseEntity(c=>{(c instanceof Cr||c instanceof fr)&&c.frame?.traverse(u=>{l(u)}),l(c)}),this.intersectionObserver=new IntersectionObserver(c=>{let u=c[0];u&&(this.isInview=u.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.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,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,r])=>{r.forEach(n=>n.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}};var HT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=_r(e,e.actions,n,s,o,r)}disconnect(){pr(this.actions)}dispatch(){this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()}),this.actions.SwitchCamera.forEach(t=>{t.play()}),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.dispatchFromStart()}),this.actions.Destroy.forEach(t=>{t.dispatchFromStart()})}dispatchAfter(t){this.actions.Audio.forEach(e=>{(e.interaction.data.triggerAfter??"any")===t&&(e.interaction instanceof Fo?e.interaction.audioPlayer.play():e.interaction instanceof Bf&&e.interaction.dispatch())}),this.actions.Video.forEach(e=>{let r=e.interaction.data.triggerAfter??"autoplay";r===t&&(e.interaction instanceof Fa?e.interaction.play(r==="autoplay"):e.interaction instanceof Vf&&e.interaction.dispatch())}),this.actions.Particles.forEach(e=>{(e.data.triggerAfter??"any")===t&&e.dispatchBasic()})}dispatchUserEvent(t){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),t?(this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent())):(this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.playFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent())),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.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.interaction instanceof Fo?e.interaction.audioPlayer.play():e.interaction instanceof Bf&&e.interaction.dispatch()}),this.actions.Video.forEach(e=>{e.interaction instanceof Fa?e.interaction.play():e.interaction instanceof Vf&&e.interaction.dispatch()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()})}},Bb=class extends kr{constructor(e,r){super(e);this.eventManager=r;this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.actions.Audio.forEach(s=>{s.interaction instanceof Fo&&s.interaction.audioPlayer.play()}),n.actions.Video.forEach(s=>{let o=s.interaction.data.triggerAfter??"autoplay";s.interaction instanceof Fa&&s.interaction.play(o==="autoplay")}),n.actions.Particles.forEach(s=>{s.dispatchBasic()})})})};this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([e,r])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(n=>{n.dispatchAfter("autoplay")})})};this.onUserEvent=({eventName:e,target:r,reverse:n})=>{if(!e||!r)return;let s=Go(e);s&&s==="Start"&&(r instanceof nr||r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(r)?.forEach(o=>{o.dispatchUserEvent(n)}))}}connect(){let{sharedAssets:e,page:r}=this.eventContext,n=s=>{if(!!s.data?.events.length)for(let{id:o,data:a}of s.data.events){if(a.disabled||a.type!=="Start")continue;let l=new HT(o,a,s,r,e,this.eventManager);(l.actions.Transition.length||l.actions.Animation.length||l.actions.SwitchCamera.length||l.actions.Create.length||l.actions.Destroy.length||l.actions.SceneTransition.length||l.actions.Reset.length||l.actions.SetVariable.length||l.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(l):this.eventsPerObject.set(s,[l])),l.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l])),l.actions.Particles.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(l):this.eventsAfterPerObject.set(s,[l]))}};if(r.traverseEntity(s=>{(s instanceof Cr||s instanceof fr)&&s.frame?.traverse(o=>{n(o)}),n(s)}),[...this.eventsAfterPerObject.values()].some(s=>s.length)){if(this.eventManager.activateCount===0){let{domElement:s,isExport:o}=this.eventContext,a=o?document:s;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(([l,c])=>{l.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>a.dispatch()),s.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:r}=this.eventContext,n=r?document:e;n.removeEventListener("pointerdown",this.onMouseDown),n.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),n.removeEventListener("pointerdown",this.onAny),n.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,r])=>{e.removeEventListener("userEvent",this.onUserEvent),r.forEach(n=>n.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}};var Fb=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.disabled=!1;this.alreadyPlayedNonTogglingActions=new Set;this.actions=_r(e,e.actions,n,s,o,r),this.target=e.target,this.useToggle=e.runMode==="Toggle"}disconnect(){pr(this.actions)}dispatch(t){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this?(e.object.currentTransitionEvent=this,e.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(e)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(e=>{e.toggle()}),this.actions.Animation.forEach(e=>{e.toggle()})):(this.actions.Transition.forEach(e=>{this.alreadyPlayedNonTogglingActions.has(e)===!1&&e.play()}),this.actions.Animation.forEach(e=>{e.play()})),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Reset.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Particles.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}};var Ub=class extends kr{constructor(e,r,n,s,o){super(e);this.sharedVariables=r;this.eventManager=n;this.needsMouse=s;this.needsRaycast=o;this.dynamicVars=[];this.variablesToWatch=[];this.prevMouseProperty=null;this.prevRaycastProperty=null;this.pauseTime=0;this.events=[];this.onFrame=e=>{this.rafId=window.requestAnimationFrame(this.onFrame);let r=new Date,n=[],s=[];for(let l=0;l<this.propertiesToWatch.length;l++){let{objectId:c,property:u,prevValue:h}=this.propertiesToWatch[l],d=this.eventContext.scene.find(c),f=Wv.propertyPaths[u];if(f[0]==="width"||f[0]==="height"||f[0]==="depth")d=d.geometry.userData.parameters[f[0]];else for(let p=0;p<f.length;p++)d=d[f[p]];h===null?this.propertiesToWatch[l].prevValue=d instanceof T?d.clone():d:(d instanceof T?!d.equals(h):h!==d)&&(s.push({objId:c,property:u}),d instanceof T?this.propertiesToWatch[l].prevValue.copy(d):this.propertiesToWatch[l].prevValue=d)}for(let l=0;l<this.variablesToWatch.length;l++){let{id:c,prevValue:u}=this.variablesToWatch[l],h=this.shared.getVariable(c);h!==u&&(n.push(c),this.variablesToWatch[l].prevValue=h)}for(let l=0;l<this.dynamicVars.length;l++){let{id:c,expectedTime:u,last:h,data:d,timerSeconds:f,startValue:p}=this.dynamicVars[l],g=1e3;if((d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&d.format==="number3decimal"?g=1:d.dynamicVariableType==="counter"?g=d.updateInterval:d.dynamicVariableType==="random"&&(g=d.isStatic?1/0:d.updateInterval),u===-1){this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+g;continue}if(!((this.shared.getDynamicVariablePlayState(c)==="Stopped"||this.shared.getDynamicVariablePlayState(c)==="Restarted")&&(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime=e+g,d.dynamicVariableType==="counter"&&this.shared.getVariable(c)!==p&&(this.shared.updateVariable(c,p),this.eventManager.requestRender()),(d.dynamicVariableType==="timer"||d.dynamicVariableType==="stopwatch")&&this.dynamicVars[l].timerSeconds!==p&&(this.dynamicVars[l].timerSeconds=p,this.shared.updateVariable(c,bn.getFormattedTimerTime(p,d)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(c)==="Restarted"&&this.shared.setDynamicVariablePlayState(c,"Playing"),this.shared.getDynamicVariablePlayState(c)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(c)==="Paused"){this.dynamicVars[l].deltaToExpectedTime===void 0&&(this.dynamicVars[l].deltaToExpectedTime=Math.max(this.dynamicVars[l].expectedTime-e,0)),this.dynamicVars[l].last=e-(g-this.dynamicVars[l].deltaToExpectedTime),this.dynamicVars[l].expectedTime=e+this.dynamicVars[l].deltaToExpectedTime;continue}else this.dynamicVars[l].deltaToExpectedTime=void 0;if(e>=u)if(this.dynamicVars[l].last=e,this.dynamicVars[l].expectedTime+=g,d.dynamicVariableType==="random"){let y=d.min+Math.random()*(d.max-d.min),m=d.decimals;y=Math.round(y*Math.pow(10,m))/Math.pow(10,m),this.shared.updateVariable(c,y),n.push(c),this.eventManager.requestRender()}else if(d.dynamicVariableType==="counter"){if(d.increment===0)continue;let y=this.shared.getVariable(c),m=this.shared.getDynamicVariableToggleIsForward(c)??!0,v=this.shared.getVariable(c)+d.increment*(m?1:-1);d.hasEnd&&(v=d.increment>0?_e.clamp(v,p,d.endValue):_e.clamp(v,d.endValue,p),v===p&&this.shared.setDynamicVariableToggleIsForward(c,void 0),d.repeat?v===d.endValue&&(v=p):(v===p||v===d.endValue)&&this.shared.setDynamicVariablePlayState(c,"Paused")),v!==y&&(n.push(c),this.shared.updateVariable(c,v),this.eventManager.requestRender())}else if(d.dynamicVariableType==="time")this.shared.updateVariable(c,d1(r,d)),n.push(c),this.eventManager.requestRender();else{let y=ki.isTextValue(d.endValue)?_3(d.endValue.textValue):d.endValue,m=this.shared.getDynamicVariableToggleIsForward(c)??!0,v=f+(e-h)/1e3*(d.dynamicVariableType==="timer"?-1:1)*(m?1:-1);v=Math.max(v,0),d.hasEnd&&(v=d.dynamicVariableType==="stopwatch"?_e.clamp(v,p,y):_e.clamp(v,y,p),v===p&&this.shared.setDynamicVariableToggleIsForward(c,void 0),d.repeat?Math.abs(v-y)<(d.format==="number3decimal"?1e-4:.1)&&(v=p):(Math.abs(v-p)<(d.format==="number3decimal"?1e-4:.1)||Math.abs(v-y)<(d.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(c,"Paused")),v!==f&&(n.push(c),this.dynamicVars[l].timerSeconds=v,this.shared.updateVariable(c,bn.getFormattedTimerTime(v,d)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(l=>{l.data.variableId==="mouseProperty"&&(l.dispatch(),this.eventManager.requestRender())}));let o=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,o=!0);let a=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,a=!0),this.events.forEach(l=>{(n.includes(l.data.variableId)||s.find(c=>c.objId===l.data.objectId&&c.property===l.data.property)||l.data.variableId==="mouseProperty"&&o||l.data.variableId==="raycastProperty"&&a)&&(l.dispatch(),this.eventManager.requestRender())})};this.onBlur=()=>{this.pause()};this.onFocus=()=>{this.resume()};e.page.traverseEntity(a=>{a.data?.events.filter(l=>l.data.type==="VariableChange"&&!l.data.disabled).forEach(l=>{this.events.push(new jT(a.uuid,l.data,a,e.page,e.sharedAssets,n))})}),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:l})=>{if(!("dynamicVariableType"in l)){this.events.find(u=>u.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let c;if(l.dynamicVariableType==="timer"||l.dynamicVariableType==="stopwatch"){let u;if(ki.isTextValue(l.value)&&Array.isArray(l.value.textValue)){let h=l.value.textValue;h.length===3?u=h[2]+h[1]*60+h[0]*3600:u=h[1]+h[0]*60}else u=l.value;c=u,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,timerSeconds:u,startValue:c})}else l.dynamicVariableType==="time"&&this.shared.updateVariable(a,d1(new Date,l)),l.dynamicVariableType==="counter"&&(c=ki.isTextValue(l.value)?_3(l.value.textValue):l.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:l,startValue:c})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let r=0;r<this.dynamicVars.length;r++)this.dynamicVars[r].last+=e,this.dynamicVars[r].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())}},jT=class{constructor(t,e,r,n,s,o){this.id=t;this.data=e;this.object=r;this.actions=_r(e,e.actions,n,s,o,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch())}dispose(){pr(this.actions)}};function _3(i){return i.length===3?i[2]+i[1]*60+i[0]*3600:i[1]+i[0]*60}var D3=!1?typeof window<"u"?window.location.href:"":"https://unpkg.com/@splinetool/runtime@1.0.89/build/",mJ=!1?D3:"https://unpkg.com/@splinetool/navmesh-wasm@1.0.89/build/",gJ=`
8003
8003
  (async function() {
8004
8004
  const [wasmImport, wasmBinary] = await Promise.all([
8005
8005
  import('${D3}' + 'navmesh.js'),
@@ -8065,4 +8065,4 @@ onmessage = function(messageEvent) {
8065
8065
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
8066
8066
  </svg>
8067
8067
  `),P.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),P.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,g];return}let E={zone:g,mode:"static",position:b,size:y};v==="hide"&&(E.restOpacity=0);let A=gB.create(E);A.on("move",(P,M)=>{let C=this.gameControl;f==="pos"?M.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-M.angle.radian),C.movementState.movePosX=Math.cos(-M.angle.radian),M.force>1.2?C.movementState.run=1:C.movementState.run=0,M.force<.3?C.moveForce=(M.force-.2)/.1:C.moveForce=1):f==="rot"&&(M.force<.2?C.rotForce=0:(C.movementState.rotPosX=M.vector.y,C.movementState.rotPosY=-M.vector.x,M.force<.3?C.rotForce=(M.force-.2)/.1:C.rotForce=1)),this.requestRender()}),A.on("end",(P,M)=>{let C=this.gameControl;f==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):f==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[A,g]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(f=>f.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new Wt.World(new Wt.Vector3(0,this.gravity,0)),this.events=new Wt.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(a=>{let l;if(a instanceof Wi)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;l=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof zr)l=a.object;else{if(a instanceof Zl||a instanceof Hl)return;if(l=a,l.dataPatched.cloner?.disabled===!1&&l.dataPatched.cloner?.hideBase&&l.dataPatched.physics?.fusedBody!==!0)return!0}let c=l.dataPatched,u;for(let m of c.events)m.data.disabled!==!0&&m.data.type==="GameControl"&&(u=m.data);if(!c.physics||(c.physics.enabled==="visibility"?!c.visible:!c.physics.enabled))return!0;a.updateMatrixWorldSVD();let h=Sg(c),d=!1,f=l.userData.hasDestroy,p=l.userData.hasDrag,g=!1;for(let m of c.events)if(m.data.disabled!==!0){if(m.data.type==="Collision"){d=!0;let v=new Fb(m.id,m.data,l,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].every(x=>x.id!==m.id)?this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[l.uuid]=[v]}else if(m.data.type==="Follow"){g=!0;let v=m.data.target;a.traverseVisible(x=>{x.userData.isFollowingObj=v})}}c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let y=a.geometry;if(u!==void 0){let m=Wt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(xi,no,rc),a.position0=xi.clone().divideScalar(this.pixelsPerMeter),a.rotation0=no.clone(),xi.divideScalar(this.pixelsPerMeter),m.setTranslation(xi.x,xi.y,xi.z).setRotation(no);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(m);a.rigidBody=v;let x;u.collider.type==="sphere"?x=Wt.ColliderDesc.ball(u.collider.radius/this.pixelsPerMeter):u.collider.type==="capsule"?x=Wt.ColliderDesc.capsule((u.collider.height/2-u.collider.radius)/this.pixelsPerMeter,u.collider.radius/this.pixelsPerMeter):x=Wt.ColliderDesc.cuboid(u.collider.width/this.pixelsPerMeter/2,u.collider.height/this.pixelsPerMeter/2,u.collider.depth/this.pixelsPerMeter/2),x.setFrictionCombineRule(Wt.CoefficientCombineRule.Average).setRestitutionCombineRule(Wt.CoefficientCombineRule.Average).setDensity(c.physics.density).setFriction(c.physics.friction).setRestitution(c.physics.restitution);let b=this.sharedGameControlGlobals.rapierWorld.createCollider(x,v);this.sharedGameControlGlobals.colliderToEntity.set(b.handle,l),xi.fromArray(u.collider.position).multiply(rc.setFromMatrixScale(l.matrixWorld)).divideScalar(this.pixelsPerMeter),b.setTranslationWrtParent(xi);let S=new Qe().setFromEuler(new Ht().setFromVector3(new T().fromArray(u.collider.rotation)));b.setRotationWrtParent(S),b.setActiveEvents(Wt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(l,!0)}else c.physics.rigidBody==="dynamic"||h||g||f||p||d?(this.addRigidBody(a,l,{hasFollow:g,hasTransformAnim:h,hasDrag:p}),this.generateSensorColliderDescs(l,c.physics.fusedBody)):(y&&t.push(ro(y,a.matrixWorld)),c.physics.fusedBody&&a.traverseObject((m,v)=>{if(v===0)return;let x;if(m instanceof Wi)if(m.objectForSample){if(m.objectForSample.dataPatched.physics.fusedBody)return;x=m.object}else return m.object.dataPatched.physics.fusedBody===!0&&m.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else{if(m instanceof Zl||m instanceof Hl)return;if(m instanceof zr)x=m.object;else if(x=m,x.dataPatched.cloner?.hideBase)return!0}let b=x.dataPatched;if(b.physics.enabled==="visibility"?!b.visible:!b.physics.enabled)return!0;let S=m.geometry;S?.getAttribute("position")!==void 0&&t.push(ro(S,m.matrixWorld))}),this.generateSensorColliderDescs(l,c.physics.fusedBody,e));if(c.physics?.fusedBody===!0||u)return!0}),t.length===0)return;let r=zs(t);r.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let n=Wt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n),o=Wt.ColliderDesc.trimesh(r.getAttribute("position").array,r.getIndex().array).setFrictionCombineRule(Wt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(Wt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(o,s);for(let[a,l]of e){let c=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[c.handle]=l}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(e.data.type==="Trigger"&&e.data.disabled!==!0){let r=new wg(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),n=new ue().compose(so.fromArray(e.data.position),Kf.setFromEuler(B3.fromArray(e.data.rotation)),JT);if(e.data.triggerZone==="box"){let s=new zt;s.min.fromArray(e.data.size).multiplyScalar(-.5),s.max.fromArray(e.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,n,t,r])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,n,t,r])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(!!this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.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(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(e=>e.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t,e,r){if(!this.isEnabled)return!0;let n=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(n=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,n=!1):this.initializationCounter===2&&this.gameControl&&(n=!this.gameControl.update(t,e,r)&&n),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(t===0)n=this.stepPhysics()&&n;else{let o=t/1e3;o<s&&o>s*.55&&(o=s),this.accumulator+=o;let a=performance.now(),l=0,c=6;for(;this.accumulator>=s&&l<c&&(n=this.stepPhysics()&&n,this.accumulator-=s,l++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return n}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(xi,no,rc),QT.setFromQuaternion(no);let r=e;r.prevR===void 0?(r.prevR=QT.clone(),r.prevT=xi.clone()):(r.prevR.copy(QT),r.prevT.copy(xi)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(xi.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(no))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,r){let n=(this.sharedGameControlGlobals.rapierWorld?.getCollider(r))._parent,s;if(e.cloner){for(let o of e.cloner.children)if(o.rigidBody===n){s=o;break}}t.dispatch(s),e.dispatchEvent(Ab)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,r){let n=F3.copy(t.matrixWorld).invert();t.traverseEntity((s,o)=>{if(e===!1&&o===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let l=new wg(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),c;if(a.data.triggerZone==="box"?c=Wt.ColliderDesc.cuboid(...a.data.size.map(u=>u/(2*this.pixelsPerMeter))):c=Wt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),c.setDensity(0).setSensor(!0).setActiveEvents(Wt.ActiveEvents.COLLISION_EVENTS),so.fromArray(a.data.position),Kf.setFromEuler(B3.fromArray(a.data.rotation)),Gb.compose(so,Kf,JT).premultiply(s.matrixWorld),r?(Gb.decompose(so,Kf,ZT),c.setActiveCollisionTypes(Wt.ActiveCollisionTypes.KINEMATIC_FIXED|Wt.ActiveCollisionTypes.DYNAMIC_FIXED)):(Gb.premultiply(n).decompose(so,Kf,ZT),t.rigidBody.bodyType()===Wt.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===Wt.RigidBodyType.Fixed?c.setActiveCollisionTypes(Wt.ActiveCollisionTypes.KINEMATIC_FIXED|Wt.ActiveCollisionTypes.DYNAMIC_FIXED):c.setActiveCollisionTypes(Wt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|Wt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),so.divideScalar(this.pixelsPerMeter),c.setTranslation(so.x,so.y,so.z),c.setRotation(Kf),r)r.push([c,l]);else{let u=this.sharedGameControlGlobals.rapierWorld.createCollider(c,t.rigidBody);this.sensorToTriggerEvent[u.handle]=l}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[r,n,s,o]=this.sharedGameControlGlobals.triggers[e];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let l=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===l||o.isValidTriggeringObject(At.is(l)?l:l.object)===!1)continue;let c=F3.copy(s.matrixWorld).decompose(so,U3,ZT).compose(so,U3,JT).multiply(n),u=Gb.copy(l.matrixWorld).invert().multiply(c);r instanceof zt?t=l.bvhGeometry.boundsTree.intersectsBox(r,u):($T.radius=r,$T.center.setFromMatrixPosition(u),t=l.bvhGeometry.boundsTree.intersectsSphere($T)),t?o.currentIntersectedObjects.indexOf(l)===-1&&(o.currentIntersectedObjects.push(l),o.dispatch(),s.dispatchEvent(PJ)):o.currentIntersectedObjects=o.currentIntersectedObjects.filter(h=>h!==l)}}}};function z3(i){let t=this._clip.duration,e=this._clip.start??0,r=this.loop,n=this.time+i,s=this._loopCount,o=r===Cp;if(i===0)return s===-1?n:o&&(s&1)===1?t-(n-e):n;if(r===Ew){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:i<0?-1:1})}}else{if(s===-1&&(i>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<e){let a=Math.floor((n-e)/(t-e));n-=(t-e)*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,o||(n=i>0?t:e,this.repetitions===1&&(n=t)),this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:i>0?1:-1});else{if(l===1){let c=i<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return t-(n-e)}return n}var k3=!1,jb=class{constructor(t,e,r,n){this.scene=t;this.requestRender=e;this.updateDisplayProgress=r;this.animationInspectorState=n;this.clipIdToAction={};this.activeClip=null;this.needsUpdate=!1;this.addClip=t=>{t.data.type==="Empty"&&t.data.animations&&t.data.animations.forEach((e,r)=>{let n=e[0]+"/";if(Array.isArray(t.identity)?n+=t.identity[0]:n+=t.uuid,this.clipIdToAction[n])return;let s=Qu.parse(JSON.parse(e[2]));t.animations[r]=s;let o=this.mixer.clipAction(s,t);k3===!1&&(Object.getPrototypeOf(o)._updateTime=z3,k3=!0),o.clampWhenFinished=!0,this.clipIdToAction[n]=o})};this.mixer=new Iy(t),this.scene.traverseEntity(this.addClip)}deleteClip(t,e){let r=this.scene.find(e);if(!r)return;let n=r.animations.find(o=>o.uuid===t);if(!n)return;let s=this.clipIdToAction[t];!s||(s.stop(),this.mixer.uncacheClip(n),delete this.clipIdToAction[t],r.animations=r.animations.filter(o=>o.uuid!==t))}get isPlaying(){return Object.values(this.clipIdToAction).some(t=>t.isRunning())}playFromInspector(t){this.mixer.stopAllAction();let e=this.clipIdToAction[t];!e||(e.play(),this.activeClip=e.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(t=>{t.repetitions=1/0,t.loop=Tw}),this.mixer.stopAllAction(),this.requestRender()}play(t){let e=t.clipId+"/"+t.object,r=this.clipIdToAction[e];if(!!r)return t&&(t.repeat>=0&&(r.repetitions=t.repeat+1),t.direction==="pingpong"&&t.repeat!==0&&(r.loop=Cp)),r.play(),r.paused=!1,this.requestRender(),r}resumeFromInspector(t){let e=this.clipIdToAction[t];!e||(e.play(),e.paused=!1,this.requestRender())}pauseFromInspector(t){let e=this.clipIdToAction[t];!e||(e.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(t){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(t/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(t,e){if(!this.clipIdToAction[e])return;this.activeClip!==this.clipIdToAction[e].getClip()&&this.playFromInspector(e);let r=this.clipIdToAction[e].paused;this.clipIdToAction[e].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?t/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),r&&(this.clipIdToAction[e].paused=!0)}};var eM=new WeakMap,Wb=class extends aa{constructor(t){super(t),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(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,r,n){let s=new Zu(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,o=>{this.parse(o,e,n)},r,n)}parse(t,e,r=()=>{}){this.decodeDracoFile(t,e,null,null,Ot).catch(r)}decodeDracoFile(t,e,r,n,s=an,o=()=>{}){let a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:s};return this.decodeGeometry(t,a).then(e).catch(o)}decodeGeometry(t,e){let r=JSON.stringify(e);if(eM.has(t)){let l=eM.get(t);if(l.key===r)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n,s=this.workerNextTaskID++,o=t.byteLength,a=this._getWorker(s,o).then(l=>(n=l,new Promise((c,u)=>{n._callbacks[s]={resolve:c,reject:u},n.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),eM.set(t,{key:r,promise:a}),a}_createGeometry(t){let e=new Ne;t.index&&e.setIndex(new Ye(t.index.array,1));for(let r=0;r<t.attributes.length;r++){let n=t.attributes[r],s=n.name,o=n.array,a=n.itemSize,l=new Ye(o,a);s==="color"&&(this._assignVertexColorSpace(l,n.vertexColorSpace),l.normalized=!(o instanceof Float32Array)),e.setAttribute(s,l)}return e}_assignVertexColorSpace(t,e){if(e!==Ot)return;let r=new ke;for(let n=0,s=t.count;n<s;n++)r.fromBufferAttribute(t,n).convertSRGBToLinear(),t.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(t,e){let r=new Zu(this.manager);return r.setPath(this.decoderPath),r.setResponseType(e),r.setWithCredentials(this.withCredentials),new Promise((n,s)=>{r.load(t,n,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(r=>{let n=r[0];t||(this.decoderConfig.wasmBinary=r[1]);let s=DJ.toString(),o=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
8068
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){let o=s.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function DJ(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(u){i.onModuleLoaded=function(h){u({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,c=a.taskConfig;t.then(u=>{let h=u.draco,d=new h.Decoder;try{let f=e(h,d,new Int8Array(l),c),p=f.attributes.map(g=>g.array.buffer);f.index&&p.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},p)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{h.destroy(d)}});break}};function e(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let g={index:null,attributes:[]};for(let y in u){let m=self[h[y]],v,x;if(c.useUniqueIDs)x=u[y],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[u[y]]),x===-1)continue;v=a.GetAttribute(d,x)}let b=n(o,a,d,y,m,v);y==="color"&&(b.vertexColorSpace=c.vertexColorSpace),g.attributes.push(b)}return p===o.TRIANGULAR_MESH&&(g.index=r(o,a,d)),o.destroy(d),g}function r(o,a,l){let u=l.num_faces()*3,h=u*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,u).slice();return o._free(d),{array:f,itemSize:1}}function n(o,a,l,c,u,h){let d=h.num_components(),p=l.num_points()*d,g=p*u.BYTES_PER_ELEMENT,y=s(o,u),m=o._malloc(g);a.GetAttributeDataArrayForAllPoints(l,h,y,g,m);let v=new u(o.HEAPF32.buffer,m,p).slice();return o._free(m),{name:c,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var ic;function G3(){return ic||(ic=new Wb,ic.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ic.decoderPending}async function OJ(i){if(ic){let t={attributeIDs:ic.defaultAttributeIDs,attributeTypes:ic.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ic.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function H3(i,t){let[e,r]=nA(zv.deserialize(new Uint8Array(i)));return a0(e),t&&t(e),r.result().data}function j3(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function W3(i){for(let t of i){let e=await OJ(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let n={};e.attributes.forEach(({name:s,array:o,itemSize:a})=>{n[s]={array:o,itemSize:a,type:"Float32Array",normalized:!1}}),r.attributes=n,r.draco=void 0}}}var tM=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.dataEvent=r;this.object=n;this.stage=!1;this.actions=_r(r,e.actions,s,o,a,n)}disconnect(){pr(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),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())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},qb=class extends kr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(n=>{let s=jv.deviceToSize(n.data.size),o=n.dataEvent.orientation==="horizontal"?e:r,a;switch(n.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}n.stage!==a&&(n.stage=a,n.stage?n.dispatchIn():n.dispatchOut())})};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:n,height:s}=r.contentRect;this.resize(n,s)}})}connect(){let{page:e,sharedAssets:r,domElement:n}=this.eventContext;this.onResizeObserver.observe(n);let s=o=>{if(!(!o.visible||!o.data?.events.length))for(let{data:a}of o.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:l,id:c})=>{try{let u=new tM(c,l,a,o,e,r,this.eventManager);this.breakpoints.push(u)}catch(u){!1&&console.log(u)}})};e.traverseEntity(o=>{(o instanceof Cr||o instanceof fr)&&o.frame?.traverse(a=>{s(a)}),s(o)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var Xb=class{constructor(t,e,r,n,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=n;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{let e=window.parent!==window,r=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(t.touches.length>1||this.preventTouchScroll||e===!1&&r===!1)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:n}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:n-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=n.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 Mb(this.eventContext),DynamicVariable:new Ub(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new Pb(this.eventContext,this),["Start"]:new Bb(this.eventContext,this),Basic:new Cb(this.eventContext,this,this.needsRaycast),["MouseHover"]:new Lb(this.eventContext,this),["Scroll"]:new Nb(this.eventContext,this),["Follow"]:new Ob(this.eventContext,this),["DragDrop"]:new Db(this.eventContext,this),["LookAt"]:new Rb(this.eventContext),["Resize"]:new qb(this.eventContext,this)};let{page:t,domElement:e}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.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:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.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(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let n of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in n&&Array.isArray(n.id)&&(n.id[0]==="mouse"&&(this.needsMouse=!0),n.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let n of r.data.events)if(!n.data.disabled)if(n.data.type==="VariableChange"&&(n.data.variableId==="mouseProperty"&&(this.needsMouse=!0),n.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),n.data.type==="Conditional")for(let s of["inActions","outActions"])n.data[s].forEach(e);else if(n.data.type==="DragDrop")for(let s of["drag","drop"])n.data.dragDropActions[s].forEach(e);else if(n.data.type==="GameControl")for(let s of["idle","move","jump","run"])n.data.gameActions[s].forEach(e);else if(n.data.type==="Resize")for(let s of n.data.breakpoints)s.data.actions.forEach(e);else n.data.type==="LookAt"||n.data.actions.forEach(e)}})}};var Yb=class{constructor(t,e,r,n,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new U().copy(r),this._editorSize=new U().copy(n),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,n=this._fov;if(t&&e>r){let s=IJ(e,1080,2160,1,15)/100;n*=e/r,n*=1-s}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function IJ(i,t,e,r,n){return(i-t)/(e-t)*(n-r)+r}var Kb=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Yc(t.shared,e),this.scene=new ql(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof fr&&!t.uiScene&&t.personalCamera.updateState(t.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(t=>{t instanceof dr&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Qb=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function RJ(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Ag(i){return i instanceof Ks?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function LJ(i,t){let e={};return i.traverseEntity(r=>{if(!r.visible||!(r instanceof yr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let n=r.parent;for(;n;){if(n instanceof yr&&r.states&&Object.keys(r.states).length)return;n=n.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!li.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!li.isMergable(c.material))return;s=li.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][Ag(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][Ag(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][Ag(r)].push(c)}),e}function NJ(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(r=>{let n=r.length;n>t&&(t=n)})}),t}function q3(i,t){let e=LJ(t,i),r=NJ(e),n=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),c=0,u=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,c=0,p.forEach(y=>{y instanceof yr&&(o[a++]=y.geometry.clone(),l[c++]=y)}),c<2)continue;for(let y=0;y<c;y++)l[y].updateWorldMatrix(!0,!1),o[y].applyMatrix4(l[y].matrixWorld),l[y].matrixWorld.determinant()<0&&RJ(o[y]);let g=zs(o.slice(0,a),!1);if(g){let y;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),y=new tr(g,l[0].material);break}default:{y=new tr(g,l[0].material);break}}y.castShadow=l[0].castShadow,y.receiveShadow=l[0].receiveShadow,t.add(y);let m=v=>{h=0;for(let x of v)x.children&&m(x.children),x instanceof yr&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Ag(x)]&&e[x.material.uuid][Ag(x)].length>1||(u[h++]=x));for(let x=0;x<h;x++)t.attach(u[x])};for(let v=0;v<c;v++){let x=l[v];m(x.children),n[s++]=x}}}for(let d=0;d<s;d++)n[d].removeFromParent()}var K3=qo(Y3(),1);var FJ=new U;function UJ(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var rM=class{constructor(t,{renderOnDemand:e,renderMode:r="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=t=>{if(this.time=t,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(e=>{e.type==="ParticleSystem"&&(e.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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,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=FJ.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 t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="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=_c(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Qb({x:10,y:10})),iD(t)}async load(t,e,r){UJ(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let n=await H3(t);this._data=n;let s=j3(n);n.version&&(0,K3.default)(n.version,"1.0.88")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([s.length&&G3(),D1(n)&&tR(),YR(n)&&YI(),Cl.physicsEnabled(n.scene.objects)&&uD(),w1(n)&&GR(),sb(n)&&eT(),VR(n)&&FR(),H1(n)&&cN(),qT(n)&&aD()].filter(Boolean)),s.length&&await W3(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new Kb(n);if(o.resetPersonalCameraFromDocumentData(),this._scene=o.scene,this._sharedAssetsManager=o.sharedAssets,this._camera=this._scene.activeCamera,this._renderer||(this._renderer=new Bx({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),await this._renderer.compileAsync(this._scene,this._camera),window.location.search.includes("merge-geometries")){let c=performance.now();q3(n,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}D1(n)&&this._scene.traverse(c=>{Mn(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Wi&&c.pendingMediaLoad&&c.update()})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop())});let a=Object.keys(n.shared.fonts).map(c=>this._sharedAssetsManager.getFont(c).loadingPromise);if(Promise.all(a).then(()=>{o.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),w1(n)&&V3(n)&&await Promise.all(a),H1(n)){let c=[];this._scene.traverseEntity(u=>{(u instanceof Cr||u instanceof fr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),Ff(this._scene.activePage,this._sharedAssetsManager),sb(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let l=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(l.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=l.size[0],this._viewportHeight=l.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 Yb(this._renderer,this._camera,new U(this._viewportWidth,this._viewportHeight),new U(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(l.allowResponsive??!1)&&l.preset==="fullscreen"),e){let c=new Tb(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new Hb(c),this._animationControls=new jb(this._scene,this._requestRenderAutoMode),this._eventManager=new Xb(n.scene.publish,this._controls,this._animationControls,c,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),r!==void 0&&this.setVariables(r),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(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,n]of e)this.setVariable(r,n)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let n=e;typeof r.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(n=e.toString());let s=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&ki.isTextValue(t)?ki.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==ds&&!this._scene.isInvisibleObjects(e)&&!(e instanceof fr)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Yf&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:r,b:n,a:s}={r:0,g:0,b:0,a:1},o=new Ar(e,r,n,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Hw.unsubscribe(t)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),this.dt=0,nD(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(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof fr&&(e=s.name)});let r={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof fr||t instanceof ql?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},n=Hw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}setUIWasmUrl(t){$0.skiaWasmUrl=t}};
8068
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){let o=s.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[t]=e,r._taskLoad+=e,r})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function DJ(){let i,t;onmessage=function(o){let a=o.data;switch(a.type){case"init":i=a.decoderConfig,t=new Promise(function(u){i.onModuleLoaded=function(h){u({draco:h})},DracoDecoderModule(i)});break;case"decode":let l=a.buffer,c=a.taskConfig;t.then(u=>{let h=u.draco,d=new h.Decoder;try{let f=e(h,d,new Int8Array(l),c),p=f.attributes.map(g=>g.array.buffer);f.index&&p.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},p)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{h.destroy(d)}});break}};function e(o,a,l,c){let u=c.attributeIDs,h=c.attributeTypes,d,f,p=a.GetEncodedGeometryType(l);if(p===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,d);else if(p===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let g={index:null,attributes:[]};for(let y in u){let m=self[h[y]],v,x;if(c.useUniqueIDs)x=u[y],v=a.GetAttributeByUniqueId(d,x);else{if(x=a.GetAttributeId(d,o[u[y]]),x===-1)continue;v=a.GetAttribute(d,x)}let b=n(o,a,d,y,m,v);y==="color"&&(b.vertexColorSpace=c.vertexColorSpace),g.attributes.push(b)}return p===o.TRIANGULAR_MESH&&(g.index=r(o,a,d)),o.destroy(d),g}function r(o,a,l){let u=l.num_faces()*3,h=u*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,u).slice();return o._free(d),{array:f,itemSize:1}}function n(o,a,l,c,u,h){let d=h.num_components(),p=l.num_points()*d,g=p*u.BYTES_PER_ELEMENT,y=s(o,u),m=o._malloc(g);a.GetAttributeDataArrayForAllPoints(l,h,y,g,m);let v=new u(o.HEAPF32.buffer,m,p).slice();return o._free(m),{name:c,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var ic;function G3(){return ic||(ic=new Wb,ic.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ic.decoderPending}async function OJ(i){if(ic){let t={attributeIDs:ic.defaultAttributeIDs,attributeTypes:ic.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ic.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,n])=>({name:r,itemSize:n.itemSize,array:n.array}))}}return null}async function H3(i,t){let[e,r]=nA(zv.deserialize(new Uint8Array(i)));return a0(e),t&&t(e),r.result().data}function j3(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function W3(i){for(let t of i){let e=await OJ(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let n={};e.attributes.forEach(({name:s,array:o,itemSize:a})=>{n[s]={array:o,itemSize:a,type:"Float32Array",normalized:!1}}),r.attributes=n,r.draco=void 0}}}var tM=class{constructor(t,e,r,n,s,o,a){this.id=t;this.data=e;this.dataEvent=r;this.object=n;this.stage=!1;this.actions=_r(r,e.actions,s,o,a,n)}disconnect(){pr(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),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())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},qb=class extends kr{constructor(e,r){super(e);this.eventManager=r;this.breakpoints=[];this.resize=(e,r)=>{this.breakpoints.forEach(n=>{let s=jv.deviceToSize(n.data.size),o=n.dataEvent.orientation==="horizontal"?e:r,a;switch(n.data.operator){case"<":a=o<s[0];break;case">":a=o>s[0];break;case"<>":a=o>s[0]&&o<s[1];break}n.stage!==a&&(n.stage=a,n.stage?n.dispatchIn():n.dispatchOut())})};this.onResizeObserver=new ResizeObserver(e=>{for(let r of e){let{width:n,height:s}=r.contentRect;this.resize(n,s)}})}connect(){let{page:e,sharedAssets:r,domElement:n}=this.eventContext;this.onResizeObserver.observe(n);let s=o=>{if(!(!o.visible||!o.data?.events.length))for(let{data:a}of o.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:l,id:c})=>{try{let u=new tM(c,l,a,o,e,r,this.eventManager);this.breakpoints.push(u)}catch(u){!1&&console.log(u)}})};e.traverseEntity(o=>{(o instanceof Cr||o instanceof fr)&&o.frame?.traverse(a=>{s(a)}),s(o)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}};var Xb=class{constructor(t,e,r,n,s){this.publish=t;this.controlsManager=e;this.animationControls=r;this.eventContext=n;this.sharedVariables=s;this.isEnabled=!1;this.activateCount=0;this.needsMouse=!1;this.needsRaycast=!1;this.onTouchMovePreventScroll=t=>{let e=window.parent!==window,r=document.documentElement.scrollHeight>document.documentElement.clientHeight||document.documentElement.scrollWidth>document.documentElement.clientWidth;(t.touches.length>1||this.preventTouchScroll||e===!1&&r===!1)&&t.preventDefault()};this.onMouseWheelPreventScroll=t=>{this.preventScroll&&t.preventDefault()};this.onMouseMove=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:t.buttons>0}};this.onMouseDown=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!0}};this.onMouseUp=t=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(t),pressed:!1}};this.getMousePosition=t=>{let{domRect:e}=this.eventContext,{pageX:r,pageY:n}=t.touches?.length>0?t.touches[0]:t;return{x:r-(e.left+window.scrollX),y:n-(e.top+window.scrollY)}};this.stopRaycast=t.stopRaycast,this.preventScroll=t.preventScroll,this.preventTouchScroll=t.preventTouchScroll,this.hideCursor=t.hideCursor,this.requestRender=n.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 Mb(this.eventContext),DynamicVariable:new Ub(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),["Conditional"]:new Pb(this.eventContext,this),["Start"]:new Bb(this.eventContext,this),Basic:new Cb(this.eventContext,this,this.needsRaycast),["MouseHover"]:new Lb(this.eventContext,this),["Scroll"]:new Nb(this.eventContext,this),["Follow"]:new Ob(this.eventContext,this),["DragDrop"]:new Db(this.eventContext,this),["LookAt"]:new Rb(this.eventContext),["Resize"]:new qb(this.eventContext,this)};let{page:t,domElement:e}=this.eventContext;this.hideCursor&&(e.style.cursor="none"),t.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),e.addEventListener("wheel",this.onMouseWheelPreventScroll),e.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:t,domElement:e}=this.eventContext;e.style.cursor="",Object.values(this.handlers).forEach(r=>r.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),t.traverseEntity(r=>{r.removeEventListener("requestRender",this.requestRender),r.destroyedInAction=!1}),e.removeEventListener("touchmove",this.onTouchMovePreventScroll),e.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(t){let e=this.isEnabled;e&&this.deactivate(),this.eventContext.useWindowEvents=t,e&&this.activate()}initializeActionsDependentStates(){let t=this.eventContext.sharedAssets;t.resetDynamicVariablePlayState();let e=r=>{if(r.data.type==="Conditional"&&(r.data.ifActions.forEach(e),r.data.elseActions.forEach(e)),r.data.type==="Conditional"||r.data.type==="SetVariable")for(let n of r.data.type==="Conditional"?r.data.condition:r.data.expression)"id"in n&&Array.isArray(n.id)&&(n.id[0]==="mouse"&&(this.needsMouse=!0),n.id[0]==="raycast"&&(this.needsRaycast=!0));r.data.type==="DynamicVariablePlay"&&r.data.variableId!==""&&(r.data.mode==="Play"||r.data.mode==="PlayPause"||r.data.mode==="Toggle")&&t.setDynamicVariablePlayState(r.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(r=>{if(!!r.data?.events.length){for(let n of r.data.events)if(!n.data.disabled)if(n.data.type==="VariableChange"&&(n.data.variableId==="mouseProperty"&&(this.needsMouse=!0),n.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),n.data.type==="Conditional")for(let s of["inActions","outActions"])n.data[s].forEach(e);else if(n.data.type==="DragDrop")for(let s of["drag","drop"])n.data.dragDropActions[s].forEach(e);else if(n.data.type==="GameControl")for(let s of["idle","move","jump","run"])n.data.gameActions[s].forEach(e);else if(n.data.type==="Resize")for(let s of n.data.breakpoints)s.data.actions.forEach(e);else n.data.type==="LookAt"||n.data.actions.forEach(e)}})}};var Yb=class{constructor(t,e,r,n,s){this._aspect=1;this.enableResponsive=!1;this._renderer=t,this._camera=e,this._frameSize=new U().copy(r),this._editorSize=new U().copy(n),this._aspect=e.aspect,this._fov=s??e.fov}set frameSize(t){this._frameSize.copy(t)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let t=this._frameSize.x,e=this._frameSize.y,r=this._editorSize.y;this._aspect=t/e,e<=r&&(this._camera.zoom*=r/e),this._renderer.setViewport(0,0,t,e)}updateCamera(t=!0){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,r=this._editorSize.y,n=this._fov;if(t&&e>r){let s=IJ(e,1080,2160,1,15)/100;n*=e/r,n*=1-s}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(t){this._camera=t,this._aspect=t.aspect,this._fov=t.fov}revert(){let t=window.innerWidth,e=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,t,e),this._renderer.setSize(t,e)),this._camera&&(this._camera.aspect=t/e,this._camera.fov=this._fov,this._camera.setViewplaneSize(t,e,this.enableResponsive),this._camera.updateProjectionMatrix())}};function IJ(i,t,e,r,n){return(i-t)/(e-t)*(n-r)+r}var Kb=class{get sharedAssets(){return this.shared}constructor(t,e={}){this.shared=new Yc(t.shared,e),this.scene=new ql(t.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(t,e){this.scene.clearScene(),this.sharedAssets.reset(t.shared),this.scene.resetAfterClear(t.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let t of this.scene.children)t instanceof fr&&!t.uiScene&&t.personalCamera.updateState(t.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(t=>{t instanceof dr&&t.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}};var Qb=class{constructor({x:t=10,y:e=10}){this._startTime=0;let r=document.getElementById("spe-perfs");r?this.element=r:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${t}px`,this.element.style.top=`${e}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function RJ(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}function Ag(i){return i instanceof Ks?"SubdivObject":i.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function LJ(i,t){let e={};return i.traverseEntity(r=>{if(!r.visible||!(r instanceof yr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let n=r.parent;for(;n;){if(n instanceof yr&&r.states&&Object.keys(r.states).length)return;n=n.parent}let s=r.material.uuid,o=t.shared.materials[s];if(o){if(!li.isMergable(o))return}else{let c=t.scene.objects.get(r.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!li.isMergable(c.material))return;s=li.getHash(c.material)}}e[s]||(e[s]={});let l=e[s][Ag(r)];if(l){if(l.push(r),r.cloner)for(let c of r.cloner.children)l.push(c)}else if(e[s][Ag(r)]=[r],r.cloner)for(let c of r.cloner.children)e[s][Ag(r)].push(c)}),e}function NJ(i){let t=0;return Object.values(i).forEach(e=>{Object.values(e).forEach(r=>{let n=r.length;n>t&&(t=n)})}),t}function q3(i,t){let e=LJ(t,i),r=NJ(e),n=new Array(r),s=0,o=new Array(r),a=0,l=new Array(r),c=0,u=new Array(r),h=0;for(let[d,f]of Object.entries(e))for(let p of Object.values(f)){if(a=0,c=0,p.forEach(y=>{y instanceof yr&&(o[a++]=y.geometry.clone(),l[c++]=y)}),c<2)continue;for(let y=0;y<c;y++)l[y].updateWorldMatrix(!0,!1),o[y].applyMatrix4(l[y].matrixWorld),l[y].matrixWorld.determinant()<0&&RJ(o[y]);let g=zs(o.slice(0,a),!1);if(g){let y;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),y=new tr(g,l[0].material);break}default:{y=new tr(g,l[0].material);break}}y.castShadow=l[0].castShadow,y.receiveShadow=l[0].receiveShadow,t.add(y);let m=v=>{h=0;for(let x of v)x.children&&m(x.children),x instanceof yr&&(Array.isArray(x.material)||e[x.material.uuid]&&e[x.material.uuid][Ag(x)]&&e[x.material.uuid][Ag(x)].length>1||(u[h++]=x));for(let x=0;x<h;x++)t.attach(u[x])};for(let v=0;v<c;v++){let x=l[v];m(x.children),n[s++]=x}}}for(let d=0;d<s;d++)n[d].removeFromParent()}var K3=qo(Y3(),1);var FJ=new U;function UJ(i){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";i.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):i.endsWith(".splinecode")||console.warn(t)}var rM=class{constructor(t,{renderOnDemand:e,renderMode:r="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=t=>{if(this.time=t,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(e=>{e.type==="ParticleSystem"&&(e.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 e=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=e,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=FJ.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 t=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(t!=="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=_c(this._resize,10);this._onScroll=t=>{this.eventManager&&(this.eventManager.eventContext.domRect=this.canvas.getBoundingClientRect())};this.canvas=t,this.renderMode=e?"auto":r,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Qb({x:10,y:10})),iD(t)}async load(t,e,r){UJ(t),this.disposed=!1;let s=await(await fetch(t,r)).arrayBuffer();await this.start(s,{variables:e})}async start(t,{interactive:e=!0,variables:r}={}){if(this.disposed)return;let n=await H3(t);this._data=n;let s=j3(n);n.version&&(0,K3.default)(n.version,"1.0.89")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([s.length&&G3(),D1(n)&&tR(),YR(n)&&YI(),Cl.physicsEnabled(n.scene.objects)&&uD(),w1(n)&&GR(),sb(n)&&eT(),VR(n)&&FR(),H1(n)&&cN(),qT(n)&&aD()].filter(Boolean)),s.length&&await W3(s),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let o=new Kb(n);if(o.resetPersonalCameraFromDocumentData(),this._scene=o.scene,this._sharedAssetsManager=o.sharedAssets,this._camera=this._scene.activeCamera,this._renderer||(this._renderer=new Bx({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=n.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.enableUIOverlay(),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),await this._renderer.compileAsync(this._scene,this._camera),window.location.search.includes("merge-geometries")){let c=performance.now();q3(n,o.scene);let u=performance.now();console.log("Merged geometries in ",u-c," ms")}D1(n)&&this._scene.traverse(c=>{Mn(c)&&c.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(c=>{c instanceof Wi&&c.pendingMediaLoad&&c.update()})}),this._scene?.traverse(c=>{c.type==="ParticleSystem"&&(c.wakeUp(),c.data.autoPlay?c.start():c.stop())});let a=Object.keys(n.shared.fonts).map(c=>this._sharedAssetsManager.getFont(c).loadingPromise);if(Promise.all(a).then(()=>{o.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),w1(n)&&V3(n)&&await Promise.all(a),H1(n)){let c=[];this._scene.traverseEntity(u=>{(u instanceof Cr||u instanceof fr)&&u.uiCanvas&&c.push(u.uiCanvas)}),await Promise.all(c.map(u=>u.promise))}this._scene.rewriteEventsBeforeGoToPlayMode(),Ff(this._scene.activePage,this._sharedAssetsManager),sb(n)&&this._scene.initializeSplatViewer(),n.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(n.scene.blueNoiseTextureData);let l=Object.values(n.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(l.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=l.size[0],this._viewportHeight=l.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 Yb(this._renderer,this._camera,new U(this._viewportWidth,this._viewportHeight),new U(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(l.allowResponsive??!1)&&l.preset==="fullscreen"),e){let c=new Tb(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,l);this._scene.updateMatrixWorld(!0),this._controls=new Hb(c),this._animationControls=new jb(this._scene,this._requestRenderAutoMode),this._eventManager=new Xb(n.scene.publish,this._controls,this._animationControls,c,n.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),r!==void 0&&this.setVariables(r),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(t){if(this._data!==void 0){let e=Object.entries(t);for(let[r,n]of e)this.setVariable(r,n)}}setVariable(t,e){let r=this._getVariableByName(t);if(r&&!("dynamicVariableType"in r.data)){let n=e;typeof r.data.value=="number"?n=typeof e=="number"?e:typeof e=="boolean"?e===!0?1:0:parseFloat(e):typeof r.data.value=="boolean"?n=typeof e=="number"?!!e:typeof e=="boolean"?e:e.toLocaleLowerCase()==="false"?!1:!!e:typeof r.data.value!="string"&&r.data.value.textValue!==void 0&&(n=e.toString());let s=typeof n=="string"?{textValue:n}:n;this._sharedAssetsManager?.updateVariable(r.id,s),this.requestRender(),this._requestRenderAutoMode()}else r===void 0?console.warn(`No variable named ${t} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in r.data&&console.warn(`Dynamic variables like ${t} cannot be updated from code.`)}getVariables(){let t={};return this._data&&this._data.shared.variables.forEach(e=>{t[e.data.name]===void 0&&(t[e.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(e.id)))}),t}getVariable(t){let e=this._getVariableByName(t);if(e){let r=this._sharedAssetsManager.getVariable(e.id);return this._getVariableValue(r)}}_getVariableValue(t){return typeof t!="string"&&ki.isTextValue(t)?ki.getDisplayedValue(t):t}_getVariableByName(t){if(this._data){if(this._variablesCache.has(t))return this._variablesCache.get(t);let e=this._data.shared.variables.find(r=>r.data.name===t);return e&&this._variablesCache.set(t,e),e}}findObjectById(t){let e=this._scene?.getObjectByProperty("uuid",t);return this._createProxyObject(e)}findObjectByName(t){let e=this._scene?.getObjectByName(t);return this._createProxyObject(e)}getAllObjects(){let t=[];return this._scene?.traverseEntity(e=>{if(e.uuid!==ds&&!this._scene.isInvisibleObjects(e)&&!(e instanceof fr)){let r=this._createProxyObject(e);r&&t.push(r)}}),t}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEvent(t)}emitEventReverse(t,e){(this.findObjectById(e)||this.findObjectByName(e))?.emitEventReverse(t)}addEventListener(t,e){this.canvas.addEventListener(t,e)}removeEventListener(t,e){this.canvas.removeEventListener(t,e)}setZoom(t){this._controls?.orbitControls instanceof Yf&&this._controls?.orbitControls.zoomOut(t)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(t,e){this._viewportWidth=t,this._viewportHeight=e,this._viewportMode=2,this._resize()}setBackgroundColor(t){let{r:e,g:r,b:n,a:s}={r:0,g:0,b:0,a:1},o=new Ar(e,r,n,s);try{o.setStyle(t)}catch{console.error("This is not a valid css color",t)}this._scene?.activePage.setBackgroundColor(o),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(t=>{Hw.unsubscribe(t)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),this.dt=0,nD(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(t){this._eventManager?.updateUseWindowEvents(t)}get data(){return this._data}_createProxyObject(t){if(t==null)return;if(this._proxyObjectCache.has(t.uuid))return this._proxyObjectCache.get(t.uuid);let e;t.traverseAncestors(s=>{s instanceof fr&&(e=s.name)});let r={name:t.name,uuid:t.uuid,visible:t.visible,intensity:t.intensity,position:t.position,rotation:t.rotation,scale:t.scale,type:t.data.type,page:e,parentUuid:t.parent instanceof fr||t instanceof ql?void 0:t.parent?.uuid,emitEvent(s){t.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){t.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},n=Hw(r,(s,o)=>{typeof t[s]!="object"&&Object.getOwnPropertyDescriptor(t,s)?.writable&&(t[s]=o),this._requestRenderAutoMode(),t.updateMatrix()});return this._proxyObjectCache.set(t.uuid,n),n}setUIWasmUrl(t){$0.skiaWasmUrl=t}};