@splinetool/loader 2.0.11 → 2.0.12

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.
@@ -726,7 +726,7 @@ void main() {
726
726
  `;this.pyramidPassMaterial.fragmentShader=t,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new xF(zl,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,i,o){new mF().min.setScalar(0);let s=e.length-1,l=new AF;r.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let u=c;u>=0;u--){let p=u%2===c%2?o[0]:o[1],h=u===c?i:u%2===c%2?o[1]:o[0];this.pyramidPassUniforms.inputTexture.value=h.textures.length>1?h.textures[1]:h.texture,this.pyramidPassUniforms.inputWidth.value="width"in h?h.width:1,this.pyramidPassUniforms.inputHeight.value="height"in h?h.height:1,r.setRenderTarget(p);let f=e[u],m=r.getPixelRatio();r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,f/m,f/m),u===2&&t%2!==0&&r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),r.render(this.pyramidPassScene,lu);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,u<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[u+1])}r.setViewport(l);let d=e.length%2===0?0:1;return r.readRenderTargetPixelsAsync(o[d],o[d].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};ut();import{Color as CF}from"three";var Tt=class extends CF{constructor(e,r,i,o){super(e,r,i);this.isColorA=!0;this.a=o}setRGBA(e,r,i,o){super.setRGB(e,r,i),this.a=o}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 i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let o,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(o[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(o[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 Do=class extends Tt{};import{VideoTexture as OF,Texture as IF}from"three";var Ff=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.cleanupTimer=null;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let r=e;e=e.next,e.prev=this.head,this.head.next=e,r.next=null,r.prev=null,r.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}};var sx=class extends Ff{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},ax;function cP(n){return typeof n=="string"?n:(ax||(ax=new sx),ax.load(n))}var kf=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},Vf=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};import{DataTexture as EF,DataUtils as dP,HalfFloatType as PF,RGBAFormat as TF}from"three";import{HDRLoader as MF}from"three/examples/jsm/loaders/HDRLoader.js";function lx(n){return n.length>2&&n[0]===35&&n[1]===63}function uP(n){try{let t=new MF().parse(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));if(!t||!t.width||!t.height)return null;let{width:e,height:r}=t,i=t.data,o=new Uint16Array(i.length),a=e*4,s=d=>dP.toHalfFloat(Math.pow(Math.max(dP.fromHalfFloat(d),0),1/2.2)),l=new Map,c=d=>{let u=l.get(d);return u===void 0&&(u=s(d),l.set(d,u)),u};for(let d=0;d<r;d++){let u=d*a,p=(r-1-d)*a;for(let h=0;h<a;h+=4)o[p+h]=c(i[u+h]),o[p+h+1]=c(i[u+h+1]),o[p+h+2]=c(i[u+h+2]),o[p+h+3]=i[u+h+3]}return{isSplineHdr:!0,data:o,width:e,height:r}}catch{return null}}function pP(n){let t=new EF(n.data,n.width,n.height,TF,PF);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var DF=0,jl=class extends kf{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.instanceId=++DF;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this.isHdr=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let o of Object.values(i))for(let a of Object.values(o))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){let i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let o;await new Promise(a=>{i.onloadend=s=>{o=s.target?.result,a(null)}}),this.img.src=o}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else if(e instanceof Uint8Array?lx(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let i=e instanceof Uint8Array?e:null;if(i===null)try{i=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{i=null}let o=i!==null&&lx(i)?uP(i):null;o!==null&&(this.isHdr=!0,this.img=o,r())}else this.img=new Image,this.img.src=cP(e),this.img.onload=r,await new Promise(i=>{this.img.onload=()=>{r(),i(null)}})}getTexture(e,r=1008,i=1006){let o=this._cache[e]?.[r]?.[i];if(o)return o;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new OF(this.img,void 0,e,e):this.isHdr?(a=pP(this.img),a.wrapS=e,a.wrapT=e,a.magFilter=i,a.minFilter=r):a=new IF(this.img,void 0,e,e,i,r),this.isBuffer||(a.anisotropy=8,a.generateMipmaps=r===1008),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][i]=a,a}}setNeedsUpdate(e){if(!this.isBuffer)for(let r of Object.values(this._cache))for(let i of Object.values(r))for(let o of Object.values(i))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[i,o]of Object.entries(r))for(let[a,s]of Object.entries(o))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Ei=class extends jl{};var hP=new Map;function fP(n){if(typeof n=="string")return n;let t=hP.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},hP.set(n,t)),t.url}var RF,mP=new Promise(n=>{RF=n});var yP;mP.then(n=>yP=n);var Ro=class{constructor({src:t,volume:e,delay:r,loop:i}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let o;typeof t=="string"?o={src:t}:o={src:fP(t),format:"wav"},this.sound=new yP.Howl(o),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),i!==void 0&&(this.loop=i)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var gP=null;function vP(n){gP=n}function bP(){return gP}function cx(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}import{BufferGeometryLoader as pV}from"three";import{BufferGeometry as LF,ConeGeometry as _F,Float32BufferAttribute as FF,MathUtils as kF}from"three";import{BufferAttribute as Gf,BufferGeometry as wP,CylinderGeometry as BF,Float32BufferAttribute as NF,MathUtils as xP,Vector2 as cu}from"three";var Uf=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.parameters?.radiusTop,r=n.parameters?.radiusBottom,i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);i.thetaLength=xP.clamp(i.thetaLength,0,360),i.hollow=xP.clamp(i.hollow??0,0,1);let o=i.width/2,a=i.radiusTop??o,s=i.radiusBottom??o;if(a===s?(a=o,s=o):a>s?(a=o,s=s*o/a):(a=a*o/s,s=o),i.shapeBlendNode){a=e??o,s=r??o;let l=Math.max(a,s)*2;i.width=l,i.depth=l}return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:a,radiusBottom:s})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:u,cornerSegments:p,hollow:h}=n.parameters,f;l===0?(f=new wP,f.setAttribute("position",new NF([],3))):u||h?f=new du(c,d,r,i,o,a,s,l*Math.PI/180,u,u,p,h):f=new BF(c,d,r,i,o,a,s,l*Math.PI/180);let m=e/t;return m!==1&&f.scale(1,1,m),Object.assign(f,{userData:{...n,type:"CylinderGeometry"}})}};function SP(n){return new cu(n.y,-n.x)}var du=class extends wP{constructor(t,e,r,i,o,a,s,l,c,d,u,p,h=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,o=Math.floor(o)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,d=0);let f=r/2;h&&t==0&&(t=c),h&&e==0&&(e=d);let m=new cu(t,f),y=new cu(e,-f),g=null,v=null,b=null,S=null,x=m.clone().sub(y),w=0,A=0,E=0;p>0&&(w=Math.min(t,e)*(1-p),A=t-w,E=e-w);let T=m.clone();T.x-=w;let M=Math.PI-x.angle(),O=x.angle(),R=Math.tan(O/2),N=Math.tan(M/2),C=R+N,B=p?C:N,_=p?C:R;if(c=Math.min(c,(t-A)/B,x.length()/C),d=Math.min(d,(e-E)/_,x.length()/C),c>0){let se=c/R;g=m.clone().sub(new cu(se,c)),p&&(b=g.clone(),b.x-=w-C*c),m.sub(x.clone().setLength(se))}if(d>0){let se=d/N;v=y.clone().sub(new cu(se,-d)),y.add(x.clone().setLength(se)),p&&(S=v.clone(),S.x-=w-C*d,T.sub(x.clone().setLength(se)))}x=m.clone().sub(y);let F=x.length()<.5,V=[],Z=[],q=[],G=[],W=[],j=[],K=(se,ue,I,J,we)=>{for(let Ce=0;Ce<u+1;Ce++){let Pe=Ce/u,be=J<0?Pe:1-Pe;we&&(be-=1),be*=se;let Ne=Math.sin(be),Ae=Math.cos(be)*J,Re=Ae*ue+I.y;V.push(Ne*ue+I.x),Z.push(Re),q.push(Ne),G.push(Ae),W.push(.5+Re/r),j.push(!1)}},te=(se,ue,I)=>{let J=[se,ue];I<0&&J.reverse();for(let we of J)V.push(we),Z.push(f*I),q.push(0),G.push(I),W.push(.5),j.push(!0)};if(S&&v?(K(M,d,S,-1,!0),K(O,d,v,-1,!1)):v?(te(v.x,0,-1),K(O,d,v,-1,!1)):a||te(e,E,-1),!F){let se=SP(x).normalize();for(let ue=0;ue<=o;ue++){let I=ue/o,J=x.y*I+y.y;V.push(x.x*I+y.x),Z.push(J),q.push(se.x),G.push(se.y),W.push(.5+J/r),j.push(!1)}}if(b&&g?(K(M,c,g,1,!1),K(O,c,b,1,!0)):g?(K(M,c,g,1,!1),te(g.x,0,1)):a||te(t,A,1),p&&!F){let se=SP(x).multiplyScalar(-1).normalize();for(let ue=0;ue<=o;ue++){let I=ue/o,J=x.y*-I+T.y;V.push(x.x*-I+T.x),Z.push(J),q.push(se.x),G.push(se.y),W.push(.5+J/r),j.push(!1)}}let Q=V.length,re=Q+(p&&!a?1:0),ne=(se,ue)=>se*Q+(ue===Q?0:ue),de=l<Math.PI*2,ve=(i+1)*Q+(de?2*(1+re):0),me=new Float32Array(ve*3),ce=new Float32Array(ve*3),X=new Float32Array(ve*2),ee=ve-1>65535?new Uint32Array(i*Math.max(0,re-1)*6+(de?2*(re+1)*3:0)):new Uint16Array(i*Math.max(0,re-1)*6+(de?2*(re+1)*3:0)),ie=0,he=0;for(let se=0;se<=i;se++){let ue=se/i,I=ue*l+s,J=Math.sin(I),we=Math.cos(I);for(let Ce=0;Ce<Q;Ce++){let Pe=he*3,be=he*2,Ne=V[Ce],Ae=q[Ce];me[Pe]=Ne*J,me[Pe+1]=Z[Ce],me[Pe+2]=Ne*we,ce[Pe]=Ae*J,ce[Pe+1]=G[Ce],ce[Pe+2]=Ae*we,j[Ce]?(X[be]=.5,X[be+1]=.5):(X[be]=ue,X[be+1]=W[Ce]),he++}}for(let se=0;se<i;se++)for(let ue=0;ue<re-1;ue++){if(a&&p&&ue==o)continue;let I=ne(se,ue),J=ne(se+1,ue),we=ne(se+1,ue+1),Ce=ne(se,ue+1),Pe=me[we*3+0],be=me[we*3+2];ee[ie++]=I,ee[ie++]=J,ee[ie++]=Ce,(Pe!=0||be!=0)&&(ee[ie++]=J,ee[ie++]=we,ee[ie++]=Ce)}de&&(xe(-1,0,s),xe(1,i*Q,s+l)),this.setIndex(new Gf(ee.slice(0,ie),1)),this.setAttribute("position",new Gf(me,3)),this.setAttribute("normal",new Gf(ce,3)),this.setAttribute("uv",new Gf(X,2));function xe(se,ue,I){let J=Math.sin(I),we=Math.cos(I),Ce=-we,Pe=J,be=se<0?(Be,ft,Ze)=>{ee[ie++]=Be,ee[ie++]=ft,ee[ie++]=Ze}:(Be,ft,Ze)=>{ee[ie++]=Be,ee[ie++]=Ze,ee[ie++]=ft},Ne=(t+e+A+E)/4,Ae=he*3,Re=he*2;me[Ae]=Ne*J,me[Ae+1]=0,me[Ae+2]=Ne*we,ce[Ae]=Ce,ce[Ae+1]=0,ce[Ae+2]=Pe,X[Re]=.5,X[Re+1]=.5;let Xe=he++;for(let Be=0;Be<re;Be++){let ft=(ue+(Be===Q?0:Be))*3;Ae=he*3,Re=he*2,me[Ae]=me[ft],me[Ae+1]=me[ft+1],me[Ae+2]=me[ft+2],ce[Ae]=Ce,ce[Ae+1]=0,ce[Ae+2]=Pe;let Ze=ft/3*2|0;X[Re]=X[Ze],X[Re+1]=X[Ze+1],he++}for(let Be=Xe+1;Be<he-1;Be++)be(Xe,Be,Be+1);be(Xe,he-1,Xe+1)}}};var AP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,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},n.parameters);return e.thetaLength=kF.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(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:u}=n.parameters,p;l===0?(p=new LF,p.setAttribute("position",new FF([],3))):c>0||d>0||l<360?p=new du(0,t/2,r,i,o,a,s,l*Math.PI/180,c,d,u,0,!0):p=new _F(t/2,r,i,o,a);let h=e/t;return h!==1&&p.scale(1,1,h),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as VF,BufferAttribute as zf,BufferGeometry as GF,Vector3 as jf}from"three";var CP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.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(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:o,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,c;return s===0?c=new VF(t,e,r,i,o,a):c=new ux(t,e,r,i,o,a,s,l),Object.assign(c,{userData:{...n,type:"CubeGeometry"}})}},dx=Math.PI/2,ux=class extends GF{constructor(t=1,e=1,r=1,i=1,o=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",i=Math.floor(i),o=Math.floor(o),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=s>0,d=l+1,p=2*((a+1)*(o+1)+(i+1)*(a+1)+(i+1)*(o+1))+(c?d*4*(a+1+(i+1)+(o+1))+8*(d*(d+1)/2):0),h=2*(a*o+i*a+i*o)+(c?l*4*(a+i+o):0),f=c?8*l*l:0,m=new Float32Array(p*3),y=new Float32Array(p*3),g=new Float32Array(p*2),v=p-1>65535?new Uint32Array(h*6+f*3):new Uint16Array(h*6+f*3),b=0,S=0,x=new Float64Array(d),w=new Float64Array(d),A=new Float64Array(d),E=new Float64Array(d);for(let B=0;B<d;B++){let _=B/l*dx;x[B]=Math.sin(_)*s,w[B]=(1-Math.cos(_))*s,A[B]=Math.sin(_),E[B]=Math.cos(_)}let T=d*(d+1)/2,M=new Float64Array(T*3),O=new Float64Array(T*3);{let B=new jf(t/2,e/2,r/2);B.subScalar(s);let _=0;for(let F=0;F<=l;F++){let V=dx*(1-F/l),Z=Math.cos(V),q=Math.sin(V),G=0;for(let W=0;W<=F;W++){let j=Math.cos(G),K=Math.sin(G),te=Z*j,Q=q,ae=Z*K;M[_*3]=te,M[_*3+1]=Q,M[_*3+2]=ae,O[_*3]=B.x+te*s,O[_*3+1]=B.y+Q*s,O[_*3+2]=B.z+ae*s,_++,G+=dx/F}}}R("z","y","x",-1,-1,r,e,t,a,o),R("z","y","x",1,-1,r,e,-t,a,o),R("x","z","y",1,1,t,r,e,i,a),R("x","z","y",1,-1,t,r,-e,i,a),R("x","y","z",1,-1,t,e,r,i,o),R("x","y","z",-1,-1,t,e,-r,i,o),s>0&&(N("z","y","x",-1,-1,1,r,e,t,a),N("z","y","x",1,-1,-1,r,e,t,a),N("z","y","x",-1,1,-1,r,e,t,a),N("z","y","x",1,1,1,r,e,t,a),N("x","y","z",-1,-1,-1,t,e,r,i),N("x","y","z",1,-1,1,t,e,r,i),N("x","y","z",-1,1,1,t,e,r,i),N("x","y","z",1,1,-1,t,e,r,i),N("y","x","z",-1,-1,1,e,t,r,o),N("y","x","z",1,-1,-1,e,t,r,o),N("y","x","z",1,1,1,e,t,r,o),N("y","x","z",-1,1,-1,e,t,r,o),C(1,1,1),C(-1,1,1),C(1,-1,1),C(-1,-1,1),C(1,1,-1),C(-1,1,-1),C(1,-1,-1),C(-1,-1,-1)),this.setIndex(new zf(v,1)),this.setAttribute("position",new zf(m,3)),this.setAttribute("normal",new zf(y,3)),this.setAttribute("uv",new zf(g,2));function R(B,_,F,V,Z,q,G,W,j,K){let te=(q-2*s)/j,Q=(G-2*s)/K,ae=q/2-s,re=G/2-s,ne=W/2,de=j+1,ve=K+1,me=0,ce=new jf;for(let X=0;X<ve;X++){let ee=X*Q-re;for(let ie=0;ie<de;ie++){let he=ie*te-ae,xe=(b+me)*3,se=(b+me)*2;ce[B]=he*V,ce[_]=ee*Z,ce[F]=ne,m[xe]=ce.x,m[xe+1]=ce.y,m[xe+2]=ce.z,ce[B]=0,ce[_]=0,ce[F]=W>0?1:-1,y[xe]=ce.x,y[xe+1]=ce.y,y[xe+2]=ce.z,g[se]=ie/j,g[se+1]=1-X/K,me+=1}}for(let X=0;X<K;X++)for(let ee=0;ee<j;ee++){let ie=b+ee+de*X,he=b+ee+de*(X+1),xe=b+(ee+1)+de*(X+1),se=b+(ee+1)+de*X;v[S++]=ie,v[S++]=he,v[S++]=se,v[S++]=he,v[S++]=xe,v[S++]=se}b+=me}function N(B,_,F,V,Z,q,G,W,j,K){let te=(G-2*s)/K,Q=G/2-s,ae=W/2-s,re=j/2,ne=K+1,de=0,ve=new jf,me=new jf;for(let ce=0;ce<l+1;ce++){ve[_]=(ae+x[ce])*Z,ve[F]=(re-w[ce])*q,me[B]=0,me[_]=A[ce]*Math.sign(ve[_]),me[F]=E[ce]*Math.sign(ve[F]);for(let X=0;X<ne;X++){let ee=X*te-Q;ve[B]=ee*V;let ie=(b+de)*3,he=(b+de)*2;m[ie]=ve.x,m[ie+1]=ve.y,m[ie+2]=ve.z,y[ie]=me.x,y[ie+1]=me.y,y[ie+2]=me.z,g[he]=X/K,g[he+1]=0,de+=1}}for(let ce=0;ce<l;ce++)for(let X=0;X<K;X++){let ee=b+X+ne*ce,ie=b+X+ne*(ce+1),he=b+(X+1)+ne*(ce+1),xe=b+(X+1)+ne*ce;v[S++]=ee,v[S++]=ie,v[S++]=xe,v[S++]=ie,v[S++]=he,v[S++]=xe}b+=de}function C(B,_,F){let Z=B*_*F>0?(G,W,j)=>{v[S++]=G,v[S++]=W,v[S++]=j}:(G,W,j)=>{v[S++]=G,v[S++]=j,v[S++]=W},q=b;for(let G=0;G<T;G++){let W=G*3,j=b*3,K=b*2;m[j]=B*O[W],m[j+1]=_*O[W+1],m[j+2]=F*O[W+2],y[j]=B*M[W],y[j+1]=_*M[W+1],y[j+2]=F*M[W+2],g[K]=0,g[K+1]=0,b++}for(let G=0;G<l;G++){let W=q+G*(G+1)/2,j=q+(G+1)*(G+2)/2;Z(W,j+1,j);for(let K=1;K<=G;K++)Z(W+K-1,W+K,j+K),Z(W+K,j+K+1,j+K)}}}};import{BufferAttribute as px,BufferGeometry as UF,Triangle as zF,Vector3 as kn,Vector2 as hx}from"three";var xa=class extends UF{constructor(t=[],e=[],r="",i=1,o=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s,l,c,d=0;u(),p(),this.setAttribute("position",new px(new Float32Array(s.subarray(0,d)),3)),this.setAttribute("normal",new px(new Float32Array(l.subarray(0,d)),3)),this.setAttribute("uv",new px(new Float32Array(c.subarray(0,d/3*2)),2));return;function u(){o=Math.min(1-1e-5,o),o==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new kn,y=m.clone(),g=new zF,v=o*i,b=i-v,S=a+1,x=new kn,w=(X,ee)=>x.subVectors(X,ee).normalize(),A=(X,ee)=>Array(X).fill(void 0).map(ee),E=A(t.length/3,(X,ee)=>new kn().fromArray(t,ee*3).setLength(i)),T=[],M=1e6;for(let X=0;X<E.length;X++){let ee=E[X],ie=[],he,xe,se,ue=1e10,I=-1;for(;(I=e.indexOf(X,I+1))!=-1;){let Pe=I-I%3;he=e[Pe+(I+1)%3],xe=e[Pe+(I+2)%3],se=ee.distanceToSquared(E[he]),ue=Math.min(ue,se),ie.push([he,xe,se])}ue+=1e-6;let J=[],we=0,Ce=ie.length;for(let Pe=0;Pe<Ce;Pe++){[he,xe,se]=ie[we];let be=T[he]?.includes(X)==!0;se<=ue&&J.push(he+ +be*M),we=ie.findIndex(Ne=>Ne[0]==xe)}T.push(J)}let O=[];{let X=0,ee=0,ie,he,xe=f==3;for(let se=0;se<=a;se++){ie=se*(se+1)/2,he=(se+1)*(se+2)/2;for(let ue=0;ue<a-se;ue++)[X,ee]=[ie+ue+se+2,he+ue+se+3],O.push(ie,he,...xe?[ee,ie]:[X,he],ee,X),[ie,he]=[X,ee];O.push(ie,he,ie+a+2)}}let R=0;for(let X=0;X<T.length;X++)for(let ee=0;ee<f;ee++)T[X][ee]<M&&R++;let N=E.length*f*O.length*3,C=R*S*6*3,B=R*2*3*3,_=N+C+B;s=new Float64Array(_),l=new Float64Array(_),c=new Float64Array(_/3*2);let F=(X,ee,ie)=>{let he=d/3*2;c[he]=Math.atan2(ie,-X)/2/Math.PI+.5,c[he+1]=1-(Math.atan2(-ee,Math.sqrt(X*X+ie*ie))/Math.PI+.5)},V=X=>{s[d]=X.x,s[d+1]=X.y,s[d+2]=X.z,l[d]=x.x,l[d+1]=x.y,l[d+2]=x.z,F(X.x,X.y,X.z),d+=3},Z=X=>{s[d]=X[0].x,s[d+1]=X[0].y,s[d+2]=X[0].z,l[d]=X[1].x,l[d+1]=X[1].y,l[d+2]=X[1].z,F(X[0].x,X[0].y,X[0].z),d+=3},q=(a+2)*(a+3)/2,G=new Float64Array(q*3),W=new Float64Array(q*3),j=new Float64Array(q*2),K=A(f*2*S,()=>new kn),te=A(a*Math.max(0,a-1)/2,()=>new kn),Q=m.clone(),ae=m.clone(),re=m.clone(),ne=m.clone(),de=m.clone(),ve=[],me=A(E.length,()=>A(f,()=>m.clone()));for(let X=0;X<E.length;X++){m.copy(E[X]).normalize(),Q.copy(m).multiplyScalar(b);let ee=T[X];for(let J=0;J<ee.length;J++){let we=ee[J],Ce=ee[(J+1)%f];g.setFromPointsAndIndices(E,X,we%M,Ce%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(Q,me[X][J])}let ie=0,he=[],xe=[],se=new kn;a==0&&[...me[X]].reduce((J,we)=>J.add(we),se).multiplyScalar(1/f);for(let J=0;J<f;J++){let we=[],Ce=(J-1+f)%f,Pe=me[X][Ce],be=me[X][J];m.copy(Pe).sub(Q),y.copy(be).sub(Q);let Ne=Q.angleTo(m),Ae=m.angleTo(y),Re=Math.cos(Ne)*v;a==0?ae.copy(se):ae.copy(Q).setLength(b+Re),he.push(Re);let Xe=[ae,Pe,be];for(let Be=0;Be<2;Be++){let ft=Xe[Be],Ze=Xe[Be+1];ne.subVectors(ft,Q),de.subVectors(Ze,Q),re.crossVectors(ne,de).normalize();for(let es=0;es<S;es++){let Md=[Ne,Ae][Be]*es/S;m.copy(ne).applyAxisAngle(re,Md).add(Q),K[ie++].copy(m),Be&&(w(m,Q),we.push([es==0?ft:m.clone(),x.clone()]))}Be&&(w(Ze,Q),we.push([Ze,x.clone()]))}xe.push(we)}ve.push(xe);let ue=2*S,I=2;for(let J=0;J<f;J++){let we=ue*J,Ce=ue*((J+1)%f),Pe=0,be=[K[we]];for(let Ne=1;Ne<S;Ne++){let Ae=K[we+Ne],Re=K[Ce+Ne];be.push(Ae);for(let Xe=1,Be=Ne-I+1;Xe<=Be;Xe++)m.lerpVectors(Ae,Re,Xe/(Be+1)),m.sub(Q).setLength(he[J]).add(Q),be.push(te[Pe++].copy(m));be.push(Re)}for(let Ne=0;Ne<S;Ne++)be.push(K[Ne+S+we]);be.push(K[Ce+S]);for(let Ne=0,Ae=be.length;Ne<Ae;Ne++){let Re=be[Ne],Xe=Ne*3,Be=Ne*2;G[Xe]=Re.x,G[Xe+1]=Re.y,G[Xe+2]=Re.z,w(Re,Q),W[Xe]=x.x,W[Xe+1]=x.y,W[Xe+2]=x.z,j[Be]=Math.atan2(Re.z,-Re.x)/2/Math.PI+.5,j[Be+1]=1-(Math.atan2(-Re.y,Math.sqrt(Re.x*Re.x+Re.z*Re.z))/Math.PI+.5)}for(let Ne=0,Ae=O.length;Ne<Ae;Ne++){let Re=O[Ne]*3,Xe=O[Ne]*2,Be=d/3*2;s[d]=G[Re],s[d+1]=G[Re+1],s[d+2]=G[Re+2],l[d]=W[Re],l[d+1]=W[Re+1],l[d+2]=W[Re+2],c[Be]=j[Xe],c[Be+1]=j[Xe+1],d+=3}}}let ce=[];for(let X=0;X<T.length;X++)for(let ee=0;ee<f;ee++){let ie=T[X][ee];if(ie<M){let he=T[ie].findIndex(ue=>ue%M==X),xe=ve[X][ee],se=ve[ie][he];for(let ue=0;ue<S;ue++){let I=xe[ue],J=se[S-ue],we=xe[ue+1],Ce=se[S-(ue+1)];Z(I),Z(J),Z(we),Z(we),Z(J),Z(Ce)}ce.push(xe[0][0],se[S][0],xe[S][0],se[0][0])}}for(;ce.length;){let X,ee,ie,[he,xe]=ce.splice(0,2);X=xe;let se=[he];for(;he!=X;)se.push(X),ee=ce.indexOf(X),ie=ee%2,X=ce.splice(ee-ie,2)[1-ie];x.subVectors(se[0],se[1]).cross(m.subVectors(se[0],se[2])).normalize();let ue=x.dot(se[0])<0;ue&&x.negate();for(let I=1;I<=se.length-2;I++)V(se[I+ +ue]),V(se[I+1-+ue]),V(se[0])}}function p(){let h=new kn,f=new kn,m=new kn,y=new kn,g=new hx,v=new hx,b=new hx,S=(A,E,T,M)=>{M<0&&A.x===1&&(c[E]=A.x-1),T.x===0&&T.z===0&&(c[E]=M/2/Math.PI+.5)};for(let A=0,E=0;A<d;A+=9,E+=6){h.set(s[A+0],s[A+1],s[A+2]),f.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(c[E+0],c[E+1]),v.set(c[E+2],c[E+3]),b.set(c[E+4],c[E+5]),y.copy(h).add(f).add(m).divideScalar(3);let T=w(y);S(g,E+0,h,T),S(v,E+2,f,T),S(b,E+4,m,T)}let x=d/3*2;for(let A=0;A<x;A+=6){let E=c[A+0],T=c[A+2],M=c[A+4],O=Math.max(E,T,M),R=Math.min(E,T,M);O>.9&&R<.1&&(E<.2&&(c[A+0]+=1),T<.2&&(c[A+2]+=1),M<.2&&(c[A+4]+=1))}function w(A){return Math.atan2(A.z,-A.x)}}}static fromJSON(t){return new xa(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as jF}from"three";var EP=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.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(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:a}=n.parameters,s=i===0&&o!==0?new uu(t*.5,o,a):new jF(t*.5,i),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},uu=class extends xa{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=1/i,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-o,-i,0,-o,i,0,o,-i,0,o,i,-o,-i,0,-o,i,0,o,-i,0,o,i,0,-i,0,-o,i,0,-o,-i,0,o,i,0,o],s=[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(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new uu(t.radius,t.corner,t.cornerSides)}};import{Plane as ek,Shape as GP,Vector2 as Bo,Vector3 as tk,MathUtils as xx,LineCurve as fu,QuadraticBezierCurve as UP,CubicBezierCurve as Xf}from"three";import{CubicBezierCurve as Hf,EllipseCurve as HF,LineCurve as Wf,LineCurve3 as WF,MathUtils as qF,QuadraticBezierCurve as mx,SplineCurve as XF,Vector2 as Xr,Vector3 as MP}from"three";var pu=1e-12,Hl=class{constructor(t){this.position=new Xr;this.startPosition=new Xr;this.uuid=qF.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 Hl(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Wl=class extends Hl{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Wl(this.parent).copy(this)}},dn=class extends Hl{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Wl(this),new Wl(this))}static create(e,r){let i=new dn(e,new Xr(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}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 i=0,o=this.controls.length;i<o;i++){let a=this.controls[i];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.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 dn(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 Xr,r=new Xr){let[i,o]=this.computeTangents();return i&&o&&(PP(i,e),PP(o,r)),[e,r]}computeTangent(e=new Xr){let[r,i]=this.computeTangents();return r&&i&&e.copy(r).add(i).normalize(),e}computeNormal(e=new Xr){let[r,i]=this.computeNormals();return e.copy(r).add(i).normalize(),e}};function PP(n,t=new Xr){let e=n.length();return t.set(-n.y/e,n.x/e)}var yx=n=>n,ql=new Xr,qf=new Xr,YF=new Xr,QF=new Xr,KF=new Xr,ZF=new Xr,OP=new MP,IP=new MP;function DP(n){let t=new Xr;t.addVectors(n.v0,ql.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Xr;return e.addVectors(n.v2,qf.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Hf(n.v0,t,e,n.v2)}function hu(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function JF(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function $F(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function gx(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-o*o)/(2*i*r))}function RP(n,t,e){return TP(n,t)&&TP(t,e)&&fx(n.position,t.position,e.position)}function fx(n,t,e){return ql.copy(t).sub(n).cross(qf.copy(e).sub(n))===0}function BP(n,t,e,r,i){let o=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(n.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-n.x)/o;return r.set(s+l,a+c),i.set(s-l,a-c),[r,i]}function NP(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function LP(n,t,e,r,i,o){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,c=e.y-n.y,d=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),u;return gx(t,n,e)>Math.PI&&(d*=-1),hu(c,s)?u=(s+c)*(r/d-.5)*8/3/(a-l):u=(a+l)*(r/d-.5)*8/3/(c-s),i.set(t.x-u*s,t.y+u*a),o.set(e.x+u*c,e.y-u*l),[i,o]}function vx(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function TP(n,t){return fx(n.position,n.controls[1].position,t.position)&&fx(n.position,t.controls[0].position,t.position)}function _P(n,t,e,r,i=.5){let o=ql.subVectors(t,n).multiplyScalar(i).add(n),a=qf.subVectors(e,t).multiplyScalar(i).add(t),s=YF.subVectors(r,e).multiplyScalar(i).add(e),l=o,c=QF.subVectors(a,o).multiplyScalar(i).add(o),d=KF.subVectors(s,a).multiplyScalar(i).add(a),u=s,p=ZF.subVectors(d,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,p.x,p.y,d.x,d.y,u.x,u.y,r.x,r.y]}function FP(n,t,e=12,r=!0){let i=IP.set(0,0,0),o,a=0,s=[];for(let l=0;l<t.length;l++){let c=yx(t[l]),d=ql,u=Sa(c,e);s.push(u);for(let p=0;p<=u;p++)if(c instanceof Hf||c instanceof mx||c instanceof Wf){if(c.getPoint(p/u,d),i.set(d.x,d.y,0),o!==void 0&&$F(o,i))continue;o===void 0&&(o=OP),o.copy(i),n.setXYZ(a,i.x,i.y,i.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function kP(n,t,e,r=12,i=!0){let o=IP.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,d=yx(t[l]),u=ql,p=Sa(d,r);s.push(p);for(let h=0;h<=p;h++)if(d instanceof Hf||d instanceof mx||d instanceof Wf){if(d.getPoint(h/p,u),o.set(u.x,u.y,0),c?.equals(o))continue;c===void 0?c=OP:(n.setXYZ(a,c.x,c.y,c.z),a++,n.setXYZ(a,o.x,o.y,o.z),a++),c.copy(o)}}return i&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function bx(n,t=12,e=!1){let r=[];for(let i=0,o=n.length;i<o;i++){let a=n[i],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=Sa(a.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=Sa(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Sa(n[0].roundedCurveCorner,t)*.5),r}function Sa(n,t=12){return n&&n instanceof HF?t*2:n&&(n instanceof Wf||n instanceof WF)?1:n&&n instanceof XF?t*n.points.length:t}function VP(n,t,e=12,r=!0){let i,o=0;for(let a=0;a<t.length;a++){let s=yx(t[a]),l=Sa(s,e),c=ql;for(let d=0;d<=l;d++)if(s instanceof Hf||s instanceof mx||s instanceof Wf){if(s.getPoint(d/l,c),i!==void 0&&JF(i,c,pu))continue;i===void 0&&(i=qf),i.copy(c),n.push(c.x,c.y),o++}}return hu(n[0],n[n.length-2],pu)&&hu(n[1],n[n.length-1],pu)&&(n.pop(),n.pop()),r&&o>1&&!(hu(n[o-1],n[1],pu)&&hu(n[o-2],n[0],pu))&&(n.push(n[0],n[1]),o++),n}var Sx=new Bo,rk=new Bo,ik=new Bo,nk=new Bo,ok=new Bo,ak=new Bo,st=class extends GP{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new ek(new tk(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=xx.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,i){let o=new st;return o.isClosed=e.isClosed,o.points=e.points.map(a=>dn.create(a.id,a.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(a=>st.createFromState(a)),r!==void 0&&i!==void 0&&o.applySize(r,i),o.update(),o}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,i=this.points.length;r<i;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,i=this.points.findIndex(o=>o.uuid===e);if(i<0){let o=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,d=l.getPointIndexById(e);if(d<0)o+=c;else return d+o}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let i=0,o=this.shapeHoles.length;i<o;i++){let a=this.shapeHoles[i],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.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 i=0,o=this.shapeHoles.length;i<o;i++){let a=this.shapeHoles[i],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.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 i=Sx.set(e,r);for(let o=0,a=this.points.length;o<a;o++){let s=this.points[o];s.position.multiply(i),s.controls[0].position.multiply(i),s.controls[1].position.multiply(i)}for(let o=0,a=this.shapeHoles.length;o<a;o++)this.shapeHoles[o].applyScale(e,r);this._update()}createPoint(e,r=0,i=xx.generateUUID()){let o;e instanceof Bo?o=e:o=new Bo(e,r);let a=new dn(i,o);return a.roundness=this.roundness,a}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,i=this.points.length;r<i;r++){let o=this.points[r];if(o.uuid===e)return o}for(let r=0,i=this.shapeHoles.length;r<i;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}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(i=>i.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,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=i?this.roundedCurveDivisions:this.curveDivisions;return FP(e,i?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=bx(this.points,e,!1),this.roundedCurveDivisions=bx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return kP(e,this.curves,r,i,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),VP(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=Sa(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let d=o[l];if(s<i+d)return[l,(s-i+1)/d];i+=d}return[0,1]}getCurveT(e,r,i){let o=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(vx(o,a)){let u=o.position.distanceTo(a.position);return o.position.distanceTo(Sx.set(i.x,i.y))/u}let c=0;for(let u=0;u<e;u++)c+=s[u];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){vx(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 i=this.curves[this.curves.length-1];e.curveBefore=i,r.curveAfter=i;let o=i.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,i=this.points.length;r<i;r++){let o=this.points[r];if(r===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(o,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(r,i)}if(this.points.length>2){let r=0;for(let i=0,o=this.points.length;i<o;i++){let a=this.points[i],s=this.points[i-1]??this.points[this.points.length-1],l=this.points[i+1]??this.points[0],c=a.roundness,d=s&&l&&RP(s,a,l);if(!a.controlsMoved()&&c>0&&!d){let u=a.curveBefore,p=a.curveAfter;if(u===void 0||p===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=u instanceof fu?u.v1.distanceTo(u.v2):u.getLength(),y=p instanceof fu?p.v1.distanceTo(p.v2):p.getLength(),g=Math.min(c,m*.499),v=Math.min(c,y*.499),b=Math.min(g,v),S=1-b/m,x=b/y,w=u.getPointAt(S,Sx),A=p.getPointAt(x,rk);this._subSplitCurve(u,h,S,w,void 0),this._subSplitCurve(p,f,x,void 0,A);let E;if(this.useCubicForRoundedCorners){let T=gx(w,a.position,A)/2,M=Math.tan(T)*w.distanceTo(a.position),[O,R]=BP(w,A,M,ik,nk),N=NP(O,R,a.position),[C,B]=LP(N,w,A,M,ok,ak);E=new Xf(w.clone(),C.clone(),B.clone(),A.clone())}else E=new UP(w.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=E,this.roundedCurves.splice(i+r,0,E),r++}}}}_subSplitCurve(e,r,i,o,a){if(e instanceof fu)o!==void 0&&r.v2.copy(o),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(i,0),d=_P(s.v0,s.v1,s.v2,s.v3,c);return o!==void 0&&(l.v0.set(d[0],d[1]),l.v1.set(d[2],d[3]),l.v2.set(d[4],d[5]),l.v3.set(d[6],d[7])),a!==void 0&&(l.v0.set(d[6],d[7]),l.v1.set(d[8],d[9]),l.v2.set(d[10],d[11]),l.v3.set(d[12],d[13])),l}return r}clone(){let e=new st(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 i=0;i<r;i++){let o=i*7,a=e.points[o+0],s=e.points[o+1],l=e.points[o+2],c=e.points[o+3],d=e.points[o+4],u=e.points[o+5],p=e.points[o+6],h=new dn(xx.generateUUID(),new Bo(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(d,u),h.roundness=p,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let o=new st;return o.fromJSON(i),o}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let i=(a,s)=>{s instanceof Xf&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},o=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof UP&&(a[l]=DP(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],h=l>0?a[l-1]:null,f;p instanceof Xf?(f=this.createPoint(p.v0),f.controls[1].position.copy(p.v1)):p instanceof fu&&(f=this.createPoint(p.v1)),f!==void 0&&(h!==null&&i(f,h),s.push(f))}let d=a[a.length-1],u=!1;return d instanceof Xf?d.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(d.v2),u=!0):d instanceof fu&&d.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=o(e.curves),e instanceof GP&&(this.shapeHoles=e.holes.map(a=>{let s=new st;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let i=this.getPointByUuid(e);i&&(r.position!==void 0&&i.position.fromArray(r.position),r.roundness!==void 0&&(i.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let o=this.getPointByUuid(e)?.controls[0];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let o=this.getPointByUuid(e)?.controls[1];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}};var Ax=Math.PI*2;function wx({x:n,y:t},e,r,i,o){return{x:n*e+i,y:t*r+o}}function sk(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),o=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:o+a*e,y:a-o*e},{x:o,y:a}]}function zP(n,t,e,r){let i=n*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(o)}function lk(n,t,e,r,i,o,a,s,l,c){let d=Math.pow(i,2),u=Math.pow(o,2),p=Math.pow(a,2),h=Math.pow(s,2),f=d*u-d*h-u*p;f<0&&(f=0),f/=d*h+u*p,f=Math.sqrt(f)*(l===c?-1:1);let m=f*i/o*s,y=f*-o/i*a,g=m+(n+e)/2,v=y+(t+r)/2,b=(a-m)/i,S=(s-y)/o,x=(-a-m)/i,w=(-s-y)/o,A=zP(1,0,b,S),E=zP(b,S,x,w);return!c&&E>0&&(E-=Ax),c&&E<0&&(E+=Ax),{centerx:g,centery:v,ang1:A,ang2:E}}function jP({px:n,py:t,cx:e,cy:r,rx:i,ry:o,largeArcFlag:a,sweepFlag:s}){let l=[];if(i===0||o===0)return[];let c=(n-e)/2,d=(t-r)/2;if(c===0&&d===0)return[];i=Math.abs(i),o=Math.abs(o);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(d,2)/Math.pow(o,2);u>1&&(i*=Math.sqrt(u),o*=Math.sqrt(u));let p=lk(n,t,e,r,i,o,c,d,a,s),{ang1:h,ang2:f}=p,{centerx:m,centery:y}=p,g=Math.abs(f)/(Ax/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let b=0;b<v;b++)l.push(sk(h,f)),h+=f;return l.map(b=>{let{x:S,y:x}=wx(b[0],i,o,m,y),{x:w,y:A}=wx(b[1],i,o,m,y),{x:E,y:T}=wx(b[2],i,o,m,y);return{x1:S,y1:x,x2:w,y2:A,x:E,y:T}})}import{BufferAttribute as Jf,BufferGeometry as bk}from"three";var rt;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(rt||(rt={}));var Yt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Yt||(Yt={}));function _e(n,t){if(!n)throw t||"Assertion Failed!"}var Ie=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){_e(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?i<o?e.t-t.t+(t.t-r.t)*(i/(i+o)):e.t-r.t+(r.t-t.t)*(o/(i+o)):0},n.edgeSign=function(t,e,r){_e(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?(e.t-r.t)*i+(e.t-t.t)*o:0},n.transEval=function(t,e,r){_e(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?i<o?e.s-t.s+(t.s-r.s)*(i/(i+o)):e.s-r.s+(r.s-t.s)*(o/(i+o)):0},n.transSign=function(t,e,r){_e(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?(e.s-r.s)*i+(e.s-t.s)*o:0},n.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},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,o){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,i),a+s<0&&(a=-a,s=-s),o.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,i,e),a+s<0&&(a=-a,s=-s),o.s=n.interpolate(a,r.s,s,i.s)):o.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(a=n.transEval(t,r,e),s=n.transEval(r,e,i),a+s<0&&(a=-a,s=-s),o.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,i,e),a+s<0&&(a=-a,s=-s),o.t=n.interpolate(a,r.t,s,i.t)):o.t=(r.t+e.t)/2},n}(),mu=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Yf=function(){function n(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(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Xl=function(){function n(){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 n}(),HP=function(){function n(){var t=new Xl,e=new mu,r=new Yf(0),i=new Yf(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Yf(0),r=new Yf(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.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},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;_e(i,"Vertex can't be null!");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e;var a=e;do a.Org=i,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;_e(i,"Face can't be null");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var a=e;do a.Lface=i,a=a.Lnext;while(a!==e)},n.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},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},n.prototype.makeEdge=function(){var t=new Xl,e=new Xl,r=new mu,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var o=new Xl;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var a=new mu;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.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 i=new mu;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Xl;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.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},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),o=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(o,e),i.Org=t.Dst,o.Org=e.Org,i.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var a=new mu;this.makeFace_(a,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,o,a,s;i=e.Lnext;do r=i,i=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)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,o,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;i=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),s+l-2<=t&&Ie.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&Ie.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(i=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===a);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,o,a,s,l,c;for(o=t,o=t;(i=o.next)!==t;o=i){_e(i.prev===o),l=i.anEdge;do _e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l),_e(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(_e(i.prev===o&&i.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){_e(a.prev===s),l=a.anEdge;do _e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l),_e(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(_e(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)_e(l.Sym.next===c.Sym),_e(l.Sym!==l),_e(l.Sym.Sym===l),_e(l.Org!==null),_e(l.Dst!==null),_e(l.Lnext.Onext.Sym===l),_e(l.Onext.Sym.Lnext===l);_e(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),WP=function(){function n(){this.handle=null}return n}(),qP=function(){function n(){this.key=null,this.node=0}return n}(),ck=function(){function n(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 WP,this.handles[r]=new qP;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,o,a;for(i=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,_e(a<=this.max),o=e[a].handle,a>this.size||this.leq(r[i].key,r[o].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,o,a;for(i=e[t].handle;;){if(a=t>>1,o=e[a].handle,a===0||this.leq(r[o].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,o;for(o=this.nodes.length,this.nodes.length=this.max+1,i=o;i<this.nodes.length;i++)this.nodes[i]=new WP;for(o=this.handles.length,this.handles.length=this.max+1,i=o;i<this.handles.length;i++)this.handles[i]=new qP}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},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=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)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;_e(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),Cx=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),XP=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),dk=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new XP,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.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},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new XP;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),uk=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,o=e.eUp,a=r.eUp;if(o.Dst===i)return a.Dst===i?Ie.vertLeq(o.Org,a.Org)?Ie.edgeSign(a.Dst,o.Org,a.Org)<=0:Ie.edgeSign(o.Dst,a.Org,o.Org)>=0:Ie.edgeSign(a.Dst,i,a.Org)<=0;if(a.Dst===i)return Ie.edgeSign(o.Dst,i,o.Org)>=0;var s=Ie.edgeEval(o.Dst,i,o.Org),l=Ie.edgeEval(a.Dst,i,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&_e(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){_e(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new Cx;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case rt.ODD:return(e&1)!==0;case rt.NONZERO:return e!==0;case rt.POSITIVE:return e>0;case rt.NEGATIVE:return e<0;case rt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,o=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,o=n.regionBelow(a),i=o.eUp,i.Org!=s.Org){if(!o.fixUpperEdge){n.finishRegion(t,a);break}i=t.mesh.connect(s.Lprev,i.Sym),n.fixUpperEdge(t,o,i)}s.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(s,i)),n.finishRegion(t,a),s=o.eUp,a=o}return s},n.addRightEdges=function(t,e,r,i,o,a){var s,l,c,d,u=!0;c=r;do _e(Ie.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(o===null&&(o=n.regionBelow(e).eUp.Rprev),l=e,d=o;s=n.regionBelow(l),c=s.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(d.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!u&&n.checkForRightSplice(t,l)&&(n.addWinding(c,d),n.deleteRegion(t,l),t.mesh.delete(d)),u=!1,l=s,d=c;l.dirty=!0,_e(l.windingNumber-c.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=Ie.vertL1dist(e,t),o=Ie.vertL1dist(r,t),a=.5*o/(i+o),s=.5*i/(i+o);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},n.getIntersectData=function(t,e,r,i,o,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,o,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp;if(Ie.vertLeq(i.Org,o.Org)){if(Ie.edgeSign(o.Dst,i.Org,o.Org)>0)return!1;Ie.vertEq(i.Org,o.Org)?i.Org!==o.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,o.Oprev,i)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(i,o.Oprev),e.dirty=r.dirty=!0)}else{if(Ie.edgeSign(i.Dst,o.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,a;if(_e(!Ie.vertEq(i.Dst,o.Dst)),Ie.vertLeq(i.Dst,o.Dst)){if(Ie.edgeSign(i.Dst,o.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Sym,a),a.Lface.inside=e.inside}else{if(Ie.edgeSign(o.Dst,i.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Lnext,o.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,a=i.Org,s=o.Org,l=i.Dst,c=o.Dst,d,u,p=new Xl,h,f;if(_e(!Ie.vertEq(c,l)),_e(Ie.edgeSign(l,t.event,a)<=0),_e(Ie.edgeSign(c,t.event,s)>=0),_e(a!==t.event&&s!==t.event),_e(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(d=Math.min(a.t,l.t),u=Math.max(s.t,c.t),d>u))return!1;if(Ie.vertLeq(a,s)){if(Ie.edgeSign(c,a,s)>0)return!1}else if(Ie.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),Ie.intersect(l,a,c,s,p),_e(Math.min(a.t,l.t)<=p.t),_e(p.t<=Math.max(s.t,c.t)),_e(Math.min(c.s,l.s)<=p.s),_e(p.s<=Math.max(s.s,a.s)),Ie.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),h=Ie.vertLeq(a,s)?a:s,Ie.vertLeq(h,p)&&(p.s=h.s,p.t=h.t),Ie.vertEq(p,a)||Ie.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!Ie.vertEq(l,t.event)&&Ie.edgeSign(l,t.event,p)>=0||!Ie.vertEq(c,t.event)&&Ie.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Lnext,o.Oprev),r=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,o.Onext,i.Rprev,f,!0),!0):(Ie.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),Ie.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,i),i.Org.s=p.s,i.Org.t=p.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,a,l,s,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,o;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,o=r.eUp,i.Dst!==o.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(o),r=n.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==o.Org)if(i.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||o.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===o.Org&&i.Dst===o.Dst&&(n.addWinding(o,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,o=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),Ie.vertEq(s.Org,t.event)&&(t.mesh.splice(o.Oprev,s),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),c=!0),Ie.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),c=!0),c){n.addRightEdges(t,e,r.Onext,o,o,!0);return}Ie.vertLeq(l.Org,s.Org)?i=l.Oprev:i=s,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,o,a,s,l;if(i=e.eUp,Ie.vertEq(i.Org,r)){_e(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!Ie.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}_e(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,o=s=a.Onext,l.fixUpperEdge&&(_e(o!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=o.Oprev),t.mesh.splice(r.anEdge,a),Ie.edgeGoesLeft(o)||(o=null),n.addRightEdges(t,e,a.Onext,s,o,!0)},n.connectLeftVertex=function(t,e){var r,i,o,a,s,l,c=new Cx;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(a=r.eUp,s=i.eUp,Ie.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(o=Ie.vertLeq(s.Dst,a.Dst)?r:i,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(s.Dnext,e.anEdge);l=d.Sym}o.fixUpperEdge?n.fixUpperEdge(t,o,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);_e(i!==null);var o=n.regionBelow(i),a=o.eUp,s=n.finishLeftRegions(t,o,null);s.Onext===a?n.connectRightVertex(t,i,s):n.addRightEdges(t,i,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,i){var o=new Cx,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=i,a.Dst.s=e,a.Dst.t=i,t.event=a.Dst,o.eUp=a,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},n.initEdgeDict=function(t){t.dict=new dk(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,o=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,i,o,a),n.addSentinel(t,i,o,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(_e(e.fixUpperEdge),_e(++r===1)),_e(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,i=e.Lnext,Ie.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,o=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)o++;for(o+=8,e=t.pq=new ck(o,Ie.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,o;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,o=r.anEdge,_e(o.Lnext!==o),o.Lnext.Lnext===o&&(n.addWinding(o.Onext,o),t.mesh.delete(o));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!Ie.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),pk=function(){function n(){this.mesh=new HP,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=rt.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 n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.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},n.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},n.prototype.computeNormal_=function(t){var e,r,i,o,a,s,l=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)o=e.coords[y],c[y]=o,f[y]=e,l[y]=o,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)o=e.coords[g],o<c[g]&&(c[g]=o,f[g]=e),o>l[g]&&(l[g]=o,h[g]=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(s=0,r=f[v],i=h[v],d[0]=r.coords[0]-i.coords[0],d[1]=r.coords[1]-i.coords[1],d[2]=r.coords[2]-i.coords[2],e=m.next;e!==m;e=e.next)u[0]=e.coords[0]-i.coords[0],u[1]=e.coords[1]-i.coords[1],u[2]=e.coords[2]-i.coords[2],p[0]=d[1]*u[2]-d[2]*u[1],p[1]=d[2]*u[0]-d[0]*u[2],p[2]=d[0]*u[1]-d[1]*u[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,o=0,a=t.next;a!==t;a=a.next)if(i=a.anEdge,!(i.winding<=0))do o+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==a.anEdge);if(o<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]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,o=!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),o=!0),r=this.sUnit,i=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,i[a]=0,i[(a+1)%3]=0,i[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,i);o&&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))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Ie.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ie.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(var o=void 0;r.Lnext!==i;)if(Ie.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(Ie.edgeGoesLeft(i.Lnext)||Ie.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)o=t.connect(i.Lnext,i),i=o.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(Ie.edgeGoesRight(r.Lprev)||Ie.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)o=t.connect(i.Lnext,i),i=o.Sym;return!0},n.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},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,o=t.eHead.next;o!==t.eHead;o=i)i=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var o,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=s,s++),l++,o=o.Lnext}while(o!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,e===Yt.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*i,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;this.elements[p++]=c.n,l++,o=o.Lnext}while(o!==d.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1;if(e===Yt.CONNECTED_POLYGONS){o=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==d.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,o=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){i=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;o=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,i=r=s.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,a++,r=r.Lnext;while(r!==i);this.elements[d++]=o,this.elements[d++]=a,o+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new HP),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=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[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,o,a){if(t===void 0&&(t=rt.ODD),e===void 0&&(e=Yt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),uk.computeInterior(this,a);var s=this.mesh;return e===Yt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===Yt.BOUNDARY_CONTOURS?this.outputContours_(s,i):this.outputPolymesh_(s,e,r,i),!0},n}();function un(n){var t=n.windingRule,e=t===void 0?rt.ODD:t,r=n.elementType,i=r===void 0?Yt.POLYGONS:r,o=n.polySize,a=o===void 0?3:o,s=n.vertexSize,l=s===void 0?2:s,c=n.normal,d=c===void 0?[0,0,1]:c,u=n.contours,p=u===void 0?[]:u,h=n.strict,f=h===void 0?!0:h,m=n.debug,y=m===void 0?!1:m;if(!p&&f)throw new Error("Contours can't be empty");if(!!p){var g=new pk;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(l||2,p[v]);return g.tesselate(e,i,a,l,d,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var gee=rt.ODD,vee=rt.NONZERO,bee=rt.POSITIVE,xee=rt.NEGATIVE,See=rt.ABS_GEQ_TWO,wee=Yt.POLYGONS,Aee=Yt.CONNECTED_POLYGONS,Cee=Yt.BOUNDARY_CONTOURS;import{Box2 as yk,BufferAttribute as Zf,BufferGeometry as gk,Vector2 as vk}from"three";var Qf=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*Qf.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Qf.eSize,i=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(i,a*o,3*t);a+=3*t;let l=new Float32Array(i,a*o,3*t);a+=3*t;let c=new Float32Array(i,a*o,2*t);e?(s.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))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=i,this.positions=s,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let 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)}},yu=Qf;yu.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var gu=class{constructor(t=[],e=(r,i)=>r<i?-1:r>i?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,i=e[t];for(;t>0;){let o=t-1>>1,a=e[o];if(r(i,a)>=0)break;e[t]=a,t=o}e[t]=i}_down(t){let{data:e,compare:r}=this,i=this.length>>1,o=e[t];for(;t<i;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],o)>=0)break;e[t]=e[a],t=a}e[t]=o}};function Ex(n,t,e=1,r=!1){let i=1/0,o=1/0,a=-1/0,s=-1/0;for(let[v,b]of n[0])v<i&&(i=v),b<o&&(o=b),v>a&&(a=v),b>s&&(s=b);let l=a-i,c=s-o,d=Math.max(e,Math.min(l,c));if(d===e){let v=[i,o];return v.distance=0,v.distance}let u=new gu([],(v,b)=>b.max-v.max),p=fk(n),h=new Kf(i+l/2,o+c/2,0,n);h.d>p.d&&(p=h);let f=2;function m(v,b,S){let x=new Kf(v,b,S,n);if(f++,x.max>p.d+e&&u.push(x),x.d>p.d&&(p=x,r&&console.log(`found best ${Math.round(1e4*x.d)/1e4} after ${f} probes`),p.d>t))return t}let y=d/2;for(let v=i;v<a;v+=d)for(let b=o;b<s;b+=d)m(v+y,b+y,y);for(;u.length;){let{max:v,x:b,y:S,h:x}=u.pop();if(v-p.d<=e)break;y=x/2,m(b-y,S-y,y),m(b+y,S-y,y),m(b-y,S+y,y),m(b+y,S+y,y)}r&&console.log(`num probes: ${f}
727
727
  best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}function Kf(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=hk(n,t,r),this.max=this.d+this.h*Math.SQRT2}function hk(n,t,e){let r=!1,i=1/0;for(let o of e)for(let a=0,s=o.length,l=s-1;a<s;l=a++){let c=o[a],d=o[l];c[1]>t!=d[1]>t&&n<(d[0]-c[0])*(t-c[1])/(d[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,mk(n,t,c,d))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function fk(n){let t=0,e=0,r=0,i=n[0];for(let a=0,s=i.length,l=s-1;a<s;l=a++){let c=i[a],d=i[l],u=c[0]*d[1]-d[0]*c[1];e+=(c[0]+d[0])*u,r+=(c[1]+d[1])*u,t+=u*3}let o=new Kf(e/t,r/t,0,n);return t===0||o.d<0?new Kf(i[0][0],i[0][1],0,n):o}function mk(n,t,e,r){let i=e[0],o=e[1],a=r[0]-i,s=r[1]-o;if(a!==0||s!==0){let l=((n-i)*a+(t-o)*s)/(a*a+s*s);l>1?(i=r[0],o=r[1]):l>0&&(i+=a*l,o+=s*l)}return a=n-i,s=t-o,a*a+s*s}var vu={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Tx={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Mx={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},Px=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),wa=class extends gk{constructor(e,r,i=0,o=12,a=3,s=rt.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=o,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],o),d=this._shape.shapeHoles.map(O=>{let R=O.extractShapePointsToFlatArray([],o),N=[];for(let C=R.length-1;C>=1;C-=2){let B=R[C-1],_=R[C-0];N.push(B,_)}return N}),u=[],p=[];for(let O=0;O<c.length;O+=2)p.push([c[O],c[O+1]]);u.push(p);for(let O=0;O<d.length;O++){let R=d[O],N=[];for(let C=0;C<R.length;C+=2)N.push([R[C],R[C+1]]);u.push(N)}let h;e.isText?h=new yk().setFromPoints(e.points.map(R=>R.position)).getSize(new vk).length()*.1:u[0].length===0?h=i:i>0?h=Ex(u,i):h=1e-5,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,h,r/2),this._bevelSegments=Math.floor(a));let f;try{f=un({windingRule:s,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{f=vu}let m;try{m=un({windingRule:rt.ODD,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...d]})}catch{m=Tx}if(!f)throw new Error("error generating geometry");let y=f.elementCount;if(m){f.elementCount+=m.elementCount;for(let O=0;O<m.elements.length;O++){let R=m.elements[O],N=O%2===0?f.vertexCount:0;f.elements.push(R+N)}for(let O=0;O<m.vertexIndices.length;O++){let R=m.vertexIndices[O],N=f.vertexCount;f.vertexIndices.push(R+N)}for(let O=0;O<m.vertices.length;O++){let R=m.vertices[O];f.vertices.push(R)}}let g=1/0,v=-1/0,b=1/0,S=-1/0;for(let O=0,R=f.vertexCount;O<R;O++){let N=O*2,C=f.vertices[N+0],B=f.vertices[N+1];C<g&&(g=C),C>v&&(v=C),B<b&&(b=B),B>S&&(S=B)}this._minX=g,this._minY=b,this._width=v-g,this._height=S-b,this._buffer=new yu(this._computeBufferEstimatedSize(f));let x=[],w=[];for(let O=f.elementCount-1;O>=0;O--){let R=O>=y,N=O*2,C=f.elements[N+0],B=f.elements[N+1],_=C+B,F={start:C,count:B,normals:[],continuous:[],concave:[]},V=C,Z=_-1,q=C+1,G=this._shape.roundedCurves.length;do{let Q=V-C,ae=f.vertices[Z*2+0],re=f.vertices[Z*2+1],ne=f.vertices[V*2+0],de=f.vertices[V*2+1],ve=f.vertices[q*2+0],me=f.vertices[q*2+1],ce=ne-ae,X=de-re,ee=Math.sqrt(ce*ce+X*X);ce/=ee,X/=ee;let ie=ne-ve,he=de-me,xe=Math.sqrt(ie*ie+he*he);ie/=xe,he/=xe,F.normals[Q*2+0]=-he,F.normals[Q*2+1]=ie,F.concave[Q]=ce*he-X*ie>0;let se=f.vertexIndices[V];if(Array.isArray(se))F.continuous[Q]=!1;else{let[ue,I]=this._shape.getCurveIndexFromVertexId(se-1,!0);if(I>0&&I<1)F.continuous[Q]=!0;else{let J=I===1?ue+1:ue-1;J=(J+G)%G;let we=I===1?0:1,Ce=this._shape.roundedCurves[ue].getTangent(I),Pe=this._shape.roundedCurves[J].getTangent(we);F.continuous[Q]=Ce.dot(Pe)>.95}}R&&(F.normals[Q*2+0]*=-1,F.normals[Q*2+1]*=-1),[Z,V,q]=[V,q,q+1],q>=_&&(q-=B)}while(q!==C+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:f.vertices.slice(C*2,_*2),vertexCount:B,vertexIndices:new Array(B).fill(!0).map((Q,ae)=>[ae,ae]),elements:[0,B],elementCount:1,mesh:null},reverseMap:[],insetPoints:f.vertices.slice(C*2,_*2)});let j=0;for(let Q=1;Q<=this._bevelSegments;Q++){let ae=Q/this._bevelSegments*Math.PI/2,re=(1-Math.cos(ae))*this._bevel,ne=[],de=[],ve=[],me=[],ce=0;for(let ee=0;ee<B;ee++){let ie=ee*2,he=(ee-1+B)%B*2,xe=f.vertices[F.start*2+ie+0],se=f.vertices[F.start*2+ie+1],ue=-F.normals[he+0]*re,I=-F.normals[he+1]*re,J=-F.normals[ie+0]*re,we=-F.normals[ie+1]*re;if(F.concave[ee]||!F.concave[ee]&&R){let Ce=Math.atan2(I,ue),Pe=Math.atan2(we,J);Pe>Ce&&(Pe-=Math.PI*2);let be=Pe-Ce;if(F.continuous[ee]||R){let Ne=Ce+be/2,Ae=Math.cos(Ne)*re,Re=Math.sin(Ne)*re;ne[2*ce+0]=xe+Ae*(R?-1:1),ne[2*ce+1]=se+Re*(R?-1:1),me[ce]=ee,ce++}else{let Ne=Math.max(1,Math.floor(o/4*Math.abs(be)/Math.PI));for(let Ae=0;Ae<=Ne;Ae++){let Re=Ce+be*(Ae/Ne),Xe=Math.cos(Re)*re,Be=Math.sin(Re)*re;ne[2*ce+0]=xe+Xe,ne[2*ce+1]=se+Be,me[ce]=ee,ce++}}}else ne[2*ce+0]=xe+ue,ne[2*ce+1]=se+I,me[ce]=ee,de[ee]=ce,ce++,ne[2*ce+0]=xe,ne[2*ce+1]=se,me[ce]=ee,ce++,ne[2*ce+0]=xe+J,ne[2*ce+1]=se+we,me[ce]=ee,ve[ee]=ce,ce++}let X=un({windingRule:rt.POSITIVE,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ne],edgeCreateCallback:ee=>{let he=ee.Org.idx,xe=me[he],se=me[(he+1)%me.length];ee.idx=[xe,se],ee.Sym.idx=[se,xe]},vertexIdCallback:ee=>{let ie=ee.Lprev.idx;return[ie?ie[1]:0,ee.idx?ee.idx[0]:0]}});if(!X)throw console.log("Error"),new Error(`error generating bevel geometry for ${Q}'th loop`);if(!X.vertexCount){let ee=(Q-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(ee))*this._bevel;break}for(let ee=0;ee<X.vertexIndices.length;ee++){let[ie,he]=X.vertexIndices[ee];if(ie===he)continue;let xe=he;he<ie&&(xe+=B);for(let se=ie;se<xe;se++){let ue=se%B,I=(se+1)%B;if(!F.continuous[ue]||!F.continuous[I]){X.vertexIndices[ee]=[ie,ue],X.vertexIndices.splice(ee+1,0,[I,he]),X.vertices.splice((ee+1)*2,0,X.vertices[ee*2],X.vertices[ee*2+1]);break}}}W.push({bevelI:Q,angle:ae,size:re,boundary:X,reverseMap:me,insetPoints:ne})}let K=(Q,ae,re)=>{let ne=0,de=Q.boundary.vertexIndices.length;for(;ne<de&&re(Q.boundary.vertexIndices[ae]);)ae=(ae+1)%de,ne++;return ne},te=x.length;for(let Q=1;Q<W.length;Q++){let ae=W[Q-1],re=W[Q],ne=ae.boundary.vertexIndices.length,de=re.boundary.vertexIndices.length;if(!ne||!de)break;let ve=F.concave.length,me=0,ce=Px(me,B);for(;!ae.boundary.vertexIndices.filter(ce).length||!re.boundary.vertexIndices.filter(ce).length;)me++,ce=Px(me,B);let X=ae.boundary.vertexIndices.findIndex(ce),ee=re.boundary.vertexIndices.findIndex(ce);do X=(X+1)%ne;while(ce(ae.boundary.vertexIndices[X]));do ee=(ee+1)%de;while(ce(re.boundary.vertexIndices[ee]));me=(me+1)%B;let ie=me,he=0,xe=this._buildBevelVert(F,ae,(X-1+ne)%ne,void 0,he),se=this._buildBevelVert(F,re,(ee-1+de)%de,void 0,he),ue=xe,I=se,J,we,Ce=!1;do{he=(me||ve)/ve,ce=Px(me,B);let Pe=K(ae,X,ce),be=K(re,ee,ce),Ne=Ce;if(Ce=!1,Pe&&!be){for(let Ae=0;Ae<Pe;Ae++)J=this._buildBevelVert(F,ae,(X+Ae)%ne,Ae/(Pe-1),he),x.push(ue.topN,J.topP,I.topN),l===!1&&x.push(J.bottomP,ue.bottomN,I.bottomN),ue=J;Ce=!0}else if(!Pe&&be)for(let Ae=0;Ae<be;Ae++)we=this._buildBevelVert(F,re,(ee+Ae)%de,Ae/(be-1),he),x.push(I.topN,ue.topP,we.topP),l===!1&&x.push(ue.bottomP,I.bottomN,we.bottomP),I=we;else if(Pe&&be)if(J=this._buildBevelVert(F,ae,X,0,he),we=this._buildBevelVert(F,re,ee,0,he),Ne?(x.push(ue.topN,we.topP,I.topN),x.push(ue.topN,J.topP,we.topP),l===!1&&(x.push(we.bottomP,ue.bottomN,I.bottomN),x.push(we.bottomP,J.bottomP,ue.bottomN))):(x.push(I.topN,ue.topN,J.topP),x.push(I.topN,J.topP,we.topP),l===!1&&(x.push(J.bottomP,ue.bottomN,I.bottomN),x.push(J.bottomP,I.bottomN,we.bottomP))),ue=J,I=we,Pe===be)for(let Ae=1;Ae<Pe;Ae++)J=this._buildBevelVert(F,ae,(X+Ae)%ne,Ae/(Pe-1),he),we=this._buildBevelVert(F,re,(ee+Ae)%de,Ae/(be-1),he),x.push(ue.topN,J.topP,I.topN),x.push(I.topN,J.topP,we.topP),l===!1&&(x.push(J.bottomP,ue.bottomN,I.bottomN),x.push(J.bottomP,I.bottomN,we.bottomP)),ue=J,I=we;else if(Pe>be){let Ae=Pe/be,Re=0;for(let Xe=1;Xe<Pe;Xe++)J=this._buildBevelVert(F,ae,(X+Xe)%ne,Xe/(Pe-1),he),x.push(ue.topN,J.topP,I.topN),l===!1&&x.push(J.bottomP,ue.bottomN,I.bottomN),ue=J,Xe>(Re+1)*Ae&&(Re++,we=this._buildBevelVert(F,re,(ee+Re)%de,Re/(be-1),he),x.push(I.topN,J.topP,we.topP),l===!1&&x.push(J.bottomP,I.bottomN,we.bottomP),I=we)}else{let Ae=be/Pe,Re=0;for(let Xe=1;Xe<be;Xe++)we=this._buildBevelVert(F,re,(ee+Xe)%de,Xe/(be-1),he),x.push(I.topN,J.topP,we.topP),l===!1&&x.push(J.bottomP,I.bottomN,we.bottomP),I=we,Xe>(Re+1)*Ae&&(Re++,J=this._buildBevelVert(F,ae,(X+Re)%ne,Re/(Pe-1),he),x.push(ue.topN,J.topP,I.topN),l===!1&&x.push(J.bottomP,ue.bottomN,I.bottomN),ue=J)}X=(X+Pe)%ne,ee=(ee+be)%de,me=(me+1)%ve}while(me!==ie)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,F,x),R){let Q=[];for(let ae=x.length-1;ae>=te+2;ae-=3){let re=x[ae-2],ne=x[ae-1],de=x[ae-0];Q.push(de,ne,re)}x.splice(te,x.length-te,...Q)}if(R){let Q=[];for(let ae=W[W.length-1].boundary.vertices.length-1;ae>=1;ae-=2){let re=W[W.length-1].boundary.vertices[ae-1],ne=W[W.length-1].boundary.vertices[ae-0];Q.push(re,ne)}w.push(Q)}if(!R){let Q=W[W.length-1],ae;try{ae=un({windingRule:W.length>1?rt.POSITIVE:rt.ODD,elementType:Yt.POLYGONS,vertexSize:2,strict:!0,contours:[Q.insetPoints,...w]})}catch{ae=Mx}if(!ae)throw new Error("Error generating geometry for surface");d.length===0&&this._bevel<h&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let re=0;re<ae.elementCount*3;re+=3){let ne=this._buildSurfaceVert(ae,ae.elements[re+0],j),de=this._buildSurfaceVert(ae,ae.elements[re+1],j),ve=this._buildSurfaceVert(ae,ae.elements[re+2],j);x.push(ne.top,de.top,ve.top),l===!1&&x.push(ve.bottom,de.bottom,ne.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new Zf(Uint32Array.from(x),1),E=new Zf(this._buffer.positions,3),T=new Zf(this._buffer.normals,3),M=new Zf(this._buffer.uvs,2);E.needsUpdate=!0,T.needsUpdate=!0,M.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",E),this.setAttribute("normal",T),this.setAttribute("uv",M),this.setIndex(A)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let o=e[0];for(let a=0,s=o.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,o,a),c=this._buildBevelVert(r,o,(a+1)%s);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,i){let o=r.toString();if(o in this.vertexCache)return this.vertexCache[o];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let d=this._buffer.get(this.forPathBevel?1:2),u=d*3,p=d*2,h={top:d+0,bottom:d+1};return this._buffer.positions[u+0]=a,this._buffer.positions[u+1]=s,this._buffer.positions[u+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[u+0]=0,this._buffer.normals[u+1]=0,this._buffer.normals[u+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=c,this.forPathBevel===!1&&(this._buffer.positions[u+3]=a,this._buffer.positions[u+4]=s,this._buffer.positions[u+5]=i,this._buffer.normals[u+3]=0,this._buffer.normals[u+4]=0,this._buffer.normals[u+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+3]=c),this.vertexCache[o]=h,h}_buildBevelVert(e,r,i,o=1,a){let s=`${r.bevelI}:${i}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=r.boundary.vertexIndices[i],d,u,p,h;l!==c?(u=l,d=c,h=!1,p=e.continuous[u]&&e.continuous[d]):(d=l,u=(d-1+e.count)%e.count,h=e.concave[d]&&r.bevelI>0,p=e.continuous[d]||h);let f=Math.cos(r.angle),m=Math.sin(r.angle),y=i*2,g=d*2,v=u*2,b=r.boundary.vertices[y+0],S=r.boundary.vertices[y+1],x=(1-m)*this._bevel,w=(b-this._minX)/this._width,A=(S-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(w=a),A=1);let E=e.normals[g+0],T=e.normals[g+1],M=e.normals[v+0],O=e.normals[v+1];if(h){let _=M-E,F=O-T;E=E+_*(1-o),T=T+F*(1-o);let V=Math.sqrt(E*E+T*T);E/=V,T/=V}let R=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),N=R*3,C=R*2,B={i,fi:d,topP:R+0,topN:R+0,bottomP:R+1,bottomN:R+1,pathBevelUCoord:a};return this._buffer.positions[N+0]=b,this._buffer.positions[N+1]=S,this._buffer.positions[N+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[N+0]=E*f,this._buffer.normals[N+1]=T*f,this._buffer.normals[N+2]=m,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this.forPathBevel===!1&&(this._buffer.positions[N+3]=b,this._buffer.positions[N+4]=S,this._buffer.positions[N+5]=x,this._buffer.normals[N+3]=E*f,this._buffer.normals[N+4]=T*f,this._buffer.normals[N+5]=-m,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w),p||(this.forPathBevel?(R+=1,N+=3,C+=2):(R+=2,N+=6,C+=4),B.topP=R+0,B.bottomP=R+1,this._buffer.positions[N+0]=b,this._buffer.positions[N+1]=S,this._buffer.positions[N+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[N+0]=M*f,this._buffer.normals[N+1]=O*f,this._buffer.normals[N+2]=m,this._buffer.uvs[C+0]=w,this._buffer.uvs[C+1]=A,this.forPathBevel===!1&&(this._buffer.positions[N+3]=b,this._buffer.positions[N+4]=S,this._buffer.positions[N+5]=x,this._buffer.normals[N+3]=M*f,this._buffer.normals[N+4]=O*f,this._buffer.normals[N+5]=-m,this._buffer.uvs[C+2]=A,this._buffer.uvs[C+3]=w)),this.vertexCache[s]=B,B}clone(){let e=new wa(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=va(this.userData),e}};var Yl=class extends bk{constructor(e,r=12,i={}){super();this.type="ShapeGeometry";this.windingRule=rt.ODD;this.elementType=Yt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:rt.ODD,elementType:Yt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let o=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,d,u;for(let f=0,m=o.length/2;f<m;f++){let y=f*2,g=o[y+0],v=o[y+1];if(d!==void 0&&g!==d&&(l=!1),u!==void 0&&v!==u&&(c=!1),d=g,u=v,!l&&!c)break}if(!l&&!c)try{s=un({contours:[o,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=vu}let p=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new Jf(new Float32Array(p*3),3),this._normalAttribute=new Jf(new Float32Array(p*3),3),this._uvAttribute=new Jf(new Float32Array(p*2),2),this._indexAttribute=new Jf(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let S=0,x=p;S<x;S++){let w=S*2,A=s.vertices[w+0],E=s.vertices[w+1];A<f&&(f=A),A>m&&(m=A),E<y&&(y=E),E>g&&(g=E)}let v=m-f,b=g-y;for(let S=0,x=p;S<x;S++){let w=S*2,A=s.vertices[w+0],E=s.vertices[w+1],T=(A-f)/v,M=(E-y)/b;this._positionAttribute.setXYZ(S,A,E,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,T,M)}for(let S=0,x=h;S<x;S++){let w=S*3,A=s.elements[w+0],E=s.elements[w+1],T=s.elements[w+2];this._indexAttribute.setX(w+0,A),this._indexAttribute.setX(w+1,E),this._indexAttribute.setX(w+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Yl(this._shape,this._curveSegments);return e.userData=va(this.userData),e}};var Ql=class extends wa{constructor(e,r,i=0,o=12,a=3,s=rt.ODD){super(e,r,i,o,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,i){let o=e[0];for(let a=0,s=o.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,o,a),c=this._buildBevelVert(r,o,(a+1)%s);i.push(c.topP,l.topN,l.bottomN),i.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new Ql(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=va(this.userData),e}};var mi=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:rt.ODD},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness,l;a!==void 0&&(a instanceof st?(l=a,(l.width!==r||l.height!==i)&&l.applySize(r,i)):l=new st(r,i).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&l.update());let c=l??new st(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:o,roundness:s}),shape:c}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:o,windingRule:a}=n.parameters;n.shape.roundness=o;let s;return t<=0?s=new Yl(n.shape,i,{windingRule:a}):s=new Ql(n.shape,t,e,i,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as xk,Float32BufferAttribute as Sk,MathUtils as Ox,Vector2 as QP}from"three";var KP=Math.PI*2,Zl=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=Ox.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c=n.shape,d=t*.5,u=e*.5,p=wk(c,d,u,i*Math.PI/180,r,o);c.isClosed=!0,c.update();let h;return i===0?(h=new xk,h.setAttribute("position",new Sk([],3))):h=mi.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...n,type:"EllipseGeometry"}})}};function wk(n,t,e,r,i,o){if(r>=KP)return i>30||i%4===0?(Ck(n,t,e,o),Math.round(i/4)):YP(n,r,i,t,e,o);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=jP({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?Ak(n,a.x,a.y,c,i,t,e,o):YP(n,r,i,t,e,o)}function Ak(n,t,e,r,i,o,a,s){let l=Math.round(i/r.length);n.addPoint(Kl(t,e));for(let c=0,d=r.length;c<d;c++){let u=r[c],p=n.points[c],h=Kl(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),h.controls[0].position.set(u.x2,u.y2),n.addPoint(h)}return s>0?ZP(n,o,a,s):n.addPoint(Kl(0,0)),l}function YP(n,t,e,r,i,o){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,d=Math.cos(l)*i;n.addPoint(Kl(c,d))}return t<KP?o>0?ZP(n,r,i,o):n.addPoint(Kl(0,0)):(n.removePoint(n.points[n.points.length-1]),o>0&&JP(n,r,i,o)),1}function Ck(n,t,e,r=0,i=0,o=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint($f(i-t,o,i-t,o-l,i-t,o+l)),n.addPoint($f(i,o+e,i-s,o+e,i+s,o+e)),n.addPoint($f(i+t,o,i+t,o+l,i+t,o-l)),n.addPoint($f(i,o-e,i+s,o-e,i-s,o-e)),r>0&&JP(n,t,e,r)}function Kl(n,t){return new dn(Ox.generateUUID(),new QP(n,t))}function $f(n,t,e,r,i,o){let a=Kl(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(i,o),a}function ZP(n,t,e,r){$P(n,t,e,r).forEach(o=>n.addPoint(o))}function JP(n,t,e,r){let i=$P(n,t,e,r),o=new st;i.forEach(a=>o.addPoint(a)),o.isClosed=!0,n.shapeHoles.push(o)}function $P(n,t,e,r){let i=r*t/100,o=i*(Math.abs(e)/Math.abs(t)),a=new QP(i/t,o/e),s=n.points.map(l=>{let c=l.clone();return c.uuid=Ox.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),s}import{IcosahedronGeometry as Ek}from"three";var eT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.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(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:a}=n.parameters,s=i===0&&o!==0?new bu(t*.5,o,a):new Ek(t*.5,i),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},bu=class extends xa{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],s="IcosahedronGeometry";super(o,a,s,t,e,r),this.type=s}static fromJSON(t){return new bu(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as Pk,Shape as Tk}from"three";var tT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.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}]},n.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(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new Tk;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new Pk(i.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as rT,BufferGeometryLoader as Rk,Vector3 as Bk,BoxGeometry as iT,Box3 as Nk}from"three";import{BufferAttribute as em,BufferGeometry as Mk}from"three";var Ix=1e4;function Jl(n,t){return Math.abs(t-n)/2+Math.min(n,t)}var tm=class{constructor(t=1){this.subdivisions=t}modify(t){let e=Ok(t),r=this.subdivisions;for(;r-- >0;)e=Ik(e);return Dk(e,t)}};function Ok(n){let t=n.getAttribute("position");if(t===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let e=n.getAttribute("uv"),r=n.getIndex(),i=t.count,o=new Map,a=new Uint32Array(i),s=[],l=0;for(let m=0;m<i;m++){let y=t.getX(m),g=t.getY(m),v=t.getZ(m),b=Math.round(y*Ix),S=Math.round(g*Ix),x=Math.round(v*Ix),w=o.get(b);w===void 0&&(w=new Map,o.set(b,w));let A=w.get(S);A===void 0&&(A=new Map,w.set(S,A));let E=A.get(x);E===void 0&&(E=l++,A.set(x,E),s.push(y,g,v)),a[m]=E}let c=[],d=[],u=e===void 0?null:[],p=r!==null?r.count:i,h=(m,y)=>{let g=r!==null?r.getX(m):m,v=r!==null?r.getX(m+1):m+1,b=r!==null?r.getX(m+2):m+2;if(!(g<i&&v<i&&b<i))return;let S=a[g],x=a[v],w=a[b];S===x||x===w||w===S||(c.push(S,x,w),d.push(y),u!==null&&u.push(e.getX(g),e.getY(g),e.getX(v),e.getY(v),e.getX(b),e.getY(b)))},f=n.groups;if(f.length>0)for(let m=0;m<f.length;m++){let y=f[m],g=y.materialIndex===void 0?0:y.materialIndex,v=Math.max(y.start,0),b=Math.min(y.start+y.count,p);for(let S=v;S<b&&S+2<p;S+=3)h(S,g)}else for(let m=0;m+2<p;m+=3)h(m,0);return{positions:Float64Array.from(s),faces:Uint32Array.from(c),materialIndices:d,uvs:u===null?null:Float64Array.from(u)}}function Ik(n){let{positions:t,faces:e,materialIndices:r,uvs:i}=n,o=t.length/3,a=e.length/3,s=i!==null&&a>0,l=a*3,c=new Uint32Array(l),d=new Uint32Array(l),u=new Uint32Array(l),p=new Uint32Array(l),h=new Uint32Array(l),f=0,m=8;for(;m<l*2;)m*=2;let y=m-1,g=new Int32Array(m).fill(-1),v=(C,B)=>{let _=(Math.imul(C,2654435761)^B)&y;for(;;){let F=g[_];if(F===-1)return g[_]=f,c[f]=C,d[f]=B,f++;if(c[F]===C&&d[F]===B)return F;_=_+1&y}},b=(C,B)=>{let _=C<B?C:B,F=C<B?B:C,V=(Math.imul(_,2654435761)^F)&y;for(;;){let Z=g[V];if(c[Z]===_&&d[Z]===F)return Z;V=V+1&y}},S=new Uint32Array(o),x=new Float64Array(o*3),w=(C,B,_)=>{let F=C<B?v(C,B):v(B,C),V=++u[F];V===1?p[F]=_:V===2&&(h[F]=_),S[C]++,S[B]++,x[C*3]+=t[B*3],x[C*3+1]+=t[B*3+1],x[C*3+2]+=t[B*3+2],x[B*3]+=t[C*3],x[B*3+1]+=t[C*3+1],x[B*3+2]+=t[C*3+2]};for(let C=0;C<a;C++){let B=e[C*3],_=e[C*3+1],F=e[C*3+2];w(B,_,F),w(_,F,B),w(F,B,_)}let A=new Float64Array(f*3);for(let C=0;C<f;C++){let B=c[C]*3,_=d[C]*3;if(u[C]===2){let Z=p[C]*3,q=h[C]*3;A[C*3]=(t[B]+t[_])*.375+(t[Z]+t[q])*.125,A[C*3+1]=(t[B+1]+t[_+1])*.375+(t[Z+1]+t[q+1])*.125,A[C*3+2]=(t[B+2]+t[_+2])*.375+(t[Z+2]+t[q+2])*.125}else A[C*3]=(t[B]+t[_])*.5,A[C*3+1]=(t[B+1]+t[_+1])*.5,A[C*3+2]=(t[B+2]+t[_+2])*.5}let E=new Float64Array(o*3),T;for(let C=0;C<o;C++){let B=S[C];B===3?T=3/16:B>3&&(T=3/(8*B));let _=1-B*Number(T),F=Number(T);B===2&&(_=3/4,F=1/8),E[C*3]=t[C*3]*_+x[C*3]*F,E[C*3+1]=t[C*3+1]*_+x[C*3+1]*F,E[C*3+2]=t[C*3+2]*_+x[C*3+2]*F}let M=new Float64Array((o+f)*3);M.set(E),M.set(A,o*3);let O=new Uint32Array(a*12),R=new Array(a*4),N=s?new Float64Array(a*24):null;for(let C=0;C<a;C++){let B=e[C*3],_=e[C*3+1],F=e[C*3+2],V=b(B,_)+o,Z=b(_,F)+o,q=b(F,B)+o,G=C*12;O[G++]=V,O[G++]=Z,O[G++]=q,O[G++]=B,O[G++]=V,O[G++]=q,O[G++]=_,O[G++]=Z,O[G++]=V,O[G++]=F,O[G++]=q,O[G++]=Z;let W=r[C];if(R[C*4]=W,R[C*4+1]=W,R[C*4+2]=W,R[C*4+3]=W,N!==null){let j=C*6,K=i[j],te=i[j+1],Q=i[j+2],ae=i[j+3],re=i[j+4],ne=i[j+5],de=Jl(K,Q),ve=Jl(te,ae),me=Jl(Q,re),ce=Jl(ae,ne),X=Jl(K,re),ee=Jl(te,ne),ie=C*24;N[ie++]=de,N[ie++]=ve,N[ie++]=me,N[ie++]=ce,N[ie++]=X,N[ie++]=ee,N[ie++]=K,N[ie++]=te,N[ie++]=de,N[ie++]=ve,N[ie++]=X,N[ie++]=ee,N[ie++]=Q,N[ie++]=ae,N[ie++]=me,N[ie++]=ce,N[ie++]=de,N[ie++]=ve,N[ie++]=re,N[ie++]=ne,N[ie++]=X,N[ie++]=ee,N[ie++]=me,N[ie++]=ce}}return{positions:M,faces:O,materialIndices:R,uvs:N}}function Dk(n,t){let{positions:e,faces:r,materialIndices:i,uvs:o}=n,a=e.length/3,s=r.length/3,l=new Float64Array(a*3);for(let f=0;f<s;f++){let m=r[f*3]*3,y=r[f*3+1]*3,g=r[f*3+2]*3,v=e[g]-e[y],b=e[g+1]-e[y+1],S=e[g+2]-e[y+2],x=e[m]-e[y],w=e[m+1]-e[y+1],A=e[m+2]-e[y+2],E=b*A-S*w,T=S*x-v*A,M=v*w-b*x;l[m]+=E,l[m+1]+=T,l[m+2]+=M,l[y]+=E,l[y+1]+=T,l[y+2]+=M,l[g]+=E,l[g+1]+=T,l[g+2]+=M}for(let f=0;f<a;f++){let m=l[f*3],y=l[f*3+1],g=l[f*3+2],v=Math.sqrt(m*m+y*y+g*g)||1;l[f*3]=m/v,l[f*3+1]=y/v,l[f*3+2]=g/v}let c=s*3,d=new Float32Array(c*3),u=new Float32Array(c*3),p=o!==null&&o.length>0?new Float32Array(c*2):null;for(let f=0;f<c;f++){let m=r[f]*3;d[f*3]=e[m],d[f*3+1]=e[m+1],d[f*3+2]=e[m+2],u[f*3]=l[m],u[f*3+1]=l[m+1],u[f*3+2]=l[m+2]}p!==null&&p.set(o.subarray(0,c*2));let h=new Mk;h.setAttribute("position",new em(d,3)),c>0&&(h.setAttribute("normal",new em(u,3)),h.setAttribute("color",new em(new Float32Array(c*3).fill(1),3))),p!==null&&h.setAttribute("uv",new em(p,2));for(let f=0;f<s;){let m=i[f],y=f;do f++;while(f<s&&i[f]===m);h.addGroup(y*3,(f-y)*3,m)}return t.boundingBox!==null&&(h.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(h.boundingSphere=t.boundingSphere.clone()),h}var Sr=new Bk,nT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new rT().copy(new iT(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Sr),r={width:Sr.x,height:Sr.y,depth:Sr.z,subdivisions:0}):r=t.parameters;let i={...r,...n.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,o=n.geometry??new rT().copy(new iT(100,100,100)),a=o.userData.parameters;a===void 0?(o.boundingBox=Lk(o),o.boundingBox.getSize(Sr)):Sr.set(a.width,a.height,a.depth),(t!==Sr.x||e!==Sr.y||r!==Sr.z)&&o.scale(Sr.x===0?1:t/Sr.x,Sr.y===0?1:e/Sr.y,Sr.z===0?1:r/Sr.z);let s=o.originalGeometry;try{i>0?(s===void 0||a?.subdivisions!==i)&&(s===void 0&&(s=o),o=new tm(i).modify(s)):(s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals())}catch{s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()}return s!==void 0&&Object.assign(o,{originalGeometry:s}),delete n.geometry,Object.assign(o,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new Rk(e).load(n,i=>{let o=this.normalizeInputs({geometry:i});i.boundingBox.getSize(Sr);let a=100/Sr.x;Object.assign(o.parameters,{width:100,height:Sr.y*a,depth:Sr.z*a}),t(this.build(o))})}};function Lk(n){let t=new Nk,e=n.attributes.position;return e?(t.setFromBufferAttribute(e),t):(t.makeEmpty(),t)}var rm=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,c=t*.5,d=e*.5,u=0,p=0,h=2*Math.PI/r;for(let m=0;m<r;m++){let y=h*m,g=u+Math.sin(y)*c,v=p+Math.cos(y)*d;l.addPoint(l.createPoint(g,v))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=i;l.roundness=i,l.update();let f=mi.create({shape:l,parameters:{roundness:i,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as _k,Float32BufferAttribute as Dx,Vector2 as Vn,Vector3 as yr}from"three";var oT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.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(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:o,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=new Bx(t*.5,e,i,o,a,s,l),d=r/t;return d!==1&&c.scale(1,1,d),Object.assign(c,{userData:{...n,type:"PyramidGeometry"}})}};function xu(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}var Fk=new yr,kk=new yr;function Rx(n,t,e,r,i,o){let a=Fk.copy(t).sub(n),s=kk.copy(e).sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===i){let c=a.add(s).normalize();o.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);o.copy(n),o.addScaledVector(a,i/Math.sin(c)),o.addScaledVector(s,r/Math.sin(c))}}function Vk(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var Bx=class extends _k{constructor(t=.5,e=1,r=4,i=1,o=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),s=Math.floor(s);let l=[],c=[],d=[],u=[],p=0,h=e/2,f=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,v=Math.PI-g,b=new yr(0,-h,0),S=new yr(0,h,0),x=new Vn(t,-h),w=new Vn(m,-h),A=new Vn(0,S.y).sub(w),E=new Vn(0,S.y).sub(x),T=new Vn(A.y,-A.x).normalize(),M=new Vn(E.y,-E.x).normalize(),R=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,R);let N;{let q=new yr(T.x,T.y,0),G=new yr(Math.cos(y)*q.x,q.y,Math.sin(y)*q.x);N=q.angleTo(G)}let C=a/Math.tan((Math.PI-A.angle())/2),B=a/Math.tan((Math.PI-N)/2),_=new yr;if(!o){c.push(b.x,b.y,b.z),d.push(0,-1,0),u.push(0,0);let q=p++,G=[],W=x.clone(),j=C/Math.cos(Math.PI/r);W.x-=j;for(let K=0;K<r;K++){let te=K/r*Math.PI*2+f,Q=new Vn(Math.sin(te),Math.cos(te));xu(W,Q,_),c.push(_.x,_.y,_.z),d.push(0,-1,0),u.push(0,0),G.push(p++)}for(let K=0;K<G.length;K++)l.push(G[K],q,G[(K+1)%G.length])}let F=[];{let q=new yr,G=new yr,W=new yr,j=new yr,K=new yr,te=new yr;for(let Q=0;Q<r;Q++){let ae=Q/r*Math.PI*2+f,re=(Q+.5)/r*Math.PI*2+f,ne=(Q+1)/r*Math.PI*2+f,de=new Vn(Math.sin(ae),Math.cos(ae)),ve=new Vn(Math.sin(re),Math.cos(re)),me=new Vn(Math.sin(ne),Math.cos(ne));xu(x,de,G),xu(x,me,W),xu(T,ve,q),Rx(S,G,W,B,B,j),c.push(j.x,j.y,j.z),Rx(G,S,W,B,C,K),c.push(K.x,K.y,K.z),Rx(W,G,S,C,B,te),c.push(te.x,te.y,te.z),d.push(q.x,q.y,q.z),d.push(q.x,q.y,q.z),d.push(q.x,q.y,q.z),u.push(0,0),u.push(0,0),u.push(0,0);let ce=p++,X=p++,ee=p++;if(l.push(ce,X,ee),a>0){{let xe=G.clone().add(W).multiplyScalar(.5),se=S.clone().sub(xe).normalize(),I=b.clone().sub(xe).normalize().add(se).normalize().multiplyScalar(-1),J=te.clone().sub(K);V(xe,J,I,A.angle())}let ie,he;{let xe=new yr;xu(M,me,xe);let se=te.clone().add(j).multiplyScalar(.5);se=Vk(se,W,S);let ue=te.clone().sub(j);[ie,he]=V(se,ue,xe,N,j.y)}{let xe=ie,se=xe.clone().setY(0).normalize(),ue=new yr(0,-1,0),I=se.clone().cross(ue);Z(xe,se,ue,I)}F.concat(he);{let xe=A.angle(),se=Math.PI-xe,ue=S.clone();ue.y-=a/Math.sin(xe-Math.PI/2);let I=new yr,J=[];for(let Ce=0;Ce<s;Ce++){let Pe=[],be=Math.PI/2-se*Ce/s,Ne=Math.cos(be),Ae=Math.sin(be),Re=re;for(let Xe=0;Xe<=Ce;Xe++){let Be=Math.cos(Re),ft=Math.sin(Re);q.x=Ne*ft,q.y=Ae,q.z=Ne*Be,I.copy(ue).addScaledVector(q,a),c.push(I.x,I.y,I.z),d.push(q.x,q.y,q.z),u.push(0,0),Pe.push(p++),Re+=Math.PI*2/Ce/r}J.push(Pe)}he.reverse(),J.push(he);let we=J.length-1;for(let Ce=0;Ce<we;Ce++){let Pe=J[Ce],be=J[Ce+1],Ne=Pe.length-1;l.push(be[1],Pe[0],be[0]);for(let Ae=1;Ae<=Ne;Ae++)l.push(Pe[Ae],Pe[Ae-1],be[Ae]),l.push(be[Ae+1],Pe[Ae],be[Ae])}}}}}this.setIndex(l),this.setAttribute("position",new Dx(c,3)),this.setAttribute("normal",new Dx(d,3)),this.setAttribute("uv",new Dx(u,2));function V(q,G,W,j,K){let te=-j/2,Q=(Math.PI-j)/2,ae=G.clone().normalize().cross(W);q.addScaledVector(W,-a/Math.sin(Q));let re=new yr,ne=new yr,de=1,ve=p,me=[];for(let ce=0;ce<=s;ce++){let X=te+ce/s*j;ne.set(0,0,0),ne.addScaledVector(ae,Math.sin(X)),ne.addScaledVector(W,Math.cos(X));for(let ee=0;ee<=de;ee++){let ie=ee/de-.5;if(re.copy(q),re.addScaledVector(G,ie),re.addScaledVector(ne,a),K!=null){let he=Math.max(0,re.y-K);re.addScaledVector(G,-he/G.y)}c.push(re.x,re.y,re.z),d.push(ne.x,ne.y,ne.z),u.push(0,0),ee===0&&me.push(p),p++}}for(let ce=0;ce<s;ce++)for(let X=0;X<de;X++){let ee=ve+X+(de+1)*ce,ie=ee+(de+1),he=ie+1,xe=ee+1;l.push(ee,ie,xe),l.push(ie,he,xe)}return[q.clone().addScaledVector(G,.5),me]}function Z(q,G,W,j){let K=Math.PI/2,te=E.angle()-K,Q=[],ae=new yr,re=new yr;for(let de=0;de<=s;de++){let ve=[],me=de/s;for(let ce=0;ce<=de;ce++){let ee=((de?ce/de:0)-.5)*v,ie=Math.cos(ee),he=Math.sin(ee),xe=Math.atan(Math.tan(te)*ie),se=(K+xe)*me,ue=Math.cos(se),I=Math.sin(se);ae.set(0,0,0),ae.addScaledVector(G,I*ie),ae.addScaledVector(W,ue),ae.addScaledVector(j,I*he),re.copy(q).addScaledVector(ae,a),c.push(re.x,re.y,re.z),d.push(ae.x,ae.y,ae.z),u.push(0,0),ve.push(p++)}Q.push(ve)}let ne=Q.length-1;for(let de=0;de<ne;de++){let ve=Q[de],me=Q[de+1],ce=ve.length-1;l.push(ve[0],me[1],me[0]);for(let X=1;X<=ce;X++)l.push(ve[X-1],ve[X],me[X]),l.push(ve[X],me[X+1],me[X])}}}};var $l=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,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(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:r*.5},d={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function p(S,x,w){return x>e&&w>r?Math.min(S*e/x,S*r/w):x>e?S*e/x:w>r?S*r/w:S}let h=[];h[0]=i[0]===0?0:p(i[0],i[0]+i[3],i[0]+i[1]),h[1]=i[1]===0?0:p(i[1],i[1]+i[2],i[1]+i[0]),h[2]=i[2]===0?0:p(i[2],i[2]+i[1],i[2]+i[3]),h[3]=i[3]===0?0:p(i[3],i[3]+i[0],i[3]+i[2]);let f=d.x,m=u.x,y=u.y,g=d.y;t.addPoint(t.createPoint(f,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(f,g)),t.isClosed=!0;let v=!0;for(let S=0,x=t.points.length;S<x;S++)t.points[S].roundness=h[S],S>0&&h[S]!==h[S-1]&&(v=!1);v&&(t.roundness=h[0]),t.useCubicForRoundedCorners=o!==1,t.update();let b=mi.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as Gk,Float32BufferAttribute as Uk,MathUtils as aT,SphereGeometry as zk}from"three";var sT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=aT.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(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:o=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=n.parameters,d;return c===0?(d=new Gk,d.setAttribute("position",new Uk([],3))):d=new zk(.5*t,i,o,a,s,l,c*aT.DEG2RAD),d.scale(1,e/t,r/t),Object.assign(d,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as jk}from"three";var lT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,o=new jk(t,e,r,i);return o.scale(1,1,1),Object.assign(o,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as Hk,Float32BufferAttribute as Nx,Vector3 as Wk}from"three";var cT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.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(n){let{width:t,height:e,depth:r,angle:i,cornerRadius:o,cornerSegments:a}=n.parameters,s=new Lx(t,e,r,i,o,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Lx=class extends Hk{constructor(t=1,e=1,r=1,i=90,o=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],d=.001;o==0&&(a=1),a=Math.max(1,Math.floor(a)),o=Math.min(o,100),i=Math.min(180-d,i),i*=Math.PI/180;let u=[],p=Math.PI/2,h=(re=0,ne=0,de=0)=>new Wk(re,ne,de),f=h(),m=h(),[y,g,v]=[e/2,t/2,r/2],b=-g,S=+g,[x,w,A]=[h(b,-y,+v),h(b,-y,-v),h(b,+y,-v)],E=(re,ne=!1)=>Math.sin(re-Math.PI/(1+ +ne)),T=(re,ne=!1)=>Math.cos(re-Math.PI/(1+ +ne));A.y=Math.sin(i)*e-y;let M=Math.cos(i)*e-v,O=x.z-d;i<=p?(A.z=Math.min(M,O),A.z==O&&(A.y-=(M-O)/Math.tan(p-i))):w.z=Math.min(w.z-M-v,x.z-d),f.subVectors(x,w),m.subVectors(A,w);let R=Math.min(f.length(),m.length())*o/100,N=R*Math.tan(i/2),C=R/Math.cos(i/2),B=f.clone().normalize().add(m.normalize()).setLength(C).add(w);f.set(0,E(i,!0),T(i,!0)),u.push([A,f.clone()]);let _=(Math.PI-i)/a;for(let re=0;re<=a;re++){let ne=p+i+re*_;f.set(0,Math.sin(ne)*N,Math.cos(ne)*N),f.add(B),m.set(0,E(ne),T(ne)),u.push([f.clone(),m.clone()])}u.push([x,h(0,1,0)]);let F=Math.sin(_/2)*N*2,V=u.length-1,Z=u[0][0].distanceTo(u[1][0]),q=u[V-1][0].distanceTo(u[V][0]),G=Z+F*a+q;u[0].push(1);for(let re=0;re<=a;re++)u[re+1].push(1-(Z+re*F)/G);u[V].push(0);let[W,j,K]=u[0],te,Q,ae;for(let re=1;re<u.length;re++)[te,Q,ae]=u[re],s.push(b,W.y,W.z,b,te.y,te.z,S,W.y,W.z,S,W.y,W.z,b,te.y,te.z,S,te.y,te.z),l.push(0,j.y,j.z,0,Q.y,Q.z,0,j.y,j.z,0,j.y,j.z,0,Q.y,Q.z,0,Q.y,Q.z),c.push(0,K,0,ae,1,K,1,K,0,ae,1,ae),[W,j,K]=[te,Q,ae];this.setAttribute("position",new Nx(s,3)),this.setAttribute("normal",new Nx(l,3)),this.setAttribute("uv",new Nx(c,2))}};var im=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:o,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,d=n.shape,u=t*.5,p=e*.5,h=0,f=0,m=a*Math.PI/360/i,y=Math.PI/2*3*-1,g=u*r/100,v=p*r/100;if(i===3&&r===50){m=2*Math.PI/i;for(let S=0;S<i;S++){let x=m*S,w=h+Math.sin(x)*u,A=f+Math.cos(x)*p;d.addPoint(d.createPoint(w,A))}}else for(let S=0;S<i;S++){let x=h+Math.cos(y)*u,w=f+Math.sin(y)*p;d.addPoint(d.createPoint(x,w)),y+=m,x=h+Math.cos(y)*g,w=f+Math.sin(y)*v,d.addPoint(d.createPoint(x,w)),y+=m}d.isClosed=!0;for(let S=0,x=d.points.length;S<x;S++)d.points[S].roundness=o;d.roundness=o,d.update();let b=mi.create({shape:d,parameters:{roundness:o,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(b,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as qk}from"three";var dT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.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(n){let{width:t,height:e}=n.parameters,r=new qk(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as Xk,Float32BufferAttribute as Yk,MathUtils as Qk}from"three";var uT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width);e.shapeBlendNode&&(i=r);let o=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:i,depth:o})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:o,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,c=Kk(t,e,r,t*.5,a,o,0,0,i,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...n,type:"TorusGeometry"}})}};function Kk(n,t,e,r,i,o,a,s,l,c,d){[t,e]=[e,t],a=t/2;let u=Qk.clamp(i/360,0,1);if(u===0){let p=new Xk;return p.setAttribute("position",new Yk([],3)),p}return u===1&&(c=0),new iu(!0,n,t,e,r,u,o,a,s,l,c,d)}import{TorusKnotGeometry as Zk}from"three";var pT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.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(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:o,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new Zk(s,e,r,i,o,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var hT=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof st?n.shape:new st,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(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,c=t*.5,d=e*.5;s?(l.addPoint(l.createPoint(-c,d)),l.addPoint(l.createPoint(c,-d)),l.addPoint(l.createPoint(-c,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(c,-d)),l.addPoint(l.createPoint(-c,-d))),l.isClosed=!0;for(let p=0,h=l.points.length;p<h;p++)l.points[p].roundness=r;l.roundness=r,l.update();let u=mi.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};mr();import{BufferAttribute as fT,BufferGeometry as _x}from"three";import{mergeGeometries as $k}from"three/examples/jsm/utils/BufferGeometryUtils.js";function mT(){let n=new _x;return n.setAttribute("position",new fT(new Float32Array([]),3)),n.setIndex(new fT(new Uint16Array([]),1)),n}var eV=mT().attributes,tV=12,rV=1,ec=class extends _x{constructor(e,r){super();this.isTextGeometry=!0;this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,eV),this.userData={parameters:e,type:"TextGeometry"};let i=r.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let i=r.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e,r){let i=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!i?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:d,textTransform:u}=e,p=ar.getDisplayedValue(d),h=u===2?p.toUpperCase():u===3?p.toLowerCase():p,f=iV(e,i,h,r),{shapes:m,charWidths:y,charCoords:g}=i.generateShapes(f,e,r),v=(typeof o=="number"?o:Number(r.getVariable(o)))*.5,b=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,S=m.map(A=>new st().fromShape(A,!0));this.vectorShapes=S;let x=S.map(A=>mi.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?rt.NONZERO:rt.ODD,subdivisions:this.isLowResolution&&s>0?rV:tV}})),w=x.length?$k(x):mT();w.translate(-v,b,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([A,E])=>{this.setAttribute(A,E)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=xr(new _x,ec.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,i])=>{this.setAttribute(r,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function iV(n,t,e,r){let i=typeof n.width=="string"?Number(r.getVariable(n.width)):n.width,o=[""],a="";for(let s of e)a+=s,s===" "||s===`
728
728
  `?(o[o.length-1]+=a,a="",s===`
729
- `&&o.push("")):t.getTextWidth(o[o.length-1]+a,n)>i&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,n)>i&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}import{BufferGeometry as Fx,BufferAttribute as bT,Uint32BufferAttribute as kx,Float32BufferAttribute as sm,Matrix4 as aV,Vector3 as wu,Sphere as sV,Box3 as lV,BoxGeometry as cV}from"three";var gT,om=new Promise(n=>{gT=n}),yT=!1;var nm;function vT(n){if(yT)return;if(nm)return nm;async function t(){let r=n??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.11/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});gT(c),yT=!0}return nm=t(),nm}import{Matrix4 as nV}from"three";var oV=new nV;function am(n,t){if(Object.keys(n.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(n.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let s of r){let l=n.attributes[s],c=t.attributes[s];if(l===void 0||l.isInterleavedBufferAttribute===!0||c.isInterleavedBufferAttribute===!0||l.itemSize!==c.itemSize||l.normalized!==c.normalized||l.array.constructor!==c.array.constructor||l.array.length!==c.array.length)return!1}let i=n.index,o=t.index;if(i===null!=(o===null))return!1;let a=!1;if(i!==null&&o!==null){if(i.array.length!==o.array.length)return!1;let s=i.array.constructor,l=o.array.constructor;if(s!==l){if(s!==Uint32Array||l!==Uint16Array)return!1;a=!0}}if(n.groups.length!==t.groups.length)return!1;for(let s=0;s<t.groups.length;s++){let l=n.groups[s],c=t.groups[s];if(l.start!==c.start||l.count!==c.count||l.materialIndex!==c.materialIndex)return!1}for(let s of r){let l=n.attributes[s],c=t.attributes[s];l.array.set(c.array),l.needsUpdate=!0}if(i!==null&&o!==null){if(a){let s=i.array,l=o.array;for(let c=0,d=l.length;c<d;c++){let u=l[c];s[c]=u===65535?4294967295:u}}else i.array.set(o.array);i.needsUpdate=!0}return n.drawRange.start=t.drawRange.start,n.drawRange.count=t.drawRange.count,n.userData=t.userData,n.boundingBox=null,n.boundingSphere=null,!0}function Su(n,t,e,r){let i=n.position.array,o=n.normal.array,a=oV.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=i.length;d<u;d+=3)i[d]*=t,i[d+1]*=e,i[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var lm=new lV,tc=new wu,Te;om.then(n=>{Te=n});var xT=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ST=new Uint32Array([0,1,2,3]),wT=new Uint8Array([4]),St=class extends Fx{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=_i.div(r.map(l=>typeof l=="number"?l:0),i);if(o.every(l=>l===1))return;this.subdividedGeometry&&Su(this.subdividedGeometry.attributes,...o),this.originalGeometry&&Su(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(tc.fromArray(o));let s=tc.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let r=e.phongAngle??35;this.flatShading&&(r=-1);let i=null;if(e.subdivisions>0){let a=0;try{a=St.allocate(e),i=St.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&St.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new cV(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new sV,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;lm.setFromBufferAttribute(r),lm.getCenter(i),e.boundingSphere.radius=i.distanceTo(lm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),lm.getSize(tc);let o={width:tc.x,height:tc.y,depth:tc.z};return this.userData.parameters=o,o}static build(e,r,i,o){let a,s,l=e?.phongAngle??35;i===!1&&(l=-1),r&&(Te.free_bvh(r),Te.free_subdivision_surface(r));try{a=St.allocate(e,o)}catch(d){console.error(d,e),a=St.allocate({positionWASM:xT,indexWASM:ST,verticesPerFaceWASM:wT},o)}Te.set_destination_refinement_level(a,0);let c=St.buildLevel(a,!0,l);return e.subdivisions>0?s=St.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,i){try{return Te.set_destination_refinement_level(e,r),St.buildLevel(e,!1,i)??null}catch{try{return Te.set_destination_refinement_level(e,r-1),St.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,r,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let o=e.shape!==void 0||e.path!==void 0?r.geometry:Wi(e,i,!1,r),a;xf(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=Au(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=dV(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let i,o,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,o=e.indexWASM,a=e.verticesPerFaceWASM,Te.alloc_subdivision_surface_uvs&&e.uvWASM&&e.uvWASM.length===o.length*2&&(l=e.uvWASM)):(i=xT,o=ST,a=wT);let c=i.length,d=o.length,u=a.length,p=i.length+s.length+l.length,h=o.length+a.length,f=p*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Te._malloc(f),g=new Float32Array(Te.HEAPF32.buffer,y,p),v=new Uint32Array(Te.HEAPU32.buffer,y+m,h);g.set(i,0),g.set(s,i.length),g.set(l,i.length+s.length),v.set(o,0),v.set(a,o.length);let b;e?.scaleBaked?.some(w=>w!==1)&&(b=new aV().makeScale(...e.scaleBaked.map(w=>typeof w=="number"?w:1))),r&&(b?b.premultiply(r):b=r);let S=y+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,x=l.length?b?Te.alloc_subdivision_surface_uvs2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length,b.elements):Te.alloc_subdivision_surface_uvs(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length):b?Te.alloc_subdivision_surface2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,b.elements):Te.alloc_subdivision_surface(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u);return Te._free(y),x}static buildLevel(e,r,i,o,a,s=!1){let l=a?Te.get_mesh_data2(e,r?Te.Level.CONTROL:Te.Level.REFINED,i,a.elements):Te.get_mesh_data(e,r?Te.Level.CONTROL:Te.Level.REFINED,i),c=10,d=Te.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=Te.HEAPU32[d[p]>>2],f=Te.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=Te.HEAPU32[d[p]>>2],y=Te.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=Te.HEAPU32[d[p]>>2],v=Te.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let b=Te.HEAPU32[d[p]>>2],S=Te.HEAPU32.subarray(b>>2,(b>>2)+u[p]);p++;let x;if(Te.alloc_subdivision_surface_uvs){let A=d[9];if(A>0){let E=Te.HEAPU32[d[8]>>2];x=Te.HEAPF32.subarray(E>>2,(E>>2)+A)}}if(o===void 0){let A=new Fx;if(A.setIndex(new kx(S,1)),A.setAttribute("position",new sm(f,3)),A.setAttribute("normal",new sm(y,3)),x&&A.setAttribute("uv",new sm(x,2)),r){A.setAttribute("faceMap",new kx(v,1));let E=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new bT(E,4))}return Te.free_mesh_data(l),A.userData.type="SubdivGeometry",A}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let A=o.getIndex();A!==null&&A.array.length===S.length&&(A.copyArray(S),A.needsUpdate=!0)}let w=o.getAttribute("uv");x&&w&&w.array.length===x.length&&(w.copyArray(x),w.needsUpdate=!0),Te.free_mesh_data(l)}static freeSubdivPointer(e){Te.free_bvh(e),Te.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let o=Te.get_wireframe_data_for_base_level(e),a=4,s=Te.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=Te.HEAPU32[s[c]>>2],u=Te.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=Te.HEAPU32[s[c]>>2],h=Te.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new Fx;f.setAttribute("position",new sm(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=i.r,m[y++]=i.g,m[y++]=i.b;return f.setAttribute("color",new bT(m,3)),f.setIndex(new kx(h,1)),Te.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,Te.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,i){let o=r===0;o||Te.set_destination_refinement_level(e,r);let a=i?Te.get_topological_data2(e,o?Te.Level.CONTROL:Te.Level.REFINED,i.elements):Te.get_topological_data(e,o?Te.Level.CONTROL:Te.Level.REFINED),s=8,l=Te.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=Te.HEAPU32[l[d]>>2],p=new Float32Array(Te.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=Te.HEAPU32[l[d]>>2],f=new Uint32Array(Te.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=Te.HEAPU32[l[d]>>2],y=new Uint8Array(Te.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(Te.alloc_subdivision_surface_uvs){let v=l[7];if(v>0){let b=Te.HEAPU32[l[6]>>2];g=new Float32Array(Te.HEAPF32.subarray(b>>2,(b>>2)+v))}}return Te.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function dm(n){let t=Object.keys(n);return t.length===1&&t[0]==="subdivisions"}function Au(n,t){let e=t?t.count:n.count,r=0,i=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=n.getX(u),h=n.getY(u),f=n.getZ(u),m=Math.round(p*i),y=Math.round(h*i),g=Math.round(f*i),v=o.get(m);v===void 0&&(v=new Map,o.set(m,v));let b=v.get(y);b===void 0&&(b=new Map,v.set(y,b));let S=b.get(g);S===void 0&&(S=r++,b.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var cm=new wu,Vx=new wu,Gx=new wu,Ux=new wu;function dV(n,t,e,r,i){let o=[],a=[],s=i?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=i[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,v)=>Math.floor(v/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);n.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)n.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)n.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((n[t[u]*3+2]===d||n[t[u]*3+2]===0)&&p++,(n[t[u+1]*3+2]===d||n[t[u+1]*3+2]===0)&&p++,(n[t[u+2]*3+2]===d||n[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){cm.set(n[t[u]*3],n[t[u]*3+1],n[t[u]*3+2]),Vx.set(n[t[u+1]*3],n[t[u+1]*3+1],n[t[u+1]*3+2]),Gx.set(n[t[u+4]*3],n[t[u+4]*3+1],n[t[u+4]*3+2]),Ux.set(n[t[u+5]*3],n[t[u+5]*3+1],n[t[u+5]*3+2]),Vx.sub(cm).normalize(),Gx.sub(cm).normalize(),Ux.sub(cm).normalize();let p=Vx.cross(Gx).dot(Ux),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<n.length;m+=3,y++)n[m+2]===0&&(p.push(y),f++),n[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var uV={ConeGeometry:AP,CubeGeometry:CP,CylinderGeometry:Uf,DodecahedronGeometry:EP,EllipseGeometry:Zl,HelixGeometry:wE,IcosahedronGeometry:eT,LatheGeometry:tT,NonParametricGeometry:nT,PolygonGeometry:rm,PyramidGeometry:oT,RectangleGeometry:$l,SphereGeometry:sT,PlaneGeometry:lT,BackdropGeometry:cT,StarGeometry:im,TextFrameGeometry:dT,TorusGeometry:uT,TorusKnotGeometry:pT,TriangleGeometry:hT,VectorGeometry:mi},um=n=>{let t=uV[n.type]??ff(n.type);if(t===void 0)throw new Error(`No geometry factory registered for "${n.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(n)};var hV=["font"];function Wi(n,t,e,r){let i,o,a;n.type==="PathGeometry"?(o=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(o={...n},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(i in d){let u=d[i];Yv(u)&&!hV.includes(i)&&(d[i]=t.getVariable(u,[r.uuid,"geometry",...c,i]),Yv(d[i])&&(d[i]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry")s.path=o.path;else if(o.type==="VectorGeometry"){let c=st.createFromState(o.shape,o.width,o.height);s.shape=c}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new pV().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new St(o,e);return c.data=n,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=ff(o.type);if(c)return c.create(o,t);$t("text",`a ${o.type}`);let d=st.createFromState(ps.defaultData(),100,100);return um({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return $l.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=um(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=st.createFromState(ps.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=um(s)}return l}var zx=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let i=this.objects.get(t);return i===void 0?(i=this.createObject(t,e,r),this.objects.set(t,i)):i.isShared=!0,i}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Cu=class extends zx{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let o=Wi(e,r,this.flatShading,i);return o.computeBoundingSphere(),o}};var Wx="webgl",AT,jx,CT=!1;function qx(){return Wx}function PT(n){jx=n}function TT(){if(Wx==="webgpu"){if(AT!==void 0)return AT;CT||(CT=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(jx===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return jx}function pm(n,t){return TT().createRootMaterial(n,t)}function Xx(n,t,e){return TT().createSharedMaterial(n,t,e)}function Yx(n){return n.getLayersOfType===void 0&&Object.assign(n,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),n}var ET,MT;function OT(n){MT=n}function IT(){let n=Wx==="webgpu"&&ET!==void 0?ET:MT;return n===void 0?null:Yx(n())}var Hx;function DT(n){Hx=n}function RT(n,t){return Hx===void 0?!1:Hx(n,t)}var BT={markNeedsUpdateRendererDirty:()=>{}};function Gn(n,t){let e=0;if(!n.layers||n.layers.length===0)return!1;let r=n.layers?.find(i=>i.data.type==="light");if(r){let i=r.data,o=Number(t.getVariable(i.alphaOverride));if((typeof i.alphaOverride=="string"?o/100:i.alphaOverride)<1)return!0}for(let i of n.layers){if(i.data.type!=="displace"&&i.data.isMask)return!0;if(i.data.type!=="displace"&&"alpha"in i.data&&i.data.type!=="light"&&i.data.type!=="fresnel"&&i.data.type!=="cavity"&&i.data.type!=="dust"&&i.data.type!=="texture"&&i.data.type!=="matcap"&&i.data.type!=="rainbow"&&i.data.type!=="outline"&&i.data.type!=="pattern"){let o=i.data.visible?i.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&i.data.type==="depth"||i.data.type==="gradient"){for(let a of i.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&i.data.type==="noise"){let a=t.color(i.data.colorA).a,s=t.color(i.data.colorB).a,l=t.color(i.data.colorC).a,c=t.color(i.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var qi=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,ye=(n,t,e)=>typeof n=="number"?n:t.getVariable(n,e);function Qx(n){let t=typeof n=="string"?n:n.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function pn(n){return typeof n=="string"||typeof n=="number"&&n!==0}var rc={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},NT={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};import{Object3D as fV}from"three";var Kx=class extends Nl(fV){},mV=n=>n.type==="Mesh",cr=class extends Kx{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new cr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix,i.pivotMatrix=r.pivotMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1: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 mV(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};ut();import{Euler as gV,MathUtils as Jx,Matrix4 as vV,Quaternion as bV,Vector3 as HT}from"three";var LT=null,_T=null;function FT(n){LT=n}function Zx(){return LT}function kT(n){_T=n}function VT(){return _T}function hm(n){return"variable_"+n}var GT=new vV,UT=new HT,zT=new bV,xV=new HT,jT=new gV,$x=class extends Vf{constructor(e){super();this.shared=e}create(e){return new jl(e,this.shared)}},e0=class{constructor(t,e={},r=!0,i=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=i;this.geometryCache=new Cu(!0);this.geometryCache2=new Cu(!1);this.imageHolderCache=new $x(this);this.thisContext={scene:BT,shared:this};this.deletedImage=new Ei(nf.emptyImage,this);this.deletedVideo=new Ei(ml.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.timelineAnimations={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};this.transientGeometryKeys=new WeakSet;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=Xx(Xt.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:i,data:o}of t.variables)this.addVariableHolder(i,o),e&&this.updateVariableHolder(i,o);for(let[i,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(i,o);for(let[i,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(i,o);if(!r){for(let[i,o]of Object.entries(t.images))this.addImage(i,o);for(let[i,o]of Object.entries(t.videos))this.addVideo(i,o)}for(let[i,o]of Object.entries(t.colors))this.addColor(i,o);for(let[i,o]of Object.entries(t.lib.materials))this.addMaterial(i,o.asset);for(let[i,o]of Object.entries(t.materials))this.addMaterial(i,o);for(let[i,o]of Object.entries(t.audios))this.addAudio(i,o);for(let[i,o]of Object.entries(t.particles))this.addParticle(i,o);for(let[i,o]of Object.entries(t.fonts))this.addFont(i,o);for(let[i,o]of Object.entries(t.timelineAnimations??{}))this.addAnimation(i,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:Xt.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=Xx(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:Xt.defaultTwoLayerData("phong").layers}),pm(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Ei(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Ei(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Ei(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Do(e.r,e.g,e.b,e.a):this.colors[t]=new Do(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Tt(0,0,0,0))}else return"a"in t?new Tt(t.r,t.g,t.b,t.a):new Tt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Ro)return e;{let r=new Ro({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Ro&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=bP();if(r===null){$t("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}addAnimation(t,e){this.timelineAnimations[t]=e}getAnimation(t){return this.timelineAnimations[t]}deleteAniamtion(t){this.timelineAnimations[t]&&delete this.timelineAnimations[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Ro&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let i=localStorage.getItem(hm(t));r=i!==null?JSON.parse(i):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(hm(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let i=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:i,shared:this},u=s.slice(2);i.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=i.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*Jx.DEG2RAD:l[s[s.length-1]]=r}if(l=i.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),Ve.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&i.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...i,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(i.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!i||!this.transientGeometryKeys.has(i)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>e0.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let w=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(w.length===0||w.length%3!==0)return!1;for(let A=0;A<w.length;A++)if(w[A]>=l)return!1;u={array:w,itemSize:1,type:w.constructor.name,normalized:!1}}else{let w=o.data,A=w?.index;if(A?.array?.length){let E=(w?.attributes?.position?.array?.length??0)/3;if(l<E){let T=A.array;for(let M=0;M<T.length;M++)if(T[M]>=l)return!1}u=A}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let w=0;w<s.length;w+=3){let A=s[w],E=s[w+1],T=s[w+2];A<p&&(p=A),A>m&&(m=A),E<h&&(h=E),E>y&&(y=E),T<f&&(f=T),T>g&&(g=T)}let v=(w,A)=>({array:w,itemSize:A,type:"Float32Array",normalized:!1}),b={position:v(s,3)};c&&(b.normal=v(c,3)),d&&(b.uv=v(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:b,...u?{index:u}:{}}},x=this.transientGeometryKeys.has(o);return r.dataPatched={...i,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,x),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let i=r.cloner;if(i===void 0)return-1;let o=i.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?i.update(this.entityOpContext):i.syncInstanceMatrices(),i.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let i=new cr(t);i.playModeVisible=e.visible!==!1,i.expand(),typeof e.name=="string"&&(i.name=e.name);let o=Math.PI/180;return i.position.copy(t.position),i.rotation.copy(t.rotation),i.scale.copy(t.scale),i.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(i.position.x=e.position.x),typeof e.position.y=="number"&&(i.position.y=e.position.y),typeof e.position.z=="number"&&(i.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(i.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(i.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(i.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(i.scale.x=e.scale.x),typeof e.scale.y=="number"&&(i.scale.y=e.scale.y),typeof e.scale.z=="number"&&(i.scale.z=e.scale.z)),i.updateMatrix(),r.add(i),i.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),i}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let i=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!i.includes(u)&&i.push(u)}if(i.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Tt(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Do?d.setValue(u,new Tt(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of i){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:Gn(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(v=>v.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(v=>v.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=rc[f.data.type]??[],g=Object.keys(f.data);for(let[v,b]of Object.entries(h)){if(v==="id"||v==="index"||v==="type")continue;let S=g.find(w=>w===v)??g.find(w=>a(w)===a(v))??v;if(y.includes(S))continue;let x=s(b);if(x&&l(m,S,x)){c=!0;continue}if(typeof b=="number"&&isFinite(b))d.onVariableUpdate?.(["layer",f.id,S],b,o),c=!0;else if(Array.isArray(b)&&b.length<=3&&b.every(w=>typeof w=="number"&&isFinite(w))){let w=["x","y","z"];b.forEach((A,E)=>{d.onVariableUpdate?.(["layer",f.id,S,w[E]],A,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(GT))return GT.decompose(UT,zT,xV),t[1]==="position"?UT[t[2]]:(jT.setFromQuaternion(zT,r.rotation.order),jT[t[2]]*Jx.RAD2DEG);for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=Jx.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let i=this.variables[r],o=i.locations?.findIndex(a=>Ot.equal(a,e));o!==void 0&&o!==-1&&i.locations.splice(o,1)}if(typeof t=="string"){let r=t,i=t;do{if(i=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[i]!==void 0&&this.variables[i].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(jt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let i=e.userAPIs[t.path[1]];if(i){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(i):a?.update(i,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let i=e.userWebhooks[t.path[1]];i&&this.getUserWebhook(t.path[1])?.update(i)}}else t.path[0]==="lib"&&this.updateLibByOp(jt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let i=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};i.update(o),i.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=VT();return r===null?($t("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=Zx();return r===null?($t("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=Zx();return r===null?($t("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},Aa=e0;Aa.MAX_TRANSIENT_VERTICES=6e4;var WT=new Aa(ri.emptyData());function Ps(n){return n?.isClassicNodeMaterial===!0}function qT(n){return n?.isClassicSharedMaterial===!0}function fm(n){return Ps(n)||n?.isTSLNodeMaterial===!0}function XT(n){return qT(n)||n?.isTSLSharedMaterial===!0}ut();mr();var oi=5,ic=3;var tr=class extends tt{setMaterialOverride(e,r){this.materialOverride=Yx(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,i){if(super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.syncShadowCatcher(i),$w(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=i.shared.material(a);l!==s&&tr.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(jt.drop(e,1),r.material,i)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(jt.drop(e,2),a,i)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let i=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(i.flatShading,i.side,i.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(i.flatShading,i.side,i.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(i.flatShading,i.side,i.wireframe);else this.material=this.material.getFlavor(i.flatShading,i.side,i.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=IT();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=r.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){fm(e)&&!XT(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&$p(this.material).forEach(e=>{tr.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};import{BufferGeometry as mm,Matrix4 as r0,Vector3 as JT,Vector4 as i0}from"three";var YT=new JT,QT=new i0,KT=new i0,SV=new JT,ZT=new r0,Qe=class extends tr{constructor(e,r,i){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new r0().fromArray(r.bindMatrix),this.bindMatrixInverse=new r0)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof mm&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof mm?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Aa){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return jd.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return jd.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(jt.drop(e,1),r.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Wi(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&Su(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else{let o={...this.data.geometry,...e},a=Wi(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&am(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,i){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof St&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&dm(e.props)&&this.geometryCreateDeleyed instanceof St&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof mm&&!(this.geometryCreateDeleyed instanceof St)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=i.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Wi(d,a,this.data.flatShading,this);am(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}o||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let i=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof mm&&!(this.geometryCreateDeleyed instanceof St)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Wi(o,i,this.data.flatShading,this);am(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of i)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new i0,i=this.geometry.attributes.skinWeight;for(let o=0,a=i.count;o<a;o++){r.fromBufferAttribute(i,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),i.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let i=this.skeleton;if(i===void 0)return;let o=this.geometry;QT.fromBufferAttribute(o.attributes.skinIndex,e),KT.fromBufferAttribute(o.attributes.skinWeight,e),YT.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=KT.getComponent(a);if(s!==0){let l=QT.getComponent(a);ZT.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(SV.copy(YT).applyMatrix4(ZT),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};import{Group as RV}from"three";import{AxesHelper as PV,Group as TV,Quaternion as MV,Vector3 as o0}from"three";import{BoxGeometry as wV}from"three";var Un=n=>{var t;return t=class extends n{},t.geometryHelper=new wV(30,30,30),t};import{Ray as AV,Sphere as CV,Matrix4 as EV,Vector3 as No}from"three";var ym=new AV,n0=new CV,$T=new EV,zn=(n,t,e,r,i=!1,o=n)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),n0.copy(a.boundingSphere),n0.applyMatrix4(s),e.ray.intersectsSphere(n0)===!1||($T.copy(s).invert(),ym.copy(e.ray).applyMatrix4($T),a.boundingBox!==null&&ym.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(i===!1){let v=Math.max(0,f.start),b=Math.min(p.count,f.start+f.count);for(m=v,y=b;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(n,e,ym,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let b=a.attributes.position,S=new No,x=new No,w=new No,A=new No,E=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),O=M*M,R=Math.max(0,f.start),N=Math.min(b.count,f.start+f.count);for(let C=R,B=N-1;C<B;C+=E){if(S.fromBufferAttribute(b,C),x.fromBufferAttribute(b,C+1),ym.distanceSqToSegment(S,x,A,w)>O)continue;A.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(A);F<e.near||F>e.far||r.push({distance:F,point:w.clone().applyMatrix4(o.matrixWorld),object:n})}}function g(v,b,S,x,w,A,E){let T=new No,M=new No,O=new No,R=new No,N=new No;if(T.fromBufferAttribute(x,w),M.fromBufferAttribute(x,A),O.fromBufferAttribute(x,E),S.intersectTriangle(T,M,O,!1,R)===null)return null;N.copy(R),N.applyMatrix4(v.matrixWorld);let B=b.ray.origin.distanceTo(N);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:N.clone(),object:v}}};var OV=new o0(1,1,1),eM=new o0,IV=new o0,tM=new MV,Xi=class extends Un(PV){constructor(e,r=15){super(r);this.object=e;this.dummy=new TV;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){zn(this.object,Xi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(eM,tM,IV),this.matrix.compose(eM,tM,OV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};import{Box3Helper as rM,BoxGeometry as DV}from"three";var gm;(t=>t.is=e=>"objectHelper"in e)(gm||(gm={}));var Yi=(n,t)=>class extends Fl(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,o){this.objectHelper.raycast(i,o)}showGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof rM&&(o.visible=!0)}}updateEntityBoxSize(i,o){this.objectHelper.visible&&this.geometryHelper instanceof DV?(i.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,o)}hideGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof rM&&(o.visible=!1)}}};var oc=class extends Yi(RV,Xi){constructor(e,r,i){super();this.super_Entity(e,r),this.context=i,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var BV=null;function iM(){return BV}var Tm=Rd(oM());import{Object3D as JV,Vector3 as _r,Euler as Pm,MathUtils as wM,Matrix4 as Yn,Quaternion as $V}from"three";var NV=.5*(Math.sqrt(3)-1),Eu=(3-Math.sqrt(3))/6,LV=1/3,jn=1/6,dae=(Math.sqrt(5)-1)/4,uae=(5-Math.sqrt(5))/20,Pu=n=>Math.floor(n)|0,aM=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]),s0=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 sM(n=Math.random){let t=cM(n),e=new Float64Array(t).map(i=>aM[i%12*2]),r=new Float64Array(t).map(i=>aM[i%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*NV,u=Pu(o+d),p=Pu(a+d),h=(u+p)*Eu,f=u-h,m=p-h,y=o-f,g=a-m,v,b;y>g?(v=1,b=0):(v=0,b=1);let S=y-v+Eu,x=g-b+Eu,w=y-1+2*Eu,A=g-1+2*Eu,E=u&255,T=p&255,M=.5-y*y-g*g;if(M>=0){let N=E+t[T],C=e[N],B=r[N];M*=M,s=M*M*(C*y+B*g)}let O=.5-S*S-x*x;if(O>=0){let N=E+v+t[T+b],C=e[N],B=r[N];O*=O,l=O*O*(C*S+B*x)}let R=.5-w*w-A*A;if(R>=0){let N=E+1+t[T+1],C=e[N],B=r[N];R*=R,c=R*R*(C*w+B*A)}return 70*(s+l+c)}}function lM(n=Math.random){let t=cM(n),e=new Float64Array(t).map(o=>s0[o%12*3]),r=new Float64Array(t).map(o=>s0[o%12*3+1]),i=new Float64Array(t).map(o=>s0[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*LV,f=Pu(a+h),m=Pu(s+h),y=Pu(l+h),g=(f+m+y)*jn,v=f-g,b=m-g,S=y-g,x=a-v,w=s-b,A=l-S,E,T,M,O,R,N;x>=w?w>=A?(E=1,T=0,M=0,O=1,R=1,N=0):x>=A?(E=1,T=0,M=0,O=1,R=0,N=1):(E=0,T=0,M=1,O=1,R=0,N=1):w<A?(E=0,T=0,M=1,O=0,R=1,N=1):x<A?(E=0,T=1,M=0,O=0,R=1,N=1):(E=0,T=1,M=0,O=1,R=1,N=0);let C=x-E+jn,B=w-T+jn,_=A-M+jn,F=x-O+2*jn,V=w-R+2*jn,Z=A-N+2*jn,q=x-1+3*jn,G=w-1+3*jn,W=A-1+3*jn,j=f&255,K=m&255,te=y&255,Q=.6-x*x-w*w-A*A;if(Q<0)c=0;else{let de=j+t[K+t[te]];Q*=Q,c=Q*Q*(e[de]*x+r[de]*w+i[de]*A)}let ae=.6-C*C-B*B-_*_;if(ae<0)d=0;else{let de=j+E+t[K+T+t[te+M]];ae*=ae,d=ae*ae*(e[de]*C+r[de]*B+i[de]*_)}let re=.6-F*F-V*V-Z*Z;if(re<0)u=0;else{let de=j+O+t[K+R+t[te+N]];re*=re,u=re*re*(e[de]*F+r[de]*V+i[de]*Z)}let ne=.6-q*q-G*G-W*W;if(ne<0)p=0;else{let de=j+1+t[K+1+t[te+1]];ne*=ne,p=ne*ne*(e[de]*q+r[de]*G+i[de]*W)}return 32*(c+d+u+p)}}function cM(n){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 i=r+~~(n()*(256-r)),o=e[r];e[r]=e[i],e[i]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as _V}from"three";var hn=new _V,vm=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let o=1;hn.a.fromBufferAttribute(t,i),hn.b.fromBufferAttribute(t,i+1),hn.c.fromBufferAttribute(t,i+2),o*=hn.getArea(),e[i/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,o=-1;for(;r<=i;){let a=Math.ceil((r+i)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?i=a-1:r=a+1}return o}sampleFace(t,e,r){let i=this.randomFunction(),o=this.randomFunction();return i+o>1&&(i=1-i,o=1-o),hn.a.fromBufferAttribute(this.positionAttribute,t*3),hn.b.fromBufferAttribute(this.positionAttribute,t*3+1),hn.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(hn.a,i).addScaledVector(hn.b,o).addScaledVector(hn.c,1-(i+o)),hn.getNormal(r),this}};import{Box3 as GV,Matrix4 as UV,Sphere as uM,Vector3 as zV}from"three";import{BufferAttribute as FV,Float32BufferAttribute as dM,MathUtils as l0,Vector3 as d0}from"three";function kV(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,i=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new d0(i[a],i[a+1],i[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new d0})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new dM(o,3))}function VV(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),i=new d0;for(let o=0;o<e.length;o+=3)i.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=i.x,r[o+1]=i.y,r[o+2]=i.z;n.geometry.setAttribute("extrudeNormal",new dM(r,3))}function Hn(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!Ps(n.material)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?VV(n):kV(n)}function c0(n){return Math.min(2047,Math.max(1,Math.round(n*2048)))/2048}function Wn(n){if(!n.geometry.attributes.position)return;let t=n.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let i=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),a=[c0(l0.seededRandom(o)),c0(l0.seededRandom(o+1e4)),c0(l0.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)i[s]=a[s%3];n.geometry.setAttribute("randomColor",new FV(i,3))}var qn=new GV,Tu=new zV;function pM(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Lo=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new UV;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:o,subdivPointer:a}=St.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Hn(this),Wn(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(o=>o.getFlavor(!1,o.side,o.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,i=!1){r&&this.subdividedGeometry||St.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&St.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=St.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=St.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Hn(this),Wn(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,tt.prototype.raycast.call(this,e,r),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new uM,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;qn.setFromBufferAttribute(r),qn.getCenter(i),e.boundingSphere.radius=i.distanceTo(qn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qn.getSize(Tu),this.hasNonUniformScale&&Tu.divide(this.scale);let o={width:Tu.x,height:Tu.y,depth:Tu.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;qn.min.set(e[0],e[2],e[4]),qn.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(qn.min.applyMatrix4(this.shearScaleInv),qn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new uM);let i=r.boundingSphere.center;qn.getCenter(i),r.boundingSphere.radius=i.distanceTo(qn.max)}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,i=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?St.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Hn(this),Wn(this),o!==void 0&&(this.localGeometry.userData.parameters=o),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(e,r,i){super.updateByPatchedOpGeometry(e,r,i),this.localGeometry&&(e.type===0&&e.path.length===0&&dm(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};import{Triangle as jV,Vector3 as Ms}from"three";var hM=-1,HV=1,fM={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},mM={polygon_center:0,edge:1,vertex:2},Mu=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,je=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-hM)*(e-r)/(HV-hM)+r},WV=new Ms,bm=new Ms,qV=new Ms,XV=new Ms;function ac(n,t){let e=qV.fromArray(n),r=XV.fromArray(t);bm.copy(r).sub(e);let i=bm.length();return bm.normalize().multiplyScalar(i*.5),WV.copy(e).add(bm).toArray()}var Qi=new jV,xm=new Ms,Sm=new Ms,Ts=new Ms;function yM(n){let t=[],e=Math.floor(n.index.count/3);for(let r=0;r<e;r++)if(xm.fromArray(n.index.array,r*3),Qi.setFromAttributeAndIndices(n.attributes.position,xm.x,xm.y,xm.z),Qi.getNormal(Sm),Qi.getMidpoint(Ts),!(isNaN(Ts.x)||isNaN(Ts.y)||isNaN(Ts.z))){let{a:i,b:o,c:a}=Qi,s=i.toArray(),l=o.toArray(),c=a.toArray(),d=i.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(i),h=ac(s,l),f=ac(l,c),m=ac(c,s),y=[d,u,p],g=Math.max(...y),v=y.filter(x=>Math.round(x)===Math.round(g)).length>1,b=[],S=Qi.getMidpoint(Ts).toArray();g===d&&!v&&(b=[f,m,m],S=h),g===u&&!v&&(b=[h,m,m],S=f),g===p&&!v&&(b=[h,f,f],S=m),v&&(b=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:b,midpoint:S,norm:Qi.getNormal(Sm).toArray()})}return t}function gM(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Qi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Qi.getNormal(Sm),Qi.getMidpoint(Ts);let i=Qi.a.toArray(),o=Qi.b.toArray(),a=Qi.c.toArray();t.push({vertices:[i,o,a],faceCenters:[ac(i,o),ac(o,a),ac(a,i)],midpoint:Ts.toArray(),norm:Sm.toArray()})}return t}import{InstancedMesh as YV,Matrix4 as u0}from"three";var p0=class extends YV{},wm=class extends p0{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new u0;this.pivotMatrix=new u0;this.previousModelViewMatrix=new u0;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(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.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let i=this.parent;if(e&&i!==null&&i.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)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,i,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var h0=n=>.5*(1-Math.cos(n*Math.PI)),f0=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let i=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-i,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let v=i+(o<<4)+(a<<8);d=h0(s),u=h0(l),f=this.perlin[v&4095],f+=d*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=d*(this.perlin[v+16+1&4095]-m),f+=u*(m-f),v+=256,m=this.perlin[v&4095],m+=d*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=d*(this.perlin[v+16+1&4095]-y),m+=u*(y-m),f+=h0(c)*(m-f),p+=f*h,h*=.5,i<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(i++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},vM=f0;import{Vector3 as QV,Matrix4 as KV,Ray as ZV}from"three";var bM=new QV,xM=new KV,SM=new ZV,Ca=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(xM.copy(i).invert(),SM.copy(e.ray).applyMatrix4(xM),SM.intersectBox(this.singleBBox,bM))){let o=bM.applyMatrix4(i),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var ai=1e-4,Xn,NM,LM,_M,AM=new _r,CM=new _r;om.then(n=>{Xn=n,NM=[Xn.get_face_center,Xn.get_edge_midpoint,Xn.get_vertex_position],LM=[Xn.get_face_normal,Xn.get_edge_normal,Xn.get_vertex_normal],_M=[Xn.face_count,Xn.edge_count,Xn.vertex_count]});var Cse=new Yn,eG=new Yn,EM=new Yn,PM=new Yn,TM=new Yn,MM=new Yn,OM=new Yn,IM=new Yn,Ea=new _r,Am=new _r,Ou=new _r,m0=new _r,tG=new _r,DM=new _r,Cm=new _r,y0=new _r,RM=new _r,g0=new _r,BM=new _r,fn=new Pm,rG=new $V;function Em(n){return n?n.version??n.data?.version??0:-1}function Ht(n,t){return[typeof n?.[0]=="number"?n[0]:typeof n?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(n[0])??"0")):0,typeof n?.[1]=="number"?n[1]:typeof n?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(n[1])??"0")):0,typeof n?.[2]=="number"?n[2]:typeof n?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(n[2])??"0")):0]}var v0=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new vM;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(i,o,a)=>this.perlin.noise(i,o,a):this.noise=i=>this.perlin.noise(i)):e?this.noise=lM((0,Tm.default)(t.seed)):this.noise=sM((0,Tm.default)(t.seed??""))}},si=class extends Nl(JV){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof tt&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof cr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let i=r.transformOverride;i!==void 0&&(r.position.fromArray(i.position),r.rotation.fromArray(i.rotation),r.scale.fromArray(i.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||cn(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new wm(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let i of this.children)i.playModeVisible!==!1&&(EM.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),e.setMatrixAt(r++,EM));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let i;if(r!==void 0)i=r;else{let o=Ht(this.parameters.grid.count,e);i=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)i=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==i)if(this.children.length<i)for(let o=0,a=i-this.children.length;o<a;++o){let s=new cr(this.object);s.expand(),this.add(s)}else for(;this.children.length>i;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new v0(e,r)),this.random}_updateRadial(e,r){let i=e.radial,o=i.start*wM.DEG2RAD,a=i.end*wM.DEG2RAD,s=o-a,l=Ht(i.rotation,r),c=new Pm(l[0],l[1],l[2]),d;switch(i.axis){case"z":d=new _r(0,0,1);break;case"y":d=new _r(0,1,0);break;default:case"x":d=new _r(1,0,0);break}let u=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=Ht(i.scale,r),m=Ht(i.position,r),y=Ht(u.scale,r),g=Ht(u.position,r),v=Ht(u.rotation,r),b=s/e.count,S=Mu(u.strength,this.parameters.randomness);for(let[x,w]of this.children.entries()){let A=x*(u.freqScale/10)+u.movement,E=h===null?0:h.noise(A,A,A),T=x+1;w.scale.x=f[0]+S(T,je(E,y[0]))||ai,w.scale.y=f[1]+S(T,je(E,y[1]))||ai,w.scale.z=f[2]+S(T,je(E,y[2]))||ai;let M=b*x-o;switch(i.axis){default:case"x":fn.set(0,M,0);break;case"y":fn.set(0,0,M);break;case"z":fn.set(M,0,0);break}Cm.copy(d).applyQuaternion(rG.setFromEuler(fn)).multiplyScalar(i.radius),w.position.set(Cm.x+(m[0]+S(T,je(E,g[0]))),Cm.y+(m[1]+S(T,je(E,g[1]))),Cm.z+(m[2]+S(T,je(E,g[2]))));let O=S(T,je(E,v[0])),R=S(T,je(E,v[1])),N=S(T,je(E,v[2]));i.alignment===!0?w.rotation.set(fn.x+(c.x+O),fn.y+(c.y+R),fn.z+(c.z+N)):w.rotation.set(c.x+O,c.y+R,c.z+N)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let i=e.linear,o=Ht(i.rotation,r),a=Ht(i.scale,r),s=Ht(i.position,r),l=new Pm(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,d=Ht(c.rotation,r),u=Ht(c.scale,r),p=Ht(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Mu(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let v=y*(c.freqScale/10)+c.movement,b=f===null?0:f.noise(v,v,v),S=y+1,x=m(S,je(b,d[0])),w=m(S,je(b,d[1])),A=m(S,je(b,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,je(b,u[0]))||ai,g.scale.y=1+(a[1]-1)*y+m(S,je(b,u[1]))||ai,g.scale.z=1+(a[2]-1)*y+m(S,je(b,u[2]))||ai,g.rotation.set(l.x*y+x,l.y*y+w,l.z*y+A),g.position.x=s[0]*y+m(S,je(b,p[0])),g.position.y=s[1]*y+m(S,je(b,p[1])),g.position.z=s[2]*y+m(S,je(b,p[2]))}}_updateGrid(e,r){let i=0,o=e.grid,a=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,s=Ht(a.scale,r),l=Ht(a.rotation,r),c=Ht(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Mu(a.strength,this.parameters.randomness),h=Ht(o.count,r),f=Ht(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new _r(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let v=0;v<h[1];v++)for(let b=0;b<h[2];b++){let S=this.children[i++];if(!S)continue;let x=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(v+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(i,je(x,s[0]))||ai,S.scale.y=1+p(i,je(x,s[1]))||ai,S.scale.z=1+p(i,je(x,s[2]))||ai;let w=p(i,je(x,l[0])),A=p(i,je(x,l[1])),E=p(i,je(x,l[2]));S.rotation.set(w,A,E),S.position.x=f[0]*g-y.x+p(i,je(x,c[0])),S.position.y=f[1]*v-y.y+p(i,je(x,c[1])),S.position.z=f[2]*b-y.z+p(i,je(x,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let v=this.children[i++];if(!v)continue;let b=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);v.scale.x=1+p(i,je(b,s[0]))||ai,v.scale.y=1+p(i,je(b,s[1]))||ai,v.scale.z=1+p(i,je(b,s[2]))||ai;let S=p(i,je(b,l[0])),x=p(i,je(b,l[1])),w=p(i,je(b,l[2]));v.rotation.set(S,x,w),v.position.x=f[0]*m+p(i,je(b,c[0])),v.position.y=-f[1]*y+p(i,je(b,c[1])),v.position.z=-f[2]*g+p(i,je(b,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:i}=e,o=Ht(i.rotation,r),a=Ht(i.position,r),s=Ht(i.scale,r),l=new Pm(o[0],o[1],o[2]),c=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,d=Ht(c.rotation,r),u=Ht(c.position,r),p=Ht(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Mu(c.strength,this.parameters.randomness);if(!i.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof Ca)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let w=Math.round(y.length*i.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=i.spreadType==="random",v=null;g&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,Tm.default)(this.object.uuid+i.seed)));let b=fM[i.axis],S=this.children;Ea.fromArray(b),PM.copy(this.object.hiddenMatrix).invert();let x=this.objectForSample instanceof Lo;x&&TM.copy(this.objectForSample.matrixWorld).invert(),i.align!=="normal"&&this.object.getWorldDirection(DM),g0.set(Ea.y,Ea.z,Ea.x).normalize(),BM.copy(g0).cross(Ea).normalize(),OM.makeBasis(g0,Ea,BM).invert();for(let[w,A]of S.entries()){let E=w*(c.freqScale/10)+c.movement,T=f===null?0:f.noise(E,E,E),M=w+1,O=m(M,je(T,d[0])),R=m(M,je(T,d[1])),N=m(M,je(T,d[2]));g?v.sample(Ou,m0):(y.length&&(Ou.fromArray(y[w].pos),m0.fromArray(y[w].norm)),x&&Ou.applyMatrix4(TM)),Ou.applyMatrix4(PM),A.position.copy(Ou);let C=i.align==="normal"?m0:DM,B=Am.fromArray(a);Am.x+=m(M,je(T,u[0])),Am.y+=m(M,je(T,u[1])),Am.z+=m(M,je(T,u[2]));let _=Math.acos(C.dot(Ea)),F=tG.crossVectors(Ea,C).normalize(),V=eG.makeRotationAxis(F,_);y0.copy(C).cross(this.object.up).normalize(),RM.copy(y0).cross(C).normalize(),MM.makeBasis(y0,C,RM),IM.multiplyMatrices(MM,OM),fn.setFromRotationMatrix(IM),B.applyMatrix4(V),A.position.add(B),A.rotation.set(fn.x+l.x+O,fn.y+l.y+R,fn.z+l.z+N),A.scale.set(1+s[0]+m(M,je(T,p[0]))||ai,1+s[1]+m(M,je(T,p[1]))||ai,1+s[2]+m(M,je(T,p[2]))||ai),A.scale.multiply(this.object.scale),A.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,i=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===i&&a.positionVersion===Em(i)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new vm(e).build();return this.surfaceSamplerCache={geometry:r,position:i,positionVersion:Em(i),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Lo,i=this.objectForSample.geometry;if(!r&&i){let l=this.surfacePointsCache,c=i.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===i&&l.position===c&&l.positionVersion===Em(c)&&l.index===i.index&&l.indexVersion===(i.index===null?-1:i.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=mM[e],d=_M[c],u=NM[c],p=LM[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);AM.fromArray(m).applyMatrix4(l.matrixWorld),CM.fromArray(y),a(AM.toArray(),CM.toArray())}}else(i.index?yM(i):gM(i)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&i){let l=i.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:i,position:l,positionVersion:Em(l),index:i.index,indexVersion:i.index===null?-1:i.index.version,points:s}}return s}updateState(e,r){if(this.parameters=va(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let i=r.scene.find(this.parameters.toObject.object);i instanceof tt?this.objectForSample=i:this.objectForSample=void 0,this.matrix=new Yn,this.hiddenMatrix=new Yn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var mn=24,dr=96,Kn=lP(),_o=2;var C0=!1,zM=!0;try{let n=new URLSearchParams(window.location.search);C0=n.get("dbgsbstatic")==="0",zM=n.get("sb512")!=="0"}catch{}function nG(n){let t=n.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var E0=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(dr);this._prevReach=new Float32Array(dr);this._fieldDirtyFull=!0;this._fieldDirtyMin=new cc;this._fieldDirtyMax=new cc;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new S0;this.potentialPassScene=new S0;this.voxelPassScene=new S0;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new kM,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new b0(zl,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new A0(Kn.triTable,16,256,x0,Fo);o.needsUpdate=!0;let a=new A0(Kn.numTrisTable,256,1,x0,Fo);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new b0(zl,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new b0(zl,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=cG.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new VM({vertexShader:c.vertexShader,fragmentShader:`
729
+ `&&o.push("")):t.getTextWidth(o[o.length-1]+a,n)>i&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,n)>i&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}import{BufferGeometry as Fx,BufferAttribute as bT,Uint32BufferAttribute as kx,Float32BufferAttribute as sm,Matrix4 as aV,Vector3 as wu,Sphere as sV,Box3 as lV,BoxGeometry as cV}from"three";var gT,om=new Promise(n=>{gT=n}),yT=!1;var nm;function vT(n){if(yT)return;if(nm)return nm;async function t(){let r=n??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.12/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});gT(c),yT=!0}return nm=t(),nm}import{Matrix4 as nV}from"three";var oV=new nV;function am(n,t){if(Object.keys(n.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(n.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let s of r){let l=n.attributes[s],c=t.attributes[s];if(l===void 0||l.isInterleavedBufferAttribute===!0||c.isInterleavedBufferAttribute===!0||l.itemSize!==c.itemSize||l.normalized!==c.normalized||l.array.constructor!==c.array.constructor||l.array.length!==c.array.length)return!1}let i=n.index,o=t.index;if(i===null!=(o===null))return!1;let a=!1;if(i!==null&&o!==null){if(i.array.length!==o.array.length)return!1;let s=i.array.constructor,l=o.array.constructor;if(s!==l){if(s!==Uint32Array||l!==Uint16Array)return!1;a=!0}}if(n.groups.length!==t.groups.length)return!1;for(let s=0;s<t.groups.length;s++){let l=n.groups[s],c=t.groups[s];if(l.start!==c.start||l.count!==c.count||l.materialIndex!==c.materialIndex)return!1}for(let s of r){let l=n.attributes[s],c=t.attributes[s];l.array.set(c.array),l.needsUpdate=!0}if(i!==null&&o!==null){if(a){let s=i.array,l=o.array;for(let c=0,d=l.length;c<d;c++){let u=l[c];s[c]=u===65535?4294967295:u}}else i.array.set(o.array);i.needsUpdate=!0}return n.drawRange.start=t.drawRange.start,n.drawRange.count=t.drawRange.count,n.userData=t.userData,n.boundingBox=null,n.boundingSphere=null,!0}function Su(n,t,e,r){let i=n.position.array,o=n.normal.array,a=oV.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=i.length;d<u;d+=3)i[d]*=t,i[d+1]*=e,i[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var lm=new lV,tc=new wu,Te;om.then(n=>{Te=n});var xT=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ST=new Uint32Array([0,1,2,3]),wT=new Uint8Array([4]),St=class extends Fx{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let i=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=_i.div(r.map(l=>typeof l=="number"?l:0),i);if(o.every(l=>l===1))return;this.subdividedGeometry&&Su(this.subdividedGeometry.attributes,...o),this.originalGeometry&&Su(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(tc.fromArray(o));let s=tc.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let r=e.phongAngle??35;this.flatShading&&(r=-1);let i=null;if(e.subdivisions>0){let a=0;try{a=St.allocate(e),i=St.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&St.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=i??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,i;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:i}=St.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new cV(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new sV,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;lm.setFromBufferAttribute(r),lm.getCenter(i),e.boundingSphere.radius=i.distanceTo(lm.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),lm.getSize(tc);let o={width:tc.x,height:tc.y,depth:tc.z};return this.userData.parameters=o,o}static build(e,r,i,o){let a,s,l=e?.phongAngle??35;i===!1&&(l=-1),r&&(Te.free_bvh(r),Te.free_subdivision_surface(r));try{a=St.allocate(e,o)}catch(d){console.error(d,e),a=St.allocate({positionWASM:xT,indexWASM:ST,verticesPerFaceWASM:wT},o)}Te.set_destination_refinement_level(a,0);let c=St.buildLevel(a,!0,l);return e.subdivisions>0?s=St.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,i){try{return Te.set_destination_refinement_level(e,r),St.buildLevel(e,!1,i)??null}catch{try{return Te.set_destination_refinement_level(e,r-1),St.buildLevel(e,!1,i)??null}catch{return null}}}static primitiveToQuads(e,r,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let o=e.shape!==void 0||e.path!==void 0?r.geometry:Wi(e,i,!1,r),a;xf(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=Au(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=dV(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let i,o,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,o=e.indexWASM,a=e.verticesPerFaceWASM,Te.alloc_subdivision_surface_uvs&&e.uvWASM&&e.uvWASM.length===o.length*2&&(l=e.uvWASM)):(i=xT,o=ST,a=wT);let c=i.length,d=o.length,u=a.length,p=i.length+s.length+l.length,h=o.length+a.length,f=p*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Te._malloc(f),g=new Float32Array(Te.HEAPF32.buffer,y,p),v=new Uint32Array(Te.HEAPU32.buffer,y+m,h);g.set(i,0),g.set(s,i.length),g.set(l,i.length+s.length),v.set(o,0),v.set(a,o.length);let b;e?.scaleBaked?.some(w=>w!==1)&&(b=new aV().makeScale(...e.scaleBaked.map(w=>typeof w=="number"?w:1))),r&&(b?b.premultiply(r):b=r);let S=y+(i.length+s.length)*Float32Array.BYTES_PER_ELEMENT,x=l.length?b?Te.alloc_subdivision_surface_uvs2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length,b.elements):Te.alloc_subdivision_surface_uvs(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,S,l.length):b?Te.alloc_subdivision_surface2(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u,b.elements):Te.alloc_subdivision_surface(y,c,y+m,d,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,u);return Te._free(y),x}static buildLevel(e,r,i,o,a,s=!1){let l=a?Te.get_mesh_data2(e,r?Te.Level.CONTROL:Te.Level.REFINED,i,a.elements):Te.get_mesh_data(e,r?Te.Level.CONTROL:Te.Level.REFINED,i),c=10,d=Te.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=Te.HEAPU32[d[p]>>2],f=Te.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=Te.HEAPU32[d[p]>>2],y=Te.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=Te.HEAPU32[d[p]>>2],v=Te.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let b=Te.HEAPU32[d[p]>>2],S=Te.HEAPU32.subarray(b>>2,(b>>2)+u[p]);p++;let x;if(Te.alloc_subdivision_surface_uvs){let A=d[9];if(A>0){let E=Te.HEAPU32[d[8]>>2];x=Te.HEAPF32.subarray(E>>2,(E>>2)+A)}}if(o===void 0){let A=new Fx;if(A.setIndex(new kx(S,1)),A.setAttribute("position",new sm(f,3)),A.setAttribute("normal",new sm(y,3)),x&&A.setAttribute("uv",new sm(x,2)),r){A.setAttribute("faceMap",new kx(v,1));let E=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new bT(E,4))}return Te.free_mesh_data(l),A.userData.type="SubdivGeometry",A}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let A=o.getIndex();A!==null&&A.array.length===S.length&&(A.copyArray(S),A.needsUpdate=!0)}let w=o.getAttribute("uv");x&&w&&w.array.length===x.length&&(w.copyArray(x),w.needsUpdate=!0),Te.free_mesh_data(l)}static freeSubdivPointer(e){Te.free_bvh(e),Te.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,i){let o=Te.get_wireframe_data_for_base_level(e),a=4,s=Te.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=Te.HEAPU32[s[c]>>2],u=Te.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=Te.HEAPU32[s[c]>>2],h=Te.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new Fx;f.setAttribute("position",new sm(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=i.r,m[y++]=i.g,m[y++]=i.b;return f.setAttribute("color",new bT(m,3)),f.setIndex(new kx(h,1)),Te.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,Te.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,i){let o=r===0;o||Te.set_destination_refinement_level(e,r);let a=i?Te.get_topological_data2(e,o?Te.Level.CONTROL:Te.Level.REFINED,i.elements):Te.get_topological_data(e,o?Te.Level.CONTROL:Te.Level.REFINED),s=8,l=Te.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=Te.HEAPU32[l[d]>>2],p=new Float32Array(Te.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=Te.HEAPU32[l[d]>>2],f=new Uint32Array(Te.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=Te.HEAPU32[l[d]>>2],y=new Uint8Array(Te.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(Te.alloc_subdivision_surface_uvs){let v=l[7];if(v>0){let b=Te.HEAPU32[l[6]>>2];g=new Float32Array(Te.HEAPF32.subarray(b>>2,(b>>2)+v))}}return Te.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function dm(n){let t=Object.keys(n);return t.length===1&&t[0]==="subdivisions"}function Au(n,t){let e=t?t.count:n.count,r=0,i=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=n.getX(u),h=n.getY(u),f=n.getZ(u),m=Math.round(p*i),y=Math.round(h*i),g=Math.round(f*i),v=o.get(m);v===void 0&&(v=new Map,o.set(m,v));let b=v.get(y);b===void 0&&(b=new Map,v.set(y,b));let S=b.get(g);S===void 0&&(S=r++,b.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var cm=new wu,Vx=new wu,Gx=new wu,Ux=new wu;function dV(n,t,e,r,i){let o=[],a=[],s=i?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=i[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,v)=>Math.floor(v/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);n.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)n.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)n.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((n[t[u]*3+2]===d||n[t[u]*3+2]===0)&&p++,(n[t[u+1]*3+2]===d||n[t[u+1]*3+2]===0)&&p++,(n[t[u+2]*3+2]===d||n[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){cm.set(n[t[u]*3],n[t[u]*3+1],n[t[u]*3+2]),Vx.set(n[t[u+1]*3],n[t[u+1]*3+1],n[t[u+1]*3+2]),Gx.set(n[t[u+4]*3],n[t[u+4]*3+1],n[t[u+4]*3+2]),Ux.set(n[t[u+5]*3],n[t[u+5]*3+1],n[t[u+5]*3+2]),Vx.sub(cm).normalize(),Gx.sub(cm).normalize(),Ux.sub(cm).normalize();let p=Vx.cross(Gx).dot(Ux),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<n.length;m+=3,y++)n[m+2]===0&&(p.push(y),f++),n[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var uV={ConeGeometry:AP,CubeGeometry:CP,CylinderGeometry:Uf,DodecahedronGeometry:EP,EllipseGeometry:Zl,HelixGeometry:wE,IcosahedronGeometry:eT,LatheGeometry:tT,NonParametricGeometry:nT,PolygonGeometry:rm,PyramidGeometry:oT,RectangleGeometry:$l,SphereGeometry:sT,PlaneGeometry:lT,BackdropGeometry:cT,StarGeometry:im,TextFrameGeometry:dT,TorusGeometry:uT,TorusKnotGeometry:pT,TriangleGeometry:hT,VectorGeometry:mi},um=n=>{let t=uV[n.type]??ff(n.type);if(t===void 0)throw new Error(`No geometry factory registered for "${n.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(n)};var hV=["font"];function Wi(n,t,e,r){let i,o,a;n.type==="PathGeometry"?(o=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(o={...n},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(i in d){let u=d[i];Yv(u)&&!hV.includes(i)&&(d[i]=t.getVariable(u,[r.uuid,"geometry",...c,i]),Yv(d[i])&&(d[i]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry")s.path=o.path;else if(o.type==="VectorGeometry"){let c=st.createFromState(o.shape,o.width,o.height);s.shape=c}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new pV().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new St(o,e);return c.data=n,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=ff(o.type);if(c)return c.create(o,t);$t("text",`a ${o.type}`);let d=st.createFromState(ps.defaultData(),100,100);return um({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return $l.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=um(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=st.createFromState(ps.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=um(s)}return l}var zx=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let i=this.objects.get(t);return i===void 0?(i=this.createObject(t,e,r),this.objects.set(t,i)):i.isShared=!0,i}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Cu=class extends zx{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,i){let o=Wi(e,r,this.flatShading,i);return o.computeBoundingSphere(),o}};var Wx="webgl",AT,jx,CT=!1;function qx(){return Wx}function PT(n){jx=n}function TT(){if(Wx==="webgpu"){if(AT!==void 0)return AT;CT||(CT=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(jx===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return jx}function pm(n,t){return TT().createRootMaterial(n,t)}function Xx(n,t,e){return TT().createSharedMaterial(n,t,e)}function Yx(n){return n.getLayersOfType===void 0&&Object.assign(n,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),n}var ET,MT;function OT(n){MT=n}function IT(){let n=Wx==="webgpu"&&ET!==void 0?ET:MT;return n===void 0?null:Yx(n())}var Hx;function DT(n){Hx=n}function RT(n,t){return Hx===void 0?!1:Hx(n,t)}var BT={markNeedsUpdateRendererDirty:()=>{}};function Gn(n,t){let e=0;if(!n.layers||n.layers.length===0)return!1;let r=n.layers?.find(i=>i.data.type==="light");if(r){let i=r.data,o=Number(t.getVariable(i.alphaOverride));if((typeof i.alphaOverride=="string"?o/100:i.alphaOverride)<1)return!0}for(let i of n.layers){if(i.data.type!=="displace"&&i.data.isMask)return!0;if(i.data.type!=="displace"&&"alpha"in i.data&&i.data.type!=="light"&&i.data.type!=="fresnel"&&i.data.type!=="cavity"&&i.data.type!=="dust"&&i.data.type!=="texture"&&i.data.type!=="matcap"&&i.data.type!=="rainbow"&&i.data.type!=="outline"&&i.data.type!=="pattern"){let o=i.data.visible?i.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&i.data.type==="depth"||i.data.type==="gradient"){for(let a of i.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&i.data.type==="noise"){let a=t.color(i.data.colorA).a,s=t.color(i.data.colorB).a,l=t.color(i.data.colorC).a,c=t.color(i.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var qi=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,ye=(n,t,e)=>typeof n=="number"?n:t.getVariable(n,e);function Qx(n){let t=typeof n=="string"?n:n.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function pn(n){return typeof n=="string"||typeof n=="number"&&n!==0}var rc={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},NT={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};import{Object3D as fV}from"three";var Kx=class extends Nl(fV){},mV=n=>n.type==="Mesh",cr=class extends Kx{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let i=this.children[e];i?.object!==r&&(i&&this.remove(i),i=new cr(r),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=r.matrix,i.hiddenMatrix=r.hiddenMatrix,i.pivotMatrix=r.pivotMatrix),i.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1: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 mV(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};ut();import{Euler as gV,MathUtils as Jx,Matrix4 as vV,Quaternion as bV,Vector3 as HT}from"three";var LT=null,_T=null;function FT(n){LT=n}function Zx(){return LT}function kT(n){_T=n}function VT(){return _T}function hm(n){return"variable_"+n}var GT=new vV,UT=new HT,zT=new bV,xV=new HT,jT=new gV,$x=class extends Vf{constructor(e){super();this.shared=e}create(e){return new jl(e,this.shared)}},e0=class{constructor(t,e={},r=!0,i=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=i;this.geometryCache=new Cu(!0);this.geometryCache2=new Cu(!1);this.imageHolderCache=new $x(this);this.thisContext={scene:BT,shared:this};this.deletedImage=new Ei(nf.emptyImage,this);this.deletedVideo=new Ei(ml.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.timelineAnimations={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};this.transientGeometryKeys=new WeakSet;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=Xx(Xt.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:i,data:o}of t.variables)this.addVariableHolder(i,o),e&&this.updateVariableHolder(i,o);for(let[i,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(i,o);for(let[i,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(i,o);if(!r){for(let[i,o]of Object.entries(t.images))this.addImage(i,o);for(let[i,o]of Object.entries(t.videos))this.addVideo(i,o)}for(let[i,o]of Object.entries(t.colors))this.addColor(i,o);for(let[i,o]of Object.entries(t.lib.materials))this.addMaterial(i,o.asset);for(let[i,o]of Object.entries(t.materials))this.addMaterial(i,o);for(let[i,o]of Object.entries(t.audios))this.addAudio(i,o);for(let[i,o]of Object.entries(t.particles))this.addParticle(i,o);for(let[i,o]of Object.entries(t.fonts))this.addFont(i,o);for(let[i,o]of Object.entries(t.timelineAnimations??{}))this.addAnimation(i,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:Xt.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=Xx(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:Xt.defaultTwoLayerData("phong").layers}),pm(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Ei(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Ei(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Ei(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Do(e.r,e.g,e.b,e.a):this.colors[t]=new Do(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Tt(0,0,0,0))}else return"a"in t?new Tt(t.r,t.g,t.b,t.a):new Tt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Ro)return e;{let r=new Ro({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Ro&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=bP();if(r===null){$t("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}addAnimation(t,e){this.timelineAnimations[t]=e}getAnimation(t){return this.timelineAnimations[t]}deleteAniamtion(t){this.timelineAnimations[t]&&delete this.timelineAnimations[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Ro&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let i=localStorage.getItem(hm(t));r=i!==null?JSON.parse(i):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(hm(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let i=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:i,shared:this},u=s.slice(2);i.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=i.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*Jx.DEG2RAD:l[s[s.length-1]]=r}if(l=i.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),Ve.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&i.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...i,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(i.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let i=e.dataPatched?.geometry;return!i||!this.transientGeometryKeys.has(i)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(i),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let i=r.dataPatched,o=i?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>e0.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let w=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(w.length===0||w.length%3!==0)return!1;for(let A=0;A<w.length;A++)if(w[A]>=l)return!1;u={array:w,itemSize:1,type:w.constructor.name,normalized:!1}}else{let w=o.data,A=w?.index;if(A?.array?.length){let E=(w?.attributes?.position?.array?.length??0)/3;if(l<E){let T=A.array;for(let M=0;M<T.length;M++)if(T[M]>=l)return!1}u=A}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let w=0;w<s.length;w+=3){let A=s[w],E=s[w+1],T=s[w+2];A<p&&(p=A),A>m&&(m=A),E<h&&(h=E),E>y&&(y=E),T<f&&(f=T),T>g&&(g=T)}let v=(w,A)=>({array:w,itemSize:A,type:"Float32Array",normalized:!1}),b={position:v(s,3)};c&&(b.normal=v(c,3)),d&&(b.uv=v(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:b,...u?{index:u}:{}}},x=this.transientGeometryKeys.has(o);return r.dataPatched={...i,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,x),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let i=r.cloner;if(i===void 0)return-1;let o=i.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?i.update(this.entityOpContext):i.syncInstanceMatrices(),i.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let i=new cr(t);i.playModeVisible=e.visible!==!1,i.expand(),typeof e.name=="string"&&(i.name=e.name);let o=Math.PI/180;return i.position.copy(t.position),i.rotation.copy(t.rotation),i.scale.copy(t.scale),i.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(i.position.x=e.position.x),typeof e.position.y=="number"&&(i.position.y=e.position.y),typeof e.position.z=="number"&&(i.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(i.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(i.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(i.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(i.scale.x=e.scale.x),typeof e.scale.y=="number"&&(i.scale.y=e.scale.y),typeof e.scale.z=="number"&&(i.scale.z=e.scale.z)),i.updateMatrix(),r.add(i),i.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),i}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let i=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!i.includes(u)&&i.push(u)}if(i.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Tt(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Do?d.setValue(u,new Tt(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of i){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:Gn(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(v=>v.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(v=>v.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=rc[f.data.type]??[],g=Object.keys(f.data);for(let[v,b]of Object.entries(h)){if(v==="id"||v==="index"||v==="type")continue;let S=g.find(w=>w===v)??g.find(w=>a(w)===a(v))??v;if(y.includes(S))continue;let x=s(b);if(x&&l(m,S,x)){c=!0;continue}if(typeof b=="number"&&isFinite(b))d.onVariableUpdate?.(["layer",f.id,S],b,o),c=!0;else if(Array.isArray(b)&&b.length<=3&&b.every(w=>typeof w=="number"&&isFinite(w))){let w=["x","y","z"];b.forEach((A,E)=>{d.onVariableUpdate?.(["layer",f.id,S,w[E]],A,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(GT))return GT.decompose(UT,zT,xV),t[1]==="position"?UT[t[2]]:(jT.setFromQuaternion(zT,r.rotation.order),jT[t[2]]*Jx.RAD2DEG);for(let i=1;i<t.length;i++)r=r[t[i]];return t[1]==="rotation"&&(r*=Jx.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let i=this.variables[r],o=i.locations?.findIndex(a=>Ot.equal(a,e));o!==void 0&&o!==-1&&i.locations.splice(o,1)}if(typeof t=="string"){let r=t,i=t;do{if(i=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[i]!==void 0&&this.variables[i].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(jt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let i=e.userAPIs[t.path[1]];if(i){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(i):a?.update(i,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let i=e.userWebhooks[t.path[1]];i&&this.getUserWebhook(t.path[1])?.update(i)}}else t.path[0]==="lib"&&this.updateLibByOp(jt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let i=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};i.update(o),i.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=VT();return r===null?($t("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=Zx();return r===null?($t("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=Zx();return r===null?($t("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},Aa=e0;Aa.MAX_TRANSIENT_VERTICES=6e4;var WT=new Aa(ri.emptyData());function Ps(n){return n?.isClassicNodeMaterial===!0}function qT(n){return n?.isClassicSharedMaterial===!0}function fm(n){return Ps(n)||n?.isTSLNodeMaterial===!0}function XT(n){return qT(n)||n?.isTSLSharedMaterial===!0}ut();mr();var oi=5,ic=3;var tr=class extends tt{setMaterialOverride(e,r){this.materialOverride=Yx(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,i){if(super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.syncShadowCatcher(i),$w(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=i.shared.material(a);l!==s&&tr.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(jt.drop(e,1),r.material,i)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(jt.drop(e,2),a,i)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let i=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(i.flatShading,i.side,i.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(i.flatShading,i.side,i.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(i.flatShading,i.side,i.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(i.flatShading,i.side,i.wireframe);else this.material=this.material.getFlavor(i.flatShading,i.side,i.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let i=IT();if(i===null)return;this.shadowCatcherMaterial=i}this.shadowCatcherMaterial.side=r.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){fm(e)&&!XT(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&$p(this.material).forEach(e=>{tr.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};import{BufferGeometry as mm,Matrix4 as r0,Vector3 as JT,Vector4 as i0}from"three";var YT=new JT,QT=new i0,KT=new i0,SV=new JT,ZT=new r0,Qe=class extends tr{constructor(e,r,i){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new r0().fromArray(r.bindMatrix),this.bindMatrixInverse=new r0)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof mm&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof mm?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof Aa){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),i=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(i,e,this),this._geometryCacheKey=i}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return jd.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return jd.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(jt.drop(e,1),r.geometry,i)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let i=this.data.geometry.type;if(i==="NonParametricGeometry"||i==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Wi(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&Su(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else{let o={...this.data.geometry,...e},a=Wi(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&am(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,i){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof St&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&dm(e.props)&&this.geometryCreateDeleyed instanceof St&&this.chooseGeoemtryCache(i.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof mm&&!(this.geometryCreateDeleyed instanceof St)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=i.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Wi(d,a,this.data.flatShading,this);am(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(i),this.refreshAttachedPaths(i)}}o||(i.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(i)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let i=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof mm&&!(this.geometryCreateDeleyed instanceof St)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(i),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Wi(o,i,this.data.flatShading,this);am(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(i).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let i=e.morphTargetInfluences;if(i){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of i)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let i=this.morphTargetDictionary[e];i!==void 0&&(this.morphTargetInfluences[i]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;this.is2DType?e.set(0,0,i.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)):i.centerOffset?e.fromArray(i.centerOffset):e.setScalar(0),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new i0,i=this.geometry.attributes.skinWeight;for(let o=0,a=i.count;o<a;o++){r.fromBufferAttribute(i,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),i.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let i=this.skeleton;if(i===void 0)return;let o=this.geometry;QT.fromBufferAttribute(o.attributes.skinIndex,e),KT.fromBufferAttribute(o.attributes.skinWeight,e),YT.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=KT.getComponent(a);if(s!==0){let l=QT.getComponent(a);ZT.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),r.addScaledVector(SV.copy(YT).applyMatrix4(ZT),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};import{Group as RV}from"three";import{AxesHelper as PV,Group as TV,Quaternion as MV,Vector3 as o0}from"three";import{BoxGeometry as wV}from"three";var Un=n=>{var t;return t=class extends n{},t.geometryHelper=new wV(30,30,30),t};import{Ray as AV,Sphere as CV,Matrix4 as EV,Vector3 as No}from"three";var ym=new AV,n0=new CV,$T=new EV,zn=(n,t,e,r,i=!1,o=n)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),n0.copy(a.boundingSphere),n0.applyMatrix4(s),e.ray.intersectsSphere(n0)===!1||($T.copy(s).invert(),ym.copy(e.ray).applyMatrix4($T),a.boundingBox!==null&&ym.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(i===!1){let v=Math.max(0,f.start),b=Math.min(p.count,f.start+f.count);for(m=v,y=b;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(n,e,ym,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let b=a.attributes.position,S=new No,x=new No,w=new No,A=new No,E=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),O=M*M,R=Math.max(0,f.start),N=Math.min(b.count,f.start+f.count);for(let C=R,B=N-1;C<B;C+=E){if(S.fromBufferAttribute(b,C),x.fromBufferAttribute(b,C+1),ym.distanceSqToSegment(S,x,A,w)>O)continue;A.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(A);F<e.near||F>e.far||r.push({distance:F,point:w.clone().applyMatrix4(o.matrixWorld),object:n})}}function g(v,b,S,x,w,A,E){let T=new No,M=new No,O=new No,R=new No,N=new No;if(T.fromBufferAttribute(x,w),M.fromBufferAttribute(x,A),O.fromBufferAttribute(x,E),S.intersectTriangle(T,M,O,!1,R)===null)return null;N.copy(R),N.applyMatrix4(v.matrixWorld);let B=b.ray.origin.distanceTo(N);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:N.clone(),object:v}}};var OV=new o0(1,1,1),eM=new o0,IV=new o0,tM=new MV,Xi=class extends Un(PV){constructor(e,r=15){super(r);this.object=e;this.dummy=new TV;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){zn(this.object,Xi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(eM,tM,IV),this.matrix.compose(eM,tM,OV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};import{Box3Helper as rM,BoxGeometry as DV}from"three";var gm;(t=>t.is=e=>"objectHelper"in e)(gm||(gm={}));var Yi=(n,t)=>class extends Fl(n){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(i,o){this.objectHelper.raycast(i,o)}showGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof rM&&(o.visible=!0)}}updateEntityBoxSize(i,o){this.objectHelper.visible&&this.geometryHelper instanceof DV?(i.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(i,o)}hideGizmos(){for(let i in this.gizmos){let o=this.gizmos[i];o instanceof rM&&(o.visible=!1)}}};var oc=class extends Yi(RV,Xi){constructor(e,r,i){super();this.super_Entity(e,r),this.context=i,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var BV=null;function iM(){return BV}var Tm=Rd(oM());import{Object3D as JV,Vector3 as _r,Euler as Pm,MathUtils as wM,Matrix4 as Yn,Quaternion as $V}from"three";var NV=.5*(Math.sqrt(3)-1),Eu=(3-Math.sqrt(3))/6,LV=1/3,jn=1/6,dae=(Math.sqrt(5)-1)/4,uae=(5-Math.sqrt(5))/20,Pu=n=>Math.floor(n)|0,aM=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]),s0=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 sM(n=Math.random){let t=cM(n),e=new Float64Array(t).map(i=>aM[i%12*2]),r=new Float64Array(t).map(i=>aM[i%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*NV,u=Pu(o+d),p=Pu(a+d),h=(u+p)*Eu,f=u-h,m=p-h,y=o-f,g=a-m,v,b;y>g?(v=1,b=0):(v=0,b=1);let S=y-v+Eu,x=g-b+Eu,w=y-1+2*Eu,A=g-1+2*Eu,E=u&255,T=p&255,M=.5-y*y-g*g;if(M>=0){let N=E+t[T],C=e[N],B=r[N];M*=M,s=M*M*(C*y+B*g)}let O=.5-S*S-x*x;if(O>=0){let N=E+v+t[T+b],C=e[N],B=r[N];O*=O,l=O*O*(C*S+B*x)}let R=.5-w*w-A*A;if(R>=0){let N=E+1+t[T+1],C=e[N],B=r[N];R*=R,c=R*R*(C*w+B*A)}return 70*(s+l+c)}}function lM(n=Math.random){let t=cM(n),e=new Float64Array(t).map(o=>s0[o%12*3]),r=new Float64Array(t).map(o=>s0[o%12*3+1]),i=new Float64Array(t).map(o=>s0[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*LV,f=Pu(a+h),m=Pu(s+h),y=Pu(l+h),g=(f+m+y)*jn,v=f-g,b=m-g,S=y-g,x=a-v,w=s-b,A=l-S,E,T,M,O,R,N;x>=w?w>=A?(E=1,T=0,M=0,O=1,R=1,N=0):x>=A?(E=1,T=0,M=0,O=1,R=0,N=1):(E=0,T=0,M=1,O=1,R=0,N=1):w<A?(E=0,T=0,M=1,O=0,R=1,N=1):x<A?(E=0,T=1,M=0,O=0,R=1,N=1):(E=0,T=1,M=0,O=1,R=1,N=0);let C=x-E+jn,B=w-T+jn,_=A-M+jn,F=x-O+2*jn,V=w-R+2*jn,Z=A-N+2*jn,q=x-1+3*jn,G=w-1+3*jn,W=A-1+3*jn,j=f&255,K=m&255,te=y&255,Q=.6-x*x-w*w-A*A;if(Q<0)c=0;else{let de=j+t[K+t[te]];Q*=Q,c=Q*Q*(e[de]*x+r[de]*w+i[de]*A)}let ae=.6-C*C-B*B-_*_;if(ae<0)d=0;else{let de=j+E+t[K+T+t[te+M]];ae*=ae,d=ae*ae*(e[de]*C+r[de]*B+i[de]*_)}let re=.6-F*F-V*V-Z*Z;if(re<0)u=0;else{let de=j+O+t[K+R+t[te+N]];re*=re,u=re*re*(e[de]*F+r[de]*V+i[de]*Z)}let ne=.6-q*q-G*G-W*W;if(ne<0)p=0;else{let de=j+1+t[K+1+t[te+1]];ne*=ne,p=ne*ne*(e[de]*q+r[de]*G+i[de]*W)}return 32*(c+d+u+p)}}function cM(n){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 i=r+~~(n()*(256-r)),o=e[r];e[r]=e[i],e[i]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as _V}from"three";var hn=new _V,vm=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let o=1;hn.a.fromBufferAttribute(t,i),hn.b.fromBufferAttribute(t,i+1),hn.c.fromBufferAttribute(t,i+2),o*=hn.getArea(),e[i/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let i=0;i<e.length;i++)r+=e[i],this.distribution[i]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],i=this.binarySearch(this.randomFunction()*r);return this.sampleFace(i,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,i=e.length-1,o=-1;for(;r<=i;){let a=Math.ceil((r+i)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?i=a-1:r=a+1}return o}sampleFace(t,e,r){let i=this.randomFunction(),o=this.randomFunction();return i+o>1&&(i=1-i,o=1-o),hn.a.fromBufferAttribute(this.positionAttribute,t*3),hn.b.fromBufferAttribute(this.positionAttribute,t*3+1),hn.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(hn.a,i).addScaledVector(hn.b,o).addScaledVector(hn.c,1-(i+o)),hn.getNormal(r),this}};import{Box3 as GV,Matrix4 as UV,Sphere as uM,Vector3 as zV}from"three";import{BufferAttribute as FV,Float32BufferAttribute as dM,MathUtils as l0,Vector3 as d0}from"three";function kV(n){if(n.geometry.attributes.extrudeNormal||!n.geometry.attributes.position||!n.geometry.attributes.normal)return;let t=new Map,e=n.geometry.attributes,r=e.position.array,i=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new d0(i[a],i[a+1],i[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new d0})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}n.geometry.setAttribute("extrudeNormal",new dM(o,3))}function VV(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,r=new Float32Array(e.length),i=new d0;for(let o=0;o<e.length;o+=3)i.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=i.x,r[o+1]=i.y,r[o+2]=i.z;n.geometry.setAttribute("extrudeNormal",new dM(r,3))}function Hn(n){if(Array.isArray(n.material)){for(let t of n.material)if(t.getLayersOfType("outline").length===0)return}else if(!Ps(n.material)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?VV(n):kV(n)}function c0(n){return Math.min(2047,Math.max(1,Math.round(n*2048)))/2048}function Wn(n){if(!n.geometry.attributes.position)return;let t=n.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let i=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),a=[c0(l0.seededRandom(o)),c0(l0.seededRandom(o+1e4)),c0(l0.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)i[s]=a[s%3];n.geometry.setAttribute("randomColor",new FV(i,3))}var qn=new GV,Tu=new zV;function pM(n){let t=!1;return n.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Lo=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.hiddenMatrixOld=new UV;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let i=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:i,subdividedGeometry:o,subdivPointer:a}=St.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Hn(this),Wn(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let i=this.material;this.material=Array.isArray(i)?i.map(o=>o.getFlavor(!1,o.side,o.wireframe)):i.getFlavor(!1,i.side,i.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,i=!1){r&&this.subdividedGeometry||St.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,i),this.subdividedGeometry&&St.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=St.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=St.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Hn(this),Wn(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let i=this.localGeometry;this.localGeometry=this.originalGeometryNew,tt.prototype.raycast.call(this,e,r),this.localGeometry=i}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new uM,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,i=e.boundingSphere.center;qn.setFromBufferAttribute(r),qn.getCenter(i),e.boundingSphere.radius=i.distanceTo(qn.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qn.getSize(Tu),this.hasNonUniformScale&&Tu.divide(this.scale);let o={width:Tu.x,height:Tu.y,depth:Tu.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;qn.min.set(e[0],e[2],e[4]),qn.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(qn.min.applyMatrix4(this.shearScaleInv),qn.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new uM);let i=r.boundingSphere.center;qn.getCenter(i),r.boundingSphere.radius=i.distanceTo(qn.max)}freeSubdivPointer(){this.subdivPointer&&(St.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,i=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?St.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Hn(this),Wn(this),o!==void 0&&(this.localGeometry.userData.parameters=o),i&&(this.localGeometry.uuid=i)}updateByPatchedOpGeometry(e,r,i){super.updateByPatchedOpGeometry(e,r,i),this.localGeometry&&(e.type===0&&e.path.length===0&&dm(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};import{Triangle as jV,Vector3 as Ms}from"three";var hM=-1,HV=1,fM={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},mM={polygon_center:0,edge:1,vertex:2},Mu=(n,t)=>(e,r)=>!t||e===0||n===0?0:n*r/100,je=(n,t)=>{let e=Math.abs(t),r=e*-1;return(n-hM)*(e-r)/(HV-hM)+r},WV=new Ms,bm=new Ms,qV=new Ms,XV=new Ms;function ac(n,t){let e=qV.fromArray(n),r=XV.fromArray(t);bm.copy(r).sub(e);let i=bm.length();return bm.normalize().multiplyScalar(i*.5),WV.copy(e).add(bm).toArray()}var Qi=new jV,xm=new Ms,Sm=new Ms,Ts=new Ms;function yM(n){let t=[],e=Math.floor(n.index.count/3);for(let r=0;r<e;r++)if(xm.fromArray(n.index.array,r*3),Qi.setFromAttributeAndIndices(n.attributes.position,xm.x,xm.y,xm.z),Qi.getNormal(Sm),Qi.getMidpoint(Ts),!(isNaN(Ts.x)||isNaN(Ts.y)||isNaN(Ts.z))){let{a:i,b:o,c:a}=Qi,s=i.toArray(),l=o.toArray(),c=a.toArray(),d=i.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(i),h=ac(s,l),f=ac(l,c),m=ac(c,s),y=[d,u,p],g=Math.max(...y),v=y.filter(x=>Math.round(x)===Math.round(g)).length>1,b=[],S=Qi.getMidpoint(Ts).toArray();g===d&&!v&&(b=[f,m,m],S=h),g===u&&!v&&(b=[h,m,m],S=f),g===p&&!v&&(b=[h,f,f],S=m),v&&(b=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:b,midpoint:S,norm:Qi.getNormal(Sm).toArray()})}return t}function gM(n){let t=[],{position:e}=n.attributes;for(let r=0;r<e.count;r++){Qi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Qi.getNormal(Sm),Qi.getMidpoint(Ts);let i=Qi.a.toArray(),o=Qi.b.toArray(),a=Qi.c.toArray();t.push({vertices:[i,o,a],faceCenters:[ac(i,o),ac(o,a),ac(a,i)],midpoint:Ts.toArray(),norm:Sm.toArray()})}return t}import{InstancedMesh as YV,Matrix4 as u0}from"three";var p0=class extends YV{},wm=class extends p0{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new u0;this.pivotMatrix=new u0;this.previousModelViewMatrix=new u0;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(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.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let i=this.parent;if(e&&i!==null&&i.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)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,i,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var h0=n=>.5*(1-Math.cos(n*Math.PI)),f0=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let i=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-i,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let v=i+(o<<4)+(a<<8);d=h0(s),u=h0(l),f=this.perlin[v&4095],f+=d*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=d*(this.perlin[v+16+1&4095]-m),f+=u*(m-f),v+=256,m=this.perlin[v&4095],m+=d*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=d*(this.perlin[v+16+1&4095]-y),m+=u*(y-m),f+=h0(c)*(m-f),p+=f*h,h*=.5,i<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(i++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},vM=f0;import{Vector3 as QV,Matrix4 as KV,Ray as ZV}from"three";var bM=new QV,xM=new KV,SM=new ZV,Ca=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:i}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(xM.copy(i).invert(),SM.copy(e.ray).applyMatrix4(xM),SM.intersectBox(this.singleBBox,bM))){let o=bM.applyMatrix4(i),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var ai=1e-4,Xn,NM,LM,_M,AM=new _r,CM=new _r;om.then(n=>{Xn=n,NM=[Xn.get_face_center,Xn.get_edge_midpoint,Xn.get_vertex_position],LM=[Xn.get_face_normal,Xn.get_edge_normal,Xn.get_vertex_normal],_M=[Xn.face_count,Xn.edge_count,Xn.vertex_count]});var Cse=new Yn,eG=new Yn,EM=new Yn,PM=new Yn,TM=new Yn,MM=new Yn,OM=new Yn,IM=new Yn,Ea=new _r,Am=new _r,Ou=new _r,m0=new _r,tG=new _r,DM=new _r,Cm=new _r,y0=new _r,RM=new _r,g0=new _r,BM=new _r,fn=new Pm,rG=new $V;function Em(n){return n?n.version??n.data?.version??0:-1}function Ht(n,t){return[typeof n?.[0]=="number"?n[0]:typeof n?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(n[0])??"0")):0,typeof n?.[1]=="number"?n[1]:typeof n?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(n[1])??"0")):0,typeof n?.[2]=="number"?n[2]:typeof n?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(n[2])??"0")):0]}var v0=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new vM;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(i,o,a)=>this.perlin.noise(i,o,a):this.noise=i=>this.perlin.noise(i)):e?this.noise=lM((0,Tm.default)(t.seed)):this.noise=sM((0,Tm.default)(t.seed??""))}},si=class extends Nl(JV){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof tt&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof cr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let i=r.transformOverride;i!==void 0&&(r.position.fromArray(i.position),r.rotation.fromArray(i.rotation),r.scale.fromArray(i.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||cn(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new wm(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let i of this.children)i.playModeVisible!==!1&&(EM.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),e.setMatrixAt(r++,EM));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let i;if(r!==void 0)i=r;else{let o=Ht(this.parameters.grid.count,e);i=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)i=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==i)if(this.children.length<i)for(let o=0,a=i-this.children.length;o<a;++o){let s=new cr(this.object);s.expand(),this.add(s)}else for(;this.children.length>i;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new v0(e,r)),this.random}_updateRadial(e,r){let i=e.radial,o=i.start*wM.DEG2RAD,a=i.end*wM.DEG2RAD,s=o-a,l=Ht(i.rotation,r),c=new Pm(l[0],l[1],l[2]),d;switch(i.axis){case"z":d=new _r(0,0,1);break;case"y":d=new _r(0,1,0);break;default:case"x":d=new _r(1,0,0);break}let u=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=Ht(i.scale,r),m=Ht(i.position,r),y=Ht(u.scale,r),g=Ht(u.position,r),v=Ht(u.rotation,r),b=s/e.count,S=Mu(u.strength,this.parameters.randomness);for(let[x,w]of this.children.entries()){let A=x*(u.freqScale/10)+u.movement,E=h===null?0:h.noise(A,A,A),T=x+1;w.scale.x=f[0]+S(T,je(E,y[0]))||ai,w.scale.y=f[1]+S(T,je(E,y[1]))||ai,w.scale.z=f[2]+S(T,je(E,y[2]))||ai;let M=b*x-o;switch(i.axis){default:case"x":fn.set(0,M,0);break;case"y":fn.set(0,0,M);break;case"z":fn.set(M,0,0);break}Cm.copy(d).applyQuaternion(rG.setFromEuler(fn)).multiplyScalar(i.radius),w.position.set(Cm.x+(m[0]+S(T,je(E,g[0]))),Cm.y+(m[1]+S(T,je(E,g[1]))),Cm.z+(m[2]+S(T,je(E,g[2]))));let O=S(T,je(E,v[0])),R=S(T,je(E,v[1])),N=S(T,je(E,v[2]));i.alignment===!0?w.rotation.set(fn.x+(c.x+O),fn.y+(c.y+R),fn.z+(c.z+N)):w.rotation.set(c.x+O,c.y+R,c.z+N)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let i=e.linear,o=Ht(i.rotation,r),a=Ht(i.scale,r),s=Ht(i.position,r),l=new Pm(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,d=Ht(c.rotation,r),u=Ht(c.scale,r),p=Ht(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Mu(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let v=y*(c.freqScale/10)+c.movement,b=f===null?0:f.noise(v,v,v),S=y+1,x=m(S,je(b,d[0])),w=m(S,je(b,d[1])),A=m(S,je(b,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,je(b,u[0]))||ai,g.scale.y=1+(a[1]-1)*y+m(S,je(b,u[1]))||ai,g.scale.z=1+(a[2]-1)*y+m(S,je(b,u[2]))||ai,g.rotation.set(l.x*y+x,l.y*y+w,l.z*y+A),g.position.x=s[0]*y+m(S,je(b,p[0])),g.position.y=s[1]*y+m(S,je(b,p[1])),g.position.z=s[2]*y+m(S,je(b,p[2]))}}_updateGrid(e,r){let i=0,o=e.grid,a=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,s=Ht(a.scale,r),l=Ht(a.rotation,r),c=Ht(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Mu(a.strength,this.parameters.randomness),h=Ht(o.count,r),f=Ht(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new _r(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let v=0;v<h[1];v++)for(let b=0;b<h[2];b++){let S=this.children[i++];if(!S)continue;let x=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(v+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(i,je(x,s[0]))||ai,S.scale.y=1+p(i,je(x,s[1]))||ai,S.scale.z=1+p(i,je(x,s[2]))||ai;let w=p(i,je(x,l[0])),A=p(i,je(x,l[1])),E=p(i,je(x,l[2]));S.rotation.set(w,A,E),S.position.x=f[0]*g-y.x+p(i,je(x,c[0])),S.position.y=f[1]*v-y.y+p(i,je(x,c[1])),S.position.z=f[2]*b-y.z+p(i,je(x,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let v=this.children[i++];if(!v)continue;let b=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);v.scale.x=1+p(i,je(b,s[0]))||ai,v.scale.y=1+p(i,je(b,s[1]))||ai,v.scale.z=1+p(i,je(b,s[2]))||ai;let S=p(i,je(b,l[0])),x=p(i,je(b,l[1])),w=p(i,je(b,l[2]));v.rotation.set(S,x,w),v.position.x=f[0]*m+p(i,je(b,c[0])),v.position.y=-f[1]*y+p(i,je(b,c[1])),v.position.z=-f[2]*g+p(i,je(b,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:i}=e,o=Ht(i.rotation,r),a=Ht(i.position,r),s=Ht(i.scale,r),l=new Pm(o[0],o[1],o[2]),c=e.randomnessObject??Mn.defaultData([1,1,1]).randomnessObject,d=Ht(c.rotation,r),u=Ht(c.position,r),p=Ht(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Mu(c.strength,this.parameters.randomness);if(!i.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof Ca)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let w=Math.round(y.length*i.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=i.spreadType==="random",v=null;g&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,Tm.default)(this.object.uuid+i.seed)));let b=fM[i.axis],S=this.children;Ea.fromArray(b),PM.copy(this.object.hiddenMatrix).invert();let x=this.objectForSample instanceof Lo;x&&TM.copy(this.objectForSample.matrixWorld).invert(),i.align!=="normal"&&this.object.getWorldDirection(DM),g0.set(Ea.y,Ea.z,Ea.x).normalize(),BM.copy(g0).cross(Ea).normalize(),OM.makeBasis(g0,Ea,BM).invert();for(let[w,A]of S.entries()){let E=w*(c.freqScale/10)+c.movement,T=f===null?0:f.noise(E,E,E),M=w+1,O=m(M,je(T,d[0])),R=m(M,je(T,d[1])),N=m(M,je(T,d[2]));g?v.sample(Ou,m0):(y.length&&(Ou.fromArray(y[w].pos),m0.fromArray(y[w].norm)),x&&Ou.applyMatrix4(TM)),Ou.applyMatrix4(PM),A.position.copy(Ou);let C=i.align==="normal"?m0:DM,B=Am.fromArray(a);Am.x+=m(M,je(T,u[0])),Am.y+=m(M,je(T,u[1])),Am.z+=m(M,je(T,u[2]));let _=Math.acos(C.dot(Ea)),F=tG.crossVectors(Ea,C).normalize(),V=eG.makeRotationAxis(F,_);y0.copy(C).cross(this.object.up).normalize(),RM.copy(y0).cross(C).normalize(),MM.makeBasis(y0,C,RM),IM.multiplyMatrices(MM,OM),fn.setFromRotationMatrix(IM),B.applyMatrix4(V),A.position.add(B),A.rotation.set(fn.x+l.x+O,fn.y+l.y+R,fn.z+l.z+N),A.scale.set(1+s[0]+m(M,je(T,p[0]))||ai,1+s[1]+m(M,je(T,p[1]))||ai,1+s[2]+m(M,je(T,p[2]))||ai),A.scale.multiply(this.object.scale),A.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,i=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===i&&a.positionVersion===Em(i)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new vm(e).build();return this.surfaceSamplerCache={geometry:r,position:i,positionVersion:Em(i),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Lo,i=this.objectForSample.geometry;if(!r&&i){let l=this.surfacePointsCache,c=i.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===i&&l.position===c&&l.positionVersion===Em(c)&&l.index===i.index&&l.indexVersion===(i.index===null?-1:i.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=mM[e],d=_M[c],u=NM[c],p=LM[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);AM.fromArray(m).applyMatrix4(l.matrixWorld),CM.fromArray(y),a(AM.toArray(),CM.toArray())}}else(i.index?yM(i):gM(i)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&i){let l=i.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:i,position:l,positionVersion:Em(l),index:i.index,indexVersion:i.index===null?-1:i.index.version,points:s}}return s}updateState(e,r){if(this.parameters=va(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let i=r.scene.find(this.parameters.toObject.object);i instanceof tt?this.objectForSample=i:this.objectForSample=void 0,this.matrix=new Yn,this.hiddenMatrix=new Yn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,i&&i.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var mn=24,dr=96,Kn=lP(),_o=2;var C0=!1,zM=!0;try{let n=new URLSearchParams(window.location.search);C0=n.get("dbgsbstatic")==="0",zM=n.get("sb512")!=="0"}catch{}function nG(n){let t=n.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var E0=class extends Qe{constructor(e,r,i){super(e,r,i);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(dr);this._prevReach=new Float32Array(dr);this._fieldDirtyFull=!0;this._fieldDirtyMin=new cc;this._fieldDirtyMax=new cc;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new S0;this.potentialPassScene=new S0;this.voxelPassScene=new S0;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new kM,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new b0(zl,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new A0(Kn.triTable,16,256,x0,Fo);o.needsUpdate=!0;let a=new A0(Kn.numTrisTable,256,1,x0,Fo);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new b0(zl,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new b0(zl,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=cG.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new VM({vertexShader:c.vertexShader,fragmentShader:`
730
730
  #include <packing>
731
731
  void main()
732
732
  {
@@ -1309,7 +1309,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
1309
1309
  gl_FragColor = texture(inputTexture, vUv);
1310
1310
  gVelocity = vec4(0.0);
1311
1311
  }
1312
- `,r.pyramidTextureSize.value=new w0(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=i,this.material.root.shapeBlendhack=i}dispose(){super.dispose(),iM()?.release(this)}},Du=E0;Du.streamCompaction=new _f;var oG=new GM,aG=new GM,sc=new UM,Os=new cc,Mm=new cc,sG=new UM;function lG(n,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Oo.is(r)&&jM.call(r,n,t+1)}}function jM(n,t=0){if(n(this,t)!==!0){let r=this.children.length;for(;r--;){let i=this.children[r];Oo.is(i)&&jM.call(i,n,t+1)}}}function cG(){if(this.shapesDataTexture.value===void 0){let y=new A0(new Float32Array(4*dr*Io),dr,Io,lc,Fo);this.shapesDataTexture.value=y}let n=this.shapesDataTexture.value,t=n.image.data,e=0,r=0,i=this.data.geometry.blendRange,o=oG.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(lG.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof si)return;if(y instanceof oc||Zd(y))return;y instanceof cr?g=y.object:g=y;let v=y.data?.cloner;if(Ve.is(y)&&v&&!v.hideBase&&v.type!=="radial"&&v.disabled!==!0||!(g instanceof Qe))return;let b=g.geometry.userData.parameters,S=b?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(aG.multiplyMatrices(o,y.matrixWorld).decompose(Mm,sc,Os),b?.type==="TorusGeometry"&&b.arc!==360){let C=b.arc*Math.PI/180;C=C/4,sc.multiply(sG.set(0,0,Math.sin(C),Math.cos(C)))}let w=S.overrideGlobalBlend?S.blendRange:i;w=w/this.bboxSize*2,t[s*4]=(Mm.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Mm.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Mm.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[dr*4+s*4]=-sc.x,t[dr*4+s*4+1]=-sc.y,t[dr*4+s*4+2]=-sc.z,t[dr*4+s*4+3]=sc.w;let A=new Float32Array(4),E=0,T=w;if(b?.type==="SphereGeometry")b.width===b.height&&b.width===b.depth?A[0]=0:A[0]=1,A[1]=b.width/this.bboxSize,A[2]=b.height/this.bboxSize,A[3]=b.depth/this.bboxSize,T=Math.max(A[1],A[2],A[3])*Os.x+w;else if(b?.type==="CubeGeometry"){E=b.cornerRadius;let C=b.width,B=b.height,_=b.depth;A[0]=2,A[1]=(C-2*E)/this.bboxSize,A[2]=(B-2*E)/this.bboxSize,A[3]=(_-2*E)/this.bboxSize,T=Math.sqrt(C**2+B**2+_**2)/this.bboxSize*Os.x+w}else if(b?.type==="CylinderGeometry"){E=b.cornerRadius;let C=b.height,B=b.radiusBottom,_=b.radiusTop;if(_>=B){let F=Math.atan2(_-B,C),V=(Math.PI/2-F)/2;_-=E/Math.tan(V),B-=E*Math.tan(V)}else if(B>_){let F=Math.atan2(B-_,C),V=(Math.PI/2-F)/2;_-=E*Math.tan(V),B-=E/Math.tan(V)}A[1]=(b.height-2*E)/this.bboxSize,B===_?(A[0]=3,A[2]=B/this.bboxSize*2):(A[0]=4,A[2]=B/this.bboxSize*2,A[3]=_/this.bboxSize*2),T=(Math.hypot(A[1],Math.max(Math.abs(A[2]),Math.abs(A[3])))+E/this.bboxSize*2)*Os.x+w}else if(b?.type==="TorusGeometry"){if(A[0]=5,A[1]=(b.width-b.depth)/this.bboxSize,A[2]=b.depth/this.bboxSize,b.arc!==360){A[0]=6,A[3]=A[1],t[dr*12+s*4+3]=A[2];let C=2*Math.atan2(A[2]/2,A[1]),B=b.arc*Math.PI/180/2-C;A[1]=Math.sin(B),A[2]=Math.cos(B)}T=b.width*Os.x/this.bboxSize+w}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=nG(C);if((B===void 0||B.posVersion!==_)&&this._meshSdfWanted.set(C.uuid,C),B===void 0)return;A[0]=7,A[1]=B.slot,A[2]=B.boxHalf.x/this.bboxSize*2,A[3]=B.boxHalf.y/this.bboxSize*2,t[dr*12+s*4+3]=B.boxHalf.z/this.bboxSize*2,T=Math.hypot(B.boxHalf.x,B.boxHalf.y,B.boxHalf.z)/this.bboxSize*2*Os.x+w}t.set(A,dr*8+s*4),e=Math.max(e,T),r=Math.max(r,w),this._reach[s]=T,t[dr*12+s*4]=w,t[dr*12+s*4+1]=E/this.bboxSize*2,t[dr*12+s*4+2]=Os.x;let M=Array.isArray(g.material)?g.material[0]:g.material,O=M,R,N;if(O?.getShapeBlendBaseColor){let C=O.getShapeBlendBaseColor();R=C,N=C.a}else M?.uniforms?.nodeU0!==void 0?(R=M.uniforms.nodeU0.node.value,N=M.uniforms.nodeU1?.value??1):(R={r:1,g:1,b:1},N=1);S.operation!==0&&!S.useColor&&(N=-1),t[dr*16+s*4]=R.r,t[dr*16+s*4+1]=R.g,t[dr*16+s*4+2]=R.b,t[dr*16+s*4+3]=N,N<1&&this.material.defines?.SHAPEBLEND_C===1&&(this.material.transparent=!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||C0,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let v=!1;for(let O=0;O<Io;O++){let R=dr*4*O+g*4;if(t[R]!==d[R]||t[R+1]!==d[R+1]||t[R+2]!==d[R+2]||t[R+3]!==d[R+3]){v=!0;break}}if(!v)continue;if(p=!0,h)break;let b=t[g*4],S=t[g*4+1],x=t[g*4+2],w=d[g*4],A=d[g*4+1],E=d[g*4+2],T=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(b+S+x+T)||!Number.isFinite(w+A+E+M)){h=!0;continue}f.x=Math.min(f.x,b-T,w-M),f.y=Math.min(f.y,S-T,A-M),f.z=Math.min(f.z,x-T,E-M),m.x=Math.max(m.x,b+T,w+M),m.y=Math.max(m.y,S+T,A+M),m.z=Math.max(m.z,x+T,E+M)}}return C0&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,n.needsUpdate=!0),p}Ui("ShapeBlendGeometry",(n,t,e)=>new Du(n,t,e));Oe("shape-blends");var Om=class extends Qe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?nu(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Ui("VectorGeometry",(n,t,e)=>new Om(n,t,e));Oe("vector-shapes");var Im=class extends Qe{constructor(e,r,i){super(e,r,i);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=i}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=$l;break;case"Ellipse":o=Zl;break;case"Polygon":o=rm;break;case"Star":o=im;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let i=this.geometry;r&&i.inputs&&(i.inputs.shapeData=r,i.build())}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let i in e)if(!Object.is(e[i],r[i]))return!1;for(let i in r)if(!(i in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let i=this.geometry.getAttribute("position");i!==void 0&&i.count>0?nu(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,r):super.updateEntityBoxSize(e,r)}};import{Vector2 as dG,Vector3 as ur,Matrix3 as uG,Matrix4 as Is,BufferGeometry as KM,BufferAttribute as Zn,MathUtils as Dm}from"three";function HM(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var pG=new Is,hG=new Is,fG=new Is,WM=new ur,qM=new ur,XM=new ur,mG=new ur,yG=new ur,gG=new ur,vG=new ur,YM=new WeakMap,P0=new WeakMap,QM=new WeakMap;function bG(n,t,e){let r=[new ur,new ur,new ur],i=[new ur,new ur,new ur];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((o,a)=>{let s=i[a],l=Dm.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new Is().makeBasis(r[0],r[1],r[2])}function ZM(n){n.setIndex(null),n.setAttribute("position",new Zn(new Float32Array(0),3)),n.setAttribute("normal",new Zn(new Float32Array(0),3)),n.setAttribute("uv",new Zn(new Float32Array(0),2)),n.setDrawRange(0,0)}var JM=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=t?.shapeData??Zl.create({parameters:{...hs,width:typeof hs.width=="number"?hs.width:100,height:typeof hs.height=="number"?hs.height:100}}).userData.shape;return{path:n.path??yl.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:o,extrusion:{...Hh,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new T0(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else{let e=new KM;return ZM(e),Object.assign(e,{userData:{...n,type:"PathGeometry"}})}}},T0=class extends KM{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)||!HM(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){ZM(this);return}let{depth:i,offset:o}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((i+o)*a):Math.ceil(Math.min(1,i+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let j=0;j<c;j++){let K=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);d.push(e[K].clone()),u.push(r[K].clone())}let p=(j,K,te)=>{d[j]=d[j].clone().lerp(d[K],te),u[j]=bG(u[j],u[K],te)},h=0,f=o*a%1;(!this.inputs.path.isClosed||i<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+i)*a%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&o+i<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),i===0){let j=d.length-1;d[j].copy(d[0]),u[j].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,b=g>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:w,vertices:A}=this._getShapePoints(S),E=0,T;if(b==="round"){let j=this.inputs.shapeData,K=QM.get(j);K!==void 0&&K.bevel===g&&K.curveSegments===S&&K.bevelSides===v?T=K.geometry:(T=new wa(j,2*g,g,S,v,void 0,!0),QM.set(j,{bevel:g,curveSegments:S,bevelSides:v,geometry:T})),E=T.getAttribute("position").count}let M=0,O=0;w.sort((j,K)=>j.start-K.start),w.forEach(j=>{j.verticesStart=M,j.verticesCount=j.continuous.reduce((K,te,Q)=>K+(Q===0||!te?2:1),0),O+=j.verticesCount,M=O});let R=O*c,N,C=0;this._isOpenEnded()&&b==="flat"&&(N=this._getSurfaceTesselation(x),C=N.vertexCount);let B=R+2*C+E*2,_=R+2*C,F={positions:new Float32Array(B*3),normals:new Float32Array(B*3),uvs:new Float32Array(B*2)},V=T?T.getIndex().array:null,Z=0;w.forEach(j=>{Z+=j.count});let q=Z*(c-1)*6+(N?2*N.elementCount*3:0)+(V?2*V.length:0),G=new Uint32Array(q),W=0;if(w.forEach(j=>{W=this._extrudeRegion(j,A,u,d,F,G,W,this._isGeometryClosed()&&!this._isOpenEnded())}),N&&(W=this._closeEnd(N,R,G,W,F,u[0],d[0],!1),W=this._closeEnd(N,R+C,G,W,F,u[u.length-1],d[d.length-1],!0)),T){F.positions.set(T.getAttribute("position").array,_*3),F.normals.set(T.getAttribute("normal").array,_*3),F.uvs.set(T.getAttribute("uv").array,_*2);for(let Q=_;Q<_+E;Q++)F.uvs[Q*2+1]=1e-4;let j=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;_+=E,F.positions.set(T.getAttribute("position").array,_*3),F.normals.set(T.getAttribute("normal").array,_*3),F.uvs.set(T.getAttribute("uv").array,_*2);let K=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;this.setAttribute("position",new Zn(F.positions,3)),this.setAttribute("normal",new Zn(F.normals,3)),this.setAttribute("uv",new Zn(F.uvs,2)),this._setIndexFromUint32(G);let te=pG;te.copy(u[u.length-1]).setPosition(d[d.length-1]),this.applyMatrix4OnRange(te,_,B),te.copy(u[0]).setPosition(d[0]).multiply(hG.makeScale(1,1,-1)),this.applyMatrix4OnRange(te,_-E,_),this.reverseIndicesOnRange(j,K)}else this.setAttribute("position",new Zn(F.positions,3)),this.setAttribute("normal",new Zn(F.normals,3)),this.setAttribute("uv",new Zn(F.uvs,2)),this._setIndexFromUint32(G)}_setIndexFromUint32(e){let r=!1;for(let i=e.length-1;i>=0;--i)if(e[i]>=65535){r=!0;break}this.setIndex(new Zn(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=bf(e),i=YM.get(r);if(i===void 0||i.subdivisions!==e.subdivisions||i.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);i={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},YM.set(r,i)}return i}_extractPathPoints(e){let r=this.inputs.path.subdivisions,i=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(i.length<2)return[];let o=[i[0]];return i.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],i=e.length,o=this.inputs.path.isClosed,a=new ur,s=new ur,l=new ur,c=new ur,d=new ur(0,1,0);for(let y=0;y<i;y++){let g=e[y],v;y===0?v=o?e[e.length-2]:WM.copy(g).multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===i-1?b=o?e[1]:WM.copy(g).multiplyScalar(2).sub(e[y-1]):b=e[y+1],qM.subVectors(g,v).normalize(),XM.subVectors(b,g).normalize();let S=mG.addVectors(qM,XM).normalize();l.copy(S),y===0&&(S.equals(d)||yG.copy(S).negate().equals(d))&&d.set(0,0,1);let x=gG.crossVectors(d,S).normalize(),w=vG.crossVectors(S,x).normalize();d.copy(w),c.copy(x),y===0&&(a.copy(w),s.copy(S));let A=new Is().makeBasis(x,w,S);r.push(A)}let u=o?s:l,p=o?a:new ur(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(fG.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,i){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new Is,u=new Is;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(i===0?0:1)-(r+(1-i)));d.makeRotationZ(Dm.lerp(a,a+s,f)*Dm.DEG2RAD);let m=Dm.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=rt.ODD){let i=this.inputs.shapeData,o=P0.get(i);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},P0.set(i,o)),o.shapePoints}_getSurfaceTesselation(e){let r=P0.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let i;try{i=un({windingRule:rt.ODD,elementType:Yt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{i=Mx}return r!==void 0&&(r.surfaceTesselation=i),i}_computeShapePoints(e=12,r=rt.ODD){let i=this.inputs.shapeData,o=i.extractShapePointsToFlatArray([],e),a=i.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],S=y[v-0];g.push(b,S)}return g}),s;try{s=un({windingRule:r,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=vu}let l;try{l=un({windingRule:rt.ODD,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Tx}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],b=s.vertices[g+1];v<d&&(d=v),v>u&&(u=v),b<p&&(p=b),b>h&&(h=b)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],b=s.elements[g+1],S=v+b,x={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(x);let w=v,A=S-1,E=v+1,T=i.roundedCurves.length;do{let M=w-v,O=s.vertices[A*2+0],R=s.vertices[A*2+1],N=s.vertices[w*2+0],C=s.vertices[w*2+1],B=s.vertices[E*2+0],_=s.vertices[E*2+1],F=N-O,V=C-R,Z=Math.sqrt(F*F+V*V);F/=Z,V/=Z;let q=N-B,G=C-_,W=Math.sqrt(q*q+G*G);q/=W,G/=W,x.normals[M*2+0]=-G,x.normals[M*2+1]=q;let j=s.vertexIndices[w];if(Array.isArray(j))x.continuous[M]=!1;else{let[K,te]=i.getCurveIndexFromVertexId(j-1,!0);if(te>0&&te<1)x.continuous[M]=!0;else{let Q=te===1?K+1:K-1;Q=(Q+T)%T;let ae=te===1?0:1,re=i.roundedCurves[K].getTangent(te),ne=i.roundedCurves[Q].getTangent(ae);x.continuous[M]=re.dot(ne)>.95}}y&&(x.normals[M*2+0]*=-1,x.normals[M*2+1]*=-1),[A,w,E]=[w,E,E+1],E>=S&&(E-=b)}while(E!==v+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,i,o,a){let s=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,i,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let x=(e.start+S)*2,w=r[x+0],A=r[x+1],E,T;if(e.continuous[S])E=e.normals[S*2+0],T=e.normals[S*2+1];else{let O=S===0?(e.start+e.count-1)*2:x-2,R=w-r[O+0];E=-(A-r[O+1]),T=R,e.isHole||(E=-E,T=-T)}let M=S===0?1:S/e.count;if(d.push(w,A,E,T,M,0),!e.continuous[S]||S===0)if(S===0)d.push(w,A,e.normals[0],e.normals[1],0,1);else{let O=S===e.count-1?e.start*2:x+2,R=r[O+0]-w;E=-(r[O+1]-A),T=R,e.isHole||(E=-E,T=-T),d.push(w,A,E,T,M,1)}}e.wallTemplate=d}let u=i.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let x=i[S].elements,w=x[0],A=x[1],E=x[2],T=x[4],M=x[5],O=x[6],R=x[12],N=x[13],C=x[14],B=o[S],_=S/(u-1),F=0,V=0,Z=0,q=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let de=d[G+0],ve=d[G+1];F=w*de+T*ve+R+B.x,V=A*de+M*ve+N+B.y,Z=E*de+O*ve+C+B.z}let W=d[G+2],j=d[G+3],K=w*W+T*j+R,te=A*W+M*j+N,Q=E*W+O*j+C,ae=1/(Math.sqrt(K*K+te*te+Q*Q)||1);K*=ae,te*=ae,Q*=ae;let re=q*2,ne=q*3;h[ne+0]=F,h[ne+1]=V,h[ne+2]=Z,f[ne+0]=K,f[ne+1]=te,f[ne+2]=Q,m[re+0]=d[G+4],m[re+1]=_,q++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let x=0;x<e.count;x++)(!e.continuous[x]||x===0)&&S++,y.push(S,x===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,v=y.length,b=e.isHole;for(let S=0;S<g;S++){let x=e.verticesStart*u+e.verticesCount*S,w=x+e.verticesCount;for(let A=0;A<v;A+=2){let E=x+y[A],T=x+y[A+1],M=w+y[A+1],O=w+y[A];b?(s[l++]=E,s[l++]=M,s[l++]=T,s[l++]=E,s[l++]=O,s[l++]=M):(s[l++]=E,s[l++]=T,s[l++]=M,s[l++]=E,s[l++]=M,s[l++]=O)}}return l}_closeEnd(e,r,i,o,a,s,l,c){let d=e.vertexCount,u=new ur(0,0,c?-1:1).applyMatrix4(s),p=new ur,h=new dG;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;i[o++]=f[y+0]+r,i[o++]=f[y+(c?1:2)]+r,i[o++]=f[y+(c?2:1)]+r}return o}applyMatrix4OnRange(e,r,i){let o=e.elements,a=new uG().getNormalMatrix(e).elements,s,l,c,d,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let h=u.array,f=p.array,m=u.itemSize;for(let y=r*m,g=i*m;y<g;y+=m)s=h[y+0],l=h[y+1],c=h[y+2],d=1/(o[3]*s+o[7]*l+o[11]*c+o[15]),h[y+0]=(o[0]*s+o[4]*l+o[8]*c+o[12])*d,h[y+1]=(o[1]*s+o[5]*l+o[9]*c+o[13])*d,h[y+2]=(o[2]*s+o[6]*l+o[10]*c+o[14])*d,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c;u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let i=this.index;if(i){for(let o=e;o<r;o+=3){let a=i.getX(o),s=i.getX(o+1),l=i.getX(o+2);i.setXYZ(o,l,s,a)}i.needsUpdate=!0}}};Ui("PathGeometry",(n,t,e)=>new Im(n,t,e));$d("PathGeometry",JM);Oe("3d-paths");Gi.Cloner=si;Oe("cloners");ut();import{Group as xG,Matrix4 as SG,Skeleton as wG}from"three";function Ru(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)Ve.is(e)&&Ru(e)}}var Bu=class extends Yi(xG,Xi){constructor(e,r,i){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,i)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let i=ya.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(i){let o,a;for(let s of Dn.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=i.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=Cn.apply(i.data[s],e[s]));return this.overrideData=a,o}else return{...Jt.defaultData,...e,...Qd(Jt.defaultData,Dn.rootOverrideProps)}}updateByOp(e,r,i,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,i),e.type===0&&e.path.length===0&&this.component)for(let s of Dn.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&Dn.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,i,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let i=e.scene.find(r.component)??null,o=!1;if(i!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Ve.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ru(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(i){let a={};e2(e,[this.uuid],r.overrides,this,i,i,0,o,a);for(let s of this.children)if(Ve.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof Qe&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new SG().fromArray(m)),f=new wG(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function $M(n,t,e,r){return n.component===t&&Po(n.identity,r)?n.overrideData===e?2:1:0}function e2(n,t,e,r,i,o,a,s,l){if(a>50)return!1;if(r.component!==i){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}i.instances.find(d=>d===r)||i.instances.push(r),r.component=i}i instanceof Bu&&i.isInstanceRoot&&i.expandInstanceChildren(n);let c=0;for(let d of i.children)if(Ve.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=vl.resolve(e,u,1);p!=null&&!(p instanceof Et)&&(Object.setPrototypeOf(p,Et.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=Ve.is(m)?m:null,h!==null){let y=$M(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(u)??null,h!==null)){let y=$M(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?Cn.apply(d.data,p):d.data;on.is(m.type)&&(m={...m,type:"Empty"}),h=Gi.createEntity(u,m,n),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,e2(n,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(Ve.is(u))n.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var t2=(n,t,e)=>new Bu(n,t,e);vs("Component",t2);vs("Instance",t2);Oe("components");var M0=1e-10;function r2(n){let t=n[0][0],e=n[1][0],r=n[0][1],i=n[1][1],o=Math.sqrt(t*t+e*e),a=o>M0?t/o:1,s=o>M0?e/o:0,l=a*t+s*e,c=a*i-s*r,d=a*r+s*i;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>M0?d/c:0,0]}}function i2({rotation:n,scale:t,shear:e}){let r=Math.cos(n),i=Math.sin(n),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-i*a,i*t[0]+r*a,r*o-i*t[1],i*o+r*t[1]]}var De;(x=>{function n(){return[1,0,0,0,1,0,0,0,1]}x.identity=n;function t(w,A=x.identity()){for(let E=0,T=w.length;E<T;E++)A[E]=w[E];return A}x.copy=t;function e(w,A,E,T,M,O){return x.setAbcdef(x.identity(),w,A,E,T,M,O)}x.create=e;function r(w,A,E,T,M,O,R){return w[0]=A,w[1]=T,w[2]=O,w[3]=E,w[4]=M,w[5]=R,w}x.setAbcdef=r;function i(w,A){let[E,T,M,O,R,N]=a(w),[C,B,_,F,V,Z]=a(A),q=C*E+B*M,G=C*T+B*O,W=_*E+F*M,j=_*T+F*O,K=V*E+Z*M+R,te=V*T+Z*O+N;return x.create(q,G,W,j,K,te)}x.append=i;function o(w,A){let[E,T,M,O,R,N]=a(w),[C,B,_,F,V,Z]=a(A),q=E,G=T,W=M,j=O;(C!==1||B!==0||_!==0||F!==1)&&(q=E*C+T*_,G=E*B+T*F,W=M*C+O*_,j=M*B+O*F);let K=R*C+N*_+V,te=R*B+N*F+Z;return x.create(q,G,W,j,K,te)}x.prepend=o;function a(w){return[w[0],w[3],w[1],w[4],w[2],w[5]]}x.getAbcdef=a;function s(w){let[A,E,T,M,O,R]=x.getAbcdef(w),N=A*M-E*T,C=M/N,B=-E/N,_=-T/N,F=A/N,V=(T*R-M*O)/N,Z=-(A*R-E*O)/N;return x.create(C,B,_,F,V,Z)}x.invert=s;function l([w,A],E){let[T,M,O,R,N,C]=x.getAbcdef(E);return[T*w+O*A+N,M*w+R*A+C]}x.apply=l;function c(w,A){let[E,T,M,O,R,N]=x.getAbcdef(A),C=1/(E*O+M*-T),[B,_]=w;return[O*C*B+-M*C*_+(N*M-R*O)*C,E*C*_+-T*C*B+(-N*E+R*T)*C]}x.applyInverse=c;function d(w,A,E=A){let[T,M,O,R,N,C]=x.getAbcdef(w);return x.setAbcdef(w,T*A,M*E,O*A,R*E,N*A,C*E),w}x.scale=d;function u(w,A){let E=Math.cos(A),T=Math.sin(A),[M,O,R,N,C,B]=x.getAbcdef(w);return x.setAbcdef(w,M*E-O*T,M*T+O*E,R*E-N*T,R*T+N*E,C*E-B*T,C*T+B*E),w}x.rotate=u;function p(w,A,E){let[T,M]=E,O=x.translate(w,-T,-M);return O=x.rotate(O,A),O=x.translate(O,T,M),O}x.rotateAround=p;function h(w,A,E){let[T,M,O,R,N,C]=x.getAbcdef(w);return x.setAbcdef(w,T,M,O,R,N+A,C+E),w}x.translate=h;function f(w,A,E){let[T,M,O,R]=x.getAbcdef(w);return x.setAbcdef(w,T,M,O,R,A,E),w}x.setTranslate=f;function m(w,A,E){let[T,M,O,R]=x.getAbcdef(w);return x.setAbcdef(w,T,M,O,R,A,E),w}x.setPosition=m;function y(w){let[A,E,T,M]=x.getAbcdef(w),O=Math.sqrt(A*A+E*E),R=Math.sqrt(T*T+M*M);return[O,R]}x.getScale=y;function g(w){let[,,,,A,E]=x.getAbcdef(w);return[A,E]}x.getPosition=g;function v(w,A){return x.decompose(w,A).rotation}x.getRotation=v;function b(w,A){let[E,T,M,O,R,N]=x.getAbcdef(w),{rotation:C,scale:B,shear:_}=r2([[E,M],[T,O]]);return{position:[R+(A[0]*E+A[1]*M)-A[0],N+(A[0]*T+A[1]*O)-A[1]],scale:B,rotation:C,shear:_,pivot:A}}x.decompose=b;function S(w,A,E,T,M=[0,0]){let[O,R]=w,[N,C]=T,[B,_,F,V]=i2({rotation:E,scale:A,shear:M}),Z=O-(N*B+C*F)+N,q=R-(N*_+C*V)+C;return x.create(B,_,F,V,Z,q)}x.compose=S})(De||(De={}));function AG(n,t){let[[e,r],[i,o]]=n,[[a,s],[l,c]]=t,d=(e-i)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-i)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var o2=[[-1,1],[-1,-1],[1,-1],[1,1]],n2=(n,t,e)=>{let r=n.getCenter(),i=n.getHalfSize(),o=De.append(t,n.worldMatrix);i[0]===0&&i[1]===0?e.push(De.apply(r,o)):o2.forEach(a=>{let s=[a[0]*i[0]+r[0],a[1]*i[1]+r[1]];e.push(De.apply(s,o))})},Pa=class{constructor(){this.matrix=De.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),De.copy(t.worldMatrix,this.matrix);let r=De.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let i=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&n2(a,e,i)}):n2(t,e,i),this.setFromPoints(i)}setFromSize(t,e,r){this.makeEmpty(),De.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[De.apply([0,0],r),De.apply([0,e],r),De.apply([t,e],r),De.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,i]=this.getHalfSize();return De.apply([t+r,e+i],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[i,o,a,s]=De.getAbcdef(this.matrix),l=De.create(i,o,a,s,r[0],r[1]);this.vertices=o2.map(([c,d])=>De.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=De.append(e.worldMatrix,r)),De.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:i}=this;return t>=r[0]&&t<=i[0]&&e>=r[1]&&e<=i[1]}containsPoint(t){let[e,r]=t,[i,o]=this.min,[a,s]=this.max;return e>=i&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let i=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(AG(i,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let i=t.vertices[e];if(this.containsPoint(i))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],De.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Pa;return t.copy(this),t}};var CG='{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}',a2=()=>JSON.parse(CG);async function EG(n,t){return await n.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(n.Engine.prototype,"scene")||Object.defineProperty(n.Engine.prototype,"scene",{get:function(){let e=Object.create(n.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>n.Engine.create(e,a2(),!0)}}var Rm,Nu;function PG(n){Rm=n}function O0(){if(!Nu){if(!Rm)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));Nu=Rm(),Nu.catch(()=>{Nu=void 0})}return Nu}var s2;function TG(){let n=typeof process<"u"?"2.0.11":void 0;return`https://cdn.spline.design/@splinetool/runtime${n?`@${n}`:""}/build/hana-ui.wasm`}function l2(n){s2=n}function Bm(){return Rm||PG(async()=>{let t=await import("./hana-ui.js");return EG(t,s2??TG())}),O0().then(()=>{})}var _m=Rd(Lm(),1);function p2(n){let t=[],e;try{e=(0,_m.makeAbsolute)((0,_m.parseSVG)(n))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,i=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,i=a=c.y,t.push({MoveTo:{x:r,y:i}});break;case"L":r=c.x,i=c.y,t.push({LineTo:{x:r,y:i}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:i}});break;case"V":i=c.y,t.push({LineTo:{x:r,y:i}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*i-s.y}:{x:r,y:i},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*i-l.y}:{x:r,y:i};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"A":{let p=r,h=i;r=c.x,i=c.y,DG(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,i);break}case"Z":r=o,i=a,t.push("ClosePath");break}s=d,l=u}return t}function DG(n,t,e,r,i,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),i=Math.abs(i),r===0||i===0){n.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(i*i);if(g>1){let q=Math.sqrt(g);r*=q,i*=q}let v=r*r,b=i*i,S=v*b-v*y*y-b*m*m,x=v*y*y+b*m*m,w=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/x)),A=w*(r*y)/i,E=w*(-i*m)/r,T=u*A-p*E+(t+l)/2,M=p*A+u*E+(e+c)/2,O=Math.atan2((y-E)/i,(m-A)/r),N=Math.atan2((-y-E)/i,(-m-A)/r)-O;!s&&N>0?N-=2*Math.PI:s&&N<0&&(N+=2*Math.PI);let C=Math.max(1,Math.ceil(Math.abs(N)/(Math.PI/2))),B=N/C,_=4/3*Math.tan(B/4),F=O,V=t,Z=e;for(let q=0;q<C;q++){let G=F+B,W=Math.cos(F),j=Math.sin(F),K=Math.cos(G),te=Math.sin(G),Q=T+r*K*u-i*te*p,ae=M+r*K*p+i*te*u,re=-r*j*u-i*W*p,ne=-r*j*p+i*W*u,de=-r*te*u-i*K*p,ve=-r*te*p+i*K*u;n.push({CurveTo:[{x:V+_*re,y:Z+_*ne},{x:Q-_*de,y:ae-_*ve},{x:Q,y:ae}]}),F=G,V=Q,Z=ae}}var km=.5522847498307936,NG=150,LG=5*60*1e3,_G=(2728+680)/2816,FG=1536/2816;function kG(n){try{let t=new DataView(n),e=t.getUint32(0);if(e!==65536&&e!==1330926671&&e!==1953658213)return;let r=t.getUint16(4),i=-1,o=-1;for(let c=0;c<r;c++){let d=12+c*16,u=t.getUint32(d);u===1751474532&&(i=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(i<0||o<0)return;let a=t.getUint16(i+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var h2=!1;function f2(){h2||(h2=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var Vm=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=De.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=ze.transparent;this._strokeColor=ze.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=ze.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=ze.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await O0(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let i=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-i>LG){clearInterval(o);return}r()&&(clearInterval(o),t())},NG)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let i=await r.arrayBuffer();if(i.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(i,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t);let r=kG(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:De.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=De.identity();if(this.camera?.enabled&&(r=De.append(r,this.camera.worldMatrix),e)){let i=De.getScale(this.camera.worldMatrix);r=De.scale(r,1/i[0],1/i[1])}this._ctm=De.append(r,t)}transform(t){this._ctm=De.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,i,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:i},{x:o,y:a}]})}quadraticCurveTo(t,e,r,i){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:i}]})}path(t){this._startFreeform(),this._pathEls.push(...p2(t))}rect(t,e,r,i,o=0,a=0,s=0,l=0){if(!g2([t,e,r,i]))return;let c={x:t,y:e,w:r,h:i,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,v2(this._pathEls,c)}ellipse(t,e,r,i,o,a,s,l){if(!!g2([t,e,r,i])){if(r<0||i<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:i}:null,zG(this._pathEls,t,e,r,i)}}clipRect(t,e,r,i,o=0,a=0,s=0,l=0){let c=De.invert(this._ctm);!c||this._clips.push({m:De.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:i,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let i=this._applyClips(r);if(i==="skip")return;if(!t&&i!==r){let a=Lu(r);if(a){this._emitClippedRectStroke(a,e);return}}r=i;let o={shape:r,color:t?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,i=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-i,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-i,y:t.y-i,w:t.w+i*2,h:t.h+i*2,radii:s.map(g=>g>0?g+i:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(Fm(l,0));if(p==="skip")return;let h=Lu(p)??l,f=null;if(u){let g=this._applyClips(Fm(u,0));f=g==="skip"?null:Lu(g)??u}let m=[];v2(m,h),f&&UG(m,f);let y={shape:{Custom:m},color:dc(this._strokeColor),transform:De.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?Fm(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:dc(this._strokeColor),align:VG[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:dc(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[i,o]=De.getScale(this._ctm),a=(i+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[i,o,a,s]=De.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[i*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:dc(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t){if(this._clips.length===0)return t;let e=t;for(let r of this._clips){let i=De.append(r.inv,this._ctm),[o,a,s,l,c,d]=De.getAbcdef(i),u=Math.abs(a)<=1e-6*(Math.abs(o)+Math.abs(l))&&Math.abs(s)<=1e-6*(Math.abs(o)+Math.abs(l)),p=GG(e);if(!p)return e;if(!u){f2();continue}let h=o*p.minX+c,f=o*p.maxX+c,m=l*p.minY+d,y=l*p.maxY+d,g=Math.min(h,f),v=Math.max(h,f),b=Math.min(m,y),S=Math.max(m,y),x=r.rect,w=Math.max(g,x.x),A=Math.max(b,x.y),E=Math.min(v,x.x+x.w),T=Math.min(S,x.y+x.h);if(w>=E||A>=T)return"skip";if(w===g&&A===b&&E===v&&T===S)continue;let O=Lu(e);if(!O||o===0||l===0){f2();continue}let R=(w-c)/o,N=(E-c)/o,C=(A-d)/l,B=(T-d)/l,_=Math.min(R,N),F=Math.min(C,B),V=Math.abs(N-R),Z=Math.abs(B-C),[q,G,W,j]=O.radii,K=_!==O.x,te=F!==O.y,Q=_+V!==O.x+O.w,ae=F+Z!==O.y+O.h,re=Math.min(V,Z)/2,ne=[K||te?0:Math.min(q,re),Q||te?0:Math.min(G,re),Q||ae?0:Math.min(W,re),K||ae?0:Math.min(j,re)];e=Fm({x:_,y:F,w:V,h:Z,radii:ne},0)}return e}drawText(t,e){let r=this._fontXPerEm.get(e.font),i=r?r/FG:1,o={TextSimple:{text:t,font_size:e.fontSize*_G*i,size:[e.width,e.height],horizontal_align:m2[e.horizontalAlign]??"Left",vertical_align:y2[e.verticalAlign]??"Top"}},a=this._effectChain(!0),s=this._fillColor.a>0,l=this._strokeColor.a>0&&this._lineWidth>0;if(s||l||a){let c={shape:o,color:s?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(De.append(this._ctm,De.translate(De.identity(),e.x,e.y)))};l&&(c.stroke=this._strokeDesc()),a&&(c.effect_chain=a),this._shapes.push(c)}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,i=this._measureCache.get(r);if(i!==void 0)return i;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:m2[e.horizontalAlign]??"Left",verticalAlign:y2[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
1312
+ `,r.pyramidTextureSize.value=new w0(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=i,this.material.root.shapeBlendhack=i}dispose(){super.dispose(),iM()?.release(this)}},Du=E0;Du.streamCompaction=new _f;var oG=new GM,aG=new GM,sc=new UM,Os=new cc,Mm=new cc,sG=new UM;function lG(n,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Oo.is(r)&&jM.call(r,n,t+1)}}function jM(n,t=0){if(n(this,t)!==!0){let r=this.children.length;for(;r--;){let i=this.children[r];Oo.is(i)&&jM.call(i,n,t+1)}}}function cG(){if(this.shapesDataTexture.value===void 0){let y=new A0(new Float32Array(4*dr*Io),dr,Io,lc,Fo);this.shapesDataTexture.value=y}let n=this.shapesDataTexture.value,t=n.image.data,e=0,r=0,i=this.data.geometry.blendRange,o=oG.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(lG.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof si)return;if(y instanceof oc||Zd(y))return;y instanceof cr?g=y.object:g=y;let v=y.data?.cloner;if(Ve.is(y)&&v&&!v.hideBase&&v.type!=="radial"&&v.disabled!==!0||!(g instanceof Qe))return;let b=g.geometry.userData.parameters,S=b?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(aG.multiplyMatrices(o,y.matrixWorld).decompose(Mm,sc,Os),b?.type==="TorusGeometry"&&b.arc!==360){let C=b.arc*Math.PI/180;C=C/4,sc.multiply(sG.set(0,0,Math.sin(C),Math.cos(C)))}let w=S.overrideGlobalBlend?S.blendRange:i;w=w/this.bboxSize*2,t[s*4]=(Mm.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Mm.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Mm.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[dr*4+s*4]=-sc.x,t[dr*4+s*4+1]=-sc.y,t[dr*4+s*4+2]=-sc.z,t[dr*4+s*4+3]=sc.w;let A=new Float32Array(4),E=0,T=w;if(b?.type==="SphereGeometry")b.width===b.height&&b.width===b.depth?A[0]=0:A[0]=1,A[1]=b.width/this.bboxSize,A[2]=b.height/this.bboxSize,A[3]=b.depth/this.bboxSize,T=Math.max(A[1],A[2],A[3])*Os.x+w;else if(b?.type==="CubeGeometry"){E=b.cornerRadius;let C=b.width,B=b.height,_=b.depth;A[0]=2,A[1]=(C-2*E)/this.bboxSize,A[2]=(B-2*E)/this.bboxSize,A[3]=(_-2*E)/this.bboxSize,T=Math.sqrt(C**2+B**2+_**2)/this.bboxSize*Os.x+w}else if(b?.type==="CylinderGeometry"){E=b.cornerRadius;let C=b.height,B=b.radiusBottom,_=b.radiusTop;if(_>=B){let F=Math.atan2(_-B,C),V=(Math.PI/2-F)/2;_-=E/Math.tan(V),B-=E*Math.tan(V)}else if(B>_){let F=Math.atan2(B-_,C),V=(Math.PI/2-F)/2;_-=E*Math.tan(V),B-=E/Math.tan(V)}A[1]=(b.height-2*E)/this.bboxSize,B===_?(A[0]=3,A[2]=B/this.bboxSize*2):(A[0]=4,A[2]=B/this.bboxSize*2,A[3]=_/this.bboxSize*2),T=(Math.hypot(A[1],Math.max(Math.abs(A[2]),Math.abs(A[3])))+E/this.bboxSize*2)*Os.x+w}else if(b?.type==="TorusGeometry"){if(A[0]=5,A[1]=(b.width-b.depth)/this.bboxSize,A[2]=b.depth/this.bboxSize,b.arc!==360){A[0]=6,A[3]=A[1],t[dr*12+s*4+3]=A[2];let C=2*Math.atan2(A[2]/2,A[1]),B=b.arc*Math.PI/180/2-C;A[1]=Math.sin(B),A[2]=Math.cos(B)}T=b.width*Os.x/this.bboxSize+w}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=nG(C);if((B===void 0||B.posVersion!==_)&&this._meshSdfWanted.set(C.uuid,C),B===void 0)return;A[0]=7,A[1]=B.slot,A[2]=B.boxHalf.x/this.bboxSize*2,A[3]=B.boxHalf.y/this.bboxSize*2,t[dr*12+s*4+3]=B.boxHalf.z/this.bboxSize*2,T=Math.hypot(B.boxHalf.x,B.boxHalf.y,B.boxHalf.z)/this.bboxSize*2*Os.x+w}t.set(A,dr*8+s*4),e=Math.max(e,T),r=Math.max(r,w),this._reach[s]=T,t[dr*12+s*4]=w,t[dr*12+s*4+1]=E/this.bboxSize*2,t[dr*12+s*4+2]=Os.x;let M=Array.isArray(g.material)?g.material[0]:g.material,O=M,R,N;if(O?.getShapeBlendBaseColor){let C=O.getShapeBlendBaseColor();R=C,N=C.a}else M?.uniforms?.nodeU0!==void 0?(R=M.uniforms.nodeU0.node.value,N=M.uniforms.nodeU1?.value??1):(R={r:1,g:1,b:1},N=1);S.operation!==0&&!S.useColor&&(N=-1),t[dr*16+s*4]=R.r,t[dr*16+s*4+1]=R.g,t[dr*16+s*4+2]=R.b,t[dr*16+s*4+3]=N,N<1&&this.material.defines?.SHAPEBLEND_C===1&&(this.material.transparent=!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||C0,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let v=!1;for(let O=0;O<Io;O++){let R=dr*4*O+g*4;if(t[R]!==d[R]||t[R+1]!==d[R+1]||t[R+2]!==d[R+2]||t[R+3]!==d[R+3]){v=!0;break}}if(!v)continue;if(p=!0,h)break;let b=t[g*4],S=t[g*4+1],x=t[g*4+2],w=d[g*4],A=d[g*4+1],E=d[g*4+2],T=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(b+S+x+T)||!Number.isFinite(w+A+E+M)){h=!0;continue}f.x=Math.min(f.x,b-T,w-M),f.y=Math.min(f.y,S-T,A-M),f.z=Math.min(f.z,x-T,E-M),m.x=Math.max(m.x,b+T,w+M),m.y=Math.max(m.y,S+T,A+M),m.z=Math.max(m.z,x+T,E+M)}}return C0&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,n.needsUpdate=!0),p}Ui("ShapeBlendGeometry",(n,t,e)=>new Du(n,t,e));Oe("shape-blends");var Om=class extends Qe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?nu(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Ui("VectorGeometry",(n,t,e)=>new Om(n,t,e));Oe("vector-shapes");var Im=class extends Qe{constructor(e,r,i){super(e,r,i);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=i}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=$l;break;case"Ellipse":o=Zl;break;case"Polygon":o=rm;break;case"Star":o=im;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let i=this.geometry;r&&i.inputs&&(i.inputs.shapeData=r,i.build())}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let i in e)if(!Object.is(e[i],r[i]))return!1;for(let i in r)if(!(i in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let i=this.geometry.getAttribute("position");i!==void 0&&i.count>0?nu(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,r):super.updateEntityBoxSize(e,r)}};import{Vector2 as dG,Vector3 as ur,Matrix3 as uG,Matrix4 as Is,BufferGeometry as KM,BufferAttribute as Zn,MathUtils as Dm}from"three";function HM(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var pG=new Is,hG=new Is,fG=new Is,WM=new ur,qM=new ur,XM=new ur,mG=new ur,yG=new ur,gG=new ur,vG=new ur,YM=new WeakMap,P0=new WeakMap,QM=new WeakMap;function bG(n,t,e){let r=[new ur,new ur,new ur],i=[new ur,new ur,new ur];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(i[0],i[1],i[2]),r.forEach((o,a)=>{let s=i[a],l=Dm.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new Is().makeBasis(r[0],r[1],r[2])}function ZM(n){n.setIndex(null),n.setAttribute("position",new Zn(new Float32Array(0),3)),n.setAttribute("normal",new Zn(new Float32Array(0),3)),n.setAttribute("uv",new Zn(new Float32Array(0),2)),n.setDrawRange(0,0)}var JM=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=t?.shapeData??Zl.create({parameters:{...hs,width:typeof hs.width=="number"?hs.width:100,height:typeof hs.height=="number"?hs.height:100}}).userData.shape;return{path:n.path??yl.defaultData(),parameters:Object.assign(e,{width:r,height:i,depth:o,extrusion:{...Hh,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new T0(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else{let e=new KM;return ZM(e),Object.assign(e,{userData:{...n,type:"PathGeometry"}})}}},T0=class extends KM{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)||!HM(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){ZM(this);return}let{depth:i,offset:o}=this.inputs.parameters.extrusion;i=Math.max(0,Math.min(i,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((i+o)*a):Math.ceil(Math.min(1,i+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let j=0;j<c;j++){let K=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);d.push(e[K].clone()),u.push(r[K].clone())}let p=(j,K,te)=>{d[j]=d[j].clone().lerp(d[K],te),u[j]=bG(u[j],u[K],te)},h=0,f=o*a%1;(!this.inputs.path.isClosed||i<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+i)*a%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&o+i<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),i===0){let j=d.length-1;d[j].copy(d[0]),u[j].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,b=g>0?this.inputs.parameters.extrusion.capType:"flat",S=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(S=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:w,vertices:A}=this._getShapePoints(S),E=0,T;if(b==="round"){let j=this.inputs.shapeData,K=QM.get(j);K!==void 0&&K.bevel===g&&K.curveSegments===S&&K.bevelSides===v?T=K.geometry:(T=new wa(j,2*g,g,S,v,void 0,!0),QM.set(j,{bevel:g,curveSegments:S,bevelSides:v,geometry:T})),E=T.getAttribute("position").count}let M=0,O=0;w.sort((j,K)=>j.start-K.start),w.forEach(j=>{j.verticesStart=M,j.verticesCount=j.continuous.reduce((K,te,Q)=>K+(Q===0||!te?2:1),0),O+=j.verticesCount,M=O});let R=O*c,N,C=0;this._isOpenEnded()&&b==="flat"&&(N=this._getSurfaceTesselation(x),C=N.vertexCount);let B=R+2*C+E*2,_=R+2*C,F={positions:new Float32Array(B*3),normals:new Float32Array(B*3),uvs:new Float32Array(B*2)},V=T?T.getIndex().array:null,Z=0;w.forEach(j=>{Z+=j.count});let q=Z*(c-1)*6+(N?2*N.elementCount*3:0)+(V?2*V.length:0),G=new Uint32Array(q),W=0;if(w.forEach(j=>{W=this._extrudeRegion(j,A,u,d,F,G,W,this._isGeometryClosed()&&!this._isOpenEnded())}),N&&(W=this._closeEnd(N,R,G,W,F,u[0],d[0],!1),W=this._closeEnd(N,R+C,G,W,F,u[u.length-1],d[d.length-1],!0)),T){F.positions.set(T.getAttribute("position").array,_*3),F.normals.set(T.getAttribute("normal").array,_*3),F.uvs.set(T.getAttribute("uv").array,_*2);for(let Q=_;Q<_+E;Q++)F.uvs[Q*2+1]=1e-4;let j=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;_+=E,F.positions.set(T.getAttribute("position").array,_*3),F.normals.set(T.getAttribute("normal").array,_*3),F.uvs.set(T.getAttribute("uv").array,_*2);let K=W;for(let Q=0;Q<V.length;Q++)G[W++]=V[Q]+_;this.setAttribute("position",new Zn(F.positions,3)),this.setAttribute("normal",new Zn(F.normals,3)),this.setAttribute("uv",new Zn(F.uvs,2)),this._setIndexFromUint32(G);let te=pG;te.copy(u[u.length-1]).setPosition(d[d.length-1]),this.applyMatrix4OnRange(te,_,B),te.copy(u[0]).setPosition(d[0]).multiply(hG.makeScale(1,1,-1)),this.applyMatrix4OnRange(te,_-E,_),this.reverseIndicesOnRange(j,K)}else this.setAttribute("position",new Zn(F.positions,3)),this.setAttribute("normal",new Zn(F.normals,3)),this.setAttribute("uv",new Zn(F.uvs,2)),this._setIndexFromUint32(G)}_setIndexFromUint32(e){let r=!1;for(let i=e.length-1;i>=0;--i)if(e[i]>=65535){r=!0;break}this.setIndex(new Zn(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=bf(e),i=YM.get(r);if(i===void 0||i.subdivisions!==e.subdivisions||i.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);i={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},YM.set(r,i)}return i}_extractPathPoints(e){let r=this.inputs.path.subdivisions,i=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(i.length<2)return[];let o=[i[0]];return i.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],i=e.length,o=this.inputs.path.isClosed,a=new ur,s=new ur,l=new ur,c=new ur,d=new ur(0,1,0);for(let y=0;y<i;y++){let g=e[y],v;y===0?v=o?e[e.length-2]:WM.copy(g).multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===i-1?b=o?e[1]:WM.copy(g).multiplyScalar(2).sub(e[y-1]):b=e[y+1],qM.subVectors(g,v).normalize(),XM.subVectors(b,g).normalize();let S=mG.addVectors(qM,XM).normalize();l.copy(S),y===0&&(S.equals(d)||yG.copy(S).negate().equals(d))&&d.set(0,0,1);let x=gG.crossVectors(d,S).normalize(),w=vG.crossVectors(S,x).normalize();d.copy(w),c.copy(x),y===0&&(a.copy(w),s.copy(S));let A=new Is().makeBasis(x,w,S);r.push(A)}let u=o?s:l,p=o?a:new ur(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(fG.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,i){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new Is,u=new Is;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(i===0?0:1)-(r+(1-i)));d.makeRotationZ(Dm.lerp(a,a+s,f)*Dm.DEG2RAD);let m=Dm.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=rt.ODD){let i=this.inputs.shapeData,o=P0.get(i);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},P0.set(i,o)),o.shapePoints}_getSurfaceTesselation(e){let r=P0.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let i;try{i=un({windingRule:rt.ODD,elementType:Yt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{i=Mx}return r!==void 0&&(r.surfaceTesselation=i),i}_computeShapePoints(e=12,r=rt.ODD){let i=this.inputs.shapeData,o=i.extractShapePointsToFlatArray([],e),a=i.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],S=y[v-0];g.push(b,S)}return g}),s;try{s=un({windingRule:r,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=vu}let l;try{l=un({windingRule:rt.ODD,elementType:Yt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Tx}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],b=s.vertices[g+1];v<d&&(d=v),v>u&&(u=v),b<p&&(p=b),b>h&&(h=b)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],b=s.elements[g+1],S=v+b,x={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(x);let w=v,A=S-1,E=v+1,T=i.roundedCurves.length;do{let M=w-v,O=s.vertices[A*2+0],R=s.vertices[A*2+1],N=s.vertices[w*2+0],C=s.vertices[w*2+1],B=s.vertices[E*2+0],_=s.vertices[E*2+1],F=N-O,V=C-R,Z=Math.sqrt(F*F+V*V);F/=Z,V/=Z;let q=N-B,G=C-_,W=Math.sqrt(q*q+G*G);q/=W,G/=W,x.normals[M*2+0]=-G,x.normals[M*2+1]=q;let j=s.vertexIndices[w];if(Array.isArray(j))x.continuous[M]=!1;else{let[K,te]=i.getCurveIndexFromVertexId(j-1,!0);if(te>0&&te<1)x.continuous[M]=!0;else{let Q=te===1?K+1:K-1;Q=(Q+T)%T;let ae=te===1?0:1,re=i.roundedCurves[K].getTangent(te),ne=i.roundedCurves[Q].getTangent(ae);x.continuous[M]=re.dot(ne)>.95}}y&&(x.normals[M*2+0]*=-1,x.normals[M*2+1]*=-1),[A,w,E]=[w,E,E+1],E>=S&&(E-=b)}while(E!==v+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,i,o,a){let s=r*2,l=r*3;e.positions[l+0]=i.x,e.positions[l+1]=i.y,e.positions[l+2]=i.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,i,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let x=(e.start+S)*2,w=r[x+0],A=r[x+1],E,T;if(e.continuous[S])E=e.normals[S*2+0],T=e.normals[S*2+1];else{let O=S===0?(e.start+e.count-1)*2:x-2,R=w-r[O+0];E=-(A-r[O+1]),T=R,e.isHole||(E=-E,T=-T)}let M=S===0?1:S/e.count;if(d.push(w,A,E,T,M,0),!e.continuous[S]||S===0)if(S===0)d.push(w,A,e.normals[0],e.normals[1],0,1);else{let O=S===e.count-1?e.start*2:x+2,R=r[O+0]-w;E=-(r[O+1]-A),T=R,e.isHole||(E=-E,T=-T),d.push(w,A,E,T,M,1)}}e.wallTemplate=d}let u=i.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let x=i[S].elements,w=x[0],A=x[1],E=x[2],T=x[4],M=x[5],O=x[6],R=x[12],N=x[13],C=x[14],B=o[S],_=S/(u-1),F=0,V=0,Z=0,q=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let de=d[G+0],ve=d[G+1];F=w*de+T*ve+R+B.x,V=A*de+M*ve+N+B.y,Z=E*de+O*ve+C+B.z}let W=d[G+2],j=d[G+3],K=w*W+T*j+R,te=A*W+M*j+N,Q=E*W+O*j+C,ae=1/(Math.sqrt(K*K+te*te+Q*Q)||1);K*=ae,te*=ae,Q*=ae;let re=q*2,ne=q*3;h[ne+0]=F,h[ne+1]=V,h[ne+2]=Z,f[ne+0]=K,f[ne+1]=te,f[ne+2]=Q,m[re+0]=d[G+4],m[re+1]=_,q++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let x=0;x<e.count;x++)(!e.continuous[x]||x===0)&&S++,y.push(S,x===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,v=y.length,b=e.isHole;for(let S=0;S<g;S++){let x=e.verticesStart*u+e.verticesCount*S,w=x+e.verticesCount;for(let A=0;A<v;A+=2){let E=x+y[A],T=x+y[A+1],M=w+y[A+1],O=w+y[A];b?(s[l++]=E,s[l++]=M,s[l++]=T,s[l++]=E,s[l++]=O,s[l++]=M):(s[l++]=E,s[l++]=T,s[l++]=M,s[l++]=E,s[l++]=M,s[l++]=O)}}return l}_closeEnd(e,r,i,o,a,s,l,c){let d=e.vertexCount,u=new ur(0,0,c?-1:1).applyMatrix4(s),p=new ur,h=new dG;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;i[o++]=f[y+0]+r,i[o++]=f[y+(c?1:2)]+r,i[o++]=f[y+(c?2:1)]+r}return o}applyMatrix4OnRange(e,r,i){let o=e.elements,a=new uG().getNormalMatrix(e).elements,s,l,c,d,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let h=u.array,f=p.array,m=u.itemSize;for(let y=r*m,g=i*m;y<g;y+=m)s=h[y+0],l=h[y+1],c=h[y+2],d=1/(o[3]*s+o[7]*l+o[11]*c+o[15]),h[y+0]=(o[0]*s+o[4]*l+o[8]*c+o[12])*d,h[y+1]=(o[1]*s+o[5]*l+o[9]*c+o[13])*d,h[y+2]=(o[2]*s+o[6]*l+o[10]*c+o[14])*d,s=f[y+0],l=f[y+1],c=f[y+2],f[y+0]=a[0]*s+a[3]*l+a[6]*c,f[y+1]=a[1]*s+a[4]*l+a[7]*c,f[y+2]=a[2]*s+a[5]*l+a[8]*c;u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let i=this.index;if(i){for(let o=e;o<r;o+=3){let a=i.getX(o),s=i.getX(o+1),l=i.getX(o+2);i.setXYZ(o,l,s,a)}i.needsUpdate=!0}}};Ui("PathGeometry",(n,t,e)=>new Im(n,t,e));$d("PathGeometry",JM);Oe("3d-paths");Gi.Cloner=si;Oe("cloners");ut();import{Group as xG,Matrix4 as SG,Skeleton as wG}from"three";function Ru(n){if(n.component){let t=n.component.instances.indexOf(n);t>=0&&n.component.instances.splice(t,1);for(let e of n.children)Ve.is(e)&&Ru(e)}}var Bu=class extends Yi(xG,Xi){constructor(e,r,i){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,i)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let i=ya.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(i){let o,a;for(let s of Dn.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=i.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=Cn.apply(i.data[s],e[s]));return this.overrideData=a,o}else return{...Jt.defaultData,...e,...Qd(Jt.defaultData,Dn.rootOverrideProps)}}updateByOp(e,r,i,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,i),e.type===0&&e.path.length===0&&this.component)for(let s of Dn.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&Dn.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,i,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let i=e.scene.find(r.component)??null,o=!1;if(i!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Ve.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ru(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(i){let a={};e2(e,[this.uuid],r.overrides,this,i,i,0,o,a);for(let s of this.children)if(Ve.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof Qe&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new SG().fromArray(m)),f=new wG(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function $M(n,t,e,r){return n.component===t&&Po(n.identity,r)?n.overrideData===e?2:1:0}function e2(n,t,e,r,i,o,a,s,l){if(a>50)return!1;if(r.component!==i){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}i.instances.find(d=>d===r)||i.instances.push(r),r.component=i}i instanceof Bu&&i.isInstanceRoot&&i.expandInstanceChildren(n);let c=0;for(let d of i.children)if(Ve.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=vl.resolve(e,u,1);p!=null&&!(p instanceof Et)&&(Object.setPrototypeOf(p,Et.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=Ve.is(m)?m:null,h!==null){let y=$M(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=n.scene.findInstance(u)??null,h!==null)){let y=$M(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),n.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?Cn.apply(d.data,p):d.data;on.is(m.type)&&(m={...m,type:"Empty"}),h=Gi.createEntity(u,m,n),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,n),f&&h.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,e2(n,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(Ve.is(u))n.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var t2=(n,t,e)=>new Bu(n,t,e);vs("Component",t2);vs("Instance",t2);Oe("components");var M0=1e-10;function r2(n){let t=n[0][0],e=n[1][0],r=n[0][1],i=n[1][1],o=Math.sqrt(t*t+e*e),a=o>M0?t/o:1,s=o>M0?e/o:0,l=a*t+s*e,c=a*i-s*r,d=a*r+s*i;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>M0?d/c:0,0]}}function i2({rotation:n,scale:t,shear:e}){let r=Math.cos(n),i=Math.sin(n),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-i*a,i*t[0]+r*a,r*o-i*t[1],i*o+r*t[1]]}var De;(x=>{function n(){return[1,0,0,0,1,0,0,0,1]}x.identity=n;function t(w,A=x.identity()){for(let E=0,T=w.length;E<T;E++)A[E]=w[E];return A}x.copy=t;function e(w,A,E,T,M,O){return x.setAbcdef(x.identity(),w,A,E,T,M,O)}x.create=e;function r(w,A,E,T,M,O,R){return w[0]=A,w[1]=T,w[2]=O,w[3]=E,w[4]=M,w[5]=R,w}x.setAbcdef=r;function i(w,A){let[E,T,M,O,R,N]=a(w),[C,B,_,F,V,Z]=a(A),q=C*E+B*M,G=C*T+B*O,W=_*E+F*M,j=_*T+F*O,K=V*E+Z*M+R,te=V*T+Z*O+N;return x.create(q,G,W,j,K,te)}x.append=i;function o(w,A){let[E,T,M,O,R,N]=a(w),[C,B,_,F,V,Z]=a(A),q=E,G=T,W=M,j=O;(C!==1||B!==0||_!==0||F!==1)&&(q=E*C+T*_,G=E*B+T*F,W=M*C+O*_,j=M*B+O*F);let K=R*C+N*_+V,te=R*B+N*F+Z;return x.create(q,G,W,j,K,te)}x.prepend=o;function a(w){return[w[0],w[3],w[1],w[4],w[2],w[5]]}x.getAbcdef=a;function s(w){let[A,E,T,M,O,R]=x.getAbcdef(w),N=A*M-E*T,C=M/N,B=-E/N,_=-T/N,F=A/N,V=(T*R-M*O)/N,Z=-(A*R-E*O)/N;return x.create(C,B,_,F,V,Z)}x.invert=s;function l([w,A],E){let[T,M,O,R,N,C]=x.getAbcdef(E);return[T*w+O*A+N,M*w+R*A+C]}x.apply=l;function c(w,A){let[E,T,M,O,R,N]=x.getAbcdef(A),C=1/(E*O+M*-T),[B,_]=w;return[O*C*B+-M*C*_+(N*M-R*O)*C,E*C*_+-T*C*B+(-N*E+R*T)*C]}x.applyInverse=c;function d(w,A,E=A){let[T,M,O,R,N,C]=x.getAbcdef(w);return x.setAbcdef(w,T*A,M*E,O*A,R*E,N*A,C*E),w}x.scale=d;function u(w,A){let E=Math.cos(A),T=Math.sin(A),[M,O,R,N,C,B]=x.getAbcdef(w);return x.setAbcdef(w,M*E-O*T,M*T+O*E,R*E-N*T,R*T+N*E,C*E-B*T,C*T+B*E),w}x.rotate=u;function p(w,A,E){let[T,M]=E,O=x.translate(w,-T,-M);return O=x.rotate(O,A),O=x.translate(O,T,M),O}x.rotateAround=p;function h(w,A,E){let[T,M,O,R,N,C]=x.getAbcdef(w);return x.setAbcdef(w,T,M,O,R,N+A,C+E),w}x.translate=h;function f(w,A,E){let[T,M,O,R]=x.getAbcdef(w);return x.setAbcdef(w,T,M,O,R,A,E),w}x.setTranslate=f;function m(w,A,E){let[T,M,O,R]=x.getAbcdef(w);return x.setAbcdef(w,T,M,O,R,A,E),w}x.setPosition=m;function y(w){let[A,E,T,M]=x.getAbcdef(w),O=Math.sqrt(A*A+E*E),R=Math.sqrt(T*T+M*M);return[O,R]}x.getScale=y;function g(w){let[,,,,A,E]=x.getAbcdef(w);return[A,E]}x.getPosition=g;function v(w,A){return x.decompose(w,A).rotation}x.getRotation=v;function b(w,A){let[E,T,M,O,R,N]=x.getAbcdef(w),{rotation:C,scale:B,shear:_}=r2([[E,M],[T,O]]);return{position:[R+(A[0]*E+A[1]*M)-A[0],N+(A[0]*T+A[1]*O)-A[1]],scale:B,rotation:C,shear:_,pivot:A}}x.decompose=b;function S(w,A,E,T,M=[0,0]){let[O,R]=w,[N,C]=T,[B,_,F,V]=i2({rotation:E,scale:A,shear:M}),Z=O-(N*B+C*F)+N,q=R-(N*_+C*V)+C;return x.create(B,_,F,V,Z,q)}x.compose=S})(De||(De={}));function AG(n,t){let[[e,r],[i,o]]=n,[[a,s],[l,c]]=t,d=(e-i)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-i)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var o2=[[-1,1],[-1,-1],[1,-1],[1,1]],n2=(n,t,e)=>{let r=n.getCenter(),i=n.getHalfSize(),o=De.append(t,n.worldMatrix);i[0]===0&&i[1]===0?e.push(De.apply(r,o)):o2.forEach(a=>{let s=[a[0]*i[0]+r[0],a[1]*i[1]+r[1]];e.push(De.apply(s,o))})},Pa=class{constructor(){this.matrix=De.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),De.copy(t.worldMatrix,this.matrix);let r=De.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let i=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&n2(a,e,i)}):n2(t,e,i),this.setFromPoints(i)}setFromSize(t,e,r){this.makeEmpty(),De.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[De.apply([0,0],r),De.apply([0,e],r),De.apply([t,e],r),De.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,i]=this.getHalfSize();return De.apply([t+r,e+i],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[i,o,a,s]=De.getAbcdef(this.matrix),l=De.create(i,o,a,s,r[0],r[1]);this.vertices=o2.map(([c,d])=>De.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=De.append(e.worldMatrix,r)),De.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:i}=this;return t>=r[0]&&t<=i[0]&&e>=r[1]&&e<=i[1]}containsPoint(t){let[e,r]=t,[i,o]=this.min,[a,s]=this.max;return e>=i&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let i=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(AG(i,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let i=t.vertices[e];if(this.containsPoint(i))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],De.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Pa;return t.copy(this),t}};var CG='{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}',a2=()=>JSON.parse(CG);async function EG(n,t){return await n.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(n.Engine.prototype,"scene")||Object.defineProperty(n.Engine.prototype,"scene",{get:function(){let e=Object.create(n.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>n.Engine.create(e,a2(),!0)}}var Rm,Nu;function PG(n){Rm=n}function O0(){if(!Nu){if(!Rm)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));Nu=Rm(),Nu.catch(()=>{Nu=void 0})}return Nu}var s2;function TG(){let n=typeof process<"u"?"2.0.12":void 0;return`https://cdn.spline.design/@splinetool/runtime${n?`@${n}`:""}/build/hana-ui.wasm`}function l2(n){s2=n}function Bm(){return Rm||PG(async()=>{let t=await import("./hana-ui.js");return EG(t,s2??TG())}),O0().then(()=>{})}var _m=Rd(Lm(),1);function p2(n){let t=[],e;try{e=(0,_m.makeAbsolute)((0,_m.parseSVG)(n))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,i=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,i=a=c.y,t.push({MoveTo:{x:r,y:i}});break;case"L":r=c.x,i=c.y,t.push({LineTo:{x:r,y:i}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:i}});break;case"V":i=c.y,t.push({LineTo:{x:r,y:i}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*i-s.y}:{x:r,y:i},h={x:c.x2,y:c.y2};r=c.x,i=c.y,t.push({CurveTo:[p,h,{x:r,y:i}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*i-l.y}:{x:r,y:i};r=c.x,i=c.y,t.push({QuadTo:[p,{x:r,y:i}]}),u=p;break}case"A":{let p=r,h=i;r=c.x,i=c.y,DG(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,i);break}case"Z":r=o,i=a,t.push("ClosePath");break}s=d,l=u}return t}function DG(n,t,e,r,i,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),i=Math.abs(i),r===0||i===0){n.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(i*i);if(g>1){let q=Math.sqrt(g);r*=q,i*=q}let v=r*r,b=i*i,S=v*b-v*y*y-b*m*m,x=v*y*y+b*m*m,w=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/x)),A=w*(r*y)/i,E=w*(-i*m)/r,T=u*A-p*E+(t+l)/2,M=p*A+u*E+(e+c)/2,O=Math.atan2((y-E)/i,(m-A)/r),N=Math.atan2((-y-E)/i,(-m-A)/r)-O;!s&&N>0?N-=2*Math.PI:s&&N<0&&(N+=2*Math.PI);let C=Math.max(1,Math.ceil(Math.abs(N)/(Math.PI/2))),B=N/C,_=4/3*Math.tan(B/4),F=O,V=t,Z=e;for(let q=0;q<C;q++){let G=F+B,W=Math.cos(F),j=Math.sin(F),K=Math.cos(G),te=Math.sin(G),Q=T+r*K*u-i*te*p,ae=M+r*K*p+i*te*u,re=-r*j*u-i*W*p,ne=-r*j*p+i*W*u,de=-r*te*u-i*K*p,ve=-r*te*p+i*K*u;n.push({CurveTo:[{x:V+_*re,y:Z+_*ne},{x:Q-_*de,y:ae-_*ve},{x:Q,y:ae}]}),F=G,V=Q,Z=ae}}var km=.5522847498307936,NG=150,LG=5*60*1e3,_G=(2728+680)/2816,FG=1536/2816;function kG(n){try{let t=new DataView(n),e=t.getUint32(0);if(e!==65536&&e!==1330926671&&e!==1953658213)return;let r=t.getUint16(4),i=-1,o=-1;for(let c=0;c<r;c++){let d=12+c*16,u=t.getUint32(d);u===1751474532&&(i=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(i<0||o<0)return;let a=t.getUint16(i+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var h2=!1;function f2(){h2||(h2=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var Vm=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=De.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=ze.transparent;this._strokeColor=ze.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=ze.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=ze.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await O0(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let i=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-i>LG){clearInterval(o);return}r()&&(clearInterval(o),t())},NG)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let i=await r.arrayBuffer();if(i.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(i,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t);let r=kG(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:De.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=De.identity();if(this.camera?.enabled&&(r=De.append(r,this.camera.worldMatrix),e)){let i=De.getScale(this.camera.worldMatrix);r=De.scale(r,1/i[0],1/i[1])}this._ctm=De.append(r,t)}transform(t){this._ctm=De.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,i,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:i},{x:o,y:a}]})}quadraticCurveTo(t,e,r,i){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:i}]})}path(t){this._startFreeform(),this._pathEls.push(...p2(t))}rect(t,e,r,i,o=0,a=0,s=0,l=0){if(!g2([t,e,r,i]))return;let c={x:t,y:e,w:r,h:i,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,v2(this._pathEls,c)}ellipse(t,e,r,i,o,a,s,l){if(!!g2([t,e,r,i])){if(r<0||i<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:i}:null,zG(this._pathEls,t,e,r,i)}}clipRect(t,e,r,i,o=0,a=0,s=0,l=0){let c=De.invert(this._ctm);!c||this._clips.push({m:De.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:i,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let i=this._applyClips(r);if(i==="skip")return;if(!t&&i!==r){let a=Lu(r);if(a){this._emitClippedRectStroke(a,e);return}}r=i;let o={shape:r,color:t?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,i=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-i,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-i,y:t.y-i,w:t.w+i*2,h:t.h+i*2,radii:s.map(g=>g>0?g+i:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(Fm(l,0));if(p==="skip")return;let h=Lu(p)??l,f=null;if(u){let g=this._applyClips(Fm(u,0));f=g==="skip"?null:Lu(g)??u}let m=[];v2(m,h),f&&UG(m,f);let y={shape:{Custom:m},color:dc(this._strokeColor),transform:De.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?Fm(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:dc(this._strokeColor),align:VG[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:dc(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[i,o]=De.getScale(this._ctm),a=(i+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[i,o,a,s]=De.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[i*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:dc(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t){if(this._clips.length===0)return t;let e=t;for(let r of this._clips){let i=De.append(r.inv,this._ctm),[o,a,s,l,c,d]=De.getAbcdef(i),u=Math.abs(a)<=1e-6*(Math.abs(o)+Math.abs(l))&&Math.abs(s)<=1e-6*(Math.abs(o)+Math.abs(l)),p=GG(e);if(!p)return e;if(!u){f2();continue}let h=o*p.minX+c,f=o*p.maxX+c,m=l*p.minY+d,y=l*p.maxY+d,g=Math.min(h,f),v=Math.max(h,f),b=Math.min(m,y),S=Math.max(m,y),x=r.rect,w=Math.max(g,x.x),A=Math.max(b,x.y),E=Math.min(v,x.x+x.w),T=Math.min(S,x.y+x.h);if(w>=E||A>=T)return"skip";if(w===g&&A===b&&E===v&&T===S)continue;let O=Lu(e);if(!O||o===0||l===0){f2();continue}let R=(w-c)/o,N=(E-c)/o,C=(A-d)/l,B=(T-d)/l,_=Math.min(R,N),F=Math.min(C,B),V=Math.abs(N-R),Z=Math.abs(B-C),[q,G,W,j]=O.radii,K=_!==O.x,te=F!==O.y,Q=_+V!==O.x+O.w,ae=F+Z!==O.y+O.h,re=Math.min(V,Z)/2,ne=[K||te?0:Math.min(q,re),Q||te?0:Math.min(G,re),Q||ae?0:Math.min(W,re),K||ae?0:Math.min(j,re)];e=Fm({x:_,y:F,w:V,h:Z,radii:ne},0)}return e}drawText(t,e){let r=this._fontXPerEm.get(e.font),i=r?r/FG:1,o={TextSimple:{text:t,font_size:e.fontSize*_G*i,size:[e.width,e.height],horizontal_align:m2[e.horizontalAlign]??"Left",vertical_align:y2[e.verticalAlign]??"Top"}},a=this._effectChain(!0),s=this._fillColor.a>0,l=this._strokeColor.a>0&&this._lineWidth>0;if(s||l||a){let c={shape:o,color:s?dc(this._fillColor):[0,0,0,0],transform:De.getAbcdef(De.append(this._ctm,De.translate(De.identity(),e.x,e.y)))};l&&(c.stroke=this._strokeDesc()),a&&(c.effect_chain=a),this._shapes.push(c)}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,i=this._measureCache.get(r);if(i!==void 0)return i;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:m2[e.horizontalAlign]??"Left",verticalAlign:y2[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
1313
1313
  `))c+=Math.max(1,Math.ceil(d.length/l));o=c*e.fontSize*e.lineHeight}return this._measureCache.size>512&&this._measureCache.clear(),this._measureCache.set(r,o),o}clear(){this._shapes=[],this._ctm=De.identity(),this._stack.length=0,this._clips.length=0}render(){let t=this._engine;if(!t||this._crashed)return;let e=JSON.stringify(this._shapes);e!==this._lastPushedJSON&&(this._guard(()=>t.scene.updateUiShapes(this._shapes)),this._lastPushedJSON=e),this._guard(()=>t.onFrame())}},VG={inside:"Inside",outside:"Outside",center:"Center"},m2={[1]:"Left",[2]:"Right",[3]:"Center",[4]:"Justify"},y2={[1]:"Top",[2]:"Center",[3]:"Bottom"};function dc({r:n,g:t,b:e,a:r}){return[n,t,e,r]}function g2(n){for(let t=0;t<n.length;t++)if(n[t]!==void 0&&!Number.isFinite(n[t]))return!1;return!0}function Fm(n,t){let[e,r,i,o]=n.radii;return e===0&&r===0&&i===0&&o===0?{Rectangle:{x:n.x,y:n.y,width:n.w,height:n.h}}:{RoundedRectangle:{x:n.x,y:n.y,width:n.w,height:n.h,radius:[e,r,i,o],corner_smoothing:t}}}function Lu(n){if("Rectangle"in n){let t=n.Rectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[0,0,0,0]}}if("RoundedRectangle"in n){let t=n.RoundedRectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[t.radius[0],t.radius[1],t.radius[2],t.radius[3]]}}return null}function GG(n){let t=Lu(n);if(t)return{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h};if("Ellipse"in n){let e=n.Ellipse;return{minX:e.center_x-e.rx,minY:e.center_y-e.ry,maxX:e.center_x+e.rx,maxY:e.center_y+e.ry}}if("TextSimple"in n){let e=n.TextSimple;return{minX:0,minY:0,maxX:e.size[0],maxY:e.size[1]}}if("Custom"in n){let e=1/0,r=1/0,i=-1/0,o=-1/0,a=s=>{s.x<e&&(e=s.x),s.y<r&&(r=s.y),s.x>i&&(i=s.x),s.y>o&&(o=s.y)};for(let s of n.Custom)s!=="ClosePath"&&("MoveTo"in s?a(s.MoveTo):"LineTo"in s?a(s.LineTo):"QuadTo"in s?s.QuadTo.forEach(a):"CurveTo"in s&&s.CurveTo.forEach(a));return e===1/0?null:{minX:e,minY:r,maxX:i,maxY:o}}return null}function v2(n,t){let{x:e,y:r,w:i,h:o}=t,a=Math.min(i,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){n.push({MoveTo:{x:e,y:r}},{LineTo:{x:e+i,y:r}},{LineTo:{x:e+i,y:r+o}},{LineTo:{x:e,y:r+o}},"ClosePath");return}let u=1-km;n.push({MoveTo:{x:e+s,y:r}}),n.push({LineTo:{x:e+i-l,y:r}}),l>0&&n.push({CurveTo:[{x:e+i-l*u,y:r},{x:e+i,y:r+l*u},{x:e+i,y:r+l}]}),n.push({LineTo:{x:e+i,y:r+o-c}}),c>0&&n.push({CurveTo:[{x:e+i,y:r+o-c*u},{x:e+i-c*u,y:r+o},{x:e+i-c,y:r+o}]}),n.push({LineTo:{x:e+d,y:r+o}}),d>0&&n.push({CurveTo:[{x:e+d*u,y:r+o},{x:e,y:r+o-d*u},{x:e,y:r+o-d}]}),n.push({LineTo:{x:e,y:r+s}}),s>0&&n.push({CurveTo:[{x:e,y:r+s*u},{x:e+s*u,y:r},{x:e+s,y:r}]}),n.push("ClosePath")}function UG(n,t){let{x:e,y:r,w:i,h:o}=t,a=Math.min(i,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){n.push({MoveTo:{x:e,y:r}},{LineTo:{x:e,y:r+o}},{LineTo:{x:e+i,y:r+o}},{LineTo:{x:e+i,y:r}},"ClosePath");return}let u=1-km;n.push({MoveTo:{x:e+s,y:r}}),s>0&&n.push({CurveTo:[{x:e+s*u,y:r},{x:e,y:r+s*u},{x:e,y:r+s}]}),n.push({LineTo:{x:e,y:r+o-d}}),d>0&&n.push({CurveTo:[{x:e,y:r+o-d*u},{x:e+d*u,y:r+o},{x:e+d,y:r+o}]}),n.push({LineTo:{x:e+i-c,y:r+o}}),c>0&&n.push({CurveTo:[{x:e+i-c*u,y:r+o},{x:e+i,y:r+o-c*u},{x:e+i,y:r+o-c}]}),n.push({LineTo:{x:e+i,y:r+l}}),l>0&&n.push({CurveTo:[{x:e+i,y:r+l*u},{x:e+i-l*u,y:r},{x:e+i-l,y:r}]}),n.push("ClosePath")}function zG(n,t,e,r,i){let o=r*km,a=i*km;n.push({MoveTo:{x:t+r,y:e}},{CurveTo:[{x:t+r,y:e+a},{x:t+o,y:e+i},{x:t,y:e+i}]},{CurveTo:[{x:t-o,y:e+i},{x:t-r,y:e+a},{x:t-r,y:e}]},{CurveTo:[{x:t-r,y:e-a},{x:t-o,y:e-i},{x:t,y:e-i}]},{CurveTo:[{x:t+o,y:e-i},{x:t+r,y:e-a},{x:t+r,y:e}]},"ClosePath")}function b2(n){let t=!1;return n.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var jG=Math.PI/180,Tce=180/Math.PI;function x2(n,t,e,r,i,o){let a=n-e,s=t-r;return a*a/(i*i)+s*s/(o*o)<=1}function S2(n){return n*jG}ut();function ko(n){return{all:n=n||new Map,on:function(t,e){var r=n.get(t);r?r.push(e):n.set(t,[e])},off:function(t,e){var r=n.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var r=n.get(t);r&&r.slice().map(function(i){i(e)}),(r=n.get("*"))&&r.slice().map(function(i){i(t,e)})}}}var Vo=class{constructor(t,e,r){this.uuid=t;this.data=e;this.isObject2D=!0;this.localMatrix=De.identity();this.worldMatrix=De.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Pa;this._recursiveBBox=new Pa;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=ko();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=De.append(e.worldMatrix,r)),De.applyInverse(t,r)}intersects(t,e,r,i=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),i)}intersectsInLocalSpace(t,e,r=!1){let{min:i,max:o}=r?this.recursiveBBox:this.singleBBox;return t>=i[0]&&t<=o[0]&&e>=i[1]&&e<=o[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=De.compose(this.position,this.scale,S2(this.rotation),Eo.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let i=this.parent;e&&i!==null&&i!==void 0&&i.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=De.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=De.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Eo.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let i=t,o=Ye(t.path,["states","*"]);if(o!==null){if(t.type===0){let[a]=o;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=Ot.zoom(l,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(s[d]=c[d])}}i={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=Ot.removeOverridden(t.path,t.props,a);i={...t,props:s}}}this.updateByPatchedOpBase(i,Co.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let i of this.data.states)Co.toOps(this.data,i.data).forEach(a=>{let s=sl.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let i=this.data.states.data(t);i&&(this.dataPatched=Co.patch(this.data,i),Co.toOps(this.data,i).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new Vo(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof Vo&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};ut();var _u=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=ze.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var Fu=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var Gm=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=ze.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var Um=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=ze.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var Rt=class extends Vo{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Gm(e+"-fill",r.fill,i),this.stroke=new Um(e+"-stroke",r.stroke,i),this.dropShadow=new _u(e+"-dropShadow",r.dropShadow,i),this.innerShadow=new _u(e+"-innerShadow",r.innerShadow,i),this.backgroundBlur=new Fu(e+"-backgroundBlur",r.backgroundBlur,i),this.layerBlur=new Fu(e+"-layerBlur",r.layerBlur,i)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:ze.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:ze.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=ze.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=ze.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new Rt(this.uuid,this.data,e);return r.parent=void 0,r}};var Ta=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,i)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return x2(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new Ta(this.uuid,this.data,e);return r.parent=void 0,r}};var Ki=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,i)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Ki(this.uuid,this.data,e);return r.parent=void 0,r}};var Ma=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,i)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:ze.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:ze.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,i=this.data.text.textValue.toString(),o=r===2?i.toUpperCase():r===3?i.toLowerCase():i,{height:a}=e.drawText(o,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Ma(this.uuid,this.data,e);return r.parent=void 0,r}};var uc=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,i)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(o=>zm.extremas(o)),r=[1/0,1/0],i=[-1/0,-1/0];for(let o=0,a=e.length;o<a;o++){let s=e[o];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>i[0]&&(i[0]=s[1][0]),s[1][1]>i[1]&&(i[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[i[0],i[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let i=1,o=this.data.points.length;i<o;i++){let a=this.data.points[i].data,s=this.data.points[i-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let i={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(i)}}getCenter(){let[e,r]=this.extremasBBox.min,[i,o]=this.getHalfSize();return[e+i,r+o]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let o=0,a=this.data.points.length;o<a;o++){let s=this.data.points[o].data;if(o===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[o-1].data,[c,d]=l.controlNext.position,[u,p]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};zm.derive(m),e.bezierCurveTo(c,d,u,p,h,f)}}let r=this.data.points[0].data,i=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[o,a]=i.controlNext.position,[s,l]=r.controlPrevious.position,[c,d]=r.position;e.bezierCurveTo(o,a,s,l,c,d)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new uc(this.uuid,this.data,e);return r.parent=void 0,r}},zm;(o=>{function n(a){let s=a.start,l=a.cp1,c=a.cp2,d=a.end,u=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(d[0]-c[0]),3*(d[1]-c[1])],f={start:u,cp:p,end:h};return a.derivative=f,f.derivative=I0.derive(f),f}o.derive=n;function t(a,s,l,c=!1){let d=a-2*s+l;if(d!==0){let u=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,h=-(u+p)/d,f=-(-u+p)/d;return[h,f]}else if(s!==l&&d===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??o.derive(a),l=s.start,c=s.cp,d=s.end;return[t(l[0],c[0],d[0]),t(l[1],c[1],d[1])]}o.droot=e;function r(a){let[s,l]=o.droot(a),c=[a.start[0],a.end[0]],d=[a.start[1],a.end[1]];for(let u of s)c.push(o.compute(a,Math.min(1,Math.max(0,u)))[0]);for(let u of l)d.push(o.compute(a,Math.min(1,Math.max(0,u)))[1]);return c.sort((u,p)=>u-p),d.sort((u,p)=>u-p),[[c[0],d[0]],[c[c.length-1],d[d.length-1]]]}o.extremas=r;function i(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,d=s*s,u=c*l,p=c*s*3,h=l*d*3,f=s*d;return[u*a.start[0]+p*a.cp1[0]+h*a.cp2[0]+f*a.end[0],u*a.start[1]+p*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}o.compute=i})(zm||(zm={}));var I0;(r=>{function n(i){let o=i.start,a=i.cp,s=i.end,l=[2*(a[0]-o[0]),2*(a[1]-o[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],d={start:l,end:c};return d.derivative=D0.derive(d),i.derivative=d,d}r.derive=n;function t(i){let o=i.derivative??r.derive(i),a=o.start,s=o.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(i,o){if(o===0)return[...i.start];if(o===1)return[...i.end];let a=1-o,s=a*a,l=o*o,c=s,d=a*o*2,u=l;return[c*i.start[0]+d*i.cp[0]+u*i.end[0],c*i.start[1]+d*i.cp[1]+u*i.end[1]]}r.compute=e})(I0||(I0={}));var D0;(e=>{function n(r){let i=r.start,o=r.end,a=[o[0]-i[0],o[1]-i[1]];return r.derivative=a,r.derivative}e.derive=n;function t(r,i){if(i===0)return[...r.start];if(i===1)return[...r.end];let o=r.start,a=r.end;return[o[0]+(a[0]-o[0])*i,o[1]+(a[1]-o[1])*i]}e.compute=t})(D0||(D0={}));var li=class extends Vo{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.context=i;this.isBaseGroup=!0;this.children=[]}add(e){e.parent&&e.parent instanceof li&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let i of this.children)i instanceof li?i.traverse(e):r=e(i)}intersectsChildrenHelper(e,r,i,o,a){for(let s of this.children)if(s.intersects(e,r,i,!1)&&(a.push(s),o)||s instanceof li&&s.intersectsChildrenHelper(e,r,i,o,a))return!0;return!1}intersectsChildren(e,r,i,o=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,r,i,o,a),a}intersectsChildrenHelperReverse(e,r,i,o,a){for(let s of this.children)if(s instanceof li&&s.intersectsChildrenHelperReverse(e,r,i,o,a)||s.intersects(e,r,i,!1)&&(a.push(s),o))return!0;return!1}intersectsChildrenReverse(e,r,i,o=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,r,i,o,a),a}updateWorldMatrix(e,r,i){if(super.updateWorldMatrix(e,r,i),i&&this.children)for(let o of this.children)o.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(i=>{i.uuid===e&&(r=i)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new li(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}},yi=class extends li{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this.updateState(r,i)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new yi(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};ut();var Fr=class extends li{constructor(e,r,i){super(e,r,i);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Ki(e+"-background",Pl.defaultData,i),this.background.parent=this,this.updateState(r,i)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,i){super.updateWorldMatrix(e,r,i),this.background?.updateWorldMatrix(e,r,i)}draw(e){if(!this.visible)return;e.save();let r=this.width,i=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=i,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,i,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Fr(this.uuid,this.data,e);r.parent=void 0;for(let i of this.children)r.add(i.clone(e));return r}};var w2=Rd(Lm(),1),jm=new Map,HG=4096,pc=null;function WG(n){let t=jm.get(n);if(t!==void 0)return t;if(pc===null||!pc.isConnected){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none",pc=document.createElementNS("http://www.w3.org/2000/svg","path"),r.appendChild(pc),document.body.appendChild(r)}pc.setAttribute("d",n);let e=pc.getBBox();return jm.size>=HG&&jm.clear(),jm.set(n,e),e}var Go=class extends Rt{constructor(e,r,i){super(e,r,i);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,i),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=this.path;A2(this.path)&&(console.warn("Invalid SVG path",this.uuid),e=""),this._pathBBox=WG(e)}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new Go(this.uuid,this.data,e);return r.parent=void 0,r}};function A2(n){return/NaN/.test(n)}function C2(n,t=1,e=1){if(t<=0||e<=0)return n;if(A2(n))return console.warn("Cannot scale invalid path",n),Hm([]);if(t===1&&e===1)return n;try{let i=(0,w2.parseSVG)(n).map(o=>{let a={...o};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return Hm(i)}catch(r){return console.warn("Error parsing SVG path",r),Hm([])}}function Hm(n){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return n.map(r=>{let i=[];t.forEach(a=>{if(a in r){let s=r[a]*1;i.length&&s>=0&&i.push(","),i.push(s)}});let o=(e===r.code?i[0]<0?"":",":r.code)+i.join("");return e=r.code,o}).join("")}function E2(n,t,e){switch(t.type){case"ellipse2d":return new Ta(n,t,e);case"rectangle2d":return new Ki(n,t,e);case"text2d":return new Ma(n,t,e);case"vector2d":return new uc(n,t,e);case"path2d":return new Go(n,t,e);case"frame2d":return new Fr(n,t,e);case"group2d":default:return new yi(n,t,e)}}mr();var R0=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new yi(R0.GROUP_ID,{...qd.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,i,o,a){let s=E2(t,e,a);s&&(i.add(s),i.children.splice(o,0,i.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof yi||s instanceof Fr)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let i=0;for(let o of t)this.createObject(o.id,o.data,o.children,e,i,r),i+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,i){let o=this.find(t);if(o)try{o.updateByOp(e,r,{shared:i})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof li&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof li){let i=r.parent;r.resetBBoxNeedsUpdate(),i?.remove(r),i?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let i=r.parent,o=t.parent===null?this:this.find(t.parent);if(o===void 0&&!1&&console.error("unexpected",o,t),o instanceof li||o===this){o.add(r);let a=t.localIndex;o.children.splice(a,0,o.children.pop()),r.updateWorldMatrix(!0,!1,!0),i?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,i=!1,o=[]){return this.group.intersectsChildren(t,e,r,i,o,!0)}intersectsChildrenReverse(t,e,r,i=!1,o=[]){return this.group.intersectsChildrenReverse(t,e,r,i,o,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],i=e;for(;i!==this.group;){let o=i;i=i.parent;let a=i.children.indexOf(o);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let i=this.getWithSortKey(r.id);i!==void 0&&e.push(i)}return e.sort((r,i)=>ns(r.sortKey,i.sortKey)),e.map(r=>r.entity)}},Rs=R0;Rs.GROUP_ID="scene2d";function B0({constraints:n,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:i,objectInitialWidth:o,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=n,d=t-r,u=e-i,p=o,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=d;else if(l===3)f+=d/2;else if(l===2)p=Math.max(1,p+d);else if(l===4){let y=t/r;p*=y,f*=y}}if(c!==0){if(c===1)m+=u;else if(c===3)m+=u/2;else if(c===2)h=Math.max(1,h+u);else if(c===4){let y=e/i;h*=y,m*=y}}return{width:p,height:h,position:[f,m]}}var qG=Rd(Lm(),1);var Iue={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};ut();import{BufferGeometry as QG,CanvasTexture as KG,Float32BufferAttribute as M2,HalfFloatType as ZG,MathUtils as JG,Mesh as $G,OrthographicCamera as eU,ShaderMaterial as tU,Uniform as rU,WebGLRenderTarget as iU}from"three";var XG=new Set;function P2(n){XG.add(n)}function N0(n,t,e,r){return r?e:2048/Math.max(1,n,t)}function T2(n,t,e,r){let i=N0(n,t,e,r),o=Math.max(e,512/Math.min(n,t)),a=Math.min(o,i);return{width:Math.max(1,Math.ceil(n*a)),height:Math.max(1,Math.ceil(t*a))}}var nU=`
1314
1314
  varying vec2 vUv;
1315
1315
  void main() {
@@ -1325,7 +1325,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
1325
1325
  `,e),u=e.horizontalAlign===1?d:0,p=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],d),h=this.getLineInitialOffsetY(a,t.length,c,o,e.verticalAlign),f=[],m=t.map(()=>[]),y=t.map(()=>[]);for(let v=0;v<t.length;v++){let b=t[v],S={features:{liga:!0},letterSpacing:e.letterSpacing},x=[];try{x=i.stringToGlyphs(b,S)}catch(M){this.warnLayoutError(M)}p=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,b,d);let w=[];try{w=this.reverseLigaturesTable(i,b,x)}catch(M){this.warnLayoutError(M)}let A=this.computeSpaceWidthForLine(t,v,e,r),E=0,T=x[0];T&&e.horizontalAlign===2&&T.leftSideBearing!==void 0&&(p-=T.leftSideBearing*o);try{this.font?.forEachGlyph(b,p,h,e.fontSize,S,(M,O,R,N,C)=>{let B=M.index===0?`
1326
1326
  `:M.unicode?String.fromCharCode(M.unicode):void 0,_=w[E],F=0;if(B===`
1327
1327
  `)F=u;else if(B===" ")F=A;else{let V=this.createPath(M,o,O,R,e);V&&(F=V.offsetX,f.push(V.path))}if(!_||_.replacements.length===1)y[v].push([O,R]),m[v].push(F);else{let V=_.replacements.map(W=>(i.glyphs.get(W).advanceWidth??0)*o),Z=V.reduce((W,j)=>W+=j,0),q=V.map(W=>W/Z),G=O;for(let W=0;W<q.length;W++){let j=F*q[W];y[v].push([G,R]),m[v].push(j),G+=j}}E++})}catch(M){this.warnLayoutError(M)}h-=a}let g=[];for(let v=0,b=f.length;v<b;v++)g.push(...f[v].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,i,o){return(r===3||r===2)&&i.indexOf(`
1328
- `)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,i,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*i,l=t-s,c=-this.ascender*i-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,i,o){let a=t.getPath(r,-i,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new qm,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=EU(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,i){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(i.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function EU(n){if(n.length){let t=n[0];if(t instanceof wU)return t.v1;if(t instanceof SU||t instanceof AU)return t.v0}}Ui("TextGeometry",(n,t,e)=>new Ca(n,t,e));var _2={create:(n,t)=>new ec(n,t)};$d("TextGeometry",_2);$d("InputGeometry",_2);vP(Ym);Oe("text");var F2=200,PU=null;function k2(n){PU=n}var Vu=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},V2=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return TU(Math.atan2(r,e))},G2=(n,t,e)=>{let r={x:0,y:0};return e=Km(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Km=n=>n*(Math.PI/180),TU=n=>n*(180/Math.PI),U2=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,Qm=new Map,z2=n=>{Qm.has(n)&&clearTimeout(Qm.get(n)),Qm.set(n,setTimeout(function(){Qm.delete(n),n()},100))},fc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.addEventListener?n.addEventListener(i,e,!1):n.attachEvent&&n.attachEvent(i,e)},mc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.removeEventListener?n.removeEventListener(i,e):n.detachEvent&&n.detachEvent(i,e)};var Zm=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),z0=()=>{if(typeof window>"u")return;let n=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:n,y:t}},Jm=(n,t)=>{t.top||t.right||t.bottom||t.left?(n.style.top=t.top,n.style.right=t.right,n.style.bottom=t.bottom,n.style.left=t.left):(n.style.left=t.x+"px",n.style.top=t.y+"px")},$m=(n,t,e)=>{let r=H2(n);for(let i in r)if(Object.prototype.hasOwnProperty.call(r,i))if(typeof t=="string")r[i]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[i]=o.slice(0,-2)}return r},j2=(n,t)=>{let e=H2(n);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},H2=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},ey=(n,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n},W2=(n,t)=>{let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},Gu=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},q2=(n,t,e)=>({x:Math.min(Math.max(n.x,t.x-e),t.x+e),y:Math.min(Math.max(n.y,t.y-e),t.y+e)});typeof window<"u"&&(X2="ontouchstart"in window,Y2=!!window.PointerEvent,Q2=!!window.MSPointerEvent);var X2,Y2,Q2,Uu={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},yc,zu={};Y2?yc=Uu.pointer:Q2?yc=Uu.MSPointer:X2?(yc=Uu.touch,zu=Uu.mouse):yc=Uu.mouse;function Ns(){}Ns.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Ns.prototype.off=function(n,t){var e=this;return e._handlers_=e._handlers_||{},n===void 0?e._handlers_={}:t===void 0?e._handlers_[n]=null:e._handlers_[n]&&e._handlers_[n].indexOf(t)>=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Ns.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(a){a.call(e,{type:i,target:e},t)})};Ns.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=W2(t.options,n))};Ns.prototype.bindEvt=function(n,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.')},fc(n,yc[t],e._domHandlers_[t]),zu[t]&&fc(n,zu[t],e._domHandlers_[t]),e};Ns.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},mc(n,yc[t],e._domHandlers_[t]),zu[t]&&mc(n,zu[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var gc=Ns;function wr(n,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=n,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=wr.id,wr.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}wr.prototype=new gc;wr.constructor=wr;wr.id=0;wr.prototype.buildEl=function(n){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)};wr.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=j2("borderRadius","50%"),e=$m("transition","opacity",n),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)"},ey(r.el,e),this.options.shape==="circle"&&ey(r.back,t),ey(r.front,t),this.applyStyles(r),this};wr.prototype.applyStyles=function(n){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in n[t])this.ui[t].style[e]=n[t][e];return this};wr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};wr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};wr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};wr.prototype.show=function(n){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 n=="function"&&n.call(this)},t.options.fadeTime)),t};wr.prototype.hide=function(n){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 n=="function"&&n.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(n,r)}return t};wr.prototype.setPosition=function(n,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",i={};i.front=$m("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof n=="function"&&n.call(e),e.restCallback()},e.options.fadeTime)};wr.prototype.restCallback=function(){var n=this,t={};t.front=$m("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};wr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};wr.prototype.computeDirection=function(n){var t=n.angle.radian,e=Math.PI/4,r=Math.PI/2,i,o,a;if(t>e&&t<e*3&&!n.lockX?i="up":t>-e&&t<=e&&!n.lockY?i="left":t>-e*3&&t<=-e&&!n.lockX?i="down":n.lockY||(i="right"),n.lockY||(t>-r&&t<r?o="left":o="right"),n.lockX||(t>0?a="up":a="down"),n.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:i},n.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return n;(!c.x||!c.y)&&this.trigger("plain",n),c.x||this.trigger("plain:"+o,n),c.y||this.trigger("plain:"+a,n),c.angle||this.trigger("dir dir:"+i,n)}else this.resetDirection();return n};var K2=wr;function pr(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=pr.id,pr.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}pr.prototype=new gc;pr.constructor=pr;pr.id=0;pr.prototype.prepareNipples=function(){var n=this,t=n.nipples;t.on=n.on.bind(n),t.off=n.off.bind(n),t.options=n.options,t.destroy=n.destroy.bind(n),t.ids=n.ids,t.id=n.id,t.processOnMove=n.processOnMove.bind(n),t.processOnEnd=n.processOnEnd.bind(n),t.get=function(e){if(e===void 0)return t[0];for(var r=0,i=t.length;r<i;r+=1)if(t[r].identifier===e)return t[r];return!1}};pr.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};pr.prototype.begin=function(){var n=this,t=n.options;if(t.mode==="static"){var e=n.createNipple(t.position,n.manager.getIdentifier());e.add(),n.idles.push(e)}};pr.prototype.createNipple=function(n,t){var e=this,r=e.manager.scroll,i={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(n.x&&n.y)i={x:n.x-a.x,y:n.y-a.y};else if(n.top||n.right||n.bottom||n.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=n.top,s.style.right=n.right,s.style.bottom=n.bottom,s.style.left=n.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),i=n,n={x:l.left+r.x,y:l.top+r.y}}var c=new K2(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:n,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(Jm(c.ui.el,i),Jm(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};pr.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};pr.prototype.bindNipple=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};pr.prototype.pressureFn=function(n,t,e){var r=this,i=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=n.force||n.pressure||n.webkitForce||0;o!==i&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),i=o)}.bind(r),100)};pr.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=Zm(n),t.updateBox();var i=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[n[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return Gu(n,i),t.manager.bindDocument(),!1};pr.prototype.processOnStart=function(n){var t=this,e=t.options,r,i=t.manager.getIdentifier(n),o=n.force||n.pressure||n.webkitForce||0,a={x:n.pageX,y:n.pageY},s=t.getOrCreate(i,a);s.identifier!==i&&t.manager.removeIdentifier(s.identifier),s.identifier=i;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(n,d,d.identifier),t.processOnMove(n)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=Vu(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(n);return}}return s};pr.prototype.getOrCreate=function(n,t){var e=this,r=e.options,i;return/(semi|static)/.test(r.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):r.mode==="semi"?e.createNipple(t,n):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,n),i)};pr.prototype.processOnMove=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.scroll;if(!U2(n)){this.processOnEnd(n);return}if(!i){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=i.el.getBoundingClientRect();i.position={x:o.x+a.left,y:o.y+a.top}}i.identifier=r;var s=i.options.size/2,l={x:n.pageX,y:n.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var c=Vu(l,i.position),d=V2(l,i.position),u=Km(d),p=c/s,h={distance:c,position:l},f,m;if(i.options.shape==="circle"?(f=Math.min(c,s),m=G2(i.position,f,d)):(m=q2(l,i.position,s),f=Vu(m,i.position)),e.follow){if(c>s){let b=l.x-m.x,S=l.y-m.y;i.position.x+=b,i.position.y+=S,i.el.style.top=i.position.y-(t.box.top+o.y)+"px",i.el.style.left=i.position.x-(t.box.left+o.x)+"px",c=Vu(l,i.position)}}else l=m,c=f;var y=l.x-i.position.x,g=l.y-i.position.y;i.frontPosition={x:y,y:g},e.dataOnly||Jm(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:p,pressure:n.force||n.pressure||n.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:i,lockX:e.lockX,lockY:e.lockY};v=i.computeDirection(v),v.angle={radian:Km(180-d),degree:180-d},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};pr.prototype.processOnEnd=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};pr.prototype.onDestroyed=function(n,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()};pr.prototype.destroy=function(){var n=this;n.unbindEvt(n.options.zone,"start"),n.nipples.forEach(function(e){e.destroy()});for(var t in n.pressureIntervals)Object.prototype.hasOwnProperty.call(n.pressureIntervals,t)&&clearInterval(n.pressureIntervals[t]);n.trigger("destroyed",n.nipples),n.manager.unbindDocument(),n.off(),n.pressureIntervals={},n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.manager=null};var Z2=pr;function gr(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=z0(),t._windowBound=!1,t.config(n),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(i){i.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){z2(e)},t._onScroll=function(){t.scroll=z0()},t.collections}gr.prototype=new gc;gr.constructor=gr;gr.prototype.prepareCollections=function(){var n=this;n.collections.create=n.create.bind(n),n.collections.on=n.on.bind(n),n.collections.off=n.off.bind(n),n.collections.destroy=n.destroy.bind(n),n.collections.get=function(t){var e;return n.collections.every(function(r){return e=r.get(t),!e}),e}};gr.prototype.create=function(n){return this.createCollection(n)};gr.prototype.bindWindowEvents=function(){var n=this;n._windowBound||typeof window>"u"||(n._windowBound=!0,fc(window,"resize",n._onResize),fc(window,"scroll",n._onScroll))};gr.prototype.unbindWindowEvents=function(){var n=this;!n._windowBound||typeof window>"u"||(n._windowBound=!1,mc(window,"resize",n._onResize),mc(window,"scroll",n._onScroll))};gr.prototype.createCollection=function(n){var t=this,e=new Z2(t,n);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};gr.prototype.bindCollection=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};gr.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};gr.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};gr.prototype.getIdentifier=function(n){var t;return n?(t=n.identifier===void 0?n.pointerId:n.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]};gr.prototype.removeIdentifier=function(n){var t={};for(var e in this.ids)if(this.ids[e]===n){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};gr.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};gr.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};gr.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};gr.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=Zm(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[i](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),Gu(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return Gu(t,a),!1};gr.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.unbindWindowEvents(),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.collections=[],n.off()};gr.prototype.onDestroyed=function(n,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var J2=gr;var vc=null;function $2(){return vc||(vc=new J2),vc}var MU={create:function(n){return $2().create(n)},destroy:function(){vc&&(vc.destroy(),vc=null)},get factory(){return $2()}},eO=MU;import{Box3 as qU,Euler as wc,EventDispatcher as XU,Line3 as gO,MathUtils as Oa,Matrix4 as eo,Quaternion as Qr,Vector2 as YU,Vector3 as ke}from"three";import{Camera as _U,OrthographicCamera as FU,PerspectiveCamera as kU,Vector3 as gn,Object3D as rO,Quaternion as VU,Matrix4 as Ls}from"three";import{Camera as DU,LineSegments as RU,BufferGeometry as BU,LineBasicMaterial as NU,Color as j0,Vector3 as LU,Float32BufferAttribute as tO}from"three";var ry=new LU,Zi=new DU,H0=class extends RU{constructor(e){let r=new BU,i=new NU({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new j0(15711266),c=new j0(15711266),d=new j0(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new tO(o,3)),r.setAttribute("color",new tO(a,3));super(r,i);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,i=!0;Zi.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=i?.8:1e-4;yn("n1",r,e,Zi,-o,-a,s),yn("n2",r,e,Zi,o,-a,s),yn("n3",r,e,Zi,-o,a,s),yn("n4",r,e,Zi,o,a,s);let l=s;yn("f1",r,e,Zi,-o,-a,l),yn("f2",r,e,Zi,o,-a,l),yn("f3",r,e,Zi,-o,a,l),yn("f4",r,e,Zi,o,a,l);let c=l,d=.5;yn("u1",r,e,Zi,o*.7*d,a*1.1,c),yn("u2",r,e,Zi,-o*.7*d,a*1.1,c),yn("u3",r,e,Zi,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yn(n,t,e,r,i,o,a){ry.set(i,o,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],ry.x,ry.y,ry.z)}}var iy=class extends Un(H0){constructor(e){super(e);this.object=e;this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){zn(this.object,this.geometry,e,r,!0)}};var ny=790;function iO(n){return 1-Math.pow(1-n,3)}var bc=new gn,W0=new gn,q0=new VU,X0=new gn,ju=new gn,Y0=new gn,Jn=class extends Yi(_U,iy){constructor(e="",r={...fs.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=an.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=Jn.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new Ls,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,o=this.height;this.orthoCamera=new FU(i*-.5,i*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new kU(45,i/o,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let r=Jn.projectionTransitionsEnabled;Jn.projectionTransitionsEnabled=!1;try{return e()}finally{Jn.projectionTransitionsEnabled=r}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,i){typeof e=="number"&&(e=new gn(e,r,i)),super.lookAt(e),this.getWorldPosition(bc),this.targetOffset=bc.distanceTo(e)}getTarget(e=new gn){return this.getWorldDirection(W0),this.getWorldPosition(bc),W0.multiplyScalar(this.targetOffset),e.copy(bc).add(W0),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(bc),bc.distanceTo(e)}updateUp(){this.getWorldQuaternion(q0),X0.set(0,0,1).applyQuaternion(q0),ju.copy(rO.DEFAULT_UP),this.isUpVectorFlipped&&ju.negate(),ju.applyQuaternion(q0),Y0.copy(rO.DEFAULT_UP).projectOnPlane(X0),this.angleOffsetFromUp=Y0.angleTo(ju),this.angleOffsetFromUp*=Y0.cross(ju).dot(X0)>=0?1:-1}updateTransformState(e,r){let i=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let r=e.getWorldPosition(new gn),o=e.getWorldDirection(new gn).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new gn).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new gn;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,i=!1){if(this.aspect=e/r,i){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-ny*.5*o,this.right=ny*.5*o,this.top=ny*.5*(1/a),this.bottom=-ny*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let e=this._projectionTransition;if(e===void 0)return 1;let r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:iO(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Jn.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Jn.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new Ls,blend:new Ls,blendInverse:new Ls,start:0,duration:Jn.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=Jn.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let i=iO(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=i*c/(i*c+(1-i)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let i=this._projectionTransition;i===void 0?(i={from:new Ls,blend:new Ls,blendInverse:new Ls,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(r.from),i.start=r.start,i.duration=r.duration,i.referenceDepth=r.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,i,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,a,s):this.orthoCamera.setViewOffset(e,r,i,o,a,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=an.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Kd(r,e)}updateCameraSubtype(e,r){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(i,r.zoom),r.near!==void 0&&this.setNear(i,r.near),r.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(r?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(i=>typeof i=="number"?i:0)),e.targetOffset!==void 0&&(this.targetOffset=an.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},mt=Jn;mt.projectionTransitionsEnabled=!1,mt.projectionTransitionDuration=350,mt.projectionTransitionMinAgeMs=1e3;var GU=null;function nO(n){GU=n}var UU,oO=new Promise(n=>{UU=n});import{Box3 as Che,Euler as aO,Matrix4 as sO,Quaternion as K0,Sphere as HU,Vector3 as Hu}from"three";import{BufferGeometry as zU,Float32BufferAttribute as Q0}from"three";function jU(n){let t=n.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,i=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||i<l||o<l||a<l||s<l}function oy(n,t){let e=new zU;if(t&&jU(t))return e.setAttribute("position",new Q0([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new Q0([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Au(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Q0(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}import{mergeGeometries as Mhe}from"three/examples/jsm/utils/BufferGeometryUtils.js";var WU;oO.then(n=>WU=n);var Ihe=new Hu,Dhe=new K0,Rhe=new Hu,Bhe=new aO(0,0,0,"YXZ"),Nhe=new aO(0,0,0,"XYZ"),Lhe=new Hu,_he=new Hu,Fhe=new Hu(1,1,1),khe=new K0,Vhe=new sO,Ghe=new sO;var Uhe=new K0,zhe=new HU;var Z0={type:"beginEvent",eventName:"Collision"};var J0=n=>n.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);import{Mesh as QU}from"three";ut();var lO=4,$0=8;var eS=.02,tS=.3,KU=65,cO=new ke,dO=new ke,ZU=new ke,Yr=new ke,Uo=new ke,xc=new ke,rS=new eo,uO=new eo,JU=new eo,Pi=new Qr,_s=new Qr,Sc=new wc(0,0,0,"YXZ"),$U=new ke(1,0,0),$n=new ke(0,1,0),ez=new ke(0,0,1),pO=new ke(1,1,1),iS=[],hO=n=>iS[n]??(iS[n]=new ke),nS=new ke,tz=new ke,rz=new ke,iz=new ke,fO=new Qr,nz=new ke,mO=new Qr,oz=1,az=.025,sz=16e-6,yO=12,lz=20,Or=new gO,Ji=new qU,cz={type:"requestRender"},dz={type:"updateMatrix"},ay=class extends XU{constructor(e,r,i,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new eo;this.target0=new ke;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=F2;this.euler0=new wc(0,0,0,"YXZ");this.position0Cam=new ke;this.quat0Cam=new Qr;this.scale0Cam=new ke;this.hiddenMatrix0Cam=new eo;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new gO(new ke(0,-40,0),new ke(0,40,0)),matrix:new eo,position:new ke,rotation:new Qr};this.euler=new wc(0,0,0,"YXZ");this.eulerDelta=new ke;this.lastPosition=new ke;this.lastCameraQuaternion=new Qr;this.lastCameraPosition=new ke;this.PI_2=Math.PI/2;this.prevMouse=new YU;this.velocityTarget=new ke;this.velocity=new ke;this.directionXZ=new ke;this.rotVelocityStick=new ke;this.rotVelocityTarget=new ke;this.rotVelocity=new ke;this.rotDirection=new ke;this.nonColliderRotOffset=new eo;this.nonColliderPosOffset=new eo;this.firstPointerId=-1;this.rot=new ke;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.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 eo;this.objectToTarget=new ke;this.objectToTarget0=new ke;this.objectToCamXZ=new ke;this.objectToCamXZ0=new ke;this.targetToCamera=new ke;this.targetToCamera0=new ke;this.cameraPolarAxis0=new ke;this.targetPos=new ke;this.targetQuat=new Qr;this.lerpFactorPos=new ke().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Qr;this.objXZQuatInv=new Qr;this.objXZRotMat=new eo;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new ke;this.pushedVelocity=new ke;this.groundYRotation=0;this.objectRealQuat=new Qr;this.colliderWorldQuat=new Qr;this.groundNormal=new ke;this.groundTilt=new Qr;this.groundTiltInv=new Qr;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new ke;this.quaternion=new Qr;this.scale=new ke;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(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"&&!fi&&!Tb&&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,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Tb&&$C<15.5&&!fi?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*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=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?ay.isLocked=!0:ay.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 i=2;i<4;i++){let o=e.axes[i];r===0?i===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.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 u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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 ke(0,0,-1).applyQuaternion(this.camera.quaternion),g=new ke().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,v=g.projectOnVector(y)):g.y/y.y>0?v=y.multiplyScalar(g.y/y.y):v=y.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate();let b=this.camera.position.clone().add(v);this.objectToTarget0.subVectors(b,this.position);let S=new wc().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof mt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*oz,this.speedOrbit=(i.speedRotate??100)*az,this.mouseOrbitSensitivity=(i.speedRotate??100)*sz,this.keyAssignments=i.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??fa.defaultData.gravity)*yO,this.usePhysics=this.gloabalPhysics.usePhysics??fa.defaultData.usePhysics,this.jumpPower=i.jumpPower*lz,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??wl.defaultDataThirdPerson.orientWith,this.slopeThresh=KU*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*eS/this.pixelsPerMeter,this.stepThresh=i.collider.height*tS/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*eS/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*tS/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*eS/this.pixelsPerMeter,this.stepThresh=i.collider.height*tS/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let h=new ke().fromArray(i.collider.position.map(y=>typeof y=="number"?y:0)),f=new Qr().setFromEuler(new wc().fromArray([...i.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,pO),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let m=i.navmesh.destinationHelperRadius*2;if(m>0){let y=new fe;y.push({fi:0,data:{...kt.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...kt.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=pm({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new QU(Uf.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new wc().setFromQuaternion(this.quaternion,"YXZ"),i=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,i,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 mt?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={},Sl.list.forEach(i=>{this.actions[i]=Pt({...e,disabled:!1,type:"GameControl"},e.gameActions[i],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"),er(this.actions.idle),er(this.actions.move),er(this.actions.run),er(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].TimelineAnimation.forEach(r=>{r.play()}),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].TimelineAnimation.forEach(r=>{r.stop()}),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 Yr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Uo.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*yO),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,$0,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(Yr).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}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*i),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 s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Yr.subVectors(this.path[1],this.position),c=Uo.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.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)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):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.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=ZU.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Uo.copy(a);s.y=0,a.set(0,a.y,s.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 s=Yr;this.camera.getWorldDirection(s);let l=xc.copy($n).multiplyScalar(s.dot($n));s.sub(l);let c=Uo.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).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(Sc.setFromVector3(this.rot),this.moveMode==="walk"&&(Sc.x=0),a.applyEuler(Sc),o&&(_s.setFromUnitVectors($n,this.groundNormal),a.applyQuaternion(_s)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(nS,fO,tz);let c=this.object.getWorldPosition(rz).add(this.collider.position).sub(nS);mO.copy(l.prevQ).invert().premultiply(fO);let d=xc.subVectors(nS,l.prevT).add(iz.copy(c).applyQuaternion(mO).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Yr.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=Ve.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof cr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(Z0));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),hO(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=hO(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle($n,this.euler.y-this.euler0.y);let s=Uo.copy(this.objectToCamXZ).normalize(),l=xc.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(Yr.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Oa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Oa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Oa.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Sc.copy(this.euler),Sc.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Sc)),Pi.setFromAxisAngle($U,this.rot.x),_s.setFromAxisAngle($n,this.rot.y),_s.multiply(Pi),Pi.setFromAxisAngle(ez,this.rot.z),_s.multiply(Pi),this.quaternion.copy(_s),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Uo.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new ke;for(let p=0;p<5;p++){let h=s.length(),f=xc.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,$0|lO,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let b=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(b){for(let S of b)if(S.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,w;if(m.cloner){for(let A of m.cloner.children)if(A.rigidBody===x){w=A;break}}S.dispatch(w),m.dispatchEvent(Z0)}}}let y=cO.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=dO.copy(f).multiplyScalar(l.time_of_impact).dot(y),v=l.time_of_impact;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(v=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,v)),s.copy(f).multiplyScalar(h-v),Math.acos(-y.y)>this.slopeThresh){let b=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=xc.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let x=b.add(S);x.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,$0|lO,void 0,void 0,this.object.rigidBody);w!==null&&w.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),Yr.copy(this.position).divideScalar(this.pixelsPerMeter),Pi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&nz.copy(Yr).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(Yr,!0),d.setRotation(Pi,!0)):(d.setNextKinematicTranslation(Yr),d.setNextKinematicRotation(Pi)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);rS.lookAt(l,s,$n).setPosition(l),rS.decompose(this.targetPos,this.targetQuat,Yr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Oa.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Oa.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(dz),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(cz),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Pi.setFromAxisAngle($n,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Oa.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=Oa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Oa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Yr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let o=_s.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){$n.angleTo(e)*180/Math.PI<15||$n.angleTo(e)*180/Math.PI>85?Pi.identity():Pi.setFromUnitVectors($n,e),this.groundTilt.slerp(Pi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=dO.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=rS.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Yr,Pi,Uo).compose(Yr,Pi,pO);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Ji.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=uO.copy(s).invert(),c=JU.copy(uO).multiply(i);Or.copy(this.collider.segment),Or.start.applyMatrix4(c),Or.end.applyMatrix4(c);let d=cO.copy(this.position).applyMatrix4(l);Ji.expandByPoint(Or.start),Ji.expandByPoint(Or.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(Or.end)},intersectsBounds:u=>u.intersectsBox(Ji),intersectsTriangle:u=>{let p=Yr,h=Uo,f=u.closestPointToSegment(Or,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=xc.copy(d);g.addScaledVector(y,m);let v=g.applyMatrix4(s).sub(this.position);r.add(v),Or.start.addScaledVector(y,m),Or.end.addScaledVector(y,m)}}})}),Ji.makeEmpty(),Or.copy(this.collider.segment),Or.start.applyMatrix4(i),Or.end.applyMatrix4(i),Ji.expandByPoint(Or.start),Ji.expandByPoint(Or.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(Or.end)},intersectsBounds:a=>a.intersectsBox(Ji),intersectsTriangle:a=>{let s=Yr,l=Uo,c=a.closestPointToSegment(Or,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),Or.start.addScaledVector(u,d),Or.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},Wu=ay;Wu.isLocked=!1;import{BufferAttribute as xO,BufferGeometry as pz,Vector3 as qu}from"three";import{mergeGeometries as hz}from"three/examples/jsm/utils/BufferGeometryUtils.js";var uz,vO=new Promise(n=>{uz=n});var bO;var fz=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.11/build/",mz=n=>`
1328
+ `)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,i,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*i,l=t-s,c=-this.ascender*i-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,i,o){let a=t.getPath(r,-i,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new qm,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=EU(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,i){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(i.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function EU(n){if(n.length){let t=n[0];if(t instanceof wU)return t.v1;if(t instanceof SU||t instanceof AU)return t.v0}}Ui("TextGeometry",(n,t,e)=>new Ca(n,t,e));var _2={create:(n,t)=>new ec(n,t)};$d("TextGeometry",_2);$d("InputGeometry",_2);vP(Ym);Oe("text");var F2=200,PU=null;function k2(n){PU=n}var Vu=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)},V2=(n,t)=>{let e=t.x-n.x,r=t.y-n.y;return TU(Math.atan2(r,e))},G2=(n,t,e)=>{let r={x:0,y:0};return e=Km(e),r.x=n.x-t*Math.cos(e),r.y=n.y-t*Math.sin(e),r},Km=n=>n*(Math.PI/180),TU=n=>n*(180/Math.PI),U2=n=>isNaN(n.buttons)?n.pressure!==0:n.buttons!==0,Qm=new Map,z2=n=>{Qm.has(n)&&clearTimeout(Qm.get(n)),Qm.set(n,setTimeout(function(){Qm.delete(n),n()},100))},fc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.addEventListener?n.addEventListener(i,e,!1):n.attachEvent&&n.attachEvent(i,e)},mc=(n,t,e)=>{let r=t.split(/[ ,]+/g),i;for(let o=0;o<r.length;o+=1)i=r[o],n.removeEventListener?n.removeEventListener(i,e):n.detachEvent&&n.detachEvent(i,e)};var Zm=n=>(n.preventDefault(),n.type.match(/^touch/)?n.changedTouches:n),z0=()=>{if(typeof window>"u")return;let n=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:n,y:t}},Jm=(n,t)=>{t.top||t.right||t.bottom||t.left?(n.style.top=t.top,n.style.right=t.right,n.style.bottom=t.bottom,n.style.left=t.left):(n.style.left=t.x+"px",n.style.top=t.y+"px")},$m=(n,t,e)=>{let r=H2(n);for(let i in r)if(Object.prototype.hasOwnProperty.call(r,i))if(typeof t=="string")r[i]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[i]=o.slice(0,-2)}return r},j2=(n,t)=>{let e=H2(n);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},H2=n=>{let t={};return t[n]="",["webkit","Moz","o"].forEach(function(r){t[r+n.charAt(0).toUpperCase()+n.slice(1)]=""}),t},ey=(n,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n},W2=(n,t)=>{let e={};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},Gu=(n,t)=>{if(n.length)for(let e=0,r=n.length;e<r;e+=1)t(n[e]);else t(n)},q2=(n,t,e)=>({x:Math.min(Math.max(n.x,t.x-e),t.x+e),y:Math.min(Math.max(n.y,t.y-e),t.y+e)});typeof window<"u"&&(X2="ontouchstart"in window,Y2=!!window.PointerEvent,Q2=!!window.MSPointerEvent);var X2,Y2,Q2,Uu={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},yc,zu={};Y2?yc=Uu.pointer:Q2?yc=Uu.MSPointer:X2?(yc=Uu.touch,zu=Uu.mouse):yc=Uu.mouse;function Ns(){}Ns.prototype.on=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]=e._handlers_[i]||[],e._handlers_[i].push(t);return e};Ns.prototype.off=function(n,t){var e=this;return e._handlers_=e._handlers_||{},n===void 0?e._handlers_={}:t===void 0?e._handlers_[n]=null:e._handlers_[n]&&e._handlers_[n].indexOf(t)>=0&&e._handlers_[n].splice(e._handlers_[n].indexOf(t),1),e};Ns.prototype.trigger=function(n,t){var e=this,r=n.split(/[ ,]+/g),i;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)i=r[o],e._handlers_[i]&&e._handlers_[i].length&&e._handlers_[i].forEach(function(a){a.call(e,{type:i,target:e},t)})};Ns.prototype.config=function(n){var t=this;t.options=t.defaults||{},n&&(t.options=W2(t.options,n))};Ns.prototype.bindEvt=function(n,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.')},fc(n,yc[t],e._domHandlers_[t]),zu[t]&&fc(n,zu[t],e._domHandlers_[t]),e};Ns.prototype.unbindEvt=function(n,t){var e=this;return e._domHandlers_=e._domHandlers_||{},mc(n,yc[t],e._domHandlers_[t]),zu[t]&&mc(n,zu[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var gc=Ns;function wr(n,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=n,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=wr.id,wr.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}wr.prototype=new gc;wr.constructor=wr;wr.id=0;wr.prototype.buildEl=function(n){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)};wr.prototype.stylize=function(){if(this.options.dataOnly)return this;var n=this.options.fadeTime+"ms",t=j2("borderRadius","50%"),e=$m("transition","opacity",n),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)"},ey(r.el,e),this.options.shape==="circle"&&ey(r.back,t),ey(r.front,t),this.applyStyles(r),this};wr.prototype.applyStyles=function(n){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in n[t])this.ui[t].style[e]=n[t][e];return this};wr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};wr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};wr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};wr.prototype.show=function(n){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 n=="function"&&n.call(this)},t.options.fadeTime)),t};wr.prototype.hide=function(n){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 n=="function"&&n.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(n,r)}return t};wr.prototype.setPosition=function(n,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",i={};i.front=$m("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(i),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof n=="function"&&n.call(e),e.restCallback()},e.options.fadeTime)};wr.prototype.restCallback=function(){var n=this,t={};t.front=$m("transition","none",""),n.applyStyles(t),n.trigger("rested",n.instance)};wr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};wr.prototype.computeDirection=function(n){var t=n.angle.radian,e=Math.PI/4,r=Math.PI/2,i,o,a;if(t>e&&t<e*3&&!n.lockX?i="up":t>-e&&t<=e&&!n.lockY?i="left":t>-e*3&&t<=-e&&!n.lockX?i="down":n.lockY||(i="right"),n.lockY||(t>-r&&t<r?o="left":o="right"),n.lockX||(t>0?a="up":a="down"),n.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:i},n.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return n;(!c.x||!c.y)&&this.trigger("plain",n),c.x||this.trigger("plain:"+o,n),c.y||this.trigger("plain:"+a,n),c.angle||this.trigger("dir dir:"+i,n)}else this.resetDirection();return n};var K2=wr;function pr(n,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=n,e.id=pr.id,pr.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}pr.prototype=new gc;pr.constructor=pr;pr.id=0;pr.prototype.prepareNipples=function(){var n=this,t=n.nipples;t.on=n.on.bind(n),t.off=n.off.bind(n),t.options=n.options,t.destroy=n.destroy.bind(n),t.ids=n.ids,t.id=n.id,t.processOnMove=n.processOnMove.bind(n),t.processOnEnd=n.processOnEnd.bind(n),t.get=function(e){if(e===void 0)return t[0];for(var r=0,i=t.length;r<i;r+=1)if(t[r].identifier===e)return t[r];return!1}};pr.prototype.bindings=function(){var n=this;n.bindEvt(n.options.zone,"start"),n.options.zone.style.touchAction="none",n.options.zone.style.msTouchAction="none"};pr.prototype.begin=function(){var n=this,t=n.options;if(t.mode==="static"){var e=n.createNipple(t.position,n.manager.getIdentifier());e.add(),n.idles.push(e)}};pr.prototype.createNipple=function(n,t){var e=this,r=e.manager.scroll,i={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(n.x&&n.y)i={x:n.x-a.x,y:n.y-a.y};else if(n.top||n.right||n.bottom||n.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=n.top,s.style.right=n.right,s.style.bottom=n.bottom,s.style.left=n.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),i=n,n={x:l.left+r.x,y:l.top+r.y}}var c=new K2(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:n,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(Jm(c.ui.el,i),Jm(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};pr.prototype.updateBox=function(){var n=this;n.box=n.options.zone.getBoundingClientRect()};pr.prototype.bindNipple=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};pr.prototype.pressureFn=function(n,t,e){var r=this,i=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=n.force||n.pressure||n.webkitForce||0;o!==i&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),i=o)}.bind(r),100)};pr.prototype.onstart=function(n){var t=this,e=t.options,r=n;n=Zm(n),t.updateBox();var i=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[n[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return Gu(n,i),t.manager.bindDocument(),!1};pr.prototype.processOnStart=function(n){var t=this,e=t.options,r,i=t.manager.getIdentifier(n),o=n.force||n.pressure||n.webkitForce||0,a={x:n.pageX,y:n.pageY},s=t.getOrCreate(i,a);s.identifier!==i&&t.manager.removeIdentifier(s.identifier),s.identifier=i;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(n,d,d.identifier),t.processOnMove(n)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=Vu(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(n);return}}return s};pr.prototype.getOrCreate=function(n,t){var e=this,r=e.options,i;return/(semi|static)/.test(r.mode)?(i=e.idles[0],i?(e.idles.splice(0,1),i):r.mode==="semi"?e.createNipple(t,n):(console.warn("Coudln't find the needed nipple."),!1)):(i=e.createNipple(t,n),i)};pr.prototype.processOnMove=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.scroll;if(!U2(n)){this.processOnEnd(n);return}if(!i){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=i.el.getBoundingClientRect();i.position={x:o.x+a.left,y:o.y+a.top}}i.identifier=r;var s=i.options.size/2,l={x:n.pageX,y:n.pageY};e.lockX&&(l.y=i.position.y),e.lockY&&(l.x=i.position.x);var c=Vu(l,i.position),d=V2(l,i.position),u=Km(d),p=c/s,h={distance:c,position:l},f,m;if(i.options.shape==="circle"?(f=Math.min(c,s),m=G2(i.position,f,d)):(m=q2(l,i.position,s),f=Vu(m,i.position)),e.follow){if(c>s){let b=l.x-m.x,S=l.y-m.y;i.position.x+=b,i.position.y+=S,i.el.style.top=i.position.y-(t.box.top+o.y)+"px",i.el.style.left=i.position.x-(t.box.left+o.x)+"px",c=Vu(l,i.position)}}else l=m,c=f;var y=l.x-i.position.x,g=l.y-i.position.y;i.frontPosition={x:y,y:g},e.dataOnly||Jm(i.ui.front,i.frontPosition);var v={identifier:i.identifier,position:l,force:p,pressure:n.force||n.pressure||n.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:i,lockX:e.lockX,lockY:e.lockY};v=i.computeDirection(v),v.angle={radian:Km(180-d),degree:180-d},i.trigger("move",v),t.trigger("move "+i.id+":move",v)};pr.prototype.processOnEnd=function(n){var t=this,e=t.options,r=t.manager.getIdentifier(n),i=t.nipples.get(r),o=t.manager.removeIdentifier(i.identifier);!i||(e.dataOnly||i.hide(function(){e.mode==="dynamic"&&(i.trigger("removed",i),t.trigger("removed "+i.id+":removed",i),t.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(t.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),t.trigger("end "+i.id+":end",i),t.ids.indexOf(i.identifier)>=0&&t.ids.splice(t.ids.indexOf(i.identifier),1),t.actives.indexOf(i)>=0&&t.actives.splice(t.actives.indexOf(i),1),/(semi|static)/.test(e.mode)?t.idles.push(i):t.nipples.indexOf(i)>=0&&t.nipples.splice(t.nipples.indexOf(i),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};pr.prototype.onDestroyed=function(n,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()};pr.prototype.destroy=function(){var n=this;n.unbindEvt(n.options.zone,"start"),n.nipples.forEach(function(e){e.destroy()});for(var t in n.pressureIntervals)Object.prototype.hasOwnProperty.call(n.pressureIntervals,t)&&clearInterval(n.pressureIntervals[t]);n.trigger("destroyed",n.nipples),n.manager.unbindDocument(),n.off(),n.pressureIntervals={},n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.manager=null};var Z2=pr;function gr(n){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=z0(),t._windowBound=!1,t.config(n),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(i){i.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){z2(e)},t._onScroll=function(){t.scroll=z0()},t.collections}gr.prototype=new gc;gr.constructor=gr;gr.prototype.prepareCollections=function(){var n=this;n.collections.create=n.create.bind(n),n.collections.on=n.on.bind(n),n.collections.off=n.off.bind(n),n.collections.destroy=n.destroy.bind(n),n.collections.get=function(t){var e;return n.collections.every(function(r){return e=r.get(t),!e}),e}};gr.prototype.create=function(n){return this.createCollection(n)};gr.prototype.bindWindowEvents=function(){var n=this;n._windowBound||typeof window>"u"||(n._windowBound=!0,fc(window,"resize",n._onResize),fc(window,"scroll",n._onScroll))};gr.prototype.unbindWindowEvents=function(){var n=this;!n._windowBound||typeof window>"u"||(n._windowBound=!1,mc(window,"resize",n._onResize),mc(window,"scroll",n._onScroll))};gr.prototype.createCollection=function(n){var t=this,e=new Z2(t,n);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};gr.prototype.bindCollection=function(n){var t=this,e,r=function(i,o){e=i.type+" "+o.id+":"+i.type,t.trigger(e,o)};n.on("destroyed",t.onDestroyed.bind(t)),n.on("shown hidden rested dir plain",r),n.on("dir:up dir:right dir:down dir:left",r),n.on("plain:up plain:right plain:down plain:left",r)};gr.prototype.bindDocument=function(){var n=this;n.binded||(n.bindEvt(document,"move").bindEvt(document,"end"),n.binded=!0)};gr.prototype.unbindDocument=function(n){var t=this;(!Object.keys(t.ids).length||n===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};gr.prototype.getIdentifier=function(n){var t;return n?(t=n.identifier===void 0?n.pointerId:n.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]};gr.prototype.removeIdentifier=function(n){var t={};for(var e in this.ids)if(this.ids[e]===n){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};gr.prototype.onmove=function(n){var t=this;return t.onAny("move",n),!1};gr.prototype.onend=function(n){var t=this;return t.onAny("end",n),!1};gr.prototype.oncancel=function(n){var t=this;return t.onAny("end",n),!1};gr.prototype.onAny=function(n,t){var e=this,r,i="processOn"+n.charAt(0).toUpperCase()+n.slice(1);t=Zm(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[i](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),Gu(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return Gu(t,a),!1};gr.prototype.destroy=function(){var n=this;n.unbindDocument(!0),n.unbindWindowEvents(),n.ids={},n.index=0,n.collections.forEach(function(t){t.destroy()}),n.collections=[],n.off()};gr.prototype.onDestroyed=function(n,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var J2=gr;var vc=null;function $2(){return vc||(vc=new J2),vc}var MU={create:function(n){return $2().create(n)},destroy:function(){vc&&(vc.destroy(),vc=null)},get factory(){return $2()}},eO=MU;import{Box3 as qU,Euler as wc,EventDispatcher as XU,Line3 as gO,MathUtils as Oa,Matrix4 as eo,Quaternion as Qr,Vector2 as YU,Vector3 as ke}from"three";import{Camera as _U,OrthographicCamera as FU,PerspectiveCamera as kU,Vector3 as gn,Object3D as rO,Quaternion as VU,Matrix4 as Ls}from"three";import{Camera as DU,LineSegments as RU,BufferGeometry as BU,LineBasicMaterial as NU,Color as j0,Vector3 as LU,Float32BufferAttribute as tO}from"three";var ry=new LU,Zi=new DU,H0=class extends RU{constructor(e){let r=new BU,i=new NU({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new j0(15711266),c=new j0(15711266),d=new j0(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new tO(o,3)),r.setAttribute("color",new tO(a,3));super(r,i);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,i=!0;Zi.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=i?.8:1e-4;yn("n1",r,e,Zi,-o,-a,s),yn("n2",r,e,Zi,o,-a,s),yn("n3",r,e,Zi,-o,a,s),yn("n4",r,e,Zi,o,a,s);let l=s;yn("f1",r,e,Zi,-o,-a,l),yn("f2",r,e,Zi,o,-a,l),yn("f3",r,e,Zi,-o,a,l),yn("f4",r,e,Zi,o,a,l);let c=l,d=.5;yn("u1",r,e,Zi,o*.7*d,a*1.1,c),yn("u2",r,e,Zi,-o*.7*d,a*1.1,c),yn("u3",r,e,Zi,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yn(n,t,e,r,i,o,a){ry.set(i,o,a).unproject(r);let s=t[n];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],ry.x,ry.y,ry.z)}}var iy=class extends Un(H0){constructor(e){super(e);this.object=e;this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){zn(this.object,this.geometry,e,r,!0)}};var ny=790;function iO(n){return 1-Math.pow(1-n,3)}var bc=new gn,W0=new gn,q0=new VU,X0=new gn,ju=new gn,Y0=new gn,Jn=class extends Yi(_U,iy){constructor(e="",r={...fs.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=an.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=Jn.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new Ls,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let i=this.width,o=this.height;this.orthoCamera=new FU(i*-.5,i*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new kU(45,i/o,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let r=Jn.projectionTransitionsEnabled;Jn.projectionTransitionsEnabled=!1;try{return e()}finally{Jn.projectionTransitionsEnabled=r}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,i){typeof e=="number"&&(e=new gn(e,r,i)),super.lookAt(e),this.getWorldPosition(bc),this.targetOffset=bc.distanceTo(e)}getTarget(e=new gn){return this.getWorldDirection(W0),this.getWorldPosition(bc),W0.multiplyScalar(this.targetOffset),e.copy(bc).add(W0),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(bc),bc.distanceTo(e)}updateUp(){this.getWorldQuaternion(q0),X0.set(0,0,1).applyQuaternion(q0),ju.copy(rO.DEFAULT_UP),this.isUpVectorFlipped&&ju.negate(),ju.applyQuaternion(q0),Y0.copy(rO.DEFAULT_UP).projectOnPlane(X0),this.angleOffsetFromUp=Y0.angleTo(ju),this.angleOffsetFromUp*=Y0.cross(ju).dot(X0)>=0?1:-1}updateTransformState(e,r){let i=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),i}getViewFrontToObject(e){let r=e.getWorldPosition(new gn),o=e.getWorldDirection(new gn).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let i=this.getWorldDirection(new gn).multiplyScalar(this.targetOffset);return{position:e.clone().sub(i),target:e}}getViewToObject(e){let r=new gn;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,i=!1){if(this.aspect=e/r,i){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-ny*.5*o,this.right=ny*.5*o,this.top=ny*.5*(1/a),this.bottom=-ny*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let e=this._projectionTransition;if(e===void 0)return 1;let r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:iO(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return Jn.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=Jn.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new Ls,blend:new Ls,blendInverse:new Ls,start:0,duration:Jn.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=Jn.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let i=iO(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=i*c/(i*c+(1-i)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let i=this._projectionTransition;i===void 0?(i={from:new Ls,blend:new Ls,blendInverse:new Ls,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=i):i.raf!==0&&(cancelAnimationFrame(i.raf),i.raf=0),i.requestRender=void 0,i.from.copy(r.from),i.start=r.start,i.duration=r.duration,i.referenceDepth=r.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,i,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,a,s):this.orthoCamera.setViewOffset(e,r,i,o,a,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=an.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Kd(r,e)}updateCameraSubtype(e,r){let i=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(i,r.zoom),r.near!==void 0&&this.setNear(i,r.near),r.fov!==void 0&&i==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(r?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(i=>typeof i=="number"?i:0)),e.targetOffset!==void 0&&(this.targetOffset=an.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,i){super.updateByPatchedOp(e,r,i),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},mt=Jn;mt.projectionTransitionsEnabled=!1,mt.projectionTransitionDuration=350,mt.projectionTransitionMinAgeMs=1e3;var GU=null;function nO(n){GU=n}var UU,oO=new Promise(n=>{UU=n});import{Box3 as Che,Euler as aO,Matrix4 as sO,Quaternion as K0,Sphere as HU,Vector3 as Hu}from"three";import{BufferGeometry as zU,Float32BufferAttribute as Q0}from"three";function jU(n){let t=n.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,i=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||i<l||o<l||a<l||s<l}function oy(n,t){let e=new zU;if(t&&jU(t))return e.setAttribute("position",new Q0([],3)),e.setIndex([]),e;if(!n.getAttribute("position"))return e.setAttribute("position",new Q0([],3)),e.setIndex([]),e;let{positions:r,triIndices:i}=Au(n.getAttribute("position"),n.getIndex());return e.setAttribute("position",new Q0(r,3)),e.setIndex(i),t&&e.applyMatrix4(t),e}import{mergeGeometries as Mhe}from"three/examples/jsm/utils/BufferGeometryUtils.js";var WU;oO.then(n=>WU=n);var Ihe=new Hu,Dhe=new K0,Rhe=new Hu,Bhe=new aO(0,0,0,"YXZ"),Nhe=new aO(0,0,0,"XYZ"),Lhe=new Hu,_he=new Hu,Fhe=new Hu(1,1,1),khe=new K0,Vhe=new sO,Ghe=new sO;var Uhe=new K0,zhe=new HU;var Z0={type:"beginEvent",eventName:"Collision"};var J0=n=>n.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);import{Mesh as QU}from"three";ut();var lO=4,$0=8;var eS=.02,tS=.3,KU=65,cO=new ke,dO=new ke,ZU=new ke,Yr=new ke,Uo=new ke,xc=new ke,rS=new eo,uO=new eo,JU=new eo,Pi=new Qr,_s=new Qr,Sc=new wc(0,0,0,"YXZ"),$U=new ke(1,0,0),$n=new ke(0,1,0),ez=new ke(0,0,1),pO=new ke(1,1,1),iS=[],hO=n=>iS[n]??(iS[n]=new ke),nS=new ke,tz=new ke,rz=new ke,iz=new ke,fO=new Qr,nz=new ke,mO=new Qr,oz=1,az=.025,sz=16e-6,yO=12,lz=20,Or=new gO,Ji=new qU,cz={type:"requestRender"},dz={type:"updateMatrix"},ay=class extends XU{constructor(e,r,i,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=i;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new eo;this.target0=new ke;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=F2;this.euler0=new wc(0,0,0,"YXZ");this.position0Cam=new ke;this.quat0Cam=new Qr;this.scale0Cam=new ke;this.hiddenMatrix0Cam=new eo;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new gO(new ke(0,-40,0),new ke(0,40,0)),matrix:new eo,position:new ke,rotation:new Qr};this.euler=new wc(0,0,0,"YXZ");this.eulerDelta=new ke;this.lastPosition=new ke;this.lastCameraQuaternion=new Qr;this.lastCameraPosition=new ke;this.PI_2=Math.PI/2;this.prevMouse=new YU;this.velocityTarget=new ke;this.velocity=new ke;this.directionXZ=new ke;this.rotVelocityStick=new ke;this.rotVelocityTarget=new ke;this.rotVelocity=new ke;this.rotDirection=new ke;this.nonColliderRotOffset=new eo;this.nonColliderPosOffset=new eo;this.firstPointerId=-1;this.rot=new ke;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.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 eo;this.objectToTarget=new ke;this.objectToTarget0=new ke;this.objectToCamXZ=new ke;this.objectToCamXZ0=new ke;this.targetToCamera=new ke;this.targetToCamera0=new ke;this.cameraPolarAxis0=new ke;this.targetPos=new ke;this.targetQuat=new Qr;this.lerpFactorPos=new ke().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new Qr;this.objXZQuatInv=new Qr;this.objXZRotMat=new eo;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new ke;this.pushedVelocity=new ke;this.groundYRotation=0;this.objectRealQuat=new Qr;this.colliderWorldQuat=new Qr;this.groundNormal=new ke;this.groundTilt=new Qr;this.groundTiltInv=new Qr;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new ke;this.quaternion=new Qr;this.scale=new ke;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(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"&&!fi&&!Tb&&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,i=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(Tb&&$C<15.5&&!fi?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*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=-i*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?ay.isLocked=!0:ay.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 i=2;i<4;i++){let o=e.axes[i];r===0?i===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,i===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.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 u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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 ke(0,0,-1).applyQuaternion(this.camera.quaternion),g=new ke().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,v=g.projectOnVector(y)):g.y/y.y>0?v=y.multiplyScalar(g.y/y.y):v=y.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate();let b=this.camera.position.clone().add(v);this.objectToTarget0.subVectors(b,this.position);let S=new wc().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof mt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*oz,this.speedOrbit=(i.speedRotate??100)*az,this.mouseOrbitSensitivity=(i.speedRotate??100)*sz,this.keyAssignments=i.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??fa.defaultData.gravity)*yO,this.usePhysics=this.gloabalPhysics.usePhysics??fa.defaultData.usePhysics,this.jumpPower=i.jumpPower*lz,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??wl.defaultDataThirdPerson.orientWith,this.slopeThresh=KU*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*eS/this.pixelsPerMeter,this.stepThresh=i.collider.height*tS/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*eS/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*tS/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*eS/this.pixelsPerMeter,this.stepThresh=i.collider.height*tS/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let h=new ke().fromArray(i.collider.position.map(y=>typeof y=="number"?y:0)),f=new Qr().setFromEuler(new wc().fromArray([...i.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,pO),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=i.runMultiplier??2;let m=i.navmesh.destinationHelperRadius*2;if(m>0){let y=new fe;y.push({fi:0,data:{...kt.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...kt.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=pm({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new QU(Uf.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new wc().setFromQuaternion(this.quaternion,"YXZ"),i=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,i,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 mt?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={},Sl.list.forEach(i=>{this.actions[i]=Pt({...e,disabled:!1,type:"GameControl"},e.gameActions[i],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"),er(this.actions.idle),er(this.actions.move),er(this.actions.run),er(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].TimelineAnimation.forEach(r=>{r.play()}),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].TimelineAnimation.forEach(r=>{r.stop()}),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 Yr.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Uo.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*yO),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,$0,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(Yr).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}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*i),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 s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Yr.subVectors(this.path[1],this.position),c=Uo.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.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)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):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.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=ZU.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Uo.copy(a);s.y=0,a.set(0,a.y,s.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 s=Yr;this.camera.getWorldDirection(s);let l=xc.copy($n).multiplyScalar(s.dot($n));s.sub(l);let c=Uo.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).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(Sc.setFromVector3(this.rot),this.moveMode==="walk"&&(Sc.x=0),a.applyEuler(Sc),o&&(_s.setFromUnitVectors($n,this.groundNormal),a.applyQuaternion(_s)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(nS,fO,tz);let c=this.object.getWorldPosition(rz).add(this.collider.position).sub(nS);mO.copy(l.prevQ).invert().premultiply(fO);let d=xc.subVectors(nS,l.prevT).add(iz.copy(c).applyQuaternion(mO).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Yr.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=Ve.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof cr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(Z0));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),hO(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=hO(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle($n,this.euler.y-this.euler0.y);let s=Uo.copy(this.objectToCamXZ).normalize(),l=xc.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(Yr.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Oa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Oa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Oa.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Sc.copy(this.euler),Sc.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Sc)),Pi.setFromAxisAngle($U,this.rot.x),_s.setFromAxisAngle($n,this.rot.y),_s.multiply(Pi),Pi.setFromAxisAngle(ez,this.rot.z),_s.multiply(Pi),this.quaternion.copy(_s),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Uo.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new ke;for(let p=0;p<5;p++){let h=s.length(),f=xc.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,$0|lO,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let b=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(b){for(let S of b)if(S.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,w;if(m.cloner){for(let A of m.cloner.children)if(A.rigidBody===x){w=A;break}}S.dispatch(w),m.dispatchEvent(Z0)}}}let y=cO.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=dO.copy(f).multiplyScalar(l.time_of_impact).dot(y),v=l.time_of_impact;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(v=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,v)),s.copy(f).multiplyScalar(h-v),Math.acos(-y.y)>this.slopeThresh){let b=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=xc.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let x=b.add(S);x.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,$0|lO,void 0,void 0,this.object.rigidBody);w!==null&&w.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),Yr.copy(this.position).divideScalar(this.pixelsPerMeter),Pi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&nz.copy(Yr).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(Yr,!0),d.setRotation(Pi,!0)):(d.setNextKinematicTranslation(Yr),d.setNextKinematicRotation(Pi)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);rS.lookAt(l,s,$n).setPosition(l),rS.decompose(this.targetPos,this.targetQuat,Yr),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Oa.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Oa.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(dz),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(cz),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=Pi.setFromAxisAngle($n,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Oa.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=Oa.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=Oa.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Yr.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let o=_s.setFromAxisAngle(i,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){$n.angleTo(e)*180/Math.PI<15||$n.angleTo(e)*180/Math.PI>85?Pi.identity():Pi.setFromUnitVectors($n,e),this.groundTilt.slerp(Pi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=dO.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=rS.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Yr,Pi,Uo).compose(Yr,Pi,pO);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;Ji.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=uO.copy(s).invert(),c=JU.copy(uO).multiply(i);Or.copy(this.collider.segment),Or.start.applyMatrix4(c),Or.end.applyMatrix4(c);let d=cO.copy(this.position).applyMatrix4(l);Ji.expandByPoint(Or.start),Ji.expandByPoint(Or.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(Or.end)},intersectsBounds:u=>u.intersectsBox(Ji),intersectsTriangle:u=>{let p=Yr,h=Uo,f=u.closestPointToSegment(Or,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=xc.copy(d);g.addScaledVector(y,m);let v=g.applyMatrix4(s).sub(this.position);r.add(v),Or.start.addScaledVector(y,m),Or.end.addScaledVector(y,m)}}})}),Ji.makeEmpty(),Or.copy(this.collider.segment),Or.start.applyMatrix4(i),Or.end.applyMatrix4(i),Ji.expandByPoint(Or.start),Ji.expandByPoint(Or.end),Ji.min.addScalar(-this.collider.radius),Ji.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(Or.end)},intersectsBounds:a=>a.intersectsBox(Ji),intersectsTriangle:a=>{let s=Yr,l=Uo,c=a.closestPointToSegment(Or,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),Or.start.addScaledVector(u,d),Or.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},Wu=ay;Wu.isLocked=!1;import{BufferAttribute as xO,BufferGeometry as pz,Vector3 as qu}from"three";import{mergeGeometries as hz}from"three/examples/jsm/utils/BufferGeometryUtils.js";var uz,vO=new Promise(n=>{uz=n});var bO;var fz=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.12/build/",mz=n=>`
1329
1329
  (async function() {
1330
1330
  const [wasmImport, wasmBinary] = await Promise.all([
1331
1331
  import('${n}' + 'navmesh.js'),
@@ -5238,4 +5238,4 @@ vec3 lab2rgb (in vec3 lab) {
5238
5238
 
5239
5239
  `;var dv=class extends $8{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],dt.startContext(dt.globalContext),this.lightLayer=new hi(0,"",{...kt.defaultData("light","phong"),visible:!1},new Ya,{},r.shared),dt.endContext(dt.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new od;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(fB),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(mB),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(CN),e.addFragmentParsCode(PN),e.addVertexFinalCode(EN({easeSize:this.easeSize})),e.addFragmentFinalCode(TN({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.nodeExtensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};import{GPUComputationRenderer as eq}from"three/examples/jsm/misc/GPUComputationRenderer.js";jE({createMaterial:(n,t)=>new dv(n,t),createComputation:(n,t,e)=>new eq(n,t,e)});import{Vector2 as MN}from"three";function ON(n,t,e,r){let i=e,o=i.type==="texture"?i.texture.image!=null?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.getImage(""):r.video(i.texture.video),a=new $o(o,i.texture.wrapping??(i.type==="texture"?1e3:1001),i.texture.minFilter??1008,i.texture.magFilter??1006),s=new zg(o),l=new jg($s(i.texture.repeat??[1,1],r),$s(i.texture.offset??[0,0],r),ye(i.texture.rotation??0,r)),c=new le(i.crop?1:0),d=new Ue(i.projection??0),u=new Ue(["x","y","z"].indexOf(i.axis)??0),p=i.projectionAxis?["x","y","z"].indexOf(i.projectionAxis):-1,h=new Ue(i.side??0),f=new Ft(i.size?new MN(...$s(i.size,r)):new MN(100,100)),m=new le(i.blending??0),y=new le(qi(i.alpha,r)),g=new Ue(i.mode??0),v=new Ct(i.isMask??!1),b=new ta(a,s,c,d,u,h,f,m,l,y,g,v,p),S=new Le(b.calpha,"f");return new We(n,t,i,{texture:a,textureSize:s,crop:c,projection:d,axis:u,side:h,size:f,blending:m,mat:l,alpha:y,mode:g,isMask:v},b,g,S,v,r)}ot("texture",ON);ot("video",ON);import{MathUtils as tq}from"three";ot("matcap",(n,t,e,r)=>{let i=e,o=i.texture.image!=null?r.image(i.texture.image):r.getImage(""),a=new $o(o,i.texture.wrapping??1001,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new le(qi(i.alpha,r)),l=new Ue(i.mode??0),c=new Ct(i.isMask??!1),d=new le((ye(i.texture.rotation??0,r)??0)*tq.DEG2RAD),u=new fd(a,s,l,c,d),p=new Le(u.calpha,"f");return new We(n,t,i,{texture:a,alpha:s,mode:l,isMask:c,rotation:d},u,l,p,c,r)});import{Vector3 as rq}from"three";ot("displace",(n,t,e,r)=>{let i=e;if(i.displacementType==="noise"){let o=new Kt(new rq(...i.offset.map(g=>ye(g,r)??0))),a=new le(ye(i.scale,r)??10),s=new le(ye(i.intensity,r)??8),l=new le(ye(i.movement,r)??1),c=new Ue(i.noiseType??0),d=new Ue(i.voronoiStyle??0),u=new le(ye(i.smoothness,r)??.5),p=new le(ye(i.seed,r)??0),h=new le(ye(i.highCut,r)??1),f=new le(ye(i.lowCut,r)??0),m=new Ue(ye(i.quality,r)??1),y=new wd(s,l,o,d,u,p,h,f,m,a,c);return new Ad(n,t,i,{offset:o,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:d,smoothness:u,seed:p,highCut:h,lowCut:f,quality:m},y,r)}else throw new Error});ot("cavity",(n,t,e,r)=>{let i=vt(e,r),o=new le(ye(i.ridge,r)??1),a=new le(ye(i.valley,r)??1),s=bt(i),l=new ud(o,a,He.normalViewRenderTarget,He.resolution,s.alpha,s.mode,s.isMask),c=new Le(l.calpha,"f");return new We(n,t,e,{ridge:o,valley:a,...s},l,s.mode,c,s.isMask,r)});ot("dust",(n,t,e,r)=>{let i=vt(e,r),o=new Je(i.color??10323813),a=new le(i.coverage??.2),s=new le(i.softness??.2),l=new le(i.noiseStrength??.2),c=new le(i.noiseScale??1),d=bt(i),u=new pd(o,a,s,l,c,d.alpha,d.isMask),p=new Le(u.calpha,"f");return new We(n,t,e,{color:o,coverage:a,softness:s,noiseStrength:l,noiseScale:c,...d},u,d.mode,p,d.isMask,r)});ot("fresnel",(n,t,e,r)=>{let i=vt(e,r),o=new Je(i.color??16777215),a=new le(ye(i.bias,r)??.1),s=new le(ye(i.scale,r)??1),l=new le(ye(i.intensity,r)??2),c=new le(ye(i.factor,r)??1),d=bt(i),u=new jp(o,a,s,l,c,d.alpha,d.mode,d.isMask),p=new Le(u.calpha,"f");return new We(n,t,e,{color:o,bias:a,scale:s,intensity:l,factor:c,...d},u,d.mode,p,d.isMask,r)});import{Vector2 as IN,Vector4 as DN}from"three";ot("gradient",(n,t,e,r)=>{let i=vt(e,r),o=new Ue(i.gradientType??0),a=new Ct(i.smooth??!1),s;i.colors?s=new Di(i.colors.length,i.colors):(s=new Di(10,new DN(0,0,0,1)),s.value[1]=new DN(1,1,1,1));let l;i.steps?l=new Ii(i.steps.length,i.steps):(l=new Ii(10,1),l.value[0]=0);let c=new Ft(rn(i.offset??new IN(0,0),r)),d=new Ft(rn(i.morph??new IN(0,0),r)),u=new le(ye(i.angle??0,r)),p=bt(i),h=new hd(o,a,s,l,c,d,u,p.alpha,p.isMask),f=new Le(h.calpha,"f");return new We(n,t,e,{gradientType:o,smooth:a,colors:s,steps:l,offset:c,morph:d,angle:u,...p},h,p.mode,f,p.isMask,r)});import{Vector4 as RN}from"three";ot("depth",(n,t,e,r)=>{let i=vt(e,r),o=new Ue(i.gradientType??0),a=new Ct(i.smooth??!1),s=new le(ye(i.near,r)??50),l=new le(ye(i.far,r)??200),c=new le(i.isVector??1),d=new le(i.isWorldSpace??0),u=new Kt(Ri(i.origin,r)),p=new Kt(Ri(i.direction,r)),h;i.colors?h=new Di(i.colors.length,i.colors):(h=new Di(2,new RN(0,0,0,1)),h.value[1]=new RN(1,1,1,1));let f;i.steps?f=new Ii(i.steps.length,i.steps):(f=new Ii(2,1),f.value[0]=0);let m=bt(i),y=new dd(o,a,s,l,c,d,u,p,h,f,m.alpha,m.isMask),g=new Le(y.calpha,"f");return new We(n,t,e,{gradientType:o,smooth:a,near:s,far:l,isVector:c,isWorldSpace:d,origin:u,direction:p,colors:h,steps:f,...m},y,m.mode,g,m.isMask,r)});import{Vector3 as iq}from"three";ot("normal",(n,t,e,r)=>{let i=vt(e,r),o=new Kt(i.cnormal??new iq(1,1,1)),a=bt(i),s=new ld(o,a.alpha),l=new Le(s.calpha,"f");return new We(n,t,e,{cnormal:o,...a},s,a.mode,l,a.isMask,r)});import{Vector2 as Mw,Vector3 as nq}from"three";ot("noise",(n,t,e,r)=>{let i=vt(e,r),o=new le(ye(i.scale,r)??1),a=new Kt(Ri(i.size??new nq(100,100,100),r)),s=new le(ye(i.move,r)??1),l=new Ft(rn(i.fA??new Mw(1.7,9.2),r)),c=new Ft(rn(i.fB??new Mw(8.3,2.8),r)),d=new Ft(rn(i.distortion??new Mw(1,1),r)),u=new Jr(i.colorA),p=new Jr(i.colorB),h=new Jr(i.colorC),f=new Jr(i.colorD),m=new Ue(i.noiseType??0),y=new Ue(i.voronoiStyle??0),g=new le(ye(i.highCut,r)??1),v=new le(ye(i.lowCut,r)??0),b=new le(ye(i.smoothness,r)??.5),S=new le(ye(i.seed,r)??.5),x=new Ue(i.quality??1),w=bt(i),A=new md(o,a,s,l,c,d,u,p,h,f,w.alpha,m,w.isMask,y,g,v,b,S,x),E=new Le(A.calpha,"f");return new We(n,t,e,{scale:o,size:a,move:s,fA:l,fB:c,distortion:d,colorA:u,colorB:p,colorC:h,colorD:f,noiseType:m,...w,voronoiStyle:y,highCut:g,lowCut:v,smoothness:b,seed:S,quality:x},A,w.mode,E,w.isMask,r)});ot("rainbow",(n,t,e,r,i)=>{let o=vt(e,r),a=new le(ye(o.filmThickness,r)??30),s=new le(ye(o.movement,r)??0),l=new Kt(Ri(o.wavelengths,r)),c=new le(ye(o.noiseStrength,r)??0),d=new le(ye(o.noiseScale,r)??1),u=new Kt(Ri(o.offset,r)),p=bt(o),h=i?.forceRainbowNoise===!0,f=h||pn(o.noiseStrength),m=new vd(a,s,l,c,d,u,p.alpha,p.isMask,f),y=new Le(m.calpha,"f"),g=new We(n,t,e,{filmThickness:a,movement:s,wavelengths:l,noiseStrength:c,noiseScale:d,offset:u,...p},m,p.mode,y,p.isMask,r);return g.noiseCompiledIn=f,g.noiseForced=h,g});import{Vector3 as BN,Vector4 as NN}from"three";ot("toon",(n,t,e,r)=>{let i=vt(e,r),o=new Ue(i.positioning??0),a;i.colors?a=new Di(i.colors.length,i.colors):(a=new Di(10,new NN(0,0,0,1)),a.value[1]=new NN(1,1,1,1));let s;i.steps?s=new Ii(i.steps.length,i.steps):(s=new Ii(10,1),s.value[0]=0);let l=new Kt(Ri(i.source??new BN(0,0,0),r)),c=new Ct(i.isWorldSpace??!0),d=new le(ye(i.noiseStrength??0,r)),u=new le(ye(i.noiseScale??1,r)),p=new Jr(i.shadowColor),h=new Kt(Ri(i.offset??new BN(0,0,0),r)),f=bt(i),m=new bd(o,a,s,l,c,d,u,p,h,f.alpha),y=new Le(m.calpha,"f");return new We(n,t,e,{positioning:o,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:d,noiseScale:u,shadowColor:p,offset:h,...f},m,f.mode,y,f.isMask,r)});import{Vector3 as oq}from"three";ot("outline",(n,t,e,r)=>{let i=vt(e,r),o=new Je(i.outlineColor??16777215),a=new Je(i.contourColor??16777215),s=new le(ye(i.outlineWidth??.1,r)),l=new le(ye(i.contourWidth??.1,r)),c=new le(ye(i.outlineThreshold??.1,r)),d=new le(ye(i.contourThreshold??.1,r)),u=new le(ye(i.outlineSmoothing??.1,r)),p=new le(ye(i.contourFrequency??.1,r)),h=new Kt(Ri(i.contourDirection??new oq(0,1,0),r)),f=new Ct(i.positionalLines??!1),m=new Ct(i.compensation??!0),y=He.normalRenderTarget,g=He.normalRenderTargetDepth,v=He.pixelRatioNode,b=He.resolution,S=bt(i),x=new yd(o,a,s,l,c,d,u,p,h,f,m,b,y,g,v,S.alpha),w=new Le(x.calpha,"f");return new We(n,t,e,{outlineColor:o,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:d,outlineSmoothing:u,contourFrequency:p,contourDirection:h,positionalLines:f,compensation:m,...S},x,S.mode,w,S.isMask,r)});ot("transmission",(n,t,e,r)=>{let i=vt(e,r),o=new le(ye(i.thickness??10,r)),a=new le(ye(i.ior??1.5,r)),s=new le(ye(i.roughness??.5,r)),l=He.transmissionSize,c=He.transmissionRenderTarget,d=He.transmissionRenderTargetDepth,u=window.innerWidth,p=window.innerHeight,h=u>=p?new Ft(p/u,1):new Ft(1,u/p),f=bt(i),m=new xd(o,a,s,l,c,d,h,f.alpha),y=new Le(m.calpha,"f");return new We(n,t,e,{thickness:o,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,r)});var LN=!1;function aq(){LN||(LN=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer \u2014 it renders as invisible on the classic WebGL pipeline."))}ot("reflection",(n,t,e,r)=>{aq();let i=vt(e,r),o=new le(i.blur??0),a=new le(i.thickness??10/1e4),s=new Ue(i.steps??60),l=new le(i.stepSize??5/1e3),c=new Ue(i.tracingMode??1),d=bt(i),u=new Je(0,0,0,1),p=new le(0),h=new ea(u,p),f=new Le(h.calpha,"f");return new We(n,t,e,{blur:o,thickness:a,steps:s,stepSize:l,tracingMode:c,...d},h,d.mode,f,d.isMask,r)});import{Vector2 as Ow}from"three";ot("pattern",(n,t,e,r)=>{let i=vt(e,r),o=new Ue(i.style??0),a=new Ue(i.projection??0),s=new Ue(["x","y","z"].indexOf(i.axis)??0),l=new le(ye(i.blending??0,r)),c=new Ft(rn(i.offset,r)),d=new Jr(i.colorA),u=new Jr(i.colorB),p=new Ft(rn(i.frequency??new Ow(10,10),r)),h=new le(ye(i.size??.5,r)),f=new le(ye(i.variation??0,r)),m=new le(ye(i.smoothness??.5,r)),y=new le(ye(i.zigzag??0,r)),g=new le(ye(i.rotation??0,r)),v=new Ft(rn(i.vertical??new Ow(0,1),r)),b=new Ft(rn(i.horizontal??new Ow(0,1),r)),S=new Ue(i.sides??6),x=bt(i),w=new gd(o,a,s,l,c,d,u,p,h,f,m,y,g,v,b,S,x.alpha,x.isMask),A=new Le(w.calpha,"f");return new We(n,t,e,{style:o,projection:a,axis:s,blending:l,offset:c,colorA:d,colorB:u,frequency:p,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:v,horizontal:b,sides:S,...x},w,x.mode,A,x.isMask,r)});ot("vertexColor",(n,t,e,r)=>{let i=vt(e,r),o=bt(i),a=new Sd(o.alpha),s=new Le(a.calpha,"f");return new We(n,t,e,{...o},a,o.mode,s,o.isMask,r)});PT({createRootMaterial:(n,t)=>new Cd(n,t),createSharedMaterial:(n,t,e)=>new cv(n,t,e)});DT((n,t)=>n?kB(t):VB());OT(()=>{let n=new sq;return n.depthWrite=!1,n.opacity=.5,n.onBeforeCompile=t=>{t.fragmentShader=`layout(location = 1) out vec4 gVelocity;
5240
5240
  `+t.fragmentShader.replace("void main() {",`void main() {
5241
- gVelocity = vec4(0.0);`)},n});var _N="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Iw=class extends cq{load(t,e,r,i=console.error){let o=new lq(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(_N+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(_N),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){i(s)}},r,a=>i(a))}async parse(t){let e=await iB(t,bN),r=nB(e);e.version&&"2.0.11"&&(0,FN.default)(e.version,"2.0.11")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&rB(),pM(e)&&vT(),cx(e)&&N2(),b2(e)&&Bm(),ov(e)&&Ew()].filter(Boolean)),r.length&&await oB(r);let i=!1,o=new Aa(e.shared,{},i);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new lv(e.scene,o);ov(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=gN(a),a=fN(a),a=mN(a),a=yN(a),a=vN(a),a}};export{Iw as default};
5241
+ gVelocity = vec4(0.0);`)},n});var _N="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Iw=class extends cq{load(t,e,r,i=console.error){let o=new lq(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(_N+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(_N),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){i(s)}},r,a=>i(a))}async parse(t){let e=await iB(t,bN),r=nB(e);e.version&&"2.0.12"&&(0,FN.default)(e.version,"2.0.12")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&rB(),pM(e)&&vT(),cx(e)&&N2(),b2(e)&&Bm(),ov(e)&&Ew()].filter(Boolean)),r.length&&await oB(r);let i=!1,o=new Aa(e.shared,{},i);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new lv(e.scene,o);ov(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=gN(a),a=fN(a),a=mN(a),a=yN(a),a=vN(a),a}};export{Iw as default};