@bugsbunnycodes1998/cartographer 0.1.2 → 0.1.4

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.
@@ -80,13 +80,13 @@ Error generating stack: `+P.message+`
80
80
  gl_FragColor = texture2D( tEquirect, sampleUV );
81
81
 
82
82
  }
83
- `},r=new cc(5,5,5),s=new li({name:"CubemapFromEquirect",uniforms:Sd(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Wi,blending:Rr});s.uniforms.tEquirect.value=t;const a=new fi(r,s),c=t.minFilter;return t.minFilter===ca&&(t.minFilter=On),new _w(1,10,this).update(e,a),t.minFilter=c,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class qv{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new yt(e),this.density=t}clone(){return new qv(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Kv{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new yt(e),this.near=t,this.far=n}clone(){return new Kv(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Du extends Cn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Vs,this.environmentIntensity=1,this.environmentRotation=new Vs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Qv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=mp,this.updateRanges=[],this.version=0,this.uuid=ks()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ks()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ks()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ts=new X;class zs{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)ts.fromBufferAttribute(this,t),ts.applyMatrix4(e),this.setXYZ(t,ts.x,ts.y,ts.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ts.fromBufferAttribute(this,t),ts.applyNormalMatrix(e),this.setXYZ(t,ts.x,ts.y,ts.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ts.fromBufferAttribute(this,t),ts.transformDirection(e),this.setXYZ(t,ts.x,ts.y,ts.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=rs(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=vn(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=rs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=rs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=rs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=rs(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=vn(t,this.array),n=vn(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=vn(t,this.array),n=vn(n,this.array),r=vn(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=vn(t,this.array),n=vn(n,this.array),r=vn(r,this.array),s=vn(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new jn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new zs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class cx extends pr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let qh;const If=new X,Kh=new X,Qh=new X,Jh=new ke,Pf=new ke,yw=new qt,ng=new X,Lf=new X,ig=new X,t1=new ke,x_=new ke,n1=new ke;class xw extends Cn{constructor(e=new cx){if(super(),this.isSprite=!0,this.type="Sprite",qh===void 0){qh=new yn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Qv(t,5);qh.setIndex([0,1,2,0,2,3]),qh.setAttribute("position",new zs(n,3,0,!1)),qh.setAttribute("uv",new zs(n,2,3,!1))}this.geometry=qh,this.material=e,this.center=new ke(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Kh.setFromMatrixScale(this.matrixWorld),yw.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Qh.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Kh.multiplyScalar(-Qh.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;rg(ng.set(-.5,-.5,0),Qh,a,Kh,r,s),rg(Lf.set(.5,-.5,0),Qh,a,Kh,r,s),rg(ig.set(.5,.5,0),Qh,a,Kh,r,s),t1.set(0,0),x_.set(1,0),n1.set(1,1);let c=e.ray.intersectTriangle(ng,Lf,ig,!1,If);if(c===null&&(rg(Lf.set(-.5,.5,0),Qh,a,Kh,r,s),x_.set(0,1),c=e.ray.intersectTriangle(ng,ig,Lf,!1,If),c===null))return;const d=e.ray.origin.distanceTo(If);d<e.near||d>e.far||t.push({distance:d,point:If.clone(),uv:Ms.getInterpolation(If,ng,Lf,ig,t1,x_,n1,new ke),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function rg(i,e,t,n,r,s){Jh.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(Pf.x=s*Jh.x-r*Jh.y,Pf.y=r*Jh.x+s*Jh.y):Pf.copy(Jh),i.copy(e),i.x+=Pf.x,i.y+=Pf.y,i.applyMatrix4(yw)}const sg=new X,i1=new X;class Sw extends Cn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n<r;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){sg.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(sg);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){sg.setFromMatrixPosition(e.matrixWorld),i1.setFromMatrixPosition(this.matrixWorld);const n=sg.distanceTo(i1)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),n>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let r=0,s=n.length;r<s;r++){const a=n[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const r1=new X,s1=new _n,o1=new _n,Cb=new X,a1=new qt,og=new X,S_=new rr,l1=new qt,E_=new Cd;class Ew extends fi{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ey,this.bindMatrix=new qt,this.bindMatrixInverse=new qt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ir),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,og),this.boundingBox.expandByPoint(og)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rr),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,og),this.boundingSphere.expandByPoint(og)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),S_.copy(this.boundingSphere),S_.applyMatrix4(r),e.ray.intersectsSphere(S_)!==!1&&(l1.copy(r).invert(),E_.copy(e.ray).applyMatrix4(l1),!(this.boundingBox!==null&&E_.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,E_)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new _n,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Ey?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ew?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;s1.fromBufferAttribute(r.attributes.skinIndex,e),o1.fromBufferAttribute(r.attributes.skinWeight,e),r1.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=o1.getComponent(s);if(a!==0){const c=s1.getComponent(s);a1.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(Cb.copy(r1).applyMatrix4(a1),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class ux extends Cn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ko extends Wn{constructor(e=null,t=1,n=1,r,s,a,c,d,f=Ui,p=Ui,g,v){super(null,a,c,d,f,p,r,s,g,v),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const c1=new qt,bb=new qt;class Jv{constructor(e=[],t=[]){this.uuid=ks(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new qt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new qt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const c=e[s]?e[s].matrixWorld:bb;c1.multiplyMatrices(c,t[s]),c1.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Jv(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new ko(t,e,e,Ni,di);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new ux),this.bones.push(a),this.boneInverses.push(new qt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const c=n[r];e.boneInverses.push(c.toArray())}return e}}class Nu extends jn{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const $h=new qt,u1=new qt,ag=[],h1=new ir,Rb=new qt,Df=new fi,Nf=new rr;class Ed extends fi{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nu(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Rb)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ir),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,$h),h1.copy(e.boundingBox).applyMatrix4($h),this.boundingBox.union(h1)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,$h),Nf.copy(e.boundingSphere).applyMatrix4($h),this.boundingSphere.union(Nf)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let c=0;c<n.length;c++)n[c]=r[a+c]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(Df.geometry=this.geometry,Df.material=this.material,Df.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nf.copy(this.boundingSphere),Nf.applyMatrix4(n),e.ray.intersectsSphere(Nf)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,$h),u1.multiplyMatrices(n,$h),Df.matrixWorld=u1,Df.raycast(e,ag);for(let a=0,c=ag.length;a<c;a++){const d=ag[a];d.instanceId=s,d.object=this,t.push(d)}ag.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new ko(new Float32Array(r*this.count),r,this.count,Pp,di));const s=this.morphTexture.source.data.data;let a=0;for(let f=0;f<n.length;f++)a+=n[f];const c=this.geometry.morphTargetsRelative?1:1-a,d=r*e;s[d]=c,s.set(n,d+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}const M_=new X,Ib=new X,Pb=new pn;class el{constructor(e=new X(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=M_.subVectors(n,t).cross(Ib.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(M_),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Pb.getNormalMatrix(e),r=this.coplanarPoint(M_).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const iu=new rr,lg=new X;class Op{constructor(e=new el,t=new el,n=new el,r=new el,s=new el,a=new el){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(r),c[4].copy(s),c[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Bo){const n=this.planes,r=e.elements,s=r[0],a=r[1],c=r[2],d=r[3],f=r[4],p=r[5],g=r[6],v=r[7],y=r[8],E=r[9],T=r[10],w=r[11],_=r[12],C=r[13],b=r[14],I=r[15];if(n[0].setComponents(d-s,v-f,w-y,I-_).normalize(),n[1].setComponents(d+s,v+f,w+y,I+_).normalize(),n[2].setComponents(d+a,v+p,w+E,I+C).normalize(),n[3].setComponents(d-a,v-p,w-E,I-C).normalize(),n[4].setComponents(d-c,v-g,w-T,I-b).normalize(),t===Bo)n[5].setComponents(d+c,v+g,w+T,I+b).normalize();else if(t===gp)n[5].setComponents(c,g,T,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),iu.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),iu.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(iu)}intersectsSprite(e){return iu.center.set(0,0,0),iu.radius=.7071067811865476,iu.applyMatrix4(e.matrixWorld),this.intersectsSphere(iu)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(lg.x=r.normal.x>0?e.max.x:e.min.x,lg.y=r.normal.y>0?e.max.y:e.min.y,lg.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(lg)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function w_(i,e){return i-e}function Lb(i,e){return i.z-e.z}function Db(i,e){return e.z-i.z}class Nb{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){const s=this.pool,a=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const c=s[this.index];a.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=r}reset(){this.list.length=0,this.index=0}}const xs=new qt,Ub=new yt(1,1,1),T_=new Op,cg=new ir,ru=new rr,Uf=new X,d1=new X,Ob=new X,A_=new Nb,kr=new fi,ug=[];function Fb(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let s=0;s<r;s++)for(let a=0;a<n;a++)e.setComponent(s+t,a,i.getComponent(s,a))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function su(i,e){if(i.constructor!==e.constructor){const t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{const t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}class Mw extends fi{get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}constructor(e,t,n=t*2,r){super(new yn,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new ko(t,e,e,Ni,di);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new ko(t,e,e,Lp,fa);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new ko(t,e,e,Ni,di);n.colorSpace=Dn.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:c,itemSize:d,normalized:f}=a,p=new c.constructor(n*d),g=new jn(p,d,f);t.setAttribute(s,g)}if(e.getIndex()!==null){const s=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new jn(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ir);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,xs),this.getBoundingBoxAt(s,cg).applyMatrix4(xs),e.union(cg)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new rr);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,xs),this.getBoundingSphereAt(s,ru).applyMatrix4(xs),e.union(ru)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(w_),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;xs.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(Ub.toArray(a.image.data,r*4),a.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(w_),d=this._availableGeometryIds.shift(),s[d]=r):(d=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(d,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,d}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),c=this._geometryInfo[e];if(r&&a.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const d=c.vertexStart,f=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const g=t.getAttribute(p),v=n.getAttribute(p);Fb(g,v,d);const y=g.itemSize;for(let E=g.count,T=f;E<T;E++){const w=d+E;for(let _=0;_<y;_++)v.setComponent(w,_,0)}v.needsUpdate=!0,v.addUpdateRange(d*y,f*y)}if(r){const p=c.indexStart,g=c.reservedIndexCount;c.indexCount=t.getIndex().count;for(let v=0;v<a.count;v++)s.setX(p+v,d+a.getX(v));for(let v=a.count,y=g;v<y;v++)s.setX(p+v,d);s.needsUpdate=!0,s.addUpdateRange(p,c.reservedIndexCount)}return c.start=r?c.indexStart:c.vertexStart,c.count=r?c.indexCount:c.vertexCount,c.boundingBox=null,t.boundingBox!==null&&(c.boundingBox=t.boundingBox.clone()),c.boundingSphere=null,t.boundingSphere!==null&&(c.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let r=0,s=n.length;r<s;r++)n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,r=n.map((a,c)=>c).sort((a,c)=>n[a].vertexStart-n[c].vertexStart),s=this.geometry;for(let a=0,c=n.length;a<c;a++){const d=r[a],f=n[d];if(f.active!==!1){if(s.index!==null){if(f.indexStart!==t){const{indexStart:p,vertexStart:g,reservedIndexCount:v}=f,y=s.index,E=y.array,T=e-g;for(let w=p;w<p+v;w++)E[w]=E[w]+T;y.array.copyWithin(t,p,p+v),y.addUpdateRange(t,v),f.indexStart=t}t+=f.reservedIndexCount}if(f.vertexStart!==e){const{vertexStart:p,reservedVertexCount:g}=f,v=s.attributes;for(const y in v){const E=v[y],{array:T,itemSize:w}=E;T.copyWithin(e*w,p*w,(p+g)*w),E.addUpdateRange(e*w,g*w)}f.vertexStart=e}e+=f.reservedVertexCount,f.start=s.index?f.indexStart:f.vertexStart,this._nextIndexStart=s.index?f.indexStart+f.reservedIndexCount:0,this._nextVertexStart=f.vertexStart+f.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const s=new ir,a=n.index,c=n.attributes.position;for(let d=r.start,f=r.start+r.count;d<f;d++){let p=d;a&&(p=a.getX(p)),s.expandByPoint(Uf.fromBufferAttribute(c,p))}r.boundingBox=s}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const s=new rr;this.getBoundingBoxAt(e,cg),cg.getCenter(s.center);const a=n.index,c=n.attributes.position;let d=0;for(let f=r.start,p=r.start+r.count;f<p;f++){let g=f;a&&(g=a.getX(g)),Uf.fromBufferAttribute(c,g),d=Math.max(d,s.center.distanceToSquared(Uf))}s.radius=Math.sqrt(d),r.boundingSphere=s}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(w_);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),s=new Int32Array(e);su(this._multiDrawCounts,r),su(this._multiDrawStarts,s),this._multiDrawCounts=r,this._multiDrawStarts=s,this._maxInstanceCount=e;const a=this._indirectTexture,c=this._matricesTexture,d=this._colorsTexture;a.dispose(),this._initIndirectTexture(),su(a.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),su(c.image.data,this._matricesTexture.image.data),d&&(d.dispose(),this._initColorsTexture(),su(d.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(c=>c.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(d=>d.indexStart+d.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new yn,this._initializeGeometry(s));const a=this.geometry;s.index&&su(s.index.array,a.index.array);for(const c in s.attributes)su(s.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,a=this.geometry;kr.material=this.material,kr.geometry.index=a.index,kr.geometry.attributes=a.attributes,kr.geometry.boundingBox===null&&(kr.geometry.boundingBox=new ir),kr.geometry.boundingSphere===null&&(kr.geometry.boundingSphere=new rr);for(let c=0,d=n.length;c<d;c++){if(!n[c].visible||!n[c].active)continue;const f=n[c].geometryIndex,p=r[f];kr.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,kr.matrixWorld).premultiply(s),this.getBoundingBoxAt(f,kr.geometry.boundingBox),this.getBoundingSphereAt(f,kr.geometry.boundingSphere),kr.raycast(e,ug);for(let g=0,v=ug.length;g<v;g++){const y=ug[g];y.object=this,y.batchId=c,t.push(y)}ug.length=0}kr.material=null,kr.geometry.index=null,kr.geometry.attributes={},kr.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),c=a===null?1:a.array.BYTES_PER_ELEMENT,d=this._instanceInfo,f=this._multiDrawStarts,p=this._multiDrawCounts,g=this._geometryInfo,v=this.perObjectFrustumCulled,y=this._indirectTexture,E=y.image.data;v&&(xs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),T_.setFromProjectionMatrix(xs,e.coordinateSystem));let T=0;if(this.sortObjects){xs.copy(this.matrixWorld).invert(),Uf.setFromMatrixPosition(n.matrixWorld).applyMatrix4(xs),d1.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(xs);for(let C=0,b=d.length;C<b;C++)if(d[C].visible&&d[C].active){const I=d[C].geometryIndex;this.getMatrixAt(C,xs),this.getBoundingSphereAt(I,ru).applyMatrix4(xs);let N=!1;if(v&&(N=!T_.intersectsSphere(ru)),!N){const O=g[I],H=Ob.subVectors(ru.center,Uf).dot(d1);A_.push(O.start,O.count,H,C)}}const w=A_.list,_=this.customSort;_===null?w.sort(s.transparent?Db:Lb):_.call(this,w,n);for(let C=0,b=w.length;C<b;C++){const I=w[C];f[T]=I.start*c,p[T]=I.count,E[T]=I.index,T++}A_.reset()}else for(let w=0,_=d.length;w<_;w++)if(d[w].visible&&d[w].active){const C=d[w].geometryIndex;let b=!1;if(v&&(this.getMatrixAt(w,xs),this.getBoundingSphereAt(C,ru).applyMatrix4(xs),b=!T_.intersectsSphere(ru)),!b){const I=g[C];f[T]=I.start*c,p[T]=I.count,E[T]=w,T++}}y.needsUpdate=!0,this._multiDrawCount=T,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class os extends pr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Rv=new X,Iv=new X,f1=new qt,Of=new Cd,hg=new rr,C_=new X,p1=new X;let sc=class extends Cn{constructor(e=new yn,t=new os){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)Rv.fromBufferAttribute(t,r-1),Iv.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Rv.distanceTo(Iv);e.setAttribute("lineDistance",new Ut(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hg.copy(n.boundingSphere),hg.applyMatrix4(r),hg.radius+=s,e.ray.intersectsSphere(hg)===!1)return;f1.copy(r).invert(),Of.copy(e.ray).applyMatrix4(f1);const c=s/((this.scale.x+this.scale.y+this.scale.z)/3),d=c*c,f=this.isLineSegments?2:1,p=n.index,v=n.attributes.position;if(p!==null){const y=Math.max(0,a.start),E=Math.min(p.count,a.start+a.count);for(let T=y,w=E-1;T<w;T+=f){const _=p.getX(T),C=p.getX(T+1),b=dg(this,e,Of,d,_,C);b&&t.push(b)}if(this.isLineLoop){const T=p.getX(E-1),w=p.getX(y),_=dg(this,e,Of,d,T,w);_&&t.push(_)}}else{const y=Math.max(0,a.start),E=Math.min(v.count,a.start+a.count);for(let T=y,w=E-1;T<w;T+=f){const _=dg(this,e,Of,d,T,T+1);_&&t.push(_)}if(this.isLineLoop){const T=dg(this,e,Of,d,E-1,y);T&&t.push(T)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const c=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=s}}}}};function dg(i,e,t,n,r,s){const a=i.geometry.attributes.position;if(Rv.fromBufferAttribute(a,r),Iv.fromBufferAttribute(a,s),t.distanceSqToSegment(Rv,Iv,C_,p1)>n)return;C_.applyMatrix4(i.matrixWorld);const d=e.ray.origin.distanceTo(C_);if(!(d<e.near||d>e.far))return{distance:d,point:p1.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const m1=new X,g1=new X;class pa extends sc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)m1.fromBufferAttribute(t,r),g1.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+m1.distanceTo(g1);e.setAttribute("lineDistance",new Ut(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ww extends sc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class hx extends pr{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const v1=new qt,Ay=new Cd,fg=new rr,pg=new X;class Tw extends Cn{constructor(e=new yn,t=new hx){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),fg.copy(n.boundingSphere),fg.applyMatrix4(r),fg.radius+=s,e.ray.intersectsSphere(fg)===!1)return;v1.copy(r).invert(),Ay.copy(e.ray).applyMatrix4(v1);const c=s/((this.scale.x+this.scale.y+this.scale.z)/3),d=c*c,f=n.index,g=n.attributes.position;if(f!==null){const v=Math.max(0,a.start),y=Math.min(f.count,a.start+a.count);for(let E=v,T=y;E<T;E++){const w=f.getX(E);pg.fromBufferAttribute(g,w),_1(pg,w,d,r,e,t,this)}}else{const v=Math.max(0,a.start),y=Math.min(g.count,a.start+a.count);for(let E=v,T=y;E<T;E++)pg.fromBufferAttribute(g,E),_1(pg,E,d,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const c=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=s}}}}}function _1(i,e,t,n,r,s,a){const c=Ay.distanceSqToPoint(i);if(c<t){const d=new X;Ay.closestPointToPoint(i,d),d.applyMatrix4(n);const f=r.ray.origin.distanceTo(d);if(f<r.near||f>r.far)return;s.push({distance:f,distanceToRay:Math.sqrt(c),point:d,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class dd extends Cn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Bb extends Wn{constructor(e,t,n,r,s,a,c,d,f){super(e,t,n,r,s,a,c,d,f),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:On,this.magFilter=s!==void 0?s:On,this.generateMipmaps=!1;const p=this;function g(){p.needsUpdate=!0,e.requestVideoFrameCallback(g)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(g)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class zb extends Wn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ui,this.minFilter=Ui,this.generateMipmaps=!1,this.needsUpdate=!0}}class $v extends Wn{constructor(e,t,n,r,s,a,c,d,f,p,g,v){super(null,a,c,d,f,p,r,s,g,v),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class kb extends $v{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=ji,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Hb extends $v{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,da),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Aw extends Wn{constructor(e,t,n,r,s,a,c,d,f){super(e,t,n,r,s,a,c,d,f),this.isCanvasTexture=!0,this.needsUpdate=!0}}class e0 extends Wn{constructor(e,t,n,r,s,a,c,d,f,p=Cu){if(p!==Cu&&p!==rc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&p===Cu&&(n=fa),n===void 0&&p===rc&&(n=ic),super(null,r,s,a,c,d,p,n,f),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=c!==void 0?c:Ui,this.minFilter=d!==void 0?d:Ui,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Ho{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let c=0,d=s-1,f;for(;c<=d;)if(r=Math.floor(c+(d-c)/2),f=n[r]-a,f<0)c=r+1;else if(f>0)d=r-1;else{d=r;break}if(r=d,n[r]===a)return r/(s-1);const p=n[r],v=n[r+1]-p,y=(a-p)/v;return(r+y)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),c=this.getPoint(s),d=t||(a.isVector2?new ke:new X);return d.copy(c).sub(a).normalize(),d}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new X,r=[],s=[],a=[],c=new X,d=new qt;for(let y=0;y<=e;y++){const E=y/e;r[y]=this.getTangentAt(E,new X)}s[0]=new X,a[0]=new X;let f=Number.MAX_VALUE;const p=Math.abs(r[0].x),g=Math.abs(r[0].y),v=Math.abs(r[0].z);p<=f&&(f=p,n.set(1,0,0)),g<=f&&(f=g,n.set(0,1,0)),v<=f&&n.set(0,0,1),c.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],c),a[0].crossVectors(r[0],s[0]);for(let y=1;y<=e;y++){if(s[y]=s[y-1].clone(),a[y]=a[y-1].clone(),c.crossVectors(r[y-1],r[y]),c.length()>Number.EPSILON){c.normalize();const E=Math.acos(un(r[y-1].dot(r[y]),-1,1));s[y].applyMatrix4(d.makeRotationAxis(c,E))}a[y].crossVectors(r[y],s[y])}if(t===!0){let y=Math.acos(un(s[0].dot(s[e]),-1,1));y/=e,r[0].dot(c.crossVectors(s[0],s[e]))>0&&(y=-y);for(let E=1;E<=e;E++)s[E].applyMatrix4(d.makeRotationAxis(r[E],y*E)),a[E].crossVectors(r[E],s[E])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class t0 extends Ho{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,c=!1,d=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=c,this.aRotation=d}getPoint(e,t=new ke){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const c=this.aStartAngle+e*s;let d=this.aX+this.xRadius*Math.cos(c),f=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){const p=Math.cos(this.aRotation),g=Math.sin(this.aRotation),v=d-this.aX,y=f-this.aY;d=v*p-y*g+this.aX,f=v*g+y*p+this.aY}return n.set(d,f)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Cw extends t0{constructor(e,t,n,r,s,a){super(e,t,n,n,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function dx(){let i=0,e=0,t=0,n=0;function r(s,a,c,d){i=s,e=c,t=-3*s+3*a-2*c-d,n=2*s-2*a+c+d}return{initCatmullRom:function(s,a,c,d,f){r(a,c,f*(c-s),f*(d-a))},initNonuniformCatmullRom:function(s,a,c,d,f,p,g){let v=(a-s)/f-(c-s)/(f+p)+(c-a)/p,y=(c-a)/p-(d-a)/(p+g)+(d-c)/g;v*=p,y*=p,r(a,c,v,y)},calc:function(s){const a=s*s,c=a*s;return i+e*s+t*a+n*c}}}const mg=new X,b_=new dx,R_=new dx,I_=new dx;class n0 extends Ho{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new X){const n=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let c=Math.floor(a),d=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/s)+1)*s:d===0&&c===s-1&&(c=s-2,d=1);let f,p;this.closed||c>0?f=r[(c-1)%s]:(mg.subVectors(r[0],r[1]).add(r[0]),f=mg);const g=r[c%s],v=r[(c+1)%s];if(this.closed||c+2<s?p=r[(c+2)%s]:(mg.subVectors(r[s-1],r[s-2]).add(r[s-1]),p=mg),this.curveType==="centripetal"||this.curveType==="chordal"){const y=this.curveType==="chordal"?.5:.25;let E=Math.pow(f.distanceToSquared(g),y),T=Math.pow(g.distanceToSquared(v),y),w=Math.pow(v.distanceToSquared(p),y);T<1e-4&&(T=1),E<1e-4&&(E=T),w<1e-4&&(w=T),b_.initNonuniformCatmullRom(f.x,g.x,v.x,p.x,E,T,w),R_.initNonuniformCatmullRom(f.y,g.y,v.y,p.y,E,T,w),I_.initNonuniformCatmullRom(f.z,g.z,v.z,p.z,E,T,w)}else this.curveType==="catmullrom"&&(b_.initCatmullRom(f.x,g.x,v.x,p.x,this.tension),R_.initCatmullRom(f.y,g.y,v.y,p.y,this.tension),I_.initCatmullRom(f.z,g.z,v.z,p.z,this.tension));return n.set(b_.calc(d),R_.calc(d),I_.calc(d)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new X().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function y1(i,e,t,n,r){const s=(n-e)*.5,a=(r-t)*.5,c=i*i,d=i*c;return(2*t-2*n+s+a)*d+(-3*t+3*n-2*s-a)*c+s*i+t}function Vb(i,e){const t=1-i;return t*t*e}function Gb(i,e){return 2*(1-i)*i*e}function Wb(i,e){return i*i*e}function sp(i,e,t,n){return Vb(i,e)+Gb(i,t)+Wb(i,n)}function jb(i,e){const t=1-i;return t*t*t*e}function Xb(i,e){const t=1-i;return 3*t*t*i*e}function Yb(i,e){return 3*(1-i)*i*i*e}function Zb(i,e){return i*i*i*e}function op(i,e,t,n,r){return jb(i,e)+Xb(i,t)+Yb(i,n)+Zb(i,r)}class fx extends Ho{constructor(e=new ke,t=new ke,n=new ke,r=new ke){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new ke){const n=t,r=this.v0,s=this.v1,a=this.v2,c=this.v3;return n.set(op(e,r.x,s.x,a.x,c.x),op(e,r.y,s.y,a.y,c.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class bw extends Ho{constructor(e=new X,t=new X,n=new X,r=new X){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new X){const n=t,r=this.v0,s=this.v1,a=this.v2,c=this.v3;return n.set(op(e,r.x,s.x,a.x,c.x),op(e,r.y,s.y,a.y,c.y),op(e,r.z,s.z,a.z,c.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class px extends Ho{constructor(e=new ke,t=new ke){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ke){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ke){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Rw extends Ho{constructor(e=new X,t=new X){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new X){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new X){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class mx extends Ho{constructor(e=new ke,t=new ke,n=new ke){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ke){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sp(e,r.x,s.x,a.x),sp(e,r.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class gx extends Ho{constructor(e=new X,t=new X,n=new X){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new X){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sp(e,r.x,s.x,a.x),sp(e,r.y,s.y,a.y),sp(e,r.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class vx extends Ho{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ke){const n=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),c=s-a,d=r[a===0?a:a-1],f=r[a],p=r[a>r.length-2?r.length-1:a+1],g=r[a>r.length-3?r.length-1:a+2];return n.set(y1(c,d.x,f.x,p.x,g.x),y1(c,d.y,f.y,p.y,g.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new ke().fromArray(r))}return this}}var Pv=Object.freeze({__proto__:null,ArcCurve:Cw,CatmullRomCurve3:n0,CubicBezierCurve:fx,CubicBezierCurve3:bw,EllipseCurve:t0,LineCurve:px,LineCurve3:Rw,QuadraticBezierCurve:mx,QuadraticBezierCurve3:gx,SplineCurve:vx});class Iw extends Ho{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Pv[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const a=r[s]-n,c=this.curves[s],d=c.getLength(),f=d===0?0:1-a/d;return c.getPointAt(f,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],c=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,d=a.getPoints(c);for(let f=0;f<d.length;f++){const p=d[f];n&&n.equals(p)||(t.push(p),n=p)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(new Pv[r.type]().fromJSON(r))}return this}}class yp extends Iw{constructor(e){super(),this.type="Path",this.currentPoint=new ke,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new px(this.currentPoint.clone(),new ke(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const s=new mx(this.currentPoint.clone(),new ke(e,t),new ke(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,a){const c=new fx(this.currentPoint.clone(),new ke(e,t),new ke(n,r),new ke(s,a));return this.curves.push(c),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new vx(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,a){const c=this.currentPoint.x,d=this.currentPoint.y;return this.absarc(e+c,t+d,n,r,s,a),this}absarc(e,t,n,r,s,a){return this.absellipse(e,t,n,n,r,s,a),this}ellipse(e,t,n,r,s,a,c,d){const f=this.currentPoint.x,p=this.currentPoint.y;return this.absellipse(e+f,t+p,n,r,s,a,c,d),this}absellipse(e,t,n,r,s,a,c,d){const f=new t0(e,t,n,r,s,a,c,d);if(this.curves.length>0){const g=f.getPoint(0);g.equals(this.currentPoint)||this.lineTo(g.x,g.y)}this.curves.push(f);const p=f.getPoint(1);return this.currentPoint.copy(p),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Fp extends yn{constructor(e=[new ke(0,-.5),new ke(.5,0),new ke(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=un(r,0,Math.PI*2);const s=[],a=[],c=[],d=[],f=[],p=1/t,g=new X,v=new ke,y=new X,E=new X,T=new X;let w=0,_=0;for(let C=0;C<=e.length-1;C++)switch(C){case 0:w=e[C+1].x-e[C].x,_=e[C+1].y-e[C].y,y.x=_*1,y.y=-w,y.z=_*0,T.copy(y),y.normalize(),d.push(y.x,y.y,y.z);break;case e.length-1:d.push(T.x,T.y,T.z);break;default:w=e[C+1].x-e[C].x,_=e[C+1].y-e[C].y,y.x=_*1,y.y=-w,y.z=_*0,E.copy(y),y.x+=T.x,y.y+=T.y,y.z+=T.z,y.normalize(),d.push(y.x,y.y,y.z),T.copy(E)}for(let C=0;C<=t;C++){const b=n+C*p*r,I=Math.sin(b),N=Math.cos(b);for(let O=0;O<=e.length-1;O++){g.x=e[O].x*I,g.y=e[O].y,g.z=e[O].x*N,a.push(g.x,g.y,g.z),v.x=C/t,v.y=O/(e.length-1),c.push(v.x,v.y);const H=d[3*O+0]*I,B=d[3*O+1],D=d[3*O+0]*N;f.push(H,B,D)}}for(let C=0;C<t;C++)for(let b=0;b<e.length-1;b++){const I=b+C*e.length,N=I,O=I+e.length,H=I+e.length+1,B=I+1;s.push(N,O,B),s.push(H,B,O)}this.setIndex(s),this.setAttribute("position",new Ut(a,3)),this.setAttribute("uv",new Ut(c,2)),this.setAttribute("normal",new Ut(f,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fp(e.points,e.segments,e.phiStart,e.phiLength)}}class i0 extends Fp{constructor(e=1,t=1,n=4,r=8){const s=new yp;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new i0(e.radius,e.length,e.capSegments,e.radialSegments)}}class r0 extends yn{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],c=[],d=[],f=new X,p=new ke;a.push(0,0,0),c.push(0,0,1),d.push(.5,.5);for(let g=0,v=3;g<=t;g++,v+=3){const y=n+g/t*r;f.x=e*Math.cos(y),f.y=e*Math.sin(y),a.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(a[v]/e+1)/2,p.y=(a[v+1]/e+1)/2,d.push(p.x,p.y)}for(let g=1;g<=t;g++)s.push(g,g+1,0);this.setIndex(s),this.setAttribute("position",new Ut(a,3)),this.setAttribute("normal",new Ut(c,3)),this.setAttribute("uv",new Ut(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r0(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class uc extends yn{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,c=0,d=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:c,thetaLength:d};const f=this;r=Math.floor(r),s=Math.floor(s);const p=[],g=[],v=[],y=[];let E=0;const T=[],w=n/2;let _=0;C(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(p),this.setAttribute("position",new Ut(g,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(y,2));function C(){const I=new X,N=new X;let O=0;const H=(t-e)/n;for(let B=0;B<=s;B++){const D=[],U=B/s,W=U*(t-e)+e;for(let ne=0;ne<=r;ne++){const re=ne/r,he=re*d+c,fe=Math.sin(he),ce=Math.cos(he);N.x=W*fe,N.y=-U*n+w,N.z=W*ce,g.push(N.x,N.y,N.z),I.set(fe,H,ce).normalize(),v.push(I.x,I.y,I.z),y.push(re,1-U),D.push(E++)}T.push(D)}for(let B=0;B<r;B++)for(let D=0;D<s;D++){const U=T[D][B],W=T[D+1][B],ne=T[D+1][B+1],re=T[D][B+1];(e>0||D!==0)&&(p.push(U,W,re),O+=3),(t>0||D!==s-1)&&(p.push(W,ne,re),O+=3)}f.addGroup(_,O,0),_+=O}function b(I){const N=E,O=new ke,H=new X;let B=0;const D=I===!0?e:t,U=I===!0?1:-1;for(let ne=1;ne<=r;ne++)g.push(0,w*U,0),v.push(0,U,0),y.push(.5,.5),E++;const W=E;for(let ne=0;ne<=r;ne++){const he=ne/r*d+c,fe=Math.cos(he),ce=Math.sin(he);H.x=D*ce,H.y=w*U,H.z=D*fe,g.push(H.x,H.y,H.z),v.push(0,U,0),O.x=fe*.5+.5,O.y=ce*.5*U+.5,y.push(O.x,O.y),E++}for(let ne=0;ne<r;ne++){const re=N+ne,he=W+ne;I===!0?p.push(he,he+1,re):p.push(he+1,he,re),B+=3}f.addGroup(_,B,I===!0?1:2),_+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Bp extends uc{constructor(e=1,t=1,n=32,r=1,s=!1,a=0,c=Math.PI*2){super(0,e,t,n,r,s,a,c),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:c}}static fromJSON(e){return new Bp(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class hc extends yn{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const s=[],a=[];c(r),f(n),p(),this.setAttribute("position",new Ut(s,3)),this.setAttribute("normal",new Ut(s.slice(),3)),this.setAttribute("uv",new Ut(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function c(C){const b=new X,I=new X,N=new X;for(let O=0;O<t.length;O+=3)y(t[O+0],b),y(t[O+1],I),y(t[O+2],N),d(b,I,N,C)}function d(C,b,I,N){const O=N+1,H=[];for(let B=0;B<=O;B++){H[B]=[];const D=C.clone().lerp(I,B/O),U=b.clone().lerp(I,B/O),W=O-B;for(let ne=0;ne<=W;ne++)ne===0&&B===O?H[B][ne]=D:H[B][ne]=D.clone().lerp(U,ne/W)}for(let B=0;B<O;B++)for(let D=0;D<2*(O-B)-1;D++){const U=Math.floor(D/2);D%2===0?(v(H[B][U+1]),v(H[B+1][U]),v(H[B][U])):(v(H[B][U+1]),v(H[B+1][U+1]),v(H[B+1][U]))}}function f(C){const b=new X;for(let I=0;I<s.length;I+=3)b.x=s[I+0],b.y=s[I+1],b.z=s[I+2],b.normalize().multiplyScalar(C),s[I+0]=b.x,s[I+1]=b.y,s[I+2]=b.z}function p(){const C=new X;for(let b=0;b<s.length;b+=3){C.x=s[b+0],C.y=s[b+1],C.z=s[b+2];const I=w(C)/2/Math.PI+.5,N=_(C)/Math.PI+.5;a.push(I,1-N)}E(),g()}function g(){for(let C=0;C<a.length;C+=6){const b=a[C+0],I=a[C+2],N=a[C+4],O=Math.max(b,I,N),H=Math.min(b,I,N);O>.9&&H<.1&&(b<.2&&(a[C+0]+=1),I<.2&&(a[C+2]+=1),N<.2&&(a[C+4]+=1))}}function v(C){s.push(C.x,C.y,C.z)}function y(C,b){const I=C*3;b.x=e[I+0],b.y=e[I+1],b.z=e[I+2]}function E(){const C=new X,b=new X,I=new X,N=new X,O=new ke,H=new ke,B=new ke;for(let D=0,U=0;D<s.length;D+=9,U+=6){C.set(s[D+0],s[D+1],s[D+2]),b.set(s[D+3],s[D+4],s[D+5]),I.set(s[D+6],s[D+7],s[D+8]),O.set(a[U+0],a[U+1]),H.set(a[U+2],a[U+3]),B.set(a[U+4],a[U+5]),N.copy(C).add(b).add(I).divideScalar(3);const W=w(N);T(O,U+0,C,W),T(H,U+2,b,W),T(B,U+4,I,W)}}function T(C,b,I,N){N<0&&C.x===1&&(a[b]=C.x-1),I.x===0&&I.z===0&&(a[b]=N/2/Math.PI+.5)}function w(C){return Math.atan2(C.z,-C.x)}function _(C){return Math.atan2(-C.y,Math.sqrt(C.x*C.x+C.z*C.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hc(e.vertices,e.indices,e.radius,e.details)}}class s0 extends hc{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new s0(e.radius,e.detail)}}const gg=new X,vg=new X,P_=new X,_g=new Ms;class Pw extends yn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(bu*t),a=e.getIndex(),c=e.getAttribute("position"),d=a?a.count:c.count,f=[0,0,0],p=["a","b","c"],g=new Array(3),v={},y=[];for(let E=0;E<d;E+=3){a?(f[0]=a.getX(E),f[1]=a.getX(E+1),f[2]=a.getX(E+2)):(f[0]=E,f[1]=E+1,f[2]=E+2);const{a:T,b:w,c:_}=_g;if(T.fromBufferAttribute(c,f[0]),w.fromBufferAttribute(c,f[1]),_.fromBufferAttribute(c,f[2]),_g.getNormal(P_),g[0]=`${Math.round(T.x*r)},${Math.round(T.y*r)},${Math.round(T.z*r)}`,g[1]=`${Math.round(w.x*r)},${Math.round(w.y*r)},${Math.round(w.z*r)}`,g[2]=`${Math.round(_.x*r)},${Math.round(_.y*r)},${Math.round(_.z*r)}`,!(g[0]===g[1]||g[1]===g[2]||g[2]===g[0]))for(let C=0;C<3;C++){const b=(C+1)%3,I=g[C],N=g[b],O=_g[p[C]],H=_g[p[b]],B=`${I}_${N}`,D=`${N}_${I}`;D in v&&v[D]?(P_.dot(v[D].normal)<=s&&(y.push(O.x,O.y,O.z),y.push(H.x,H.y,H.z)),v[D]=null):B in v||(v[B]={index0:f[C],index1:f[b],normal:P_.clone()})}}for(const E in v)if(v[E]){const{index0:T,index1:w}=v[E];gg.fromBufferAttribute(c,T),vg.fromBufferAttribute(c,w),y.push(gg.x,gg.y,gg.z),y.push(vg.x,vg.y,vg.z)}this.setAttribute("position",new Ut(y,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Iu extends yp{constructor(e){super(e),this.uuid=ks(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(new yp().fromJSON(r))}return this}}const qb={triangulate:function(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=Lw(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let c,d,f,p,g,v,y;if(n&&(s=e2(i,e,s,t)),i.length>80*t){c=f=i[0],d=p=i[1];for(let E=t;E<r;E+=t)g=i[E],v=i[E+1],g<c&&(c=g),v<d&&(d=v),g>f&&(f=g),v>p&&(p=v);y=Math.max(f-c,p-d),y=y!==0?32767/y:0}return xp(s,a,t,c,d,y,0),a}};function Lw(i,e,t,n,r){let s,a;if(r===h2(i,e,t,n)>0)for(s=e;s<t;s+=n)a=x1(s,i[s],i[s+1],a);else for(s=t-n;s>=e;s-=n)a=x1(s,i[s],i[s+1],a);return a&&o0(a,a.next)&&(Ep(a),a=a.next),a}function Uu(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(o0(t,t.next)||Ei(t.prev,t,t.next)===0)){if(Ep(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function xp(i,e,t,n,r,s,a){if(!i)return;!a&&s&&s2(i,n,r,s);let c=i,d,f;for(;i.prev!==i.next;){if(d=i.prev,f=i.next,s?Qb(i,n,r,s):Kb(i)){e.push(d.i/t|0),e.push(i.i/t|0),e.push(f.i/t|0),Ep(i),i=f.next,c=f.next;continue}if(i=f,i===c){a?a===1?(i=Jb(Uu(i),e,t),xp(i,e,t,n,r,s,2)):a===2&&$b(i,e,t,n,r,s):xp(Uu(i),e,t,n,r,s,1);break}}}function Kb(i){const e=i.prev,t=i,n=i.next;if(Ei(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,c=e.y,d=t.y,f=n.y,p=r<s?r<a?r:a:s<a?s:a,g=c<d?c<f?c:f:d<f?d:f,v=r>s?r>a?r:a:s>a?s:a,y=c>d?c>f?c:f:d>f?d:f;let E=n.next;for(;E!==e;){if(E.x>=p&&E.x<=v&&E.y>=g&&E.y<=y&&fd(r,c,s,d,a,f,E.x,E.y)&&Ei(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function Qb(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Ei(r,s,a)>=0)return!1;const c=r.x,d=s.x,f=a.x,p=r.y,g=s.y,v=a.y,y=c<d?c<f?c:f:d<f?d:f,E=p<g?p<v?p:v:g<v?g:v,T=c>d?c>f?c:f:d>f?d:f,w=p>g?p>v?p:v:g>v?g:v,_=Cy(y,E,e,t,n),C=Cy(T,w,e,t,n);let b=i.prevZ,I=i.nextZ;for(;b&&b.z>=_&&I&&I.z<=C;){if(b.x>=y&&b.x<=T&&b.y>=E&&b.y<=w&&b!==r&&b!==a&&fd(c,p,d,g,f,v,b.x,b.y)&&Ei(b.prev,b,b.next)>=0||(b=b.prevZ,I.x>=y&&I.x<=T&&I.y>=E&&I.y<=w&&I!==r&&I!==a&&fd(c,p,d,g,f,v,I.x,I.y)&&Ei(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;b&&b.z>=_;){if(b.x>=y&&b.x<=T&&b.y>=E&&b.y<=w&&b!==r&&b!==a&&fd(c,p,d,g,f,v,b.x,b.y)&&Ei(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;I&&I.z<=C;){if(I.x>=y&&I.x<=T&&I.y>=E&&I.y<=w&&I!==r&&I!==a&&fd(c,p,d,g,f,v,I.x,I.y)&&Ei(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function Jb(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!o0(r,s)&&Dw(r,n,n.next,s)&&Sp(r,s)&&Sp(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Ep(n),Ep(n.next),n=i=s),n=n.next}while(n!==i);return Uu(n)}function $b(i,e,t,n,r,s){let a=i;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&l2(a,c)){let d=Nw(a,c);a=Uu(a,a.next),d=Uu(d,d.next),xp(a,e,t,n,r,s,0),xp(d,e,t,n,r,s,0);return}c=c.next}a=a.next}while(a!==i)}function e2(i,e,t,n){const r=[];let s,a,c,d,f;for(s=0,a=e.length;s<a;s++)c=e[s]*n,d=s<a-1?e[s+1]*n:i.length,f=Lw(i,c,d,n,!1),f===f.next&&(f.steiner=!0),r.push(a2(f));for(r.sort(t2),s=0;s<r.length;s++)t=n2(r[s],t);return t}function t2(i,e){return i.x-e.x}function n2(i,e){const t=i2(i,e);if(!t)return e;const n=Nw(t,i);return Uu(n,n.next),Uu(t,t.next)}function i2(i,e){let t=e,n=-1/0,r;const s=i.x,a=i.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const v=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=s&&v>n&&(n=v,r=t.x<t.next.x?t:t.next,v===s))return r}t=t.next}while(t!==e);if(!r)return null;const c=r,d=r.x,f=r.y;let p=1/0,g;t=r;do s>=t.x&&t.x>=d&&s!==t.x&&fd(a<f?s:n,a,d,f,a<f?n:s,a,t.x,t.y)&&(g=Math.abs(a-t.y)/(s-t.x),Sp(t,i)&&(g<p||g===p&&(t.x>r.x||t.x===r.x&&r2(r,t)))&&(r=t,p=g)),t=t.next;while(t!==c);return r}function r2(i,e){return Ei(i.prev,i,e.prev)<0&&Ei(e.next,i,i.next)<0}function s2(i,e,t,n){let r=i;do r.z===0&&(r.z=Cy(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,o2(r)}function o2(i){let e,t,n,r,s,a,c,d,f=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,c=0,e=0;e<f&&(c++,n=n.nextZ,!!n);e++);for(d=f;c>0||d>0&&n;)c!==0&&(d===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,c--):(r=n,n=n.nextZ,d--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,f*=2}while(a>1);return i}function Cy(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function a2(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function fd(i,e,t,n,r,s,a,c){return(r-a)*(e-c)>=(i-a)*(s-c)&&(i-a)*(n-c)>=(t-a)*(e-c)&&(t-a)*(s-c)>=(r-a)*(n-c)}function l2(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!c2(i,e)&&(Sp(i,e)&&Sp(e,i)&&u2(i,e)&&(Ei(i.prev,i,e.prev)||Ei(i,e.prev,e))||o0(i,e)&&Ei(i.prev,i,i.next)>0&&Ei(e.prev,e,e.next)>0)}function Ei(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function o0(i,e){return i.x===e.x&&i.y===e.y}function Dw(i,e,t,n){const r=xg(Ei(i,e,t)),s=xg(Ei(i,e,n)),a=xg(Ei(t,n,i)),c=xg(Ei(t,n,e));return!!(r!==s&&a!==c||r===0&&yg(i,t,e)||s===0&&yg(i,n,e)||a===0&&yg(t,i,n)||c===0&&yg(t,e,n))}function yg(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function xg(i){return i>0?1:i<0?-1:0}function c2(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Dw(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Sp(i,e){return Ei(i.prev,i,i.next)<0?Ei(i,e,i.next)>=0&&Ei(i,i.prev,e)>=0:Ei(i,e,i.prev)<0||Ei(i,i.next,e)<0}function u2(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Nw(i,e){const t=new by(i.i,i.x,i.y),n=new by(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function x1(i,e,t,n){const r=new by(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ep(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function by(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function h2(i,e,t,n){let r=0;for(let s=e,a=t-n;s<t;s+=n)r+=(i[a]-i[s])*(i[s+1]+i[a+1]),a=s;return r}class ua{static area(e){const t=e.length;let n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return ua.area(e)<0}static triangulateShape(e,t){const n=[],r=[],s=[];S1(e),E1(n,e);let a=e.length;t.forEach(S1);for(let d=0;d<t.length;d++)r.push(a),a+=t[d].length,E1(n,t[d]);const c=qb.triangulate(n,r);for(let d=0;d<c.length;d+=3)s.push(c.slice(d,d+3));return s}}function S1(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function E1(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class a0 extends yn{constructor(e=new Iu([new ke(.5,.5),new ke(-.5,.5),new ke(-.5,-.5),new ke(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],s=[];for(let c=0,d=e.length;c<d;c++){const f=e[c];a(f)}this.setAttribute("position",new Ut(r,3)),this.setAttribute("uv",new Ut(s,2)),this.computeVertexNormals();function a(c){const d=[],f=t.curveSegments!==void 0?t.curveSegments:12,p=t.steps!==void 0?t.steps:1,g=t.depth!==void 0?t.depth:1;let v=t.bevelEnabled!==void 0?t.bevelEnabled:!0,y=t.bevelThickness!==void 0?t.bevelThickness:.2,E=t.bevelSize!==void 0?t.bevelSize:y-.1,T=t.bevelOffset!==void 0?t.bevelOffset:0,w=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:d2;let b,I=!1,N,O,H,B;_&&(b=_.getSpacedPoints(p),I=!0,v=!1,N=_.computeFrenetFrames(p,!1),O=new X,H=new X,B=new X),v||(w=0,y=0,E=0,T=0);const D=c.extractPoints(f);let U=D.shape;const W=D.holes;if(!ua.isClockWise(U)){U=U.reverse();for(let Ve=0,Ge=W.length;Ve<Ge;Ve++){const K=W[Ve];ua.isClockWise(K)&&(W[Ve]=K.reverse())}}const re=ua.triangulateShape(U,W),he=U;for(let Ve=0,Ge=W.length;Ve<Ge;Ve++){const K=W[Ve];U=U.concat(K)}function fe(Ve,Ge,K){return Ge||console.error("THREE.ExtrudeGeometry: vec does not exist"),Ve.clone().addScaledVector(Ge,K)}const ce=U.length,xe=re.length;function q(Ve,Ge,K){let At,Je,dt;const it=Ve.x-Ge.x,zt=Ve.y-Ge.y,ot=K.x-Ve.x,Z=K.y-Ve.y,G=it*it+zt*zt,Se=it*Z-zt*ot;if(Math.abs(Se)>Number.EPSILON){const Fe=Math.sqrt(G),Xe=Math.sqrt(ot*ot+Z*Z),He=Ge.x-zt/Fe,Mt=Ge.y+it/Fe,ct=K.x-Z/Xe,xt=K.y+ot/Xe,rn=((ct-He)*Z-(xt-Mt)*ot)/(it*Z-zt*ot);At=He+it*rn-Ve.x,Je=Mt+zt*rn-Ve.y;const et=At*At+Je*Je;if(et<=2)return new ke(At,Je);dt=Math.sqrt(et/2)}else{let Fe=!1;it>Number.EPSILON?ot>Number.EPSILON&&(Fe=!0):it<-Number.EPSILON?ot<-Number.EPSILON&&(Fe=!0):Math.sign(zt)===Math.sign(Z)&&(Fe=!0),Fe?(At=-zt,Je=it,dt=Math.sqrt(G)):(At=it,Je=zt,dt=Math.sqrt(G/2))}return new ke(At/dt,Je/dt)}const de=[];for(let Ve=0,Ge=he.length,K=Ge-1,At=Ve+1;Ve<Ge;Ve++,K++,At++)K===Ge&&(K=0),At===Ge&&(At=0),de[Ve]=q(he[Ve],he[K],he[At]);const se=[];let Y,le=de.concat();for(let Ve=0,Ge=W.length;Ve<Ge;Ve++){const K=W[Ve];Y=[];for(let At=0,Je=K.length,dt=Je-1,it=At+1;At<Je;At++,dt++,it++)dt===Je&&(dt=0),it===Je&&(it=0),Y[At]=q(K[At],K[dt],K[it]);se.push(Y),le=le.concat(Y)}for(let Ve=0;Ve<w;Ve++){const Ge=Ve/w,K=y*Math.cos(Ge*Math.PI/2),At=E*Math.sin(Ge*Math.PI/2)+T;for(let Je=0,dt=he.length;Je<dt;Je++){const it=fe(he[Je],de[Je],At);Be(it.x,it.y,-K)}for(let Je=0,dt=W.length;Je<dt;Je++){const it=W[Je];Y=se[Je];for(let zt=0,ot=it.length;zt<ot;zt++){const Z=fe(it[zt],Y[zt],At);Be(Z.x,Z.y,-K)}}}const ze=E+T;for(let Ve=0;Ve<ce;Ve++){const Ge=v?fe(U[Ve],le[Ve],ze):U[Ve];I?(H.copy(N.normals[0]).multiplyScalar(Ge.x),O.copy(N.binormals[0]).multiplyScalar(Ge.y),B.copy(b[0]).add(H).add(O),Be(B.x,B.y,B.z)):Be(Ge.x,Ge.y,0)}for(let Ve=1;Ve<=p;Ve++)for(let Ge=0;Ge<ce;Ge++){const K=v?fe(U[Ge],le[Ge],ze):U[Ge];I?(H.copy(N.normals[Ve]).multiplyScalar(K.x),O.copy(N.binormals[Ve]).multiplyScalar(K.y),B.copy(b[Ve]).add(H).add(O),Be(B.x,B.y,B.z)):Be(K.x,K.y,g/p*Ve)}for(let Ve=w-1;Ve>=0;Ve--){const Ge=Ve/w,K=y*Math.cos(Ge*Math.PI/2),At=E*Math.sin(Ge*Math.PI/2)+T;for(let Je=0,dt=he.length;Je<dt;Je++){const it=fe(he[Je],de[Je],At);Be(it.x,it.y,g+K)}for(let Je=0,dt=W.length;Je<dt;Je++){const it=W[Je];Y=se[Je];for(let zt=0,ot=it.length;zt<ot;zt++){const Z=fe(it[zt],Y[zt],At);I?Be(Z.x,Z.y+b[p-1].y,b[p-1].x+K):Be(Z.x,Z.y,g+K)}}}ve(),Pe();function ve(){const Ve=r.length/3;if(v){let Ge=0,K=ce*Ge;for(let At=0;At<xe;At++){const Je=re[At];Ke(Je[2]+K,Je[1]+K,Je[0]+K)}Ge=p+w*2,K=ce*Ge;for(let At=0;At<xe;At++){const Je=re[At];Ke(Je[0]+K,Je[1]+K,Je[2]+K)}}else{for(let Ge=0;Ge<xe;Ge++){const K=re[Ge];Ke(K[2],K[1],K[0])}for(let Ge=0;Ge<xe;Ge++){const K=re[Ge];Ke(K[0]+ce*p,K[1]+ce*p,K[2]+ce*p)}}n.addGroup(Ve,r.length/3-Ve,0)}function Pe(){const Ve=r.length/3;let Ge=0;Le(he,Ge),Ge+=he.length;for(let K=0,At=W.length;K<At;K++){const Je=W[K];Le(Je,Ge),Ge+=Je.length}n.addGroup(Ve,r.length/3-Ve,1)}function Le(Ve,Ge){let K=Ve.length;for(;--K>=0;){const At=K;let Je=K-1;Je<0&&(Je=Ve.length-1);for(let dt=0,it=p+w*2;dt<it;dt++){const zt=ce*dt,ot=ce*(dt+1),Z=Ge+At+zt,G=Ge+Je+zt,Se=Ge+Je+ot,Fe=Ge+At+ot;ft(Z,G,Se,Fe)}}}function Be(Ve,Ge,K){d.push(Ve),d.push(Ge),d.push(K)}function Ke(Ve,Ge,K){ht(Ve),ht(Ge),ht(K);const At=r.length/3,Je=C.generateTopUV(n,r,At-3,At-2,At-1);pt(Je[0]),pt(Je[1]),pt(Je[2])}function ft(Ve,Ge,K,At){ht(Ve),ht(Ge),ht(At),ht(Ge),ht(K),ht(At);const Je=r.length/3,dt=C.generateSideWallUV(n,r,Je-6,Je-3,Je-2,Je-1);pt(dt[0]),pt(dt[1]),pt(dt[3]),pt(dt[1]),pt(dt[2]),pt(dt[3])}function ht(Ve){r.push(d[Ve*3+0]),r.push(d[Ve*3+1]),r.push(d[Ve*3+2])}function pt(Ve){s.push(Ve.x),s.push(Ve.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return f2(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const c=t[e.shapes[s]];n.push(c)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Pv[r.type]().fromJSON(r)),new a0(n,e.options)}}const d2={generateTopUV:function(i,e,t,n,r){const s=e[t*3],a=e[t*3+1],c=e[n*3],d=e[n*3+1],f=e[r*3],p=e[r*3+1];return[new ke(s,a),new ke(c,d),new ke(f,p)]},generateSideWallUV:function(i,e,t,n,r,s){const a=e[t*3],c=e[t*3+1],d=e[t*3+2],f=e[n*3],p=e[n*3+1],g=e[n*3+2],v=e[r*3],y=e[r*3+1],E=e[r*3+2],T=e[s*3],w=e[s*3+1],_=e[s*3+2];return Math.abs(c-p)<Math.abs(a-f)?[new ke(a,1-d),new ke(f,1-g),new ke(v,1-E),new ke(T,1-_)]:[new ke(c,1-d),new ke(p,1-g),new ke(y,1-E),new ke(w,1-_)]}};function f2(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class zp extends hc{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new zp(e.radius,e.detail)}}class kp extends hc{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new kp(e.radius,e.detail)}}class cl extends yn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,c=Math.floor(n),d=Math.floor(r),f=c+1,p=d+1,g=e/c,v=t/d,y=[],E=[],T=[],w=[];for(let _=0;_<p;_++){const C=_*v-a;for(let b=0;b<f;b++){const I=b*g-s;E.push(I,-C,0),T.push(0,0,1),w.push(b/c),w.push(1-_/d)}}for(let _=0;_<d;_++)for(let C=0;C<c;C++){const b=C+f*_,I=C+f*(_+1),N=C+1+f*(_+1),O=C+1+f*_;y.push(b,I,O),y.push(I,N,O)}this.setIndex(y),this.setAttribute("position",new Ut(E,3)),this.setAttribute("normal",new Ut(T,3)),this.setAttribute("uv",new Ut(w,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cl(e.width,e.height,e.widthSegments,e.heightSegments)}}class l0 extends yn{constructor(e=.5,t=1,n=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);const c=[],d=[],f=[],p=[];let g=e;const v=(t-e)/r,y=new X,E=new ke;for(let T=0;T<=r;T++){for(let w=0;w<=n;w++){const _=s+w/n*a;y.x=g*Math.cos(_),y.y=g*Math.sin(_),d.push(y.x,y.y,y.z),f.push(0,0,1),E.x=(y.x/t+1)/2,E.y=(y.y/t+1)/2,p.push(E.x,E.y)}g+=v}for(let T=0;T<r;T++){const w=T*(n+1);for(let _=0;_<n;_++){const C=_+w,b=C,I=C+n+1,N=C+n+2,O=C+1;c.push(b,I,O),c.push(I,N,O)}}this.setIndex(c),this.setAttribute("position",new Ut(d,3)),this.setAttribute("normal",new Ut(f,3)),this.setAttribute("uv",new Ut(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new l0(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class c0 extends yn{constructor(e=new Iu([new ke(0,.5),new ke(-.5,-.5),new ke(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],s=[],a=[];let c=0,d=0;if(Array.isArray(e)===!1)f(e);else for(let p=0;p<e.length;p++)f(e[p]),this.addGroup(c,d,p),c+=d,d=0;this.setIndex(n),this.setAttribute("position",new Ut(r,3)),this.setAttribute("normal",new Ut(s,3)),this.setAttribute("uv",new Ut(a,2));function f(p){const g=r.length/3,v=p.extractPoints(t);let y=v.shape;const E=v.holes;ua.isClockWise(y)===!1&&(y=y.reverse());for(let w=0,_=E.length;w<_;w++){const C=E[w];ua.isClockWise(C)===!0&&(E[w]=C.reverse())}const T=ua.triangulateShape(y,E);for(let w=0,_=E.length;w<_;w++){const C=E[w];y=y.concat(C)}for(let w=0,_=y.length;w<_;w++){const C=y[w];r.push(C.x,C.y,0),s.push(0,0,1),a.push(C.x,C.y)}for(let w=0,_=T.length;w<_;w++){const C=T[w],b=C[0]+g,I=C[1]+g,N=C[2]+g;n.push(b,I,N),d+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return p2(t,e)}static fromJSON(e,t){const n=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];n.push(a)}return new c0(n,e.curveSegments)}}function p2(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}class bd extends yn{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,a=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:a,thetaLength:c},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const d=Math.min(a+c,Math.PI);let f=0;const p=[],g=new X,v=new X,y=[],E=[],T=[],w=[];for(let _=0;_<=n;_++){const C=[],b=_/n;let I=0;_===0&&a===0?I=.5/t:_===n&&d===Math.PI&&(I=-.5/t);for(let N=0;N<=t;N++){const O=N/t;g.x=-e*Math.cos(r+O*s)*Math.sin(a+b*c),g.y=e*Math.cos(a+b*c),g.z=e*Math.sin(r+O*s)*Math.sin(a+b*c),E.push(g.x,g.y,g.z),v.copy(g).normalize(),T.push(v.x,v.y,v.z),w.push(O+I,1-b),C.push(f++)}p.push(C)}for(let _=0;_<n;_++)for(let C=0;C<t;C++){const b=p[_][C+1],I=p[_][C],N=p[_+1][C],O=p[_+1][C+1];(_!==0||a>0)&&y.push(b,I,O),(_!==n-1||d<Math.PI)&&y.push(I,N,O)}this.setIndex(y),this.setAttribute("position",new Ut(E,3)),this.setAttribute("normal",new Ut(T,3)),this.setAttribute("uv",new Ut(w,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class u0 extends hc{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new u0(e.radius,e.detail)}}class h0 extends yn{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const a=[],c=[],d=[],f=[],p=new X,g=new X,v=new X;for(let y=0;y<=n;y++)for(let E=0;E<=r;E++){const T=E/r*s,w=y/n*Math.PI*2;g.x=(e+t*Math.cos(w))*Math.cos(T),g.y=(e+t*Math.cos(w))*Math.sin(T),g.z=t*Math.sin(w),c.push(g.x,g.y,g.z),p.x=e*Math.cos(T),p.y=e*Math.sin(T),v.subVectors(g,p).normalize(),d.push(v.x,v.y,v.z),f.push(E/r),f.push(y/n)}for(let y=1;y<=n;y++)for(let E=1;E<=r;E++){const T=(r+1)*y+E-1,w=(r+1)*(y-1)+E-1,_=(r+1)*(y-1)+E,C=(r+1)*y+E;a.push(T,w,C),a.push(w,_,C)}this.setIndex(a),this.setAttribute("position",new Ut(c,3)),this.setAttribute("normal",new Ut(d,3)),this.setAttribute("uv",new Ut(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new h0(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class d0 extends yn{constructor(e=1,t=.4,n=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:s,q:a},n=Math.floor(n),r=Math.floor(r);const c=[],d=[],f=[],p=[],g=new X,v=new X,y=new X,E=new X,T=new X,w=new X,_=new X;for(let b=0;b<=n;++b){const I=b/n*s*Math.PI*2;C(I,s,a,e,y),C(I+.01,s,a,e,E),w.subVectors(E,y),_.addVectors(E,y),T.crossVectors(w,_),_.crossVectors(T,w),T.normalize(),_.normalize();for(let N=0;N<=r;++N){const O=N/r*Math.PI*2,H=-t*Math.cos(O),B=t*Math.sin(O);g.x=y.x+(H*_.x+B*T.x),g.y=y.y+(H*_.y+B*T.y),g.z=y.z+(H*_.z+B*T.z),d.push(g.x,g.y,g.z),v.subVectors(g,y).normalize(),f.push(v.x,v.y,v.z),p.push(b/n),p.push(N/r)}}for(let b=1;b<=n;b++)for(let I=1;I<=r;I++){const N=(r+1)*(b-1)+(I-1),O=(r+1)*b+(I-1),H=(r+1)*b+I,B=(r+1)*(b-1)+I;c.push(N,O,B),c.push(O,H,B)}this.setIndex(c),this.setAttribute("position",new Ut(d,3)),this.setAttribute("normal",new Ut(f,3)),this.setAttribute("uv",new Ut(p,2));function C(b,I,N,O,H){const B=Math.cos(b),D=Math.sin(b),U=N/I*b,W=Math.cos(U);H.x=O*(2+W)*.5*B,H.y=O*(2+W)*D*.5,H.z=O*Math.sin(U)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new d0(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Md extends yn{constructor(e=new gx(new X(-1,-1,0),new X(-1,1,0),new X(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const c=new X,d=new X,f=new ke;let p=new X;const g=[],v=[],y=[],E=[];T(),this.setIndex(E),this.setAttribute("position",new Ut(g,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(y,2));function T(){for(let b=0;b<t;b++)w(b);w(s===!1?t:0),C(),_()}function w(b){p=e.getPointAt(b/t,p);const I=a.normals[b],N=a.binormals[b];for(let O=0;O<=r;O++){const H=O/r*Math.PI*2,B=Math.sin(H),D=-Math.cos(H);d.x=D*I.x+B*N.x,d.y=D*I.y+B*N.y,d.z=D*I.z+B*N.z,d.normalize(),v.push(d.x,d.y,d.z),c.x=p.x+n*d.x,c.y=p.y+n*d.y,c.z=p.z+n*d.z,g.push(c.x,c.y,c.z)}}function _(){for(let b=1;b<=t;b++)for(let I=1;I<=r;I++){const N=(r+1)*(b-1)+(I-1),O=(r+1)*b+(I-1),H=(r+1)*b+I,B=(r+1)*(b-1)+I;E.push(N,O,B),E.push(O,H,B)}}function C(){for(let b=0;b<=t;b++)for(let I=0;I<=r;I++)f.x=b/t,f.y=I/r,y.push(f.x,f.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Md(new Pv[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class _x extends yn{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new X,s=new X;if(e.index!==null){const a=e.attributes.position,c=e.index;let d=e.groups;d.length===0&&(d=[{start:0,count:c.count,materialIndex:0}]);for(let f=0,p=d.length;f<p;++f){const g=d[f],v=g.start,y=g.count;for(let E=v,T=v+y;E<T;E+=3)for(let w=0;w<3;w++){const _=c.getX(E+w),C=c.getX(E+(w+1)%3);r.fromBufferAttribute(a,_),s.fromBufferAttribute(a,C),M1(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let c=0,d=a.count/3;c<d;c++)for(let f=0;f<3;f++){const p=3*c+f,g=3*c+(f+1)%3;r.fromBufferAttribute(a,p),s.fromBufferAttribute(a,g),M1(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ut(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function M1(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var w1=Object.freeze({__proto__:null,BoxGeometry:cc,CapsuleGeometry:i0,CircleGeometry:r0,ConeGeometry:Bp,CylinderGeometry:uc,DodecahedronGeometry:s0,EdgesGeometry:Pw,ExtrudeGeometry:a0,IcosahedronGeometry:zp,LatheGeometry:Fp,OctahedronGeometry:kp,PlaneGeometry:cl,PolyhedronGeometry:hc,RingGeometry:l0,ShapeGeometry:c0,SphereGeometry:bd,TetrahedronGeometry:u0,TorusGeometry:h0,TorusKnotGeometry:d0,TubeGeometry:Md,WireframeGeometry:_x});class Uw extends pr{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new yt(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Ow extends li{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ou extends pr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new yt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vs,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Fw extends Ou{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return un(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new yt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new yt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new yt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Bw extends pr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vs,this.combine=Rp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class zw extends pr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class yx extends pr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class kw extends pr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vs,this.combine=Rp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xx extends pr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ac,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Sx extends pr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Hw extends pr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Vw extends os{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function wu(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Gw(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Ww(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Ry(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const c=t[s]*e;for(let d=0;d!==e;++d)r[a++]=i[c+d]}return r}function Ex(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function m2(i,e,t,n,r=30){const s=i.clone();s.name=e;const a=[];for(let d=0;d<s.tracks.length;++d){const f=s.tracks[d],p=f.getValueSize(),g=[],v=[];for(let y=0;y<f.times.length;++y){const E=f.times[y]*r;if(!(E<t||E>=n)){g.push(f.times[y]);for(let T=0;T<p;++T)v.push(f.values[y*p+T])}}g.length!==0&&(f.times=wu(g,f.times.constructor),f.values=wu(v,f.values.constructor),a.push(f))}s.tracks=a;let c=1/0;for(let d=0;d<s.tracks.length;++d)c>s.tracks[d].times[0]&&(c=s.tracks[d].times[0]);for(let d=0;d<s.tracks.length;++d)s.tracks[d].shift(-1*c);return s.resetDuration(),s}function g2(i,e=0,t=i,n=30){n<=0&&(n=30);const r=t.tracks.length,s=e/n;for(let a=0;a<r;++a){const c=t.tracks[a],d=c.ValueTypeName;if(d==="bool"||d==="string")continue;const f=i.tracks.find(function(_){return _.name===c.name&&_.ValueTypeName===d});if(f===void 0)continue;let p=0;const g=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=g/3);let v=0;const y=f.getValueSize();f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(v=y/3);const E=c.times.length-1;let T;if(s<=c.times[0]){const _=p,C=g-p;T=c.values.slice(_,C)}else if(s>=c.times[E]){const _=E*g+p,C=_+g-p;T=c.values.slice(_,C)}else{const _=c.createInterpolant(),C=p,b=g-p;_.evaluate(s),T=_.resultBuffer.slice(C,b)}d==="quaternion"&&new ss().fromArray(T).normalize().conjugate().toArray(T);const w=f.times.length;for(let _=0;_<w;++_){const C=_*y+v;if(d==="quaternion")ss.multiplyQuaternionsFlat(f.values,C,T,0,f.values,C);else{const b=y-v*2;for(let I=0;I<b;++I)f.values[C+I]-=T[I]}}}return i.blendMode=ix,i}const v2={convertArray:wu,isTypedArray:Gw,getKeyframeOrder:Ww,sortedArray:Ry,flattenJSON:Ex,subclip:m2,makeClipAdditive:g2};class Hp{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let c=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===c)break;if(s=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=s)){const c=t[1];e<c&&(n=2,s=c);for(let d=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===d)break;if(r=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const c=n+a>>>1;e<t[c]?a=c:n=c+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class jw extends Hp{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xu,endingEnd:xu}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,a=e+1,c=r[s],d=r[a];if(c===void 0)switch(this.getSettings_().endingStart){case Su:s=e,c=2*t-n;break;case fp:s=r.length-2,c=t+r[s]-r[s+1];break;default:s=e,c=n}if(d===void 0)switch(this.getSettings_().endingEnd){case Su:a=e,d=2*n-t;break;case fp:a=1,d=n+r[1]-r[0];break;default:a=e-1,d=t}const f=(n-t)*.5,p=this.valueSize;this._weightPrev=f/(t-c),this._weightNext=f/(d-n),this._offsetPrev=s*p,this._offsetNext=a*p}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,d=e*c,f=d-c,p=this._offsetPrev,g=this._offsetNext,v=this._weightPrev,y=this._weightNext,E=(n-t)/(r-t),T=E*E,w=T*E,_=-v*w+2*v*T-v*E,C=(1+v)*w+(-1.5-2*v)*T+(-.5+v)*E+1,b=(-1-y)*w+(1.5+y)*T+.5*E,I=y*w-y*T;for(let N=0;N!==c;++N)s[N]=_*a[p+N]+C*a[f+N]+b*a[d+N]+I*a[g+N];return s}}class Mx extends Hp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,d=e*c,f=d-c,p=(n-t)/(r-t),g=1-p;for(let v=0;v!==c;++v)s[v]=a[f+v]*g+a[d+v]*p;return s}}class Xw extends Hp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Vo{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wu(t,this.TimeBufferType),this.values=wu(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wu(e.times,Array),values:wu(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Xw(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Mx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jw(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case dp:t=this.InterpolantFactoryMethodDiscrete;break;case bv:t=this.InterpolantFactoryMethodLinear;break;case jg:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return dp;case this.InterpolantFactoryMethodLinear:return bv;case this.InterpolantFactoryMethodSmooth:return jg}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const c=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*c,a*c)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let c=0;c!==s;c++){const d=n[c];if(typeof d=="number"&&isNaN(d)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,d),e=!1;break}if(a!==null&&a>d){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,d,a),e=!1;break}a=d}if(r!==void 0&&Gw(r))for(let c=0,d=r.length;c!==d;++c){const f=r[c];if(isNaN(f)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,f),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===jg,s=e.length-1;let a=1;for(let c=1;c<s;++c){let d=!1;const f=e[c],p=e[c+1];if(f!==p&&(c!==1||f!==e[0]))if(r)d=!0;else{const g=c*n,v=g-n,y=g+n;for(let E=0;E!==n;++E){const T=t[g+E];if(T!==t[v+E]||T!==t[y+E]){d=!0;break}}}if(d){if(c!==a){e[a]=e[c];const g=c*n,v=a*n;for(let y=0;y!==n;++y)t[v+y]=t[g+y]}++a}}if(s>0){e[a]=e[s];for(let c=s*n,d=a*n,f=0;f!==n;++f)t[d+f]=t[c+f];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Vo.prototype.TimeBufferType=Float32Array;Vo.prototype.ValueBufferType=Float32Array;Vo.prototype.DefaultInterpolation=bv;class Fu extends Vo{constructor(e,t,n){super(e,t,n)}}Fu.prototype.ValueTypeName="bool";Fu.prototype.ValueBufferType=Array;Fu.prototype.DefaultInterpolation=dp;Fu.prototype.InterpolantFactoryMethodLinear=void 0;Fu.prototype.InterpolantFactoryMethodSmooth=void 0;class wx extends Vo{}wx.prototype.ValueTypeName="color";class Mp extends Vo{}Mp.prototype.ValueTypeName="number";class Yw extends Hp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,d=(n-t)/(r-t);let f=e*c;for(let p=f+c;f!==p;f+=4)ss.slerpFlat(s,0,a,f-c,a,f,d);return s}}class Vp extends Vo{InterpolantFactoryMethodLinear(e){return new Yw(this.times,this.values,this.getValueSize(),e)}}Vp.prototype.ValueTypeName="quaternion";Vp.prototype.InterpolantFactoryMethodSmooth=void 0;class Bu extends Vo{constructor(e,t,n){super(e,t,n)}}Bu.prototype.ValueTypeName="string";Bu.prototype.ValueBufferType=Array;Bu.prototype.DefaultInterpolation=dp;Bu.prototype.InterpolantFactoryMethodLinear=void 0;Bu.prototype.InterpolantFactoryMethodSmooth=void 0;class wp extends Vo{}wp.prototype.ValueTypeName="vector";class Tp{constructor(e="",t=-1,n=[],r=jv){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=ks(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,c=n.length;a!==c;++a)t.push(y2(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Vo.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let c=0;c<s;c++){let d=[],f=[];d.push((c+s-1)%s,c,(c+1)%s),f.push(0,1,0);const p=Ww(d);d=Ry(d,1,p),f=Ry(f,1,p),!r&&d[0]===0&&(d.push(s),f.push(f[0])),a.push(new Mp(".morphTargetInfluences["+t[c].name+"]",d,f).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let c=0,d=e.length;c<d;c++){const f=e[c],p=f.name.match(s);if(p&&p.length>1){const g=p[1];let v=r[g];v||(r[g]=v=[]),v.push(f)}}const a=[];for(const c in r)a.push(this.CreateFromMorphTargetSequence(c,r[c],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(g,v,y,E,T){if(y.length!==0){const w=[],_=[];Ex(y,w,_,E),w.length!==0&&T.push(new g(v,w,_))}},r=[],s=e.name||"default",a=e.fps||30,c=e.blendMode;let d=e.length||-1;const f=e.hierarchy||[];for(let g=0;g<f.length;g++){const v=f[g].keys;if(!(!v||v.length===0))if(v[0].morphTargets){const y={};let E;for(E=0;E<v.length;E++)if(v[E].morphTargets)for(let T=0;T<v[E].morphTargets.length;T++)y[v[E].morphTargets[T]]=-1;for(const T in y){const w=[],_=[];for(let C=0;C!==v[E].morphTargets.length;++C){const b=v[E];w.push(b.time),_.push(b.morphTarget===T?1:0)}r.push(new Mp(".morphTargetInfluence["+T+"]",w,_))}d=y.length*a}else{const y=".bones["+t[g].name+"]";n(wp,y+".position",v,"pos",r),n(Vp,y+".quaternion",v,"rot",r),n(wp,y+".scale",v,"scl",r)}}return r.length===0?null:new this(s,d,r,c)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function _2(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Mp;case"vector":case"vector2":case"vector3":case"vector4":return wp;case"color":return wx;case"quaternion":return Vp;case"bool":case"boolean":return Fu;case"string":return Bu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function y2(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=_2(i.type);if(i.times===void 0){const t=[],n=[];Ex(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const nl={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class f0{constructor(e,t,n){const r=this;let s=!1,a=0,c=0,d;const f=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(p){c++,s===!1&&r.onStart!==void 0&&r.onStart(p,a,c),s=!0},this.itemEnd=function(p){a++,r.onProgress!==void 0&&r.onProgress(p,a,c),a===c&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(p){r.onError!==void 0&&r.onError(p)},this.resolveURL=function(p){return d?d(p):p},this.setURLModifier=function(p){return d=p,this},this.addHandler=function(p,g){return f.push(p,g),this},this.removeHandler=function(p){const g=f.indexOf(p);return g!==-1&&f.splice(g,2),this},this.getHandler=function(p){for(let g=0,v=f.length;g<v;g+=2){const y=f[g],E=f[g+1];if(y.global&&(y.lastIndex=0),y.test(p))return E}return null}}}const Zw=new f0;class as{constructor(e){this.manager=e!==void 0?e:Zw,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}as.DEFAULT_MATERIAL_NAME="__DEFAULT";const $a={};class x2 extends Error{constructor(e,t){super(e),this.response=t}}class Hs extends as{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=nl.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if($a[e]!==void 0){$a[e].push({onLoad:t,onProgress:n,onError:r});return}$a[e]=[],$a[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),c=this.mimeType,d=this.responseType;fetch(a).then(f=>{if(f.status===200||f.status===0){if(f.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||f.body===void 0||f.body.getReader===void 0)return f;const p=$a[e],g=f.body.getReader(),v=f.headers.get("X-File-Size")||f.headers.get("Content-Length"),y=v?parseInt(v):0,E=y!==0;let T=0;const w=new ReadableStream({start(_){C();function C(){g.read().then(({done:b,value:I})=>{if(b)_.close();else{T+=I.byteLength;const N=new ProgressEvent("progress",{lengthComputable:E,loaded:T,total:y});for(let O=0,H=p.length;O<H;O++){const B=p[O];B.onProgress&&B.onProgress(N)}_.enqueue(I),C()}},b=>{_.error(b)})}}});return new Response(w)}else throw new x2(`fetch for "${f.url}" responded with ${f.status}: ${f.statusText}`,f)}).then(f=>{switch(d){case"arraybuffer":return f.arrayBuffer();case"blob":return f.blob();case"document":return f.text().then(p=>new DOMParser().parseFromString(p,c));case"json":return f.json();default:if(c===void 0)return f.text();{const g=/charset="?([^;"\s]*)"?/i.exec(c),v=g&&g[1]?g[1].toLowerCase():void 0,y=new TextDecoder(v);return f.arrayBuffer().then(E=>y.decode(E))}}}).then(f=>{nl.add(e,f);const p=$a[e];delete $a[e];for(let g=0,v=p.length;g<v;g++){const y=p[g];y.onLoad&&y.onLoad(f)}}).catch(f=>{const p=$a[e];if(p===void 0)throw this.manager.itemError(e),f;delete $a[e];for(let g=0,v=p.length;g<v;g++){const y=p[g];y.onError&&y.onError(f)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class S2 extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Hs(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{t(s.parse(JSON.parse(c)))}catch(d){r?r(d):console.error(d),s.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=Tp.parse(e[n]);t.push(r)}return t}}class E2 extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=[],c=new $v,d=new Hs(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(s.withCredentials);let f=0;function p(g){d.load(e[g],function(v){const y=s.parse(v,!0);a[g]={width:y.width,height:y.height,format:y.format,mipmaps:y.mipmaps},f+=1,f===6&&(y.mipmapCount===1&&(c.minFilter=On),c.image=a,c.format=y.format,c.needsUpdate=!0,t&&t(c))},n,r)}if(Array.isArray(e))for(let g=0,v=e.length;g<v;++g)p(g);else d.load(e,function(g){const v=s.parse(g,!0);if(v.isCubemap){const y=v.mipmaps.length/v.mipmapCount;for(let E=0;E<y;E++){a[E]={mipmaps:[]};for(let T=0;T<v.mipmapCount;T++)a[E].mipmaps.push(v.mipmaps[E*v.mipmapCount+T]),a[E].format=v.format,a[E].width=v.width,a[E].height=v.height}c.image=a}else c.image.width=v.width,c.image.height=v.height,c.mipmaps=v.mipmaps;v.mipmapCount===1&&(c.minFilter=On),c.format=v.format,c.needsUpdate=!0,t&&t(c)},n,r);return c}}class Ap extends as{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=nl.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const c=vp("img");function d(){p(),nl.add(e,this),t&&t(this),s.manager.itemEnd(e)}function f(g){p(),r&&r(g),s.manager.itemError(e),s.manager.itemEnd(e)}function p(){c.removeEventListener("load",d,!1),c.removeEventListener("error",f,!1)}return c.addEventListener("load",d,!1),c.addEventListener("error",f,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(c.crossOrigin=this.crossOrigin),s.manager.itemStart(e),c.src=e,c}}class qw extends as{constructor(e){super(e)}load(e,t,n,r){const s=new Up;s.colorSpace=kn;const a=new Ap(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let c=0;function d(f){a.load(e[f],function(p){s.images[f]=p,c++,c===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let f=0;f<e.length;++f)d(f);return s}}class Tx extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new ko,c=new Hs(this.manager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(s.withCredentials),c.load(e,function(d){let f;try{f=s.parse(d)}catch(p){if(r!==void 0)r(p);else{console.error(p);return}}f.image!==void 0?a.image=f.image:f.data!==void 0&&(a.image.width=f.width,a.image.height=f.height,a.image.data=f.data),a.wrapS=f.wrapS!==void 0?f.wrapS:ji,a.wrapT=f.wrapT!==void 0?f.wrapT:ji,a.magFilter=f.magFilter!==void 0?f.magFilter:On,a.minFilter=f.minFilter!==void 0?f.minFilter:On,a.anisotropy=f.anisotropy!==void 0?f.anisotropy:1,f.colorSpace!==void 0&&(a.colorSpace=f.colorSpace),f.flipY!==void 0&&(a.flipY=f.flipY),f.format!==void 0&&(a.format=f.format),f.type!==void 0&&(a.type=f.type),f.mipmaps!==void 0&&(a.mipmaps=f.mipmaps,a.minFilter=ca),f.mipmapCount===1&&(a.minFilter=On),f.generateMipmaps!==void 0&&(a.generateMipmaps=f.generateMipmaps),a.needsUpdate=!0,t&&t(a,f)},n,r),a}}class M2 extends as{constructor(e){super(e)}load(e,t,n,r){const s=new Wn,a=new Ap(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(c){s.image=c,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class dc extends Cn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Kw extends dc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new yt(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const L_=new qt,T1=new X,A1=new X;class Ax{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.map=null,this.mapPass=null,this.matrix=new qt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Op,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new _n(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;T1.setFromMatrixPosition(e.matrixWorld),t.position.copy(T1),A1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(A1),t.updateMatrixWorld(),L_.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(L_),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(L_)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class w2 extends Ax{constructor(){super(new Di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=xd*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Qw extends dc{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new w2}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const C1=new qt,Ff=new X,D_=new X;class T2 extends Ax{constructor(){super(new Di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ke(4,2),this._viewportCount=6,this._viewports=[new _n(2,1,1,1),new _n(0,1,1,1),new _n(3,1,1,1),new _n(1,1,1,1),new _n(3,0,1,1),new _n(1,0,1,1)],this._cubeDirections=[new X(1,0,0),new X(-1,0,0),new X(0,0,1),new X(0,0,-1),new X(0,1,0),new X(0,-1,0)],this._cubeUps=[new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,0,1),new X(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ff.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ff),D_.copy(n.position),D_.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(D_),n.updateMatrixWorld(),r.makeTranslation(-Ff.x,-Ff.y,-Ff.z),C1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(C1)}}class Jw extends dc{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new T2}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ul extends Np{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,c=r+t,d=r-t;if(this.view!==null&&this.view.enabled){const f=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=f*this.view.offsetX,a=s+f*this.view.width,c-=p*this.view.offsetY,d=c-p*this.view.height}this.projectionMatrix.makeOrthographic(s,a,c,d,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class A2 extends Ax{constructor(){super(new ul(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class $w extends dc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.shadow=new A2}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class eT extends dc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class tT extends dc{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class nT{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new X)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}}class iT extends dc{constructor(e=new nT,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class p0 extends as{constructor(e){super(e),this.textures={}}load(e,t,n,r){const s=this,a=new Hs(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(JSON.parse(c)))}catch(d){r?r(d):console.error(d),s.manager.itemError(e)}},n,r)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new yt().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=n(a.value);break;case"c":r.uniforms[s].value=new yt().setHex(a.value);break;case"v2":r.uniforms[s].value=new ke().fromArray(a.value);break;case"v3":r.uniforms[s].value=new X().fromArray(a.value);break;case"v4":r.uniforms[s].value=new _n().fromArray(a.value);break;case"m3":r.uniforms[s].value=new pn().fromArray(a.value);break;case"m4":r.uniforms[s].value=new qt().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new ke().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return p0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:Uw,SpriteMaterial:cx,RawShaderMaterial:Ow,ShaderMaterial:li,PointsMaterial:hx,MeshPhysicalMaterial:Fw,MeshStandardMaterial:Ou,MeshPhongMaterial:Bw,MeshToonMaterial:zw,MeshNormalMaterial:yx,MeshLambertMaterial:kw,MeshDepthMaterial:xx,MeshDistanceMaterial:Sx,MeshBasicMaterial:ll,MeshMatcapMaterial:Hw,LineDashedMaterial:Vw,LineBasicMaterial:os,Material:pr};return new t[e]}}class Iy{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Cx extends yn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rT extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Hs(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(JSON.parse(c)))}catch(d){r?r(d):console.error(d),s.manager.itemError(e)}},n,r)}parse(e){const t={},n={};function r(y,E){if(t[E]!==void 0)return t[E];const w=y.interleavedBuffers[E],_=s(y,w.buffer),C=hd(w.type,_),b=new Qv(C,w.stride);return b.uuid=w.uuid,t[E]=b,b}function s(y,E){if(n[E]!==void 0)return n[E];const w=y.arrayBuffers[E],_=new Uint32Array(w).buffer;return n[E]=_,_}const a=e.isInstancedBufferGeometry?new Cx:new yn,c=e.data.index;if(c!==void 0){const y=hd(c.type,c.array);a.setIndex(new jn(y,1))}const d=e.data.attributes;for(const y in d){const E=d[y];let T;if(E.isInterleavedBufferAttribute){const w=r(e.data,E.data);T=new zs(w,E.itemSize,E.offset,E.normalized)}else{const w=hd(E.type,E.array),_=E.isInstancedBufferAttribute?Nu:jn;T=new _(w,E.itemSize,E.normalized)}E.name!==void 0&&(T.name=E.name),E.usage!==void 0&&T.setUsage(E.usage),a.setAttribute(y,T)}const f=e.data.morphAttributes;if(f)for(const y in f){const E=f[y],T=[];for(let w=0,_=E.length;w<_;w++){const C=E[w];let b;if(C.isInterleavedBufferAttribute){const I=r(e.data,C.data);b=new zs(I,C.itemSize,C.offset,C.normalized)}else{const I=hd(C.type,C.array);b=new jn(I,C.itemSize,C.normalized)}C.name!==void 0&&(b.name=C.name),T.push(b)}a.morphAttributes[y]=T}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const g=e.data.groups||e.data.drawcalls||e.data.offsets;if(g!==void 0)for(let y=0,E=g.length;y!==E;++y){const T=g[y];a.addGroup(T.start,T.count,T.materialIndex)}const v=e.data.boundingSphere;if(v!==void 0){const y=new X;v.center!==void 0&&y.fromArray(v.center),a.boundingSphere=new rr(y,v.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class C2 extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=this.path===""?Iy.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const c=new Hs(this.manager);c.setPath(this.path),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(d){let f=null;try{f=JSON.parse(d)}catch(g){r!==void 0&&r(g),console.error("THREE:ObjectLoader: Can't parse "+e+".",g.message);return}const p=f.metadata;if(p===void 0||p.type===void 0||p.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(f,t)},n,r)}async loadAsync(e,t){const n=this,r=this.path===""?Iy.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Hs(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),c=JSON.parse(a),d=c.metadata;if(d===void 0||d.type===void 0||d.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(c)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(f)}),c=this.parseTextures(e.textures,a),d=this.parseMaterials(e.materials,c),f=this.parseObject(e.object,s,d,c,n),p=this.parseSkeletons(e.skeletons,f);if(this.bindSkeletons(f,p),this.bindLightTargets(f),t!==void 0){let g=!1;for(const v in a)if(a[v].data instanceof HTMLImageElement){g=!0;break}g===!1&&t(f)}return f}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),c=this.parseMaterials(e.materials,a),d=this.parseObject(e.object,r,c,a,t),f=this.parseSkeletons(e.skeletons,d);return this.bindSkeletons(d,f),this.bindLightTargets(d),d}parseShapes(e){const t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){const s=new Iu().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const c=new Jv().fromJSON(e[s],r);n[c.uuid]=c}return n}parseGeometries(e,t){const n={};if(e!==void 0){const r=new rT;for(let s=0,a=e.length;s<a;s++){let c;const d=e[s];switch(d.type){case"BufferGeometry":case"InstancedBufferGeometry":c=r.parse(d);break;default:d.type in w1?c=w1[d.type].fromJSON(d,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${d.type}"`)}c.uuid=d.uuid,d.name!==void 0&&(c.name=d.name),d.userData!==void 0&&(c.userData=d.userData),n[d.uuid]=c}}return n}parseMaterials(e,t){const n={},r={};if(e!==void 0){const s=new p0;s.setTextures(t);for(let a=0,c=e.length;a<c;a++){const d=e[a];n[d.uuid]===void 0&&(n[d.uuid]=s.parse(d)),r[d.uuid]=n[d.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const r=e[n],s=Tp.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const n=this,r={};let s;function a(d){return n.manager.itemStart(d),s.load(d,function(){n.manager.itemEnd(d)},void 0,function(){n.manager.itemError(d),n.manager.itemEnd(d)})}function c(d){if(typeof d=="string"){const f=d,p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(f)?f:n.resourcePath+f;return a(p)}else return d.data?{data:hd(d.type,d.data),width:d.width,height:d.height}:null}if(e!==void 0&&e.length>0){const d=new f0(t);s=new Ap(d),s.setCrossOrigin(this.crossOrigin);for(let f=0,p=e.length;f<p;f++){const g=e[f],v=g.url;if(Array.isArray(v)){const y=[];for(let E=0,T=v.length;E<T;E++){const w=v[E],_=c(w);_!==null&&(_ instanceof HTMLImageElement?y.push(_):y.push(new ko(_.data,_.width,_.height)))}r[g.uuid]=new Eu(y)}else{const y=c(g.url);r[g.uuid]=new Eu(y)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function s(a){if(typeof a=="string"){const c=a,d=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:t.resourcePath+c;return await r.loadAsync(d)}else return a.data?{data:hd(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Ap(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,c=e.length;a<c;a++){const d=e[a],f=d.url;if(Array.isArray(f)){const p=[];for(let g=0,v=f.length;g<v;g++){const y=f[g],E=await s(y);E!==null&&(E instanceof HTMLImageElement?p.push(E):p.push(new ko(E.data,E.width,E.height)))}n[d.uuid]=new Eu(p)}else{const p=await s(d.url);n[d.uuid]=new Eu(p)}}}return n}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const c=e[s];c.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',c.uuid),t[c.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",c.image);const d=t[c.image],f=d.data;let p;Array.isArray(f)?(p=new Up,f.length===6&&(p.needsUpdate=!0)):(f&&f.data?p=new ko:p=new Wn,f&&(p.needsUpdate=!0)),p.source=d,p.uuid=c.uuid,c.name!==void 0&&(p.name=c.name),c.mapping!==void 0&&(p.mapping=n(c.mapping,b2)),c.channel!==void 0&&(p.channel=c.channel),c.offset!==void 0&&p.offset.fromArray(c.offset),c.repeat!==void 0&&p.repeat.fromArray(c.repeat),c.center!==void 0&&p.center.fromArray(c.center),c.rotation!==void 0&&(p.rotation=c.rotation),c.wrap!==void 0&&(p.wrapS=n(c.wrap[0],b1),p.wrapT=n(c.wrap[1],b1)),c.format!==void 0&&(p.format=c.format),c.internalFormat!==void 0&&(p.internalFormat=c.internalFormat),c.type!==void 0&&(p.type=c.type),c.colorSpace!==void 0&&(p.colorSpace=c.colorSpace),c.minFilter!==void 0&&(p.minFilter=n(c.minFilter,R1)),c.magFilter!==void 0&&(p.magFilter=n(c.magFilter,R1)),c.anisotropy!==void 0&&(p.anisotropy=c.anisotropy),c.flipY!==void 0&&(p.flipY=c.flipY),c.generateMipmaps!==void 0&&(p.generateMipmaps=c.generateMipmaps),c.premultiplyAlpha!==void 0&&(p.premultiplyAlpha=c.premultiplyAlpha),c.unpackAlignment!==void 0&&(p.unpackAlignment=c.unpackAlignment),c.compareFunction!==void 0&&(p.compareFunction=c.compareFunction),c.userData!==void 0&&(p.userData=c.userData),r[c.uuid]=p}return r}parseObject(e,t,n,r,s){let a;function c(v){return t[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",v),t[v]}function d(v){if(v!==void 0){if(Array.isArray(v)){const y=[];for(let E=0,T=v.length;E<T;E++){const w=v[E];n[w]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",w),y.push(n[w])}return y}return n[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",v),n[v]}}function f(v){return r[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",v),r[v]}let p,g;switch(e.type){case"Scene":a=new Du,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new yt(e.background):a.background=f(e.background)),e.environment!==void 0&&(a.environment=f(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Kv(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new qv(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new Di(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new ul(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new eT(e.color,e.intensity);break;case"DirectionalLight":a=new $w(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Jw(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new tT(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Qw(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new Kw(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new iT().fromJSON(e);break;case"SkinnedMesh":p=c(e.geometry),g=d(e.material),a=new Ew(p,g),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":p=c(e.geometry),g=d(e.material),a=new fi(p,g);break;case"InstancedMesh":p=c(e.geometry),g=d(e.material);const v=e.count,y=e.instanceMatrix,E=e.instanceColor;a=new Ed(p,g,v),a.instanceMatrix=new Nu(new Float32Array(y.array),16),E!==void 0&&(a.instanceColor=new Nu(new Float32Array(E.array),E.itemSize));break;case"BatchedMesh":p=c(e.geometry),g=d(e.material),a=new Mw(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,g),a.geometry=p,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(T=>{const w=new ir;w.min.fromArray(T.boxMin),w.max.fromArray(T.boxMax);const _=new rr;return _.radius=T.sphereRadius,_.center.fromArray(T.sphereCenter),{boxInitialized:T.boxInitialized,box:w,sphereInitialized:T.sphereInitialized,sphere:_}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=f(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=f(e.colorsTexture.uuid));break;case"LOD":a=new Sw;break;case"Line":a=new sc(c(e.geometry),d(e.material));break;case"LineLoop":a=new ww(c(e.geometry),d(e.material));break;case"LineSegments":a=new pa(c(e.geometry),d(e.material));break;case"PointCloud":case"Points":a=new Tw(c(e.geometry),d(e.material));break;case"Sprite":a=new xw(d(e.material));break;case"Group":a=new dd;break;case"Bone":a=new ux;break;default:a=new Cn}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const v=e.children;for(let y=0;y<v.length;y++)a.add(this.parseObject(v[y],t,n,r,s))}if(e.animations!==void 0){const v=e.animations;for(let y=0;y<v.length;y++){const E=v[y];a.animations.push(s[E])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const v=e.levels;for(let y=0;y<v.length;y++){const E=v[y],T=a.getObjectByProperty("uuid",E.object);T!==void 0&&a.addLevel(T,E.distance,E.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const r=t[n.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new Cn}})}}const b2={UVMapping:tc,CubeReflectionMapping:da,CubeRefractionMapping:nc,EquirectangularReflectionMapping:_d,EquirectangularRefractionMapping:cp,CubeUVReflectionMapping:Ad},b1={RepeatWrapping:up,ClampToEdgeWrapping:ji,MirroredRepeatWrapping:hp},R1={NearestFilter:Ui,NearestMipmapNearestFilter:qy,NearestMipmapLinearFilter:ud,LinearFilter:On,LinearMipmapNearestFilter:Jf,LinearMipmapLinearFilter:ca};class R2 extends as{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=nl.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(f=>{t&&t(f),s.manager.itemEnd(e)}).catch(f=>{r&&r(f)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",c.headers=this.requestHeader;const d=fetch(e,c).then(function(f){return f.blob()}).then(function(f){return createImageBitmap(f,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(f){return nl.add(e,f),t&&t(f),s.manager.itemEnd(e),f}).catch(function(f){r&&r(f),nl.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});nl.add(e,d),s.manager.itemStart(e)}}let Sg;class bx{static getContext(){return Sg===void 0&&(Sg=new(window.AudioContext||window.webkitAudioContext)),Sg}static setContext(e){Sg=e}}class I2 extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Hs(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(d){try{const f=d.slice(0);bx.getContext().decodeAudioData(f,function(g){t(g)}).catch(c)}catch(f){c(f)}},n,r);function c(d){r?r(d):console.error(d),s.manager.itemError(e)}}}const I1=new qt,P1=new qt,ou=new qt;class P2{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Di,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,ou.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(bu*t.fov*.5)/t.zoom;let c,d;P1.elements[12]=-r,I1.elements[12]=r,c=-a*t.aspect+s,d=a*t.aspect+s,ou.elements[0]=2*t.near/(d-c),ou.elements[8]=(d+c)/(d-c),this.cameraL.projectionMatrix.copy(ou),c=-a*t.aspect-s,d=a*t.aspect-s,ou.elements[0]=2*t.near/(d-c),ou.elements[8]=(d+c)/(d-c),this.cameraR.projectionMatrix.copy(ou)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(P1),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(I1)}}class sT extends Di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Rx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=L1(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=L1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function L1(){return performance.now()}const au=new X,D1=new ss,L2=new X,lu=new X;class D2 extends Cn{constructor(){super(),this.type="AudioListener",this.context=bx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Rx}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(au,D1,L2),lu.set(0,0,-1).applyQuaternion(D1),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(au.x,r),t.positionY.linearRampToValueAtTime(au.y,r),t.positionZ.linearRampToValueAtTime(au.z,r),t.forwardX.linearRampToValueAtTime(lu.x,r),t.forwardY.linearRampToValueAtTime(lu.y,r),t.forwardZ.linearRampToValueAtTime(lu.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(au.x,au.y,au.z),t.setOrientation(lu.x,lu.y,lu.z,n.x,n.y,n.z)}}class oT extends Cn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const cu=new X,N1=new ss,N2=new X,uu=new X;class U2 extends oT{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(cu,N1,N2),uu.set(0,0,1).applyQuaternion(N1);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(cu.x,n),t.positionY.linearRampToValueAtTime(cu.y,n),t.positionZ.linearRampToValueAtTime(cu.z,n),t.orientationX.linearRampToValueAtTime(uu.x,n),t.orientationY.linearRampToValueAtTime(uu.y,n),t.orientationZ.linearRampToValueAtTime(uu.z,n)}else t.setPosition(cu.x,cu.y,cu.z),t.setOrientation(uu.x,uu.y,uu.z)}}class O2{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class aT{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let c=0;c!==r;++c)n[s+c]=n[c];a=t}else{a+=t;const c=t/a;this._mixBufferRegion(n,s,0,c,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const d=t*this._origIndex;this._mixBufferRegion(n,r,d,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let d=t,f=t+t;d!==f;++d)if(n[d]!==n[d+t]){c.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){ss.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){const a=this._workIndex*s;ss.multiplyQuaternionsFlat(e,a,e,t,e,n),ss.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){const a=1-r;for(let c=0;c!==s;++c){const d=t+c;e[d]=e[d]*a+e[n+c]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){const c=t+a;e[c]=e[c]+e[n+a]*r}}}const Ix="\\[\\]\\.:\\/",F2=new RegExp("["+Ix+"]","g"),Px="[^"+Ix+"]",B2="[^"+Ix.replace("\\.","")+"]",z2=/((?:WC+[\/:])*)/.source.replace("WC",Px),k2=/(WCOD+)?/.source.replace("WCOD",B2),H2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Px),V2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Px),G2=new RegExp("^"+z2+k2+H2+V2+"$"),W2=["material","materials","bones","map"];class j2{constructor(e,t,n){const r=n||Un.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Un{constructor(e,t,n){this.path=t,this.parsedPath=n||Un.parseTrackName(t),this.node=Un.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Un.Composite(e,t,n):new Un(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(F2,"")}static parseTrackName(e){const t=G2.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);W2.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const c=s[a];if(c.name===t||c.uuid===t)return c;const d=n(c.children);if(d)return d}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Un.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let f=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let p=0;p<e.length;p++)if(e[p].name===f){f=p;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(f!==void 0){if(e[f]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[f]}}const a=e[r];if(a===void 0){const f=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+f+"."+r+" but it wasn't found.",e);return}let c=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?c=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(c=this.Versioning.MatrixWorldNeedsUpdate);let d=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}d=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(d=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(d=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[d],this.setValue=this.SetterByBindingTypeAndVersioning[d][c]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Un.Composite=j2;Un.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Un.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Un.prototype.GetterByBindingType=[Un.prototype._getValue_direct,Un.prototype._getValue_array,Un.prototype._getValue_arrayElement,Un.prototype._getValue_toArray];Un.prototype.SetterByBindingTypeAndVersioning=[[Un.prototype._setValue_direct,Un.prototype._setValue_direct_setNeedsUpdate,Un.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Un.prototype._setValue_array,Un.prototype._setValue_array_setNeedsUpdate,Un.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Un.prototype._setValue_arrayElement,Un.prototype._setValue_arrayElement_setNeedsUpdate,Un.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Un.prototype._setValue_fromArray,Un.prototype._setValue_fromArray_setNeedsUpdate,Un.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class X2{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ks(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let c,d=e.length,f=this.nCachedObjects_;for(let p=0,g=arguments.length;p!==g;++p){const v=arguments[p],y=v.uuid;let E=t[y];if(E===void 0){E=d++,t[y]=E,e.push(v);for(let T=0,w=a;T!==w;++T)s[T].push(new Un(v,n[T],r[T]))}else if(E<f){c=e[E];const T=--f,w=e[T];t[w.uuid]=E,e[E]=w,t[y]=T,e[T]=v;for(let _=0,C=a;_!==C;++_){const b=s[_],I=b[T];let N=b[E];b[E]=I,N===void 0&&(N=new Un(v,n[_],r[_])),b[T]=N}}else e[E]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=f}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_;for(let a=0,c=arguments.length;a!==c;++a){const d=arguments[a],f=d.uuid,p=t[f];if(p!==void 0&&p>=s){const g=s++,v=e[g];t[v.uuid]=p,e[p]=v,t[f]=g,e[g]=d;for(let y=0,E=r;y!==E;++y){const T=n[y],w=T[g],_=T[p];T[p]=w,T[g]=_}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_,a=e.length;for(let c=0,d=arguments.length;c!==d;++c){const f=arguments[c],p=f.uuid,g=t[p];if(g!==void 0)if(delete t[p],g<s){const v=--s,y=e[v],E=--a,T=e[E];t[y.uuid]=g,e[g]=y,t[T.uuid]=v,e[v]=T,e.pop();for(let w=0,_=r;w!==_;++w){const C=n[w],b=C[v],I=C[E];C[g]=b,C[v]=I,C.pop()}}else{const v=--a,y=e[v];v>0&&(t[y.uuid]=g),e[g]=y,e.pop();for(let E=0,T=r;E!==T;++E){const w=n[E];w[g]=w[v],w.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,c=this._parsedPaths,d=this._objects,f=d.length,p=this.nCachedObjects_,g=new Array(f);r=s.length,n[e]=r,a.push(e),c.push(t),s.push(g);for(let v=p,y=d.length;v!==y;++v){const E=d[v];g[v]=new Un(E,e,t)}return g}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,c=a.length-1,d=a[c],f=e[c];t[f]=n,a[n]=d,a.pop(),s[n]=s[c],s.pop(),r[n]=r[c],r.pop()}}}class lT{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const s=t.tracks,a=s.length,c=new Array(a),d={endingStart:xu,endingEnd:xu};for(let f=0;f!==a;++f){const p=s[f].createInterpolant(null);c[f]=p,p.settings=d}this._interpolantSettings=d,this._interpolants=c,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=nw,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const r=this._clip.duration,s=e._clip.duration,a=s/r,c=r/s;e.warp(1,a,t),this.warp(c,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,s=r.time,a=this.timeScale;let c=this._timeScaleInterpolant;c===null&&(c=r._lendControlInterpolant(),this._timeScaleInterpolant=c);const d=c.parameterPositions,f=c.sampleValues;return d[0]=s,d[1]=s+n,f[0]=e/a,f[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const d=(e-s)*n;d<0||n===0?t=0:(this._startTime=null,t=n*d)}t*=this._updateTimeScale(e);const a=this._updateTime(t),c=this._updateWeight(e);if(c>0){const d=this._interpolants,f=this._propertyBindings;switch(this.blendMode){case ix:for(let p=0,g=d.length;p!==g;++p)d[p].evaluate(a),f[p].accumulateAdditive(c);break;case jv:default:for(let p=0,g=d.length;p!==g;++p)d[p].evaluate(a),f[p].accumulate(r,c)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,s=this._loopCount;const a=n===iw;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===tw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const c=Math.floor(r/t);r-=t*c,s+=Math.abs(c);const d=this.repetitions-s;if(d<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(d===1){const f=e<0;this._setEndings(f,!f,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:c})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=Su,r.endingEnd=Su):(e?r.endingStart=this.zeroSlopeAtStart?Su:xu:r.endingStart=fp,t?r.endingEnd=this.zeroSlopeAtEnd?Su:xu:r.endingEnd=fp)}_scheduleFading(e,t,n){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const c=a.parameterPositions,d=a.sampleValues;return c[0]=s,d[0]=t,c[1]=s+e,d[1]=n,this}}const Y2=new Float32Array(1);class Z2 extends Gs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,c=e._interpolants,d=n.uuid,f=this._bindingsByRootAndName;let p=f[d];p===void 0&&(p={},f[d]=p);for(let g=0;g!==s;++g){const v=r[g],y=v.name;let E=p[y];if(E!==void 0)++E.referenceCount,a[g]=E;else{if(E=a[g],E!==void 0){E._cacheIndex===null&&(++E.referenceCount,this._addInactiveBinding(E,d,y));continue}const T=t&&t._propertyBindings[g].binding.parsedPath;E=new aT(Un.create(n,y,T),v.ValueTypeName,v.getValueSize()),++E.referenceCount,this._addInactiveBinding(E,d,y),a[g]=E}c[g].resultBuffer=E.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const c=a.knownActions;e._byClipCacheIndex=c.length,c.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,c=a[s],d=c.knownActions,f=d[d.length-1],p=e._byClipCacheIndex;f._byClipCacheIndex=p,d[p]=f,d.pop(),e._byClipCacheIndex=null;const g=c.actionByRoot,v=(e._localRoot||this._root).uuid;delete g[v],d.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,c=a[r],d=t[t.length-1],f=e._cacheIndex;d._cacheIndex=f,t[f]=d,t.pop(),delete c[s],Object.keys(c).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Mx(new Float32Array(2),new Float32Array(2),1,Y2),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?Tp.findByName(r,e):e;const c=a!==null?a.uuid:e,d=this._actionsByClip[c];let f=null;if(n===void 0&&(a!==null?n=a.blendMode:n=jv),d!==void 0){const g=d.actionByRoot[s];if(g!==void 0&&g.blendMode===n)return g;f=d.knownActions[0],a===null&&(a=f._clip)}if(a===null)return null;const p=new lT(this,a,t,n);return this._bindAction(p,f),this._addInactiveAction(p,c,s),p}existingAction(e,t){const n=t||this._root,r=n.uuid,s=typeof e=="string"?Tp.findByName(n,e):e,a=s?s.uuid:e,c=this._actionsByClip[a];return c!==void 0&&c.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let f=0;f!==n;++f)t[f]._update(r,e,s,a);const c=this._bindings,d=this._nActiveBindings;for(let f=0;f!==d;++f)c[f].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){const a=s.knownActions;for(let c=0,d=a.length;c!==d;++c){const f=a[c];this._deactivateAction(f);const p=f._cacheIndex,g=t[t.length-1];f._cacheIndex=null,f._byClipCacheIndex=null,g._cacheIndex=p,t[p]=g,t.pop(),this._removeInactiveBindingsForAction(f)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const c=n[a].actionByRoot,d=c[t];d!==void 0&&(this._deactivateAction(d),this._removeInactiveAction(d))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const c=s[a];c.restoreOriginalState(),this._removeInactiveBinding(c)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class q2 extends Yv{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Zv(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class K2 extends Yv{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTargetArray=!0,this.depth=n,this.texture=new Dp(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class bn{constructor(e){this.value=e}clone(){return new bn(this.value.clone===void 0?this.value:this.value.clone())}}let Q2=0;class J2 extends Gs{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Q2++}),this.name="",this.usage=mp,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){const s=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Lv extends Qv{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class $2{constructor(e,t,n,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const U1=new qt;class m0{constructor(e,t,n=0,r=1/0){this.ray=new Cd(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Ru,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return U1.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(U1),this}intersectObject(e,t=!0,n=[]){return Py(e,this,n,t),n.sort(O1),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Py(e[r],this,n,t);return n.sort(O1),n}}function O1(i,e){return i.distance-e.distance}function Py(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,c=s.length;a<c;a++)Py(s[a],e,t,!0)}}class cT{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=un(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(un(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class eR{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Lx{constructor(e,t,n,r){Lx.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}}const F1=new ke;class tR{constructor(e=new ke(1/0,1/0),t=new ke(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=F1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,F1).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const B1=new X,Eg=new X;class uT{constructor(e=new X,t=new X){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){B1.subVectors(e,this.start),Eg.subVectors(this.end,this.start);const n=Eg.dot(Eg);let s=Eg.dot(B1)/n;return t&&(s=un(s,0,1)),s}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const z1=new X;class nR extends Cn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new yn,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,c=1,d=32;a<d;a++,c++){const f=a/d*Math.PI*2,p=c/d*Math.PI*2;r.push(Math.cos(f),Math.sin(f),1,Math.cos(p),Math.sin(p),1)}n.setAttribute("position",new Ut(r,3));const s=new os({fog:!1,toneMapped:!1});this.cone=new pa(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),z1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(z1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Yl=new X,Mg=new qt,N_=new qt;class iR extends pa{constructor(e){const t=hT(e),n=new yn,r=[],s=[],a=new yt(0,0,1),c=new yt(0,1,0);for(let f=0;f<t.length;f++){const p=t[f];p.parent&&p.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(c.r,c.g,c.b))}n.setAttribute("position",new Ut(r,3)),n.setAttribute("color",new Ut(s,3));const d=new os({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,d),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");N_.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const c=t[s];c.parent&&c.parent.isBone&&(Mg.multiplyMatrices(N_,c.matrixWorld),Yl.setFromMatrixPosition(Mg),r.setXYZ(a,Yl.x,Yl.y,Yl.z),Mg.multiplyMatrices(N_,c.parent.matrixWorld),Yl.setFromMatrixPosition(Mg),r.setXYZ(a+1,Yl.x,Yl.y,Yl.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function hT(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push.apply(e,hT(i.children[t]));return e}class rR extends fi{constructor(e,t,n){const r=new bd(t,4,2),s=new ll({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const sR=new X,k1=new yt,H1=new yt;class oR extends Cn{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const r=new kp(t);r.rotateY(Math.PI*.5),this.material=new ll({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new jn(a,3)),this.add(new fi(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");k1.copy(this.light.color),H1.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){const s=n<r/2?k1:H1;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(sR.setFromMatrixPosition(this.light.matrixWorld).negate())}}class aR extends pa{constructor(e=10,t=10,n=4473924,r=8947848){n=new yt(n),r=new yt(r);const s=t/2,a=e/t,c=e/2,d=[],f=[];for(let v=0,y=0,E=-c;v<=t;v++,E+=a){d.push(-c,0,E,c,0,E),d.push(E,0,-c,E,0,c);const T=v===s?n:r;T.toArray(f,y),y+=3,T.toArray(f,y),y+=3,T.toArray(f,y),y+=3,T.toArray(f,y),y+=3}const p=new yn;p.setAttribute("position",new Ut(d,3)),p.setAttribute("color",new Ut(f,3));const g=new os({vertexColors:!0,toneMapped:!1});super(p,g),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class lR extends pa{constructor(e=10,t=16,n=8,r=64,s=4473924,a=8947848){s=new yt(s),a=new yt(a);const c=[],d=[];if(t>1)for(let g=0;g<t;g++){const v=g/t*(Math.PI*2),y=Math.sin(v)*e,E=Math.cos(v)*e;c.push(0,0,0),c.push(y,0,E);const T=g&1?s:a;d.push(T.r,T.g,T.b),d.push(T.r,T.g,T.b)}for(let g=0;g<n;g++){const v=g&1?s:a,y=e-e/n*g;for(let E=0;E<r;E++){let T=E/r*(Math.PI*2),w=Math.sin(T)*y,_=Math.cos(T)*y;c.push(w,0,_),d.push(v.r,v.g,v.b),T=(E+1)/r*(Math.PI*2),w=Math.sin(T)*y,_=Math.cos(T)*y,c.push(w,0,_),d.push(v.r,v.g,v.b)}}const f=new yn;f.setAttribute("position",new Ut(c,3)),f.setAttribute("color",new Ut(d,3));const p=new os({vertexColors:!0,toneMapped:!1});super(f,p),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const V1=new X,wg=new X,G1=new X;class cR extends Cn{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new yn;r.setAttribute("position",new Ut([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new os({fog:!1,toneMapped:!1});this.lightPlane=new sc(r,s),this.add(this.lightPlane),r=new yn,r.setAttribute("position",new Ut([0,0,0,0,0,1],3)),this.targetLine=new sc(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),V1.setFromMatrixPosition(this.light.matrixWorld),wg.setFromMatrixPosition(this.light.target.matrixWorld),G1.subVectors(wg,V1),this.lightPlane.lookAt(wg),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(wg),this.targetLine.scale.z=G1.length()}}const Tg=new X,bi=new Np;class uR extends pa{constructor(e){const t=new yn,n=new os({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};c("n1","n2"),c("n2","n4"),c("n4","n3"),c("n3","n1"),c("f1","f2"),c("f2","f4"),c("f4","f3"),c("f3","f1"),c("n1","f1"),c("n2","f2"),c("n3","f3"),c("n4","f4"),c("p","n1"),c("p","n2"),c("p","n3"),c("p","n4"),c("u1","u2"),c("u2","u3"),c("u3","u1"),c("c","t"),c("p","c"),c("cn1","cn2"),c("cn3","cn4"),c("cf1","cf2"),c("cf3","cf4");function c(E,T){d(E),d(T)}function d(E){r.push(0,0,0),s.push(0,0,0),a[E]===void 0&&(a[E]=[]),a[E].push(r.length/3-1)}t.setAttribute("position",new Ut(r,3)),t.setAttribute("color",new Ut(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const f=new yt(16755200),p=new yt(16711680),g=new yt(43775),v=new yt(16777215),y=new yt(3355443);this.setColors(f,p,g,v,y)}setColors(e,t,n,r,s){const c=this.geometry.getAttribute("color");c.setXYZ(0,e.r,e.g,e.b),c.setXYZ(1,e.r,e.g,e.b),c.setXYZ(2,e.r,e.g,e.b),c.setXYZ(3,e.r,e.g,e.b),c.setXYZ(4,e.r,e.g,e.b),c.setXYZ(5,e.r,e.g,e.b),c.setXYZ(6,e.r,e.g,e.b),c.setXYZ(7,e.r,e.g,e.b),c.setXYZ(8,e.r,e.g,e.b),c.setXYZ(9,e.r,e.g,e.b),c.setXYZ(10,e.r,e.g,e.b),c.setXYZ(11,e.r,e.g,e.b),c.setXYZ(12,e.r,e.g,e.b),c.setXYZ(13,e.r,e.g,e.b),c.setXYZ(14,e.r,e.g,e.b),c.setXYZ(15,e.r,e.g,e.b),c.setXYZ(16,e.r,e.g,e.b),c.setXYZ(17,e.r,e.g,e.b),c.setXYZ(18,e.r,e.g,e.b),c.setXYZ(19,e.r,e.g,e.b),c.setXYZ(20,e.r,e.g,e.b),c.setXYZ(21,e.r,e.g,e.b),c.setXYZ(22,e.r,e.g,e.b),c.setXYZ(23,e.r,e.g,e.b),c.setXYZ(24,t.r,t.g,t.b),c.setXYZ(25,t.r,t.g,t.b),c.setXYZ(26,t.r,t.g,t.b),c.setXYZ(27,t.r,t.g,t.b),c.setXYZ(28,t.r,t.g,t.b),c.setXYZ(29,t.r,t.g,t.b),c.setXYZ(30,t.r,t.g,t.b),c.setXYZ(31,t.r,t.g,t.b),c.setXYZ(32,n.r,n.g,n.b),c.setXYZ(33,n.r,n.g,n.b),c.setXYZ(34,n.r,n.g,n.b),c.setXYZ(35,n.r,n.g,n.b),c.setXYZ(36,n.r,n.g,n.b),c.setXYZ(37,n.r,n.g,n.b),c.setXYZ(38,r.r,r.g,r.b),c.setXYZ(39,r.r,r.g,r.b),c.setXYZ(40,s.r,s.g,s.b),c.setXYZ(41,s.r,s.g,s.b),c.setXYZ(42,s.r,s.g,s.b),c.setXYZ(43,s.r,s.g,s.b),c.setXYZ(44,s.r,s.g,s.b),c.setXYZ(45,s.r,s.g,s.b),c.setXYZ(46,s.r,s.g,s.b),c.setXYZ(47,s.r,s.g,s.b),c.setXYZ(48,s.r,s.g,s.b),c.setXYZ(49,s.r,s.g,s.b),c.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,r=1;bi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const s=this.camera.coordinateSystem===Bo?-1:0;Li("c",t,e,bi,0,0,s),Li("t",t,e,bi,0,0,1),Li("n1",t,e,bi,-n,-r,s),Li("n2",t,e,bi,n,-r,s),Li("n3",t,e,bi,-n,r,s),Li("n4",t,e,bi,n,r,s),Li("f1",t,e,bi,-n,-r,1),Li("f2",t,e,bi,n,-r,1),Li("f3",t,e,bi,-n,r,1),Li("f4",t,e,bi,n,r,1),Li("u1",t,e,bi,n*.7,r*1.1,s),Li("u2",t,e,bi,-n*.7,r*1.1,s),Li("u3",t,e,bi,0,r*2,s),Li("cf1",t,e,bi,-n,0,1),Li("cf2",t,e,bi,n,0,1),Li("cf3",t,e,bi,0,-r,1),Li("cf4",t,e,bi,0,r,1),Li("cn1",t,e,bi,-n,0,s),Li("cn2",t,e,bi,n,0,s),Li("cn3",t,e,bi,0,-r,s),Li("cn4",t,e,bi,0,r,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Li(i,e,t,n,r,s,a){Tg.set(r,s,a).unproject(n);const c=e[i];if(c!==void 0){const d=t.getAttribute("position");for(let f=0,p=c.length;f<p;f++)d.setXYZ(c[f],Tg.x,Tg.y,Tg.z)}}const Ag=new ir;class hR extends pa{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new yn;s.setIndex(new jn(n,1)),s.setAttribute("position",new jn(r,3)),super(s,new os({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Ag.setFromObject(this.object),Ag.isEmpty())return;const t=Ag.min,n=Ag.max,r=this.geometry.attributes.position,s=r.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class dR extends pa{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new yn;s.setIndex(new jn(n,1)),s.setAttribute("position",new Ut(r,3)),super(s,new os({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class fR extends sc{constructor(e,t=1,n=16776960){const r=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new yn;a.setAttribute("position",new Ut(s,3)),a.computeBoundingSphere(),super(a,new os({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const c=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],d=new yn;d.setAttribute("position",new Ut(c,3)),d.computeBoundingSphere(),this.add(new fi(d,new ll({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const W1=new X;let Cg,U_;class pR extends Cn{constructor(e=new X(0,0,1),t=new X(0,0,0),n=1,r=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Cg===void 0&&(Cg=new yn,Cg.setAttribute("position",new Ut([0,0,0,0,1,0],3)),U_=new uc(0,.5,1,5,1),U_.translate(0,-.5,0)),this.position.copy(t),this.line=new sc(Cg,new os({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new fi(U_,new ll({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{W1.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(W1,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class mR extends pa{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new yn;r.setAttribute("position",new Ut(t,3)),r.setAttribute("color",new Ut(n,3));const s=new os({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){const r=new yt,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class gR{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new yp,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,a){return this.currentPath.bezierCurveTo(e,t,n,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(_){const C=[];for(let b=0,I=_.length;b<I;b++){const N=_[b],O=new Iu;O.curves=N.curves,C.push(O)}return C}function n(_,C){const b=C.length;let I=!1;for(let N=b-1,O=0;O<b;N=O++){let H=C[N],B=C[O],D=B.x-H.x,U=B.y-H.y;if(Math.abs(U)>Number.EPSILON){if(U<0&&(H=C[O],D=-D,B=C[N],U=-U),_.y<H.y||_.y>B.y)continue;if(_.y===H.y){if(_.x===H.x)return!0}else{const W=U*(_.x-H.x)-D*(_.y-H.y);if(W===0)return!0;if(W<0)continue;I=!I}}else{if(_.y!==H.y)continue;if(B.x<=_.x&&_.x<=H.x||H.x<=_.x&&_.x<=B.x)return!0}}return I}const r=ua.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,c,d;const f=[];if(s.length===1)return c=s[0],d=new Iu,d.curves=c.curves,f.push(d),f;let p=!r(s[0].getPoints());p=e?!p:p;const g=[],v=[];let y=[],E=0,T;v[E]=void 0,y[E]=[];for(let _=0,C=s.length;_<C;_++)c=s[_],T=c.getPoints(),a=r(T),a=e?!a:a,a?(!p&&v[E]&&E++,v[E]={s:new Iu,p:T},v[E].s.curves=c.curves,p&&E++,y[E]=[]):y[E].push({h:c,p:T[0]});if(!v[0])return t(s);if(v.length>1){let _=!1,C=0;for(let b=0,I=v.length;b<I;b++)g[b]=[];for(let b=0,I=v.length;b<I;b++){const N=y[b];for(let O=0;O<N.length;O++){const H=N[O];let B=!0;for(let D=0;D<v.length;D++)n(H.p,v[D].p)&&(b!==D&&C++,B?(B=!1,g[D].push(H)):_=!0);B&&g[b].push(H)}}C>0&&_===!1&&(y=g)}let w;for(let _=0,C=v.length;_<C;_++){d=v[_].s,f.push(d),w=y[_];for(let b=0,I=w.length;b<I;b++)d.holes.push(w[b].h)}return f}}class vR extends Gs{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function _R(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function yR(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function xR(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function Ly(i,e,t,n){const r=SR(n);switch(t){case Qy:return i*e;case $y:return i*e;case ex:return i*e*2;case Pp:return i*e/r.components*r.byteLength;case Lp:return i*e/r.components*r.byteLength;case tx:return i*e*2/r.components*r.byteLength;case Gv:return i*e*2/r.components*r.byteLength;case Jy:return i*e*3/r.components*r.byteLength;case Ni:return i*e*4/r.components*r.byteLength;case Wv:return i*e*4/r.components*r.byteLength;case $f:case ep:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case tp:case np:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case iv:case sv:return Math.max(i,16)*Math.max(e,8)/4;case nv:case rv:return Math.max(i,8)*Math.max(e,8)/2;case ov:case av:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case lv:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case cv:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case uv:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case hv:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case dv:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case fv:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case pv:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case mv:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case gv:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case vv:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case _v:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case yv:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case xv:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Sv:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ev:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case ip:case Mv:case wv:return Math.ceil(i/4)*Math.ceil(e/4)*16;case nx:case Tv:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Av:case Cv:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function SR(i){switch(i){case Oi:case zv:return{byteLength:1,components:1};case yd:case kv:case nr:return{byteLength:2,components:1};case Hv:case Vv:return{byteLength:2,components:4};case fa:case Ip:case di:return{byteLength:4,components:1};case Ky:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}const ER={contain:_R,cover:yR,fill:xR,getByteLength:Ly};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:oc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=oc);/**
83
+ `},r=new cc(5,5,5),s=new li({name:"CubemapFromEquirect",uniforms:Sd(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Wi,blending:Rr});s.uniforms.tEquirect.value=t;const a=new fi(r,s),c=t.minFilter;return t.minFilter===ca&&(t.minFilter=On),new _w(1,10,this).update(e,a),t.minFilter=c,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class qv{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new yt(e),this.density=t}clone(){return new qv(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Kv{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new yt(e),this.near=t,this.far=n}clone(){return new Kv(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Du extends Cn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Vs,this.environmentIntensity=1,this.environmentRotation=new Vs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Qv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=mp,this.updateRanges=[],this.version=0,this.uuid=ks()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ks()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ks()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ts=new X;class zs{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)ts.fromBufferAttribute(this,t),ts.applyMatrix4(e),this.setXYZ(t,ts.x,ts.y,ts.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ts.fromBufferAttribute(this,t),ts.applyNormalMatrix(e),this.setXYZ(t,ts.x,ts.y,ts.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ts.fromBufferAttribute(this,t),ts.transformDirection(e),this.setXYZ(t,ts.x,ts.y,ts.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=rs(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=vn(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=rs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=rs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=rs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=rs(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=vn(t,this.array),n=vn(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=vn(t,this.array),n=vn(n,this.array),r=vn(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=vn(t,this.array),n=vn(n,this.array),r=vn(r,this.array),s=vn(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new jn(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new zs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class cx extends pr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let qh;const If=new X,Kh=new X,Qh=new X,Jh=new ke,Pf=new ke,yw=new qt,ng=new X,Lf=new X,ig=new X,t1=new ke,x_=new ke,n1=new ke;class xw extends Cn{constructor(e=new cx){if(super(),this.isSprite=!0,this.type="Sprite",qh===void 0){qh=new yn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Qv(t,5);qh.setIndex([0,1,2,0,2,3]),qh.setAttribute("position",new zs(n,3,0,!1)),qh.setAttribute("uv",new zs(n,2,3,!1))}this.geometry=qh,this.material=e,this.center=new ke(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Kh.setFromMatrixScale(this.matrixWorld),yw.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Qh.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Kh.multiplyScalar(-Qh.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;rg(ng.set(-.5,-.5,0),Qh,a,Kh,r,s),rg(Lf.set(.5,-.5,0),Qh,a,Kh,r,s),rg(ig.set(.5,.5,0),Qh,a,Kh,r,s),t1.set(0,0),x_.set(1,0),n1.set(1,1);let c=e.ray.intersectTriangle(ng,Lf,ig,!1,If);if(c===null&&(rg(Lf.set(-.5,.5,0),Qh,a,Kh,r,s),x_.set(0,1),c=e.ray.intersectTriangle(ng,ig,Lf,!1,If),c===null))return;const d=e.ray.origin.distanceTo(If);d<e.near||d>e.far||t.push({distance:d,point:If.clone(),uv:Ms.getInterpolation(If,ng,Lf,ig,t1,x_,n1,new ke),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function rg(i,e,t,n,r,s){Jh.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(Pf.x=s*Jh.x-r*Jh.y,Pf.y=r*Jh.x+s*Jh.y):Pf.copy(Jh),i.copy(e),i.x+=Pf.x,i.y+=Pf.y,i.applyMatrix4(yw)}const sg=new X,i1=new X;class Sw extends Cn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n<r;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){sg.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(sg);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){sg.setFromMatrixPosition(e.matrixWorld),i1.setFromMatrixPosition(this.matrixWorld);const n=sg.distanceTo(i1)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),n>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let r=0,s=n.length;r<s;r++){const a=n[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const r1=new X,s1=new _n,o1=new _n,Cb=new X,a1=new qt,og=new X,S_=new rr,l1=new qt,E_=new Cd;class Ew extends fi{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ey,this.bindMatrix=new qt,this.bindMatrixInverse=new qt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ir),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,og),this.boundingBox.expandByPoint(og)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rr),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,og),this.boundingSphere.expandByPoint(og)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),S_.copy(this.boundingSphere),S_.applyMatrix4(r),e.ray.intersectsSphere(S_)!==!1&&(l1.copy(r).invert(),E_.copy(e.ray).applyMatrix4(l1),!(this.boundingBox!==null&&E_.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,E_)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new _n,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Ey?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ew?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;s1.fromBufferAttribute(r.attributes.skinIndex,e),o1.fromBufferAttribute(r.attributes.skinWeight,e),r1.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=o1.getComponent(s);if(a!==0){const c=s1.getComponent(s);a1.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(Cb.copy(r1).applyMatrix4(a1),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class ux extends Cn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ko extends Wn{constructor(e=null,t=1,n=1,r,s,a,c,d,f=Ui,p=Ui,g,v){super(null,a,c,d,f,p,r,s,g,v),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const c1=new qt,bb=new qt;class Jv{constructor(e=[],t=[]){this.uuid=ks(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new qt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new qt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const c=e[s]?e[s].matrixWorld:bb;c1.multiplyMatrices(c,t[s]),c1.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Jv(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new ko(t,e,e,Ni,di);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new ux),this.bones.push(a),this.boneInverses.push(new qt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const c=n[r];e.boneInverses.push(c.toArray())}return e}}class Nu extends jn{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const $h=new qt,u1=new qt,ag=[],h1=new ir,Rb=new qt,Df=new fi,Nf=new rr;class Ed extends fi{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nu(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Rb)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ir),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,$h),h1.copy(e.boundingBox).applyMatrix4($h),this.boundingBox.union(h1)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,$h),Nf.copy(e.boundingSphere).applyMatrix4($h),this.boundingSphere.union(Nf)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let c=0;c<n.length;c++)n[c]=r[a+c]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(Df.geometry=this.geometry,Df.material=this.material,Df.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Nf.copy(this.boundingSphere),Nf.applyMatrix4(n),e.ray.intersectsSphere(Nf)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,$h),u1.multiplyMatrices(n,$h),Df.matrixWorld=u1,Df.raycast(e,ag);for(let a=0,c=ag.length;a<c;a++){const d=ag[a];d.instanceId=s,d.object=this,t.push(d)}ag.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new ko(new Float32Array(r*this.count),r,this.count,Pp,di));const s=this.morphTexture.source.data.data;let a=0;for(let f=0;f<n.length;f++)a+=n[f];const c=this.geometry.morphTargetsRelative?1:1-a,d=r*e;s[d]=c,s.set(n,d+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}const M_=new X,Ib=new X,Pb=new pn;class el{constructor(e=new X(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=M_.subVectors(n,t).cross(Ib.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(M_),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Pb.getNormalMatrix(e),r=this.coplanarPoint(M_).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const iu=new rr,lg=new X;class Op{constructor(e=new el,t=new el,n=new el,r=new el,s=new el,a=new el){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(r),c[4].copy(s),c[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Bo){const n=this.planes,r=e.elements,s=r[0],a=r[1],c=r[2],d=r[3],f=r[4],p=r[5],g=r[6],v=r[7],y=r[8],E=r[9],T=r[10],w=r[11],_=r[12],C=r[13],b=r[14],I=r[15];if(n[0].setComponents(d-s,v-f,w-y,I-_).normalize(),n[1].setComponents(d+s,v+f,w+y,I+_).normalize(),n[2].setComponents(d+a,v+p,w+E,I+C).normalize(),n[3].setComponents(d-a,v-p,w-E,I-C).normalize(),n[4].setComponents(d-c,v-g,w-T,I-b).normalize(),t===Bo)n[5].setComponents(d+c,v+g,w+T,I+b).normalize();else if(t===gp)n[5].setComponents(c,g,T,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),iu.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),iu.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(iu)}intersectsSprite(e){return iu.center.set(0,0,0),iu.radius=.7071067811865476,iu.applyMatrix4(e.matrixWorld),this.intersectsSphere(iu)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(lg.x=r.normal.x>0?e.max.x:e.min.x,lg.y=r.normal.y>0?e.max.y:e.min.y,lg.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(lg)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function w_(i,e){return i-e}function Lb(i,e){return i.z-e.z}function Db(i,e){return e.z-i.z}class Nb{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){const s=this.pool,a=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const c=s[this.index];a.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=r}reset(){this.list.length=0,this.index=0}}const xs=new qt,Ub=new yt(1,1,1),T_=new Op,cg=new ir,ru=new rr,Uf=new X,d1=new X,Ob=new X,A_=new Nb,kr=new fi,ug=[];function Fb(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let s=0;s<r;s++)for(let a=0;a<n;a++)e.setComponent(s+t,a,i.getComponent(s,a))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function su(i,e){if(i.constructor!==e.constructor){const t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{const t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}class Mw extends fi{get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}constructor(e,t,n=t*2,r){super(new yn,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new ko(t,e,e,Ni,di);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new ko(t,e,e,Lp,fa);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new ko(t,e,e,Ni,di);n.colorSpace=Dn.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:c,itemSize:d,normalized:f}=a,p=new c.constructor(n*d),g=new jn(p,d,f);t.setAttribute(s,g)}if(e.getIndex()!==null){const s=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new jn(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ir);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,xs),this.getBoundingBoxAt(s,cg).applyMatrix4(xs),e.union(cg)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new rr);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const s=t[n].geometryIndex;this.getMatrixAt(n,xs),this.getBoundingSphereAt(s,ru).applyMatrix4(xs),e.union(ru)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(w_),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const s=this._matricesTexture;xs.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(Ub.toArray(a.image.data,r*4),a.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let d;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(w_),d=this._availableGeometryIds.shift(),s[d]=r):(d=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(d,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,d}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),a=t.getIndex(),c=this._geometryInfo[e];if(r&&a.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const d=c.vertexStart,f=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const g=t.getAttribute(p),v=n.getAttribute(p);Fb(g,v,d);const y=g.itemSize;for(let E=g.count,T=f;E<T;E++){const w=d+E;for(let _=0;_<y;_++)v.setComponent(w,_,0)}v.needsUpdate=!0,v.addUpdateRange(d*y,f*y)}if(r){const p=c.indexStart,g=c.reservedIndexCount;c.indexCount=t.getIndex().count;for(let v=0;v<a.count;v++)s.setX(p+v,d+a.getX(v));for(let v=a.count,y=g;v<y;v++)s.setX(p+v,d);s.needsUpdate=!0,s.addUpdateRange(p,c.reservedIndexCount)}return c.start=r?c.indexStart:c.vertexStart,c.count=r?c.indexCount:c.vertexCount,c.boundingBox=null,t.boundingBox!==null&&(c.boundingBox=t.boundingBox.clone()),c.boundingSphere=null,t.boundingSphere!==null&&(c.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let r=0,s=n.length;r<s;r++)n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,r=n.map((a,c)=>c).sort((a,c)=>n[a].vertexStart-n[c].vertexStart),s=this.geometry;for(let a=0,c=n.length;a<c;a++){const d=r[a],f=n[d];if(f.active!==!1){if(s.index!==null){if(f.indexStart!==t){const{indexStart:p,vertexStart:g,reservedIndexCount:v}=f,y=s.index,E=y.array,T=e-g;for(let w=p;w<p+v;w++)E[w]=E[w]+T;y.array.copyWithin(t,p,p+v),y.addUpdateRange(t,v),f.indexStart=t}t+=f.reservedIndexCount}if(f.vertexStart!==e){const{vertexStart:p,reservedVertexCount:g}=f,v=s.attributes;for(const y in v){const E=v[y],{array:T,itemSize:w}=E;T.copyWithin(e*w,p*w,(p+g)*w),E.addUpdateRange(e*w,g*w)}f.vertexStart=e}e+=f.reservedVertexCount,f.start=s.index?f.indexStart:f.vertexStart,this._nextIndexStart=s.index?f.indexStart+f.reservedIndexCount:0,this._nextVertexStart=f.vertexStart+f.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const s=new ir,a=n.index,c=n.attributes.position;for(let d=r.start,f=r.start+r.count;d<f;d++){let p=d;a&&(p=a.getX(p)),s.expandByPoint(Uf.fromBufferAttribute(c,p))}r.boundingBox=s}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const s=new rr;this.getBoundingBoxAt(e,cg),cg.getCenter(s.center);const a=n.index,c=n.attributes.position;let d=0;for(let f=r.start,p=r.start+r.count;f<p;f++){let g=f;a&&(g=a.getX(g)),Uf.fromBufferAttribute(c,g),d=Math.max(d,s.center.distanceToSquared(Uf))}s.radius=Math.sqrt(d),r.boundingSphere=s}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(w_);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),s=new Int32Array(e);su(this._multiDrawCounts,r),su(this._multiDrawStarts,s),this._multiDrawCounts=r,this._multiDrawStarts=s,this._maxInstanceCount=e;const a=this._indirectTexture,c=this._matricesTexture,d=this._colorsTexture;a.dispose(),this._initIndirectTexture(),su(a.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),su(c.image.data,this._matricesTexture.image.data),d&&(d.dispose(),this._initColorsTexture(),su(d.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(c=>c.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(d=>d.indexStart+d.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new yn,this._initializeGeometry(s));const a=this.geometry;s.index&&su(s.index.array,a.index.array);for(const c in s.attributes)su(s.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,a=this.geometry;kr.material=this.material,kr.geometry.index=a.index,kr.geometry.attributes=a.attributes,kr.geometry.boundingBox===null&&(kr.geometry.boundingBox=new ir),kr.geometry.boundingSphere===null&&(kr.geometry.boundingSphere=new rr);for(let c=0,d=n.length;c<d;c++){if(!n[c].visible||!n[c].active)continue;const f=n[c].geometryIndex,p=r[f];kr.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,kr.matrixWorld).premultiply(s),this.getBoundingBoxAt(f,kr.geometry.boundingBox),this.getBoundingSphereAt(f,kr.geometry.boundingSphere),kr.raycast(e,ug);for(let g=0,v=ug.length;g<v;g++){const y=ug[g];y.object=this,y.batchId=c,t.push(y)}ug.length=0}kr.material=null,kr.geometry.index=null,kr.geometry.attributes={},kr.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),c=a===null?1:a.array.BYTES_PER_ELEMENT,d=this._instanceInfo,f=this._multiDrawStarts,p=this._multiDrawCounts,g=this._geometryInfo,v=this.perObjectFrustumCulled,y=this._indirectTexture,E=y.image.data;v&&(xs.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),T_.setFromProjectionMatrix(xs,e.coordinateSystem));let T=0;if(this.sortObjects){xs.copy(this.matrixWorld).invert(),Uf.setFromMatrixPosition(n.matrixWorld).applyMatrix4(xs),d1.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(xs);for(let C=0,b=d.length;C<b;C++)if(d[C].visible&&d[C].active){const I=d[C].geometryIndex;this.getMatrixAt(C,xs),this.getBoundingSphereAt(I,ru).applyMatrix4(xs);let N=!1;if(v&&(N=!T_.intersectsSphere(ru)),!N){const O=g[I],H=Ob.subVectors(ru.center,Uf).dot(d1);A_.push(O.start,O.count,H,C)}}const w=A_.list,_=this.customSort;_===null?w.sort(s.transparent?Db:Lb):_.call(this,w,n);for(let C=0,b=w.length;C<b;C++){const I=w[C];f[T]=I.start*c,p[T]=I.count,E[T]=I.index,T++}A_.reset()}else for(let w=0,_=d.length;w<_;w++)if(d[w].visible&&d[w].active){const C=d[w].geometryIndex;let b=!1;if(v&&(this.getMatrixAt(w,xs),this.getBoundingSphereAt(C,ru).applyMatrix4(xs),b=!T_.intersectsSphere(ru)),!b){const I=g[C];f[T]=I.start*c,p[T]=I.count,E[T]=w,T++}}y.needsUpdate=!0,this._multiDrawCount=T,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class os extends pr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Rv=new X,Iv=new X,f1=new qt,Of=new Cd,hg=new rr,C_=new X,p1=new X;let sc=class extends Cn{constructor(e=new yn,t=new os){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)Rv.fromBufferAttribute(t,r-1),Iv.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Rv.distanceTo(Iv);e.setAttribute("lineDistance",new Ut(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hg.copy(n.boundingSphere),hg.applyMatrix4(r),hg.radius+=s,e.ray.intersectsSphere(hg)===!1)return;f1.copy(r).invert(),Of.copy(e.ray).applyMatrix4(f1);const c=s/((this.scale.x+this.scale.y+this.scale.z)/3),d=c*c,f=this.isLineSegments?2:1,p=n.index,v=n.attributes.position;if(p!==null){const y=Math.max(0,a.start),E=Math.min(p.count,a.start+a.count);for(let T=y,w=E-1;T<w;T+=f){const _=p.getX(T),C=p.getX(T+1),b=dg(this,e,Of,d,_,C);b&&t.push(b)}if(this.isLineLoop){const T=p.getX(E-1),w=p.getX(y),_=dg(this,e,Of,d,T,w);_&&t.push(_)}}else{const y=Math.max(0,a.start),E=Math.min(v.count,a.start+a.count);for(let T=y,w=E-1;T<w;T+=f){const _=dg(this,e,Of,d,T,T+1);_&&t.push(_)}if(this.isLineLoop){const T=dg(this,e,Of,d,E-1,y);T&&t.push(T)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const c=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=s}}}}};function dg(i,e,t,n,r,s){const a=i.geometry.attributes.position;if(Rv.fromBufferAttribute(a,r),Iv.fromBufferAttribute(a,s),t.distanceSqToSegment(Rv,Iv,C_,p1)>n)return;C_.applyMatrix4(i.matrixWorld);const d=e.ray.origin.distanceTo(C_);if(!(d<e.near||d>e.far))return{distance:d,point:p1.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const m1=new X,g1=new X;class pa extends sc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)m1.fromBufferAttribute(t,r),g1.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+m1.distanceTo(g1);e.setAttribute("lineDistance",new Ut(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ww extends sc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class hx extends pr{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const v1=new qt,Ay=new Cd,fg=new rr,pg=new X;class Tw extends Cn{constructor(e=new yn,t=new hx){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),fg.copy(n.boundingSphere),fg.applyMatrix4(r),fg.radius+=s,e.ray.intersectsSphere(fg)===!1)return;v1.copy(r).invert(),Ay.copy(e.ray).applyMatrix4(v1);const c=s/((this.scale.x+this.scale.y+this.scale.z)/3),d=c*c,f=n.index,g=n.attributes.position;if(f!==null){const v=Math.max(0,a.start),y=Math.min(f.count,a.start+a.count);for(let E=v,T=y;E<T;E++){const w=f.getX(E);pg.fromBufferAttribute(g,w),_1(pg,w,d,r,e,t,this)}}else{const v=Math.max(0,a.start),y=Math.min(g.count,a.start+a.count);for(let E=v,T=y;E<T;E++)pg.fromBufferAttribute(g,E),_1(pg,E,d,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const c=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=s}}}}}function _1(i,e,t,n,r,s,a){const c=Ay.distanceSqToPoint(i);if(c<t){const d=new X;Ay.closestPointToPoint(i,d),d.applyMatrix4(n);const f=r.ray.origin.distanceTo(d);if(f<r.near||f>r.far)return;s.push({distance:f,distanceToRay:Math.sqrt(c),point:d,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class dd extends Cn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Bb extends Wn{constructor(e,t,n,r,s,a,c,d,f){super(e,t,n,r,s,a,c,d,f),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:On,this.magFilter=s!==void 0?s:On,this.generateMipmaps=!1;const p=this;function g(){p.needsUpdate=!0,e.requestVideoFrameCallback(g)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(g)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class zb extends Wn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ui,this.minFilter=Ui,this.generateMipmaps=!1,this.needsUpdate=!0}}class $v extends Wn{constructor(e,t,n,r,s,a,c,d,f,p,g,v){super(null,a,c,d,f,p,r,s,g,v),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class kb extends $v{constructor(e,t,n,r,s,a){super(e,t,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=ji,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Hb extends $v{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,da),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Aw extends Wn{constructor(e,t,n,r,s,a,c,d,f){super(e,t,n,r,s,a,c,d,f),this.isCanvasTexture=!0,this.needsUpdate=!0}}class e0 extends Wn{constructor(e,t,n,r,s,a,c,d,f,p=Cu){if(p!==Cu&&p!==rc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&p===Cu&&(n=fa),n===void 0&&p===rc&&(n=ic),super(null,r,s,a,c,d,p,n,f),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=c!==void 0?c:Ui,this.minFilter=d!==void 0?d:Ui,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Ho{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let c=0,d=s-1,f;for(;c<=d;)if(r=Math.floor(c+(d-c)/2),f=n[r]-a,f<0)c=r+1;else if(f>0)d=r-1;else{d=r;break}if(r=d,n[r]===a)return r/(s-1);const p=n[r],v=n[r+1]-p,y=(a-p)/v;return(r+y)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),c=this.getPoint(s),d=t||(a.isVector2?new ke:new X);return d.copy(c).sub(a).normalize(),d}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new X,r=[],s=[],a=[],c=new X,d=new qt;for(let y=0;y<=e;y++){const E=y/e;r[y]=this.getTangentAt(E,new X)}s[0]=new X,a[0]=new X;let f=Number.MAX_VALUE;const p=Math.abs(r[0].x),g=Math.abs(r[0].y),v=Math.abs(r[0].z);p<=f&&(f=p,n.set(1,0,0)),g<=f&&(f=g,n.set(0,1,0)),v<=f&&n.set(0,0,1),c.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],c),a[0].crossVectors(r[0],s[0]);for(let y=1;y<=e;y++){if(s[y]=s[y-1].clone(),a[y]=a[y-1].clone(),c.crossVectors(r[y-1],r[y]),c.length()>Number.EPSILON){c.normalize();const E=Math.acos(un(r[y-1].dot(r[y]),-1,1));s[y].applyMatrix4(d.makeRotationAxis(c,E))}a[y].crossVectors(r[y],s[y])}if(t===!0){let y=Math.acos(un(s[0].dot(s[e]),-1,1));y/=e,r[0].dot(c.crossVectors(s[0],s[e]))>0&&(y=-y);for(let E=1;E<=e;E++)s[E].applyMatrix4(d.makeRotationAxis(r[E],y*E)),a[E].crossVectors(r[E],s[E])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class t0 extends Ho{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,c=!1,d=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=c,this.aRotation=d}getPoint(e,t=new ke){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const c=this.aStartAngle+e*s;let d=this.aX+this.xRadius*Math.cos(c),f=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){const p=Math.cos(this.aRotation),g=Math.sin(this.aRotation),v=d-this.aX,y=f-this.aY;d=v*p-y*g+this.aX,f=v*g+y*p+this.aY}return n.set(d,f)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Cw extends t0{constructor(e,t,n,r,s,a){super(e,t,n,n,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function dx(){let i=0,e=0,t=0,n=0;function r(s,a,c,d){i=s,e=c,t=-3*s+3*a-2*c-d,n=2*s-2*a+c+d}return{initCatmullRom:function(s,a,c,d,f){r(a,c,f*(c-s),f*(d-a))},initNonuniformCatmullRom:function(s,a,c,d,f,p,g){let v=(a-s)/f-(c-s)/(f+p)+(c-a)/p,y=(c-a)/p-(d-a)/(p+g)+(d-c)/g;v*=p,y*=p,r(a,c,v,y)},calc:function(s){const a=s*s,c=a*s;return i+e*s+t*a+n*c}}}const mg=new X,b_=new dx,R_=new dx,I_=new dx;class n0 extends Ho{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new X){const n=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let c=Math.floor(a),d=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/s)+1)*s:d===0&&c===s-1&&(c=s-2,d=1);let f,p;this.closed||c>0?f=r[(c-1)%s]:(mg.subVectors(r[0],r[1]).add(r[0]),f=mg);const g=r[c%s],v=r[(c+1)%s];if(this.closed||c+2<s?p=r[(c+2)%s]:(mg.subVectors(r[s-1],r[s-2]).add(r[s-1]),p=mg),this.curveType==="centripetal"||this.curveType==="chordal"){const y=this.curveType==="chordal"?.5:.25;let E=Math.pow(f.distanceToSquared(g),y),T=Math.pow(g.distanceToSquared(v),y),w=Math.pow(v.distanceToSquared(p),y);T<1e-4&&(T=1),E<1e-4&&(E=T),w<1e-4&&(w=T),b_.initNonuniformCatmullRom(f.x,g.x,v.x,p.x,E,T,w),R_.initNonuniformCatmullRom(f.y,g.y,v.y,p.y,E,T,w),I_.initNonuniformCatmullRom(f.z,g.z,v.z,p.z,E,T,w)}else this.curveType==="catmullrom"&&(b_.initCatmullRom(f.x,g.x,v.x,p.x,this.tension),R_.initCatmullRom(f.y,g.y,v.y,p.y,this.tension),I_.initCatmullRom(f.z,g.z,v.z,p.z,this.tension));return n.set(b_.calc(d),R_.calc(d),I_.calc(d)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new X().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function y1(i,e,t,n,r){const s=(n-e)*.5,a=(r-t)*.5,c=i*i,d=i*c;return(2*t-2*n+s+a)*d+(-3*t+3*n-2*s-a)*c+s*i+t}function Vb(i,e){const t=1-i;return t*t*e}function Gb(i,e){return 2*(1-i)*i*e}function Wb(i,e){return i*i*e}function sp(i,e,t,n){return Vb(i,e)+Gb(i,t)+Wb(i,n)}function jb(i,e){const t=1-i;return t*t*t*e}function Xb(i,e){const t=1-i;return 3*t*t*i*e}function Yb(i,e){return 3*(1-i)*i*i*e}function Zb(i,e){return i*i*i*e}function op(i,e,t,n,r){return jb(i,e)+Xb(i,t)+Yb(i,n)+Zb(i,r)}class fx extends Ho{constructor(e=new ke,t=new ke,n=new ke,r=new ke){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new ke){const n=t,r=this.v0,s=this.v1,a=this.v2,c=this.v3;return n.set(op(e,r.x,s.x,a.x,c.x),op(e,r.y,s.y,a.y,c.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class bw extends Ho{constructor(e=new X,t=new X,n=new X,r=new X){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new X){const n=t,r=this.v0,s=this.v1,a=this.v2,c=this.v3;return n.set(op(e,r.x,s.x,a.x,c.x),op(e,r.y,s.y,a.y,c.y),op(e,r.z,s.z,a.z,c.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class px extends Ho{constructor(e=new ke,t=new ke){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ke){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ke){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Rw extends Ho{constructor(e=new X,t=new X){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new X){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new X){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class mx extends Ho{constructor(e=new ke,t=new ke,n=new ke){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ke){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sp(e,r.x,s.x,a.x),sp(e,r.y,s.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class gx extends Ho{constructor(e=new X,t=new X,n=new X){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new X){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(sp(e,r.x,s.x,a.x),sp(e,r.y,s.y,a.y),sp(e,r.z,s.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class vx extends Ho{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ke){const n=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),c=s-a,d=r[a===0?a:a-1],f=r[a],p=r[a>r.length-2?r.length-1:a+1],g=r[a>r.length-3?r.length-1:a+2];return n.set(y1(c,d.x,f.x,p.x,g.x),y1(c,d.y,f.y,p.y,g.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new ke().fromArray(r))}return this}}var Pv=Object.freeze({__proto__:null,ArcCurve:Cw,CatmullRomCurve3:n0,CubicBezierCurve:fx,CubicBezierCurve3:bw,EllipseCurve:t0,LineCurve:px,LineCurve3:Rw,QuadraticBezierCurve:mx,QuadraticBezierCurve3:gx,SplineCurve:vx});class Iw extends Ho{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Pv[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const a=r[s]-n,c=this.curves[s],d=c.getLength(),f=d===0?0:1-a/d;return c.getPointAt(f,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],c=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,d=a.getPoints(c);for(let f=0;f<d.length;f++){const p=d[f];n&&n.equals(p)||(t.push(p),n=p)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(new Pv[r.type]().fromJSON(r))}return this}}class yp extends Iw{constructor(e){super(),this.type="Path",this.currentPoint=new ke,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new px(this.currentPoint.clone(),new ke(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const s=new mx(this.currentPoint.clone(),new ke(e,t),new ke(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,a){const c=new fx(this.currentPoint.clone(),new ke(e,t),new ke(n,r),new ke(s,a));return this.curves.push(c),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new vx(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,a){const c=this.currentPoint.x,d=this.currentPoint.y;return this.absarc(e+c,t+d,n,r,s,a),this}absarc(e,t,n,r,s,a){return this.absellipse(e,t,n,n,r,s,a),this}ellipse(e,t,n,r,s,a,c,d){const f=this.currentPoint.x,p=this.currentPoint.y;return this.absellipse(e+f,t+p,n,r,s,a,c,d),this}absellipse(e,t,n,r,s,a,c,d){const f=new t0(e,t,n,r,s,a,c,d);if(this.curves.length>0){const g=f.getPoint(0);g.equals(this.currentPoint)||this.lineTo(g.x,g.y)}this.curves.push(f);const p=f.getPoint(1);return this.currentPoint.copy(p),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Fp extends yn{constructor(e=[new ke(0,-.5),new ke(.5,0),new ke(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=un(r,0,Math.PI*2);const s=[],a=[],c=[],d=[],f=[],p=1/t,g=new X,v=new ke,y=new X,E=new X,T=new X;let w=0,_=0;for(let C=0;C<=e.length-1;C++)switch(C){case 0:w=e[C+1].x-e[C].x,_=e[C+1].y-e[C].y,y.x=_*1,y.y=-w,y.z=_*0,T.copy(y),y.normalize(),d.push(y.x,y.y,y.z);break;case e.length-1:d.push(T.x,T.y,T.z);break;default:w=e[C+1].x-e[C].x,_=e[C+1].y-e[C].y,y.x=_*1,y.y=-w,y.z=_*0,E.copy(y),y.x+=T.x,y.y+=T.y,y.z+=T.z,y.normalize(),d.push(y.x,y.y,y.z),T.copy(E)}for(let C=0;C<=t;C++){const b=n+C*p*r,I=Math.sin(b),N=Math.cos(b);for(let O=0;O<=e.length-1;O++){g.x=e[O].x*I,g.y=e[O].y,g.z=e[O].x*N,a.push(g.x,g.y,g.z),v.x=C/t,v.y=O/(e.length-1),c.push(v.x,v.y);const H=d[3*O+0]*I,B=d[3*O+1],D=d[3*O+0]*N;f.push(H,B,D)}}for(let C=0;C<t;C++)for(let b=0;b<e.length-1;b++){const I=b+C*e.length,N=I,O=I+e.length,H=I+e.length+1,B=I+1;s.push(N,O,B),s.push(H,B,O)}this.setIndex(s),this.setAttribute("position",new Ut(a,3)),this.setAttribute("uv",new Ut(c,2)),this.setAttribute("normal",new Ut(f,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fp(e.points,e.segments,e.phiStart,e.phiLength)}}class i0 extends Fp{constructor(e=1,t=1,n=4,r=8){const s=new yp;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new i0(e.radius,e.length,e.capSegments,e.radialSegments)}}class r0 extends yn{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],c=[],d=[],f=new X,p=new ke;a.push(0,0,0),c.push(0,0,1),d.push(.5,.5);for(let g=0,v=3;g<=t;g++,v+=3){const y=n+g/t*r;f.x=e*Math.cos(y),f.y=e*Math.sin(y),a.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(a[v]/e+1)/2,p.y=(a[v+1]/e+1)/2,d.push(p.x,p.y)}for(let g=1;g<=t;g++)s.push(g,g+1,0);this.setIndex(s),this.setAttribute("position",new Ut(a,3)),this.setAttribute("normal",new Ut(c,3)),this.setAttribute("uv",new Ut(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new r0(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class uc extends yn{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,c=0,d=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:c,thetaLength:d};const f=this;r=Math.floor(r),s=Math.floor(s);const p=[],g=[],v=[],y=[];let E=0;const T=[],w=n/2;let _=0;C(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(p),this.setAttribute("position",new Ut(g,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(y,2));function C(){const I=new X,N=new X;let O=0;const H=(t-e)/n;for(let B=0;B<=s;B++){const D=[],U=B/s,W=U*(t-e)+e;for(let ne=0;ne<=r;ne++){const re=ne/r,he=re*d+c,fe=Math.sin(he),ce=Math.cos(he);N.x=W*fe,N.y=-U*n+w,N.z=W*ce,g.push(N.x,N.y,N.z),I.set(fe,H,ce).normalize(),v.push(I.x,I.y,I.z),y.push(re,1-U),D.push(E++)}T.push(D)}for(let B=0;B<r;B++)for(let D=0;D<s;D++){const U=T[D][B],W=T[D+1][B],ne=T[D+1][B+1],re=T[D][B+1];(e>0||D!==0)&&(p.push(U,W,re),O+=3),(t>0||D!==s-1)&&(p.push(W,ne,re),O+=3)}f.addGroup(_,O,0),_+=O}function b(I){const N=E,O=new ke,H=new X;let B=0;const D=I===!0?e:t,U=I===!0?1:-1;for(let ne=1;ne<=r;ne++)g.push(0,w*U,0),v.push(0,U,0),y.push(.5,.5),E++;const W=E;for(let ne=0;ne<=r;ne++){const he=ne/r*d+c,fe=Math.cos(he),ce=Math.sin(he);H.x=D*ce,H.y=w*U,H.z=D*fe,g.push(H.x,H.y,H.z),v.push(0,U,0),O.x=fe*.5+.5,O.y=ce*.5*U+.5,y.push(O.x,O.y),E++}for(let ne=0;ne<r;ne++){const re=N+ne,he=W+ne;I===!0?p.push(he,he+1,re):p.push(he+1,he,re),B+=3}f.addGroup(_,B,I===!0?1:2),_+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Bp extends uc{constructor(e=1,t=1,n=32,r=1,s=!1,a=0,c=Math.PI*2){super(0,e,t,n,r,s,a,c),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:c}}static fromJSON(e){return new Bp(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class hc extends yn{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const s=[],a=[];c(r),f(n),p(),this.setAttribute("position",new Ut(s,3)),this.setAttribute("normal",new Ut(s.slice(),3)),this.setAttribute("uv",new Ut(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function c(C){const b=new X,I=new X,N=new X;for(let O=0;O<t.length;O+=3)y(t[O+0],b),y(t[O+1],I),y(t[O+2],N),d(b,I,N,C)}function d(C,b,I,N){const O=N+1,H=[];for(let B=0;B<=O;B++){H[B]=[];const D=C.clone().lerp(I,B/O),U=b.clone().lerp(I,B/O),W=O-B;for(let ne=0;ne<=W;ne++)ne===0&&B===O?H[B][ne]=D:H[B][ne]=D.clone().lerp(U,ne/W)}for(let B=0;B<O;B++)for(let D=0;D<2*(O-B)-1;D++){const U=Math.floor(D/2);D%2===0?(v(H[B][U+1]),v(H[B+1][U]),v(H[B][U])):(v(H[B][U+1]),v(H[B+1][U+1]),v(H[B+1][U]))}}function f(C){const b=new X;for(let I=0;I<s.length;I+=3)b.x=s[I+0],b.y=s[I+1],b.z=s[I+2],b.normalize().multiplyScalar(C),s[I+0]=b.x,s[I+1]=b.y,s[I+2]=b.z}function p(){const C=new X;for(let b=0;b<s.length;b+=3){C.x=s[b+0],C.y=s[b+1],C.z=s[b+2];const I=w(C)/2/Math.PI+.5,N=_(C)/Math.PI+.5;a.push(I,1-N)}E(),g()}function g(){for(let C=0;C<a.length;C+=6){const b=a[C+0],I=a[C+2],N=a[C+4],O=Math.max(b,I,N),H=Math.min(b,I,N);O>.9&&H<.1&&(b<.2&&(a[C+0]+=1),I<.2&&(a[C+2]+=1),N<.2&&(a[C+4]+=1))}}function v(C){s.push(C.x,C.y,C.z)}function y(C,b){const I=C*3;b.x=e[I+0],b.y=e[I+1],b.z=e[I+2]}function E(){const C=new X,b=new X,I=new X,N=new X,O=new ke,H=new ke,B=new ke;for(let D=0,U=0;D<s.length;D+=9,U+=6){C.set(s[D+0],s[D+1],s[D+2]),b.set(s[D+3],s[D+4],s[D+5]),I.set(s[D+6],s[D+7],s[D+8]),O.set(a[U+0],a[U+1]),H.set(a[U+2],a[U+3]),B.set(a[U+4],a[U+5]),N.copy(C).add(b).add(I).divideScalar(3);const W=w(N);T(O,U+0,C,W),T(H,U+2,b,W),T(B,U+4,I,W)}}function T(C,b,I,N){N<0&&C.x===1&&(a[b]=C.x-1),I.x===0&&I.z===0&&(a[b]=N/2/Math.PI+.5)}function w(C){return Math.atan2(C.z,-C.x)}function _(C){return Math.atan2(-C.y,Math.sqrt(C.x*C.x+C.z*C.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new hc(e.vertices,e.indices,e.radius,e.details)}}class s0 extends hc{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new s0(e.radius,e.detail)}}const gg=new X,vg=new X,P_=new X,_g=new Ms;class Pw extends yn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),s=Math.cos(bu*t),a=e.getIndex(),c=e.getAttribute("position"),d=a?a.count:c.count,f=[0,0,0],p=["a","b","c"],g=new Array(3),v={},y=[];for(let E=0;E<d;E+=3){a?(f[0]=a.getX(E),f[1]=a.getX(E+1),f[2]=a.getX(E+2)):(f[0]=E,f[1]=E+1,f[2]=E+2);const{a:T,b:w,c:_}=_g;if(T.fromBufferAttribute(c,f[0]),w.fromBufferAttribute(c,f[1]),_.fromBufferAttribute(c,f[2]),_g.getNormal(P_),g[0]=`${Math.round(T.x*r)},${Math.round(T.y*r)},${Math.round(T.z*r)}`,g[1]=`${Math.round(w.x*r)},${Math.round(w.y*r)},${Math.round(w.z*r)}`,g[2]=`${Math.round(_.x*r)},${Math.round(_.y*r)},${Math.round(_.z*r)}`,!(g[0]===g[1]||g[1]===g[2]||g[2]===g[0]))for(let C=0;C<3;C++){const b=(C+1)%3,I=g[C],N=g[b],O=_g[p[C]],H=_g[p[b]],B=`${I}_${N}`,D=`${N}_${I}`;D in v&&v[D]?(P_.dot(v[D].normal)<=s&&(y.push(O.x,O.y,O.z),y.push(H.x,H.y,H.z)),v[D]=null):B in v||(v[B]={index0:f[C],index1:f[b],normal:P_.clone()})}}for(const E in v)if(v[E]){const{index0:T,index1:w}=v[E];gg.fromBufferAttribute(c,T),vg.fromBufferAttribute(c,w),y.push(gg.x,gg.y,gg.z),y.push(vg.x,vg.y,vg.z)}this.setAttribute("position",new Ut(y,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Iu extends yp{constructor(e){super(e),this.uuid=ks(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(new yp().fromJSON(r))}return this}}const qb={triangulate:function(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=Lw(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let c,d,f,p,g,v,y;if(n&&(s=eR(i,e,s,t)),i.length>80*t){c=f=i[0],d=p=i[1];for(let E=t;E<r;E+=t)g=i[E],v=i[E+1],g<c&&(c=g),v<d&&(d=v),g>f&&(f=g),v>p&&(p=v);y=Math.max(f-c,p-d),y=y!==0?32767/y:0}return xp(s,a,t,c,d,y,0),a}};function Lw(i,e,t,n,r){let s,a;if(r===hR(i,e,t,n)>0)for(s=e;s<t;s+=n)a=x1(s,i[s],i[s+1],a);else for(s=t-n;s>=e;s-=n)a=x1(s,i[s],i[s+1],a);return a&&o0(a,a.next)&&(Ep(a),a=a.next),a}function Uu(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(o0(t,t.next)||Ei(t.prev,t,t.next)===0)){if(Ep(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function xp(i,e,t,n,r,s,a){if(!i)return;!a&&s&&sR(i,n,r,s);let c=i,d,f;for(;i.prev!==i.next;){if(d=i.prev,f=i.next,s?Qb(i,n,r,s):Kb(i)){e.push(d.i/t|0),e.push(i.i/t|0),e.push(f.i/t|0),Ep(i),i=f.next,c=f.next;continue}if(i=f,i===c){a?a===1?(i=Jb(Uu(i),e,t),xp(i,e,t,n,r,s,2)):a===2&&$b(i,e,t,n,r,s):xp(Uu(i),e,t,n,r,s,1);break}}}function Kb(i){const e=i.prev,t=i,n=i.next;if(Ei(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,c=e.y,d=t.y,f=n.y,p=r<s?r<a?r:a:s<a?s:a,g=c<d?c<f?c:f:d<f?d:f,v=r>s?r>a?r:a:s>a?s:a,y=c>d?c>f?c:f:d>f?d:f;let E=n.next;for(;E!==e;){if(E.x>=p&&E.x<=v&&E.y>=g&&E.y<=y&&fd(r,c,s,d,a,f,E.x,E.y)&&Ei(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function Qb(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Ei(r,s,a)>=0)return!1;const c=r.x,d=s.x,f=a.x,p=r.y,g=s.y,v=a.y,y=c<d?c<f?c:f:d<f?d:f,E=p<g?p<v?p:v:g<v?g:v,T=c>d?c>f?c:f:d>f?d:f,w=p>g?p>v?p:v:g>v?g:v,_=Cy(y,E,e,t,n),C=Cy(T,w,e,t,n);let b=i.prevZ,I=i.nextZ;for(;b&&b.z>=_&&I&&I.z<=C;){if(b.x>=y&&b.x<=T&&b.y>=E&&b.y<=w&&b!==r&&b!==a&&fd(c,p,d,g,f,v,b.x,b.y)&&Ei(b.prev,b,b.next)>=0||(b=b.prevZ,I.x>=y&&I.x<=T&&I.y>=E&&I.y<=w&&I!==r&&I!==a&&fd(c,p,d,g,f,v,I.x,I.y)&&Ei(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;b&&b.z>=_;){if(b.x>=y&&b.x<=T&&b.y>=E&&b.y<=w&&b!==r&&b!==a&&fd(c,p,d,g,f,v,b.x,b.y)&&Ei(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;I&&I.z<=C;){if(I.x>=y&&I.x<=T&&I.y>=E&&I.y<=w&&I!==r&&I!==a&&fd(c,p,d,g,f,v,I.x,I.y)&&Ei(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function Jb(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!o0(r,s)&&Dw(r,n,n.next,s)&&Sp(r,s)&&Sp(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Ep(n),Ep(n.next),n=i=s),n=n.next}while(n!==i);return Uu(n)}function $b(i,e,t,n,r,s){let a=i;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&lR(a,c)){let d=Nw(a,c);a=Uu(a,a.next),d=Uu(d,d.next),xp(a,e,t,n,r,s,0),xp(d,e,t,n,r,s,0);return}c=c.next}a=a.next}while(a!==i)}function eR(i,e,t,n){const r=[];let s,a,c,d,f;for(s=0,a=e.length;s<a;s++)c=e[s]*n,d=s<a-1?e[s+1]*n:i.length,f=Lw(i,c,d,n,!1),f===f.next&&(f.steiner=!0),r.push(aR(f));for(r.sort(tR),s=0;s<r.length;s++)t=nR(r[s],t);return t}function tR(i,e){return i.x-e.x}function nR(i,e){const t=iR(i,e);if(!t)return e;const n=Nw(t,i);return Uu(n,n.next),Uu(t,t.next)}function iR(i,e){let t=e,n=-1/0,r;const s=i.x,a=i.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const v=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=s&&v>n&&(n=v,r=t.x<t.next.x?t:t.next,v===s))return r}t=t.next}while(t!==e);if(!r)return null;const c=r,d=r.x,f=r.y;let p=1/0,g;t=r;do s>=t.x&&t.x>=d&&s!==t.x&&fd(a<f?s:n,a,d,f,a<f?n:s,a,t.x,t.y)&&(g=Math.abs(a-t.y)/(s-t.x),Sp(t,i)&&(g<p||g===p&&(t.x>r.x||t.x===r.x&&rR(r,t)))&&(r=t,p=g)),t=t.next;while(t!==c);return r}function rR(i,e){return Ei(i.prev,i,e.prev)<0&&Ei(e.next,i,i.next)<0}function sR(i,e,t,n){let r=i;do r.z===0&&(r.z=Cy(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,oR(r)}function oR(i){let e,t,n,r,s,a,c,d,f=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,c=0,e=0;e<f&&(c++,n=n.nextZ,!!n);e++);for(d=f;c>0||d>0&&n;)c!==0&&(d===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,c--):(r=n,n=n.nextZ,d--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,f*=2}while(a>1);return i}function Cy(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function aR(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function fd(i,e,t,n,r,s,a,c){return(r-a)*(e-c)>=(i-a)*(s-c)&&(i-a)*(n-c)>=(t-a)*(e-c)&&(t-a)*(s-c)>=(r-a)*(n-c)}function lR(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!cR(i,e)&&(Sp(i,e)&&Sp(e,i)&&uR(i,e)&&(Ei(i.prev,i,e.prev)||Ei(i,e.prev,e))||o0(i,e)&&Ei(i.prev,i,i.next)>0&&Ei(e.prev,e,e.next)>0)}function Ei(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function o0(i,e){return i.x===e.x&&i.y===e.y}function Dw(i,e,t,n){const r=xg(Ei(i,e,t)),s=xg(Ei(i,e,n)),a=xg(Ei(t,n,i)),c=xg(Ei(t,n,e));return!!(r!==s&&a!==c||r===0&&yg(i,t,e)||s===0&&yg(i,n,e)||a===0&&yg(t,i,n)||c===0&&yg(t,e,n))}function yg(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function xg(i){return i>0?1:i<0?-1:0}function cR(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Dw(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Sp(i,e){return Ei(i.prev,i,i.next)<0?Ei(i,e,i.next)>=0&&Ei(i,i.prev,e)>=0:Ei(i,e,i.prev)<0||Ei(i,i.next,e)<0}function uR(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Nw(i,e){const t=new by(i.i,i.x,i.y),n=new by(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function x1(i,e,t,n){const r=new by(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ep(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function by(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function hR(i,e,t,n){let r=0;for(let s=e,a=t-n;s<t;s+=n)r+=(i[a]-i[s])*(i[s+1]+i[a+1]),a=s;return r}class ua{static area(e){const t=e.length;let n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return ua.area(e)<0}static triangulateShape(e,t){const n=[],r=[],s=[];S1(e),E1(n,e);let a=e.length;t.forEach(S1);for(let d=0;d<t.length;d++)r.push(a),a+=t[d].length,E1(n,t[d]);const c=qb.triangulate(n,r);for(let d=0;d<c.length;d+=3)s.push(c.slice(d,d+3));return s}}function S1(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function E1(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class a0 extends yn{constructor(e=new Iu([new ke(.5,.5),new ke(-.5,.5),new ke(-.5,-.5),new ke(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],s=[];for(let c=0,d=e.length;c<d;c++){const f=e[c];a(f)}this.setAttribute("position",new Ut(r,3)),this.setAttribute("uv",new Ut(s,2)),this.computeVertexNormals();function a(c){const d=[],f=t.curveSegments!==void 0?t.curveSegments:12,p=t.steps!==void 0?t.steps:1,g=t.depth!==void 0?t.depth:1;let v=t.bevelEnabled!==void 0?t.bevelEnabled:!0,y=t.bevelThickness!==void 0?t.bevelThickness:.2,E=t.bevelSize!==void 0?t.bevelSize:y-.1,T=t.bevelOffset!==void 0?t.bevelOffset:0,w=t.bevelSegments!==void 0?t.bevelSegments:3;const _=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:dR;let b,I=!1,N,O,H,B;_&&(b=_.getSpacedPoints(p),I=!0,v=!1,N=_.computeFrenetFrames(p,!1),O=new X,H=new X,B=new X),v||(w=0,y=0,E=0,T=0);const D=c.extractPoints(f);let U=D.shape;const W=D.holes;if(!ua.isClockWise(U)){U=U.reverse();for(let Ve=0,Ge=W.length;Ve<Ge;Ve++){const K=W[Ve];ua.isClockWise(K)&&(W[Ve]=K.reverse())}}const re=ua.triangulateShape(U,W),he=U;for(let Ve=0,Ge=W.length;Ve<Ge;Ve++){const K=W[Ve];U=U.concat(K)}function fe(Ve,Ge,K){return Ge||console.error("THREE.ExtrudeGeometry: vec does not exist"),Ve.clone().addScaledVector(Ge,K)}const ce=U.length,xe=re.length;function q(Ve,Ge,K){let At,Je,dt;const it=Ve.x-Ge.x,zt=Ve.y-Ge.y,ot=K.x-Ve.x,Z=K.y-Ve.y,G=it*it+zt*zt,Se=it*Z-zt*ot;if(Math.abs(Se)>Number.EPSILON){const Fe=Math.sqrt(G),Xe=Math.sqrt(ot*ot+Z*Z),He=Ge.x-zt/Fe,Mt=Ge.y+it/Fe,ct=K.x-Z/Xe,xt=K.y+ot/Xe,rn=((ct-He)*Z-(xt-Mt)*ot)/(it*Z-zt*ot);At=He+it*rn-Ve.x,Je=Mt+zt*rn-Ve.y;const et=At*At+Je*Je;if(et<=2)return new ke(At,Je);dt=Math.sqrt(et/2)}else{let Fe=!1;it>Number.EPSILON?ot>Number.EPSILON&&(Fe=!0):it<-Number.EPSILON?ot<-Number.EPSILON&&(Fe=!0):Math.sign(zt)===Math.sign(Z)&&(Fe=!0),Fe?(At=-zt,Je=it,dt=Math.sqrt(G)):(At=it,Je=zt,dt=Math.sqrt(G/2))}return new ke(At/dt,Je/dt)}const de=[];for(let Ve=0,Ge=he.length,K=Ge-1,At=Ve+1;Ve<Ge;Ve++,K++,At++)K===Ge&&(K=0),At===Ge&&(At=0),de[Ve]=q(he[Ve],he[K],he[At]);const se=[];let Y,le=de.concat();for(let Ve=0,Ge=W.length;Ve<Ge;Ve++){const K=W[Ve];Y=[];for(let At=0,Je=K.length,dt=Je-1,it=At+1;At<Je;At++,dt++,it++)dt===Je&&(dt=0),it===Je&&(it=0),Y[At]=q(K[At],K[dt],K[it]);se.push(Y),le=le.concat(Y)}for(let Ve=0;Ve<w;Ve++){const Ge=Ve/w,K=y*Math.cos(Ge*Math.PI/2),At=E*Math.sin(Ge*Math.PI/2)+T;for(let Je=0,dt=he.length;Je<dt;Je++){const it=fe(he[Je],de[Je],At);Be(it.x,it.y,-K)}for(let Je=0,dt=W.length;Je<dt;Je++){const it=W[Je];Y=se[Je];for(let zt=0,ot=it.length;zt<ot;zt++){const Z=fe(it[zt],Y[zt],At);Be(Z.x,Z.y,-K)}}}const ze=E+T;for(let Ve=0;Ve<ce;Ve++){const Ge=v?fe(U[Ve],le[Ve],ze):U[Ve];I?(H.copy(N.normals[0]).multiplyScalar(Ge.x),O.copy(N.binormals[0]).multiplyScalar(Ge.y),B.copy(b[0]).add(H).add(O),Be(B.x,B.y,B.z)):Be(Ge.x,Ge.y,0)}for(let Ve=1;Ve<=p;Ve++)for(let Ge=0;Ge<ce;Ge++){const K=v?fe(U[Ge],le[Ge],ze):U[Ge];I?(H.copy(N.normals[Ve]).multiplyScalar(K.x),O.copy(N.binormals[Ve]).multiplyScalar(K.y),B.copy(b[Ve]).add(H).add(O),Be(B.x,B.y,B.z)):Be(K.x,K.y,g/p*Ve)}for(let Ve=w-1;Ve>=0;Ve--){const Ge=Ve/w,K=y*Math.cos(Ge*Math.PI/2),At=E*Math.sin(Ge*Math.PI/2)+T;for(let Je=0,dt=he.length;Je<dt;Je++){const it=fe(he[Je],de[Je],At);Be(it.x,it.y,g+K)}for(let Je=0,dt=W.length;Je<dt;Je++){const it=W[Je];Y=se[Je];for(let zt=0,ot=it.length;zt<ot;zt++){const Z=fe(it[zt],Y[zt],At);I?Be(Z.x,Z.y+b[p-1].y,b[p-1].x+K):Be(Z.x,Z.y,g+K)}}}ve(),Pe();function ve(){const Ve=r.length/3;if(v){let Ge=0,K=ce*Ge;for(let At=0;At<xe;At++){const Je=re[At];Ke(Je[2]+K,Je[1]+K,Je[0]+K)}Ge=p+w*2,K=ce*Ge;for(let At=0;At<xe;At++){const Je=re[At];Ke(Je[0]+K,Je[1]+K,Je[2]+K)}}else{for(let Ge=0;Ge<xe;Ge++){const K=re[Ge];Ke(K[2],K[1],K[0])}for(let Ge=0;Ge<xe;Ge++){const K=re[Ge];Ke(K[0]+ce*p,K[1]+ce*p,K[2]+ce*p)}}n.addGroup(Ve,r.length/3-Ve,0)}function Pe(){const Ve=r.length/3;let Ge=0;Le(he,Ge),Ge+=he.length;for(let K=0,At=W.length;K<At;K++){const Je=W[K];Le(Je,Ge),Ge+=Je.length}n.addGroup(Ve,r.length/3-Ve,1)}function Le(Ve,Ge){let K=Ve.length;for(;--K>=0;){const At=K;let Je=K-1;Je<0&&(Je=Ve.length-1);for(let dt=0,it=p+w*2;dt<it;dt++){const zt=ce*dt,ot=ce*(dt+1),Z=Ge+At+zt,G=Ge+Je+zt,Se=Ge+Je+ot,Fe=Ge+At+ot;ft(Z,G,Se,Fe)}}}function Be(Ve,Ge,K){d.push(Ve),d.push(Ge),d.push(K)}function Ke(Ve,Ge,K){ht(Ve),ht(Ge),ht(K);const At=r.length/3,Je=C.generateTopUV(n,r,At-3,At-2,At-1);pt(Je[0]),pt(Je[1]),pt(Je[2])}function ft(Ve,Ge,K,At){ht(Ve),ht(Ge),ht(At),ht(Ge),ht(K),ht(At);const Je=r.length/3,dt=C.generateSideWallUV(n,r,Je-6,Je-3,Je-2,Je-1);pt(dt[0]),pt(dt[1]),pt(dt[3]),pt(dt[1]),pt(dt[2]),pt(dt[3])}function ht(Ve){r.push(d[Ve*3+0]),r.push(d[Ve*3+1]),r.push(d[Ve*3+2])}function pt(Ve){s.push(Ve.x),s.push(Ve.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return fR(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s<a;s++){const c=t[e.shapes[s]];n.push(c)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Pv[r.type]().fromJSON(r)),new a0(n,e.options)}}const dR={generateTopUV:function(i,e,t,n,r){const s=e[t*3],a=e[t*3+1],c=e[n*3],d=e[n*3+1],f=e[r*3],p=e[r*3+1];return[new ke(s,a),new ke(c,d),new ke(f,p)]},generateSideWallUV:function(i,e,t,n,r,s){const a=e[t*3],c=e[t*3+1],d=e[t*3+2],f=e[n*3],p=e[n*3+1],g=e[n*3+2],v=e[r*3],y=e[r*3+1],E=e[r*3+2],T=e[s*3],w=e[s*3+1],_=e[s*3+2];return Math.abs(c-p)<Math.abs(a-f)?[new ke(a,1-d),new ke(f,1-g),new ke(v,1-E),new ke(T,1-_)]:[new ke(c,1-d),new ke(p,1-g),new ke(y,1-E),new ke(w,1-_)]}};function fR(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class zp extends hc{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new zp(e.radius,e.detail)}}class kp extends hc{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new kp(e.radius,e.detail)}}class cl extends yn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,c=Math.floor(n),d=Math.floor(r),f=c+1,p=d+1,g=e/c,v=t/d,y=[],E=[],T=[],w=[];for(let _=0;_<p;_++){const C=_*v-a;for(let b=0;b<f;b++){const I=b*g-s;E.push(I,-C,0),T.push(0,0,1),w.push(b/c),w.push(1-_/d)}}for(let _=0;_<d;_++)for(let C=0;C<c;C++){const b=C+f*_,I=C+f*(_+1),N=C+1+f*(_+1),O=C+1+f*_;y.push(b,I,O),y.push(I,N,O)}this.setIndex(y),this.setAttribute("position",new Ut(E,3)),this.setAttribute("normal",new Ut(T,3)),this.setAttribute("uv",new Ut(w,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cl(e.width,e.height,e.widthSegments,e.heightSegments)}}class l0 extends yn{constructor(e=.5,t=1,n=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);const c=[],d=[],f=[],p=[];let g=e;const v=(t-e)/r,y=new X,E=new ke;for(let T=0;T<=r;T++){for(let w=0;w<=n;w++){const _=s+w/n*a;y.x=g*Math.cos(_),y.y=g*Math.sin(_),d.push(y.x,y.y,y.z),f.push(0,0,1),E.x=(y.x/t+1)/2,E.y=(y.y/t+1)/2,p.push(E.x,E.y)}g+=v}for(let T=0;T<r;T++){const w=T*(n+1);for(let _=0;_<n;_++){const C=_+w,b=C,I=C+n+1,N=C+n+2,O=C+1;c.push(b,I,O),c.push(I,N,O)}}this.setIndex(c),this.setAttribute("position",new Ut(d,3)),this.setAttribute("normal",new Ut(f,3)),this.setAttribute("uv",new Ut(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new l0(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class c0 extends yn{constructor(e=new Iu([new ke(0,.5),new ke(-.5,-.5),new ke(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],s=[],a=[];let c=0,d=0;if(Array.isArray(e)===!1)f(e);else for(let p=0;p<e.length;p++)f(e[p]),this.addGroup(c,d,p),c+=d,d=0;this.setIndex(n),this.setAttribute("position",new Ut(r,3)),this.setAttribute("normal",new Ut(s,3)),this.setAttribute("uv",new Ut(a,2));function f(p){const g=r.length/3,v=p.extractPoints(t);let y=v.shape;const E=v.holes;ua.isClockWise(y)===!1&&(y=y.reverse());for(let w=0,_=E.length;w<_;w++){const C=E[w];ua.isClockWise(C)===!0&&(E[w]=C.reverse())}const T=ua.triangulateShape(y,E);for(let w=0,_=E.length;w<_;w++){const C=E[w];y=y.concat(C)}for(let w=0,_=y.length;w<_;w++){const C=y[w];r.push(C.x,C.y,0),s.push(0,0,1),a.push(C.x,C.y)}for(let w=0,_=T.length;w<_;w++){const C=T[w],b=C[0]+g,I=C[1]+g,N=C[2]+g;n.push(b,I,N),d+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return pR(t,e)}static fromJSON(e,t){const n=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];n.push(a)}return new c0(n,e.curveSegments)}}function pR(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}class bd extends yn{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,a=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:a,thetaLength:c},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const d=Math.min(a+c,Math.PI);let f=0;const p=[],g=new X,v=new X,y=[],E=[],T=[],w=[];for(let _=0;_<=n;_++){const C=[],b=_/n;let I=0;_===0&&a===0?I=.5/t:_===n&&d===Math.PI&&(I=-.5/t);for(let N=0;N<=t;N++){const O=N/t;g.x=-e*Math.cos(r+O*s)*Math.sin(a+b*c),g.y=e*Math.cos(a+b*c),g.z=e*Math.sin(r+O*s)*Math.sin(a+b*c),E.push(g.x,g.y,g.z),v.copy(g).normalize(),T.push(v.x,v.y,v.z),w.push(O+I,1-b),C.push(f++)}p.push(C)}for(let _=0;_<n;_++)for(let C=0;C<t;C++){const b=p[_][C+1],I=p[_][C],N=p[_+1][C],O=p[_+1][C+1];(_!==0||a>0)&&y.push(b,I,O),(_!==n-1||d<Math.PI)&&y.push(I,N,O)}this.setIndex(y),this.setAttribute("position",new Ut(E,3)),this.setAttribute("normal",new Ut(T,3)),this.setAttribute("uv",new Ut(w,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class u0 extends hc{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new u0(e.radius,e.detail)}}class h0 extends yn{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const a=[],c=[],d=[],f=[],p=new X,g=new X,v=new X;for(let y=0;y<=n;y++)for(let E=0;E<=r;E++){const T=E/r*s,w=y/n*Math.PI*2;g.x=(e+t*Math.cos(w))*Math.cos(T),g.y=(e+t*Math.cos(w))*Math.sin(T),g.z=t*Math.sin(w),c.push(g.x,g.y,g.z),p.x=e*Math.cos(T),p.y=e*Math.sin(T),v.subVectors(g,p).normalize(),d.push(v.x,v.y,v.z),f.push(E/r),f.push(y/n)}for(let y=1;y<=n;y++)for(let E=1;E<=r;E++){const T=(r+1)*y+E-1,w=(r+1)*(y-1)+E-1,_=(r+1)*(y-1)+E,C=(r+1)*y+E;a.push(T,w,C),a.push(w,_,C)}this.setIndex(a),this.setAttribute("position",new Ut(c,3)),this.setAttribute("normal",new Ut(d,3)),this.setAttribute("uv",new Ut(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new h0(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class d0 extends yn{constructor(e=1,t=.4,n=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:s,q:a},n=Math.floor(n),r=Math.floor(r);const c=[],d=[],f=[],p=[],g=new X,v=new X,y=new X,E=new X,T=new X,w=new X,_=new X;for(let b=0;b<=n;++b){const I=b/n*s*Math.PI*2;C(I,s,a,e,y),C(I+.01,s,a,e,E),w.subVectors(E,y),_.addVectors(E,y),T.crossVectors(w,_),_.crossVectors(T,w),T.normalize(),_.normalize();for(let N=0;N<=r;++N){const O=N/r*Math.PI*2,H=-t*Math.cos(O),B=t*Math.sin(O);g.x=y.x+(H*_.x+B*T.x),g.y=y.y+(H*_.y+B*T.y),g.z=y.z+(H*_.z+B*T.z),d.push(g.x,g.y,g.z),v.subVectors(g,y).normalize(),f.push(v.x,v.y,v.z),p.push(b/n),p.push(N/r)}}for(let b=1;b<=n;b++)for(let I=1;I<=r;I++){const N=(r+1)*(b-1)+(I-1),O=(r+1)*b+(I-1),H=(r+1)*b+I,B=(r+1)*(b-1)+I;c.push(N,O,B),c.push(O,H,B)}this.setIndex(c),this.setAttribute("position",new Ut(d,3)),this.setAttribute("normal",new Ut(f,3)),this.setAttribute("uv",new Ut(p,2));function C(b,I,N,O,H){const B=Math.cos(b),D=Math.sin(b),U=N/I*b,W=Math.cos(U);H.x=O*(2+W)*.5*B,H.y=O*(2+W)*D*.5,H.z=O*Math.sin(U)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new d0(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Md extends yn{constructor(e=new gx(new X(-1,-1,0),new X(-1,1,0),new X(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const c=new X,d=new X,f=new ke;let p=new X;const g=[],v=[],y=[],E=[];T(),this.setIndex(E),this.setAttribute("position",new Ut(g,3)),this.setAttribute("normal",new Ut(v,3)),this.setAttribute("uv",new Ut(y,2));function T(){for(let b=0;b<t;b++)w(b);w(s===!1?t:0),C(),_()}function w(b){p=e.getPointAt(b/t,p);const I=a.normals[b],N=a.binormals[b];for(let O=0;O<=r;O++){const H=O/r*Math.PI*2,B=Math.sin(H),D=-Math.cos(H);d.x=D*I.x+B*N.x,d.y=D*I.y+B*N.y,d.z=D*I.z+B*N.z,d.normalize(),v.push(d.x,d.y,d.z),c.x=p.x+n*d.x,c.y=p.y+n*d.y,c.z=p.z+n*d.z,g.push(c.x,c.y,c.z)}}function _(){for(let b=1;b<=t;b++)for(let I=1;I<=r;I++){const N=(r+1)*(b-1)+(I-1),O=(r+1)*b+(I-1),H=(r+1)*b+I,B=(r+1)*(b-1)+I;E.push(N,O,B),E.push(O,H,B)}}function C(){for(let b=0;b<=t;b++)for(let I=0;I<=r;I++)f.x=b/t,f.y=I/r,y.push(f.x,f.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Md(new Pv[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class _x extends yn{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new X,s=new X;if(e.index!==null){const a=e.attributes.position,c=e.index;let d=e.groups;d.length===0&&(d=[{start:0,count:c.count,materialIndex:0}]);for(let f=0,p=d.length;f<p;++f){const g=d[f],v=g.start,y=g.count;for(let E=v,T=v+y;E<T;E+=3)for(let w=0;w<3;w++){const _=c.getX(E+w),C=c.getX(E+(w+1)%3);r.fromBufferAttribute(a,_),s.fromBufferAttribute(a,C),M1(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let c=0,d=a.count/3;c<d;c++)for(let f=0;f<3;f++){const p=3*c+f,g=3*c+(f+1)%3;r.fromBufferAttribute(a,p),s.fromBufferAttribute(a,g),M1(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ut(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function M1(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var w1=Object.freeze({__proto__:null,BoxGeometry:cc,CapsuleGeometry:i0,CircleGeometry:r0,ConeGeometry:Bp,CylinderGeometry:uc,DodecahedronGeometry:s0,EdgesGeometry:Pw,ExtrudeGeometry:a0,IcosahedronGeometry:zp,LatheGeometry:Fp,OctahedronGeometry:kp,PlaneGeometry:cl,PolyhedronGeometry:hc,RingGeometry:l0,ShapeGeometry:c0,SphereGeometry:bd,TetrahedronGeometry:u0,TorusGeometry:h0,TorusKnotGeometry:d0,TubeGeometry:Md,WireframeGeometry:_x});class Uw extends pr{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new yt(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Ow extends li{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ou extends pr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new yt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vs,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Fw extends Ou{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return un(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new yt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new yt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new yt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Bw extends pr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vs,this.combine=Rp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class zw extends pr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class yx extends pr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class kw extends pr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vs,this.combine=Rp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class xx extends pr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=ac,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Sx extends pr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Hw extends pr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lc,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Vw extends os{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function wu(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Gw(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Ww(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Ry(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const c=t[s]*e;for(let d=0;d!==e;++d)r[a++]=i[c+d]}return r}function Ex(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}function mR(i,e,t,n,r=30){const s=i.clone();s.name=e;const a=[];for(let d=0;d<s.tracks.length;++d){const f=s.tracks[d],p=f.getValueSize(),g=[],v=[];for(let y=0;y<f.times.length;++y){const E=f.times[y]*r;if(!(E<t||E>=n)){g.push(f.times[y]);for(let T=0;T<p;++T)v.push(f.values[y*p+T])}}g.length!==0&&(f.times=wu(g,f.times.constructor),f.values=wu(v,f.values.constructor),a.push(f))}s.tracks=a;let c=1/0;for(let d=0;d<s.tracks.length;++d)c>s.tracks[d].times[0]&&(c=s.tracks[d].times[0]);for(let d=0;d<s.tracks.length;++d)s.tracks[d].shift(-1*c);return s.resetDuration(),s}function gR(i,e=0,t=i,n=30){n<=0&&(n=30);const r=t.tracks.length,s=e/n;for(let a=0;a<r;++a){const c=t.tracks[a],d=c.ValueTypeName;if(d==="bool"||d==="string")continue;const f=i.tracks.find(function(_){return _.name===c.name&&_.ValueTypeName===d});if(f===void 0)continue;let p=0;const g=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=g/3);let v=0;const y=f.getValueSize();f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(v=y/3);const E=c.times.length-1;let T;if(s<=c.times[0]){const _=p,C=g-p;T=c.values.slice(_,C)}else if(s>=c.times[E]){const _=E*g+p,C=_+g-p;T=c.values.slice(_,C)}else{const _=c.createInterpolant(),C=p,b=g-p;_.evaluate(s),T=_.resultBuffer.slice(C,b)}d==="quaternion"&&new ss().fromArray(T).normalize().conjugate().toArray(T);const w=f.times.length;for(let _=0;_<w;++_){const C=_*y+v;if(d==="quaternion")ss.multiplyQuaternionsFlat(f.values,C,T,0,f.values,C);else{const b=y-v*2;for(let I=0;I<b;++I)f.values[C+I]-=T[I]}}}return i.blendMode=ix,i}const vR={convertArray:wu,isTypedArray:Gw,getKeyframeOrder:Ww,sortedArray:Ry,flattenJSON:Ex,subclip:mR,makeClipAdditive:gR};class Hp{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let c=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===c)break;if(s=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=s)){const c=t[1];e<c&&(n=2,s=c);for(let d=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===d)break;if(r=s,s=t[--n-1],e>=s)break t}a=n,n=0;break n}break e}for(;n<a;){const c=n+a>>>1;e<t[c]?a=c:n=c+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class jw extends Hp{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xu,endingEnd:xu}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,a=e+1,c=r[s],d=r[a];if(c===void 0)switch(this.getSettings_().endingStart){case Su:s=e,c=2*t-n;break;case fp:s=r.length-2,c=t+r[s]-r[s+1];break;default:s=e,c=n}if(d===void 0)switch(this.getSettings_().endingEnd){case Su:a=e,d=2*n-t;break;case fp:a=1,d=n+r[1]-r[0];break;default:a=e-1,d=t}const f=(n-t)*.5,p=this.valueSize;this._weightPrev=f/(t-c),this._weightNext=f/(d-n),this._offsetPrev=s*p,this._offsetNext=a*p}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,d=e*c,f=d-c,p=this._offsetPrev,g=this._offsetNext,v=this._weightPrev,y=this._weightNext,E=(n-t)/(r-t),T=E*E,w=T*E,_=-v*w+2*v*T-v*E,C=(1+v)*w+(-1.5-2*v)*T+(-.5+v)*E+1,b=(-1-y)*w+(1.5+y)*T+.5*E,I=y*w-y*T;for(let N=0;N!==c;++N)s[N]=_*a[p+N]+C*a[f+N]+b*a[d+N]+I*a[g+N];return s}}class Mx extends Hp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,d=e*c,f=d-c,p=(n-t)/(r-t),g=1-p;for(let v=0;v!==c;++v)s[v]=a[f+v]*g+a[d+v]*p;return s}}class Xw extends Hp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Vo{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wu(t,this.TimeBufferType),this.values=wu(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:wu(e.times,Array),values:wu(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Xw(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Mx(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jw(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case dp:t=this.InterpolantFactoryMethodDiscrete;break;case bv:t=this.InterpolantFactoryMethodLinear;break;case jg:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return dp;case this.InterpolantFactoryMethodLinear:return bv;case this.InterpolantFactoryMethodSmooth:return jg}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const c=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*c,a*c)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let c=0;c!==s;c++){const d=n[c];if(typeof d=="number"&&isNaN(d)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,d),e=!1;break}if(a!==null&&a>d){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,d,a),e=!1;break}a=d}if(r!==void 0&&Gw(r))for(let c=0,d=r.length;c!==d;++c){const f=r[c];if(isNaN(f)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,c,f),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===jg,s=e.length-1;let a=1;for(let c=1;c<s;++c){let d=!1;const f=e[c],p=e[c+1];if(f!==p&&(c!==1||f!==e[0]))if(r)d=!0;else{const g=c*n,v=g-n,y=g+n;for(let E=0;E!==n;++E){const T=t[g+E];if(T!==t[v+E]||T!==t[y+E]){d=!0;break}}}if(d){if(c!==a){e[a]=e[c];const g=c*n,v=a*n;for(let y=0;y!==n;++y)t[v+y]=t[g+y]}++a}}if(s>0){e[a]=e[s];for(let c=s*n,d=a*n,f=0;f!==n;++f)t[d+f]=t[c+f];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Vo.prototype.TimeBufferType=Float32Array;Vo.prototype.ValueBufferType=Float32Array;Vo.prototype.DefaultInterpolation=bv;class Fu extends Vo{constructor(e,t,n){super(e,t,n)}}Fu.prototype.ValueTypeName="bool";Fu.prototype.ValueBufferType=Array;Fu.prototype.DefaultInterpolation=dp;Fu.prototype.InterpolantFactoryMethodLinear=void 0;Fu.prototype.InterpolantFactoryMethodSmooth=void 0;class wx extends Vo{}wx.prototype.ValueTypeName="color";class Mp extends Vo{}Mp.prototype.ValueTypeName="number";class Yw extends Hp{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,d=(n-t)/(r-t);let f=e*c;for(let p=f+c;f!==p;f+=4)ss.slerpFlat(s,0,a,f-c,a,f,d);return s}}class Vp extends Vo{InterpolantFactoryMethodLinear(e){return new Yw(this.times,this.values,this.getValueSize(),e)}}Vp.prototype.ValueTypeName="quaternion";Vp.prototype.InterpolantFactoryMethodSmooth=void 0;class Bu extends Vo{constructor(e,t,n){super(e,t,n)}}Bu.prototype.ValueTypeName="string";Bu.prototype.ValueBufferType=Array;Bu.prototype.DefaultInterpolation=dp;Bu.prototype.InterpolantFactoryMethodLinear=void 0;Bu.prototype.InterpolantFactoryMethodSmooth=void 0;class wp extends Vo{}wp.prototype.ValueTypeName="vector";class Tp{constructor(e="",t=-1,n=[],r=jv){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=ks(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,c=n.length;a!==c;++a)t.push(yR(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=n.length;s!==a;++s)t.push(Vo.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let c=0;c<s;c++){let d=[],f=[];d.push((c+s-1)%s,c,(c+1)%s),f.push(0,1,0);const p=Ww(d);d=Ry(d,1,p),f=Ry(f,1,p),!r&&d[0]===0&&(d.push(s),f.push(f[0])),a.push(new Mp(".morphTargetInfluences["+t[c].name+"]",d,f).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let c=0,d=e.length;c<d;c++){const f=e[c],p=f.name.match(s);if(p&&p.length>1){const g=p[1];let v=r[g];v||(r[g]=v=[]),v.push(f)}}const a=[];for(const c in r)a.push(this.CreateFromMorphTargetSequence(c,r[c],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(g,v,y,E,T){if(y.length!==0){const w=[],_=[];Ex(y,w,_,E),w.length!==0&&T.push(new g(v,w,_))}},r=[],s=e.name||"default",a=e.fps||30,c=e.blendMode;let d=e.length||-1;const f=e.hierarchy||[];for(let g=0;g<f.length;g++){const v=f[g].keys;if(!(!v||v.length===0))if(v[0].morphTargets){const y={};let E;for(E=0;E<v.length;E++)if(v[E].morphTargets)for(let T=0;T<v[E].morphTargets.length;T++)y[v[E].morphTargets[T]]=-1;for(const T in y){const w=[],_=[];for(let C=0;C!==v[E].morphTargets.length;++C){const b=v[E];w.push(b.time),_.push(b.morphTarget===T?1:0)}r.push(new Mp(".morphTargetInfluence["+T+"]",w,_))}d=y.length*a}else{const y=".bones["+t[g].name+"]";n(wp,y+".position",v,"pos",r),n(Vp,y+".quaternion",v,"rot",r),n(wp,y+".scale",v,"scl",r)}}return r.length===0?null:new this(s,d,r,c)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function _R(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Mp;case"vector":case"vector2":case"vector3":case"vector4":return wp;case"color":return wx;case"quaternion":return Vp;case"bool":case"boolean":return Fu;case"string":return Bu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function yR(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=_R(i.type);if(i.times===void 0){const t=[],n=[];Ex(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const nl={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class f0{constructor(e,t,n){const r=this;let s=!1,a=0,c=0,d;const f=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(p){c++,s===!1&&r.onStart!==void 0&&r.onStart(p,a,c),s=!0},this.itemEnd=function(p){a++,r.onProgress!==void 0&&r.onProgress(p,a,c),a===c&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(p){r.onError!==void 0&&r.onError(p)},this.resolveURL=function(p){return d?d(p):p},this.setURLModifier=function(p){return d=p,this},this.addHandler=function(p,g){return f.push(p,g),this},this.removeHandler=function(p){const g=f.indexOf(p);return g!==-1&&f.splice(g,2),this},this.getHandler=function(p){for(let g=0,v=f.length;g<v;g+=2){const y=f[g],E=f[g+1];if(y.global&&(y.lastIndex=0),y.test(p))return E}return null}}}const Zw=new f0;class as{constructor(e){this.manager=e!==void 0?e:Zw,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}as.DEFAULT_MATERIAL_NAME="__DEFAULT";const $a={};class xR extends Error{constructor(e,t){super(e),this.response=t}}class Hs extends as{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=nl.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if($a[e]!==void 0){$a[e].push({onLoad:t,onProgress:n,onError:r});return}$a[e]=[],$a[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),c=this.mimeType,d=this.responseType;fetch(a).then(f=>{if(f.status===200||f.status===0){if(f.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||f.body===void 0||f.body.getReader===void 0)return f;const p=$a[e],g=f.body.getReader(),v=f.headers.get("X-File-Size")||f.headers.get("Content-Length"),y=v?parseInt(v):0,E=y!==0;let T=0;const w=new ReadableStream({start(_){C();function C(){g.read().then(({done:b,value:I})=>{if(b)_.close();else{T+=I.byteLength;const N=new ProgressEvent("progress",{lengthComputable:E,loaded:T,total:y});for(let O=0,H=p.length;O<H;O++){const B=p[O];B.onProgress&&B.onProgress(N)}_.enqueue(I),C()}},b=>{_.error(b)})}}});return new Response(w)}else throw new xR(`fetch for "${f.url}" responded with ${f.status}: ${f.statusText}`,f)}).then(f=>{switch(d){case"arraybuffer":return f.arrayBuffer();case"blob":return f.blob();case"document":return f.text().then(p=>new DOMParser().parseFromString(p,c));case"json":return f.json();default:if(c===void 0)return f.text();{const g=/charset="?([^;"\s]*)"?/i.exec(c),v=g&&g[1]?g[1].toLowerCase():void 0,y=new TextDecoder(v);return f.arrayBuffer().then(E=>y.decode(E))}}}).then(f=>{nl.add(e,f);const p=$a[e];delete $a[e];for(let g=0,v=p.length;g<v;g++){const y=p[g];y.onLoad&&y.onLoad(f)}}).catch(f=>{const p=$a[e];if(p===void 0)throw this.manager.itemError(e),f;delete $a[e];for(let g=0,v=p.length;g<v;g++){const y=p[g];y.onError&&y.onError(f)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class SR extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Hs(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{t(s.parse(JSON.parse(c)))}catch(d){r?r(d):console.error(d),s.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=Tp.parse(e[n]);t.push(r)}return t}}class ER extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=[],c=new $v,d=new Hs(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(s.withCredentials);let f=0;function p(g){d.load(e[g],function(v){const y=s.parse(v,!0);a[g]={width:y.width,height:y.height,format:y.format,mipmaps:y.mipmaps},f+=1,f===6&&(y.mipmapCount===1&&(c.minFilter=On),c.image=a,c.format=y.format,c.needsUpdate=!0,t&&t(c))},n,r)}if(Array.isArray(e))for(let g=0,v=e.length;g<v;++g)p(g);else d.load(e,function(g){const v=s.parse(g,!0);if(v.isCubemap){const y=v.mipmaps.length/v.mipmapCount;for(let E=0;E<y;E++){a[E]={mipmaps:[]};for(let T=0;T<v.mipmapCount;T++)a[E].mipmaps.push(v.mipmaps[E*v.mipmapCount+T]),a[E].format=v.format,a[E].width=v.width,a[E].height=v.height}c.image=a}else c.image.width=v.width,c.image.height=v.height,c.mipmaps=v.mipmaps;v.mipmapCount===1&&(c.minFilter=On),c.format=v.format,c.needsUpdate=!0,t&&t(c)},n,r);return c}}class Ap extends as{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=nl.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const c=vp("img");function d(){p(),nl.add(e,this),t&&t(this),s.manager.itemEnd(e)}function f(g){p(),r&&r(g),s.manager.itemError(e),s.manager.itemEnd(e)}function p(){c.removeEventListener("load",d,!1),c.removeEventListener("error",f,!1)}return c.addEventListener("load",d,!1),c.addEventListener("error",f,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(c.crossOrigin=this.crossOrigin),s.manager.itemStart(e),c.src=e,c}}class qw extends as{constructor(e){super(e)}load(e,t,n,r){const s=new Up;s.colorSpace=kn;const a=new Ap(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let c=0;function d(f){a.load(e[f],function(p){s.images[f]=p,c++,c===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let f=0;f<e.length;++f)d(f);return s}}class Tx extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new ko,c=new Hs(this.manager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(s.withCredentials),c.load(e,function(d){let f;try{f=s.parse(d)}catch(p){if(r!==void 0)r(p);else{console.error(p);return}}f.image!==void 0?a.image=f.image:f.data!==void 0&&(a.image.width=f.width,a.image.height=f.height,a.image.data=f.data),a.wrapS=f.wrapS!==void 0?f.wrapS:ji,a.wrapT=f.wrapT!==void 0?f.wrapT:ji,a.magFilter=f.magFilter!==void 0?f.magFilter:On,a.minFilter=f.minFilter!==void 0?f.minFilter:On,a.anisotropy=f.anisotropy!==void 0?f.anisotropy:1,f.colorSpace!==void 0&&(a.colorSpace=f.colorSpace),f.flipY!==void 0&&(a.flipY=f.flipY),f.format!==void 0&&(a.format=f.format),f.type!==void 0&&(a.type=f.type),f.mipmaps!==void 0&&(a.mipmaps=f.mipmaps,a.minFilter=ca),f.mipmapCount===1&&(a.minFilter=On),f.generateMipmaps!==void 0&&(a.generateMipmaps=f.generateMipmaps),a.needsUpdate=!0,t&&t(a,f)},n,r),a}}class MR extends as{constructor(e){super(e)}load(e,t,n,r){const s=new Wn,a=new Ap(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(c){s.image=c,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class dc extends Cn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class Kw extends dc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new yt(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const L_=new qt,T1=new X,A1=new X;class Ax{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.map=null,this.mapPass=null,this.matrix=new qt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Op,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new _n(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;T1.setFromMatrixPosition(e.matrixWorld),t.position.copy(T1),A1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(A1),t.updateMatrixWorld(),L_.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(L_),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(L_)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class wR extends Ax{constructor(){super(new Di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=xd*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Qw extends dc{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new wR}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const C1=new qt,Ff=new X,D_=new X;class TR extends Ax{constructor(){super(new Di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ke(4,2),this._viewportCount=6,this._viewports=[new _n(2,1,1,1),new _n(0,1,1,1),new _n(3,1,1,1),new _n(1,1,1,1),new _n(3,0,1,1),new _n(1,0,1,1)],this._cubeDirections=[new X(1,0,0),new X(-1,0,0),new X(0,0,1),new X(0,0,-1),new X(0,1,0),new X(0,-1,0)],this._cubeUps=[new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,0,1),new X(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ff.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ff),D_.copy(n.position),D_.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(D_),n.updateMatrixWorld(),r.makeTranslation(-Ff.x,-Ff.y,-Ff.z),C1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(C1)}}class Jw extends dc{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new TR}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ul extends Np{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,c=r+t,d=r-t;if(this.view!==null&&this.view.enabled){const f=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=f*this.view.offsetX,a=s+f*this.view.width,c-=p*this.view.offsetY,d=c-p*this.view.height}this.projectionMatrix.makeOrthographic(s,a,c,d,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class AR extends Ax{constructor(){super(new ul(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class $w extends dc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Cn.DEFAULT_UP),this.updateMatrix(),this.target=new Cn,this.shadow=new AR}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class eT extends dc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class tT extends dc{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class nT{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new X)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(n*s)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*n*s),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}}class iT extends dc{constructor(e=new nT,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class p0 extends as{constructor(e){super(e),this.textures={}}load(e,t,n,r){const s=this,a=new Hs(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(JSON.parse(c)))}catch(d){r?r(d):console.error(d),s.manager.itemError(e)}},n,r)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new yt().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=n(a.value);break;case"c":r.uniforms[s].value=new yt().setHex(a.value);break;case"v2":r.uniforms[s].value=new ke().fromArray(a.value);break;case"v3":r.uniforms[s].value=new X().fromArray(a.value);break;case"v4":r.uniforms[s].value=new _n().fromArray(a.value);break;case"m3":r.uniforms[s].value=new pn().fromArray(a.value);break;case"m4":r.uniforms[s].value=new qt().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new ke().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return p0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:Uw,SpriteMaterial:cx,RawShaderMaterial:Ow,ShaderMaterial:li,PointsMaterial:hx,MeshPhysicalMaterial:Fw,MeshStandardMaterial:Ou,MeshPhongMaterial:Bw,MeshToonMaterial:zw,MeshNormalMaterial:yx,MeshLambertMaterial:kw,MeshDepthMaterial:xx,MeshDistanceMaterial:Sx,MeshBasicMaterial:ll,MeshMatcapMaterial:Hw,LineDashedMaterial:Vw,LineBasicMaterial:os,Material:pr};return new t[e]}}class Iy{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Cx extends yn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rT extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Hs(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(JSON.parse(c)))}catch(d){r?r(d):console.error(d),s.manager.itemError(e)}},n,r)}parse(e){const t={},n={};function r(y,E){if(t[E]!==void 0)return t[E];const w=y.interleavedBuffers[E],_=s(y,w.buffer),C=hd(w.type,_),b=new Qv(C,w.stride);return b.uuid=w.uuid,t[E]=b,b}function s(y,E){if(n[E]!==void 0)return n[E];const w=y.arrayBuffers[E],_=new Uint32Array(w).buffer;return n[E]=_,_}const a=e.isInstancedBufferGeometry?new Cx:new yn,c=e.data.index;if(c!==void 0){const y=hd(c.type,c.array);a.setIndex(new jn(y,1))}const d=e.data.attributes;for(const y in d){const E=d[y];let T;if(E.isInterleavedBufferAttribute){const w=r(e.data,E.data);T=new zs(w,E.itemSize,E.offset,E.normalized)}else{const w=hd(E.type,E.array),_=E.isInstancedBufferAttribute?Nu:jn;T=new _(w,E.itemSize,E.normalized)}E.name!==void 0&&(T.name=E.name),E.usage!==void 0&&T.setUsage(E.usage),a.setAttribute(y,T)}const f=e.data.morphAttributes;if(f)for(const y in f){const E=f[y],T=[];for(let w=0,_=E.length;w<_;w++){const C=E[w];let b;if(C.isInterleavedBufferAttribute){const I=r(e.data,C.data);b=new zs(I,C.itemSize,C.offset,C.normalized)}else{const I=hd(C.type,C.array);b=new jn(I,C.itemSize,C.normalized)}C.name!==void 0&&(b.name=C.name),T.push(b)}a.morphAttributes[y]=T}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const g=e.data.groups||e.data.drawcalls||e.data.offsets;if(g!==void 0)for(let y=0,E=g.length;y!==E;++y){const T=g[y];a.addGroup(T.start,T.count,T.materialIndex)}const v=e.data.boundingSphere;if(v!==void 0){const y=new X;v.center!==void 0&&y.fromArray(v.center),a.boundingSphere=new rr(y,v.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class CR extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=this.path===""?Iy.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const c=new Hs(this.manager);c.setPath(this.path),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(d){let f=null;try{f=JSON.parse(d)}catch(g){r!==void 0&&r(g),console.error("THREE:ObjectLoader: Can't parse "+e+".",g.message);return}const p=f.metadata;if(p===void 0||p.type===void 0||p.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(f,t)},n,r)}async loadAsync(e,t){const n=this,r=this.path===""?Iy.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Hs(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),c=JSON.parse(a),d=c.metadata;if(d===void 0||d.type===void 0||d.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(c)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(f)}),c=this.parseTextures(e.textures,a),d=this.parseMaterials(e.materials,c),f=this.parseObject(e.object,s,d,c,n),p=this.parseSkeletons(e.skeletons,f);if(this.bindSkeletons(f,p),this.bindLightTargets(f),t!==void 0){let g=!1;for(const v in a)if(a[v].data instanceof HTMLImageElement){g=!0;break}g===!1&&t(f)}return f}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),c=this.parseMaterials(e.materials,a),d=this.parseObject(e.object,r,c,a,t),f=this.parseSkeletons(e.skeletons,d);return this.bindSkeletons(d,f),this.bindLightTargets(d),d}parseShapes(e){const t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){const s=new Iu().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const c=new Jv().fromJSON(e[s],r);n[c.uuid]=c}return n}parseGeometries(e,t){const n={};if(e!==void 0){const r=new rT;for(let s=0,a=e.length;s<a;s++){let c;const d=e[s];switch(d.type){case"BufferGeometry":case"InstancedBufferGeometry":c=r.parse(d);break;default:d.type in w1?c=w1[d.type].fromJSON(d,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${d.type}"`)}c.uuid=d.uuid,d.name!==void 0&&(c.name=d.name),d.userData!==void 0&&(c.userData=d.userData),n[d.uuid]=c}}return n}parseMaterials(e,t){const n={},r={};if(e!==void 0){const s=new p0;s.setTextures(t);for(let a=0,c=e.length;a<c;a++){const d=e[a];n[d.uuid]===void 0&&(n[d.uuid]=s.parse(d)),r[d.uuid]=n[d.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const r=e[n],s=Tp.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const n=this,r={};let s;function a(d){return n.manager.itemStart(d),s.load(d,function(){n.manager.itemEnd(d)},void 0,function(){n.manager.itemError(d),n.manager.itemEnd(d)})}function c(d){if(typeof d=="string"){const f=d,p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(f)?f:n.resourcePath+f;return a(p)}else return d.data?{data:hd(d.type,d.data),width:d.width,height:d.height}:null}if(e!==void 0&&e.length>0){const d=new f0(t);s=new Ap(d),s.setCrossOrigin(this.crossOrigin);for(let f=0,p=e.length;f<p;f++){const g=e[f],v=g.url;if(Array.isArray(v)){const y=[];for(let E=0,T=v.length;E<T;E++){const w=v[E],_=c(w);_!==null&&(_ instanceof HTMLImageElement?y.push(_):y.push(new ko(_.data,_.width,_.height)))}r[g.uuid]=new Eu(y)}else{const y=c(g.url);r[g.uuid]=new Eu(y)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function s(a){if(typeof a=="string"){const c=a,d=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:t.resourcePath+c;return await r.loadAsync(d)}else return a.data?{data:hd(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Ap(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,c=e.length;a<c;a++){const d=e[a],f=d.url;if(Array.isArray(f)){const p=[];for(let g=0,v=f.length;g<v;g++){const y=f[g],E=await s(y);E!==null&&(E instanceof HTMLImageElement?p.push(E):p.push(new ko(E.data,E.width,E.height)))}n[d.uuid]=new Eu(p)}else{const p=await s(d.url);n[d.uuid]=new Eu(p)}}}return n}parseTextures(e,t){function n(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const c=e[s];c.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',c.uuid),t[c.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",c.image);const d=t[c.image],f=d.data;let p;Array.isArray(f)?(p=new Up,f.length===6&&(p.needsUpdate=!0)):(f&&f.data?p=new ko:p=new Wn,f&&(p.needsUpdate=!0)),p.source=d,p.uuid=c.uuid,c.name!==void 0&&(p.name=c.name),c.mapping!==void 0&&(p.mapping=n(c.mapping,bR)),c.channel!==void 0&&(p.channel=c.channel),c.offset!==void 0&&p.offset.fromArray(c.offset),c.repeat!==void 0&&p.repeat.fromArray(c.repeat),c.center!==void 0&&p.center.fromArray(c.center),c.rotation!==void 0&&(p.rotation=c.rotation),c.wrap!==void 0&&(p.wrapS=n(c.wrap[0],b1),p.wrapT=n(c.wrap[1],b1)),c.format!==void 0&&(p.format=c.format),c.internalFormat!==void 0&&(p.internalFormat=c.internalFormat),c.type!==void 0&&(p.type=c.type),c.colorSpace!==void 0&&(p.colorSpace=c.colorSpace),c.minFilter!==void 0&&(p.minFilter=n(c.minFilter,R1)),c.magFilter!==void 0&&(p.magFilter=n(c.magFilter,R1)),c.anisotropy!==void 0&&(p.anisotropy=c.anisotropy),c.flipY!==void 0&&(p.flipY=c.flipY),c.generateMipmaps!==void 0&&(p.generateMipmaps=c.generateMipmaps),c.premultiplyAlpha!==void 0&&(p.premultiplyAlpha=c.premultiplyAlpha),c.unpackAlignment!==void 0&&(p.unpackAlignment=c.unpackAlignment),c.compareFunction!==void 0&&(p.compareFunction=c.compareFunction),c.userData!==void 0&&(p.userData=c.userData),r[c.uuid]=p}return r}parseObject(e,t,n,r,s){let a;function c(v){return t[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",v),t[v]}function d(v){if(v!==void 0){if(Array.isArray(v)){const y=[];for(let E=0,T=v.length;E<T;E++){const w=v[E];n[w]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",w),y.push(n[w])}return y}return n[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",v),n[v]}}function f(v){return r[v]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",v),r[v]}let p,g;switch(e.type){case"Scene":a=new Du,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new yt(e.background):a.background=f(e.background)),e.environment!==void 0&&(a.environment=f(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Kv(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new qv(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new Di(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new ul(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new eT(e.color,e.intensity);break;case"DirectionalLight":a=new $w(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new Jw(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new tT(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Qw(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new Kw(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new iT().fromJSON(e);break;case"SkinnedMesh":p=c(e.geometry),g=d(e.material),a=new Ew(p,g),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":p=c(e.geometry),g=d(e.material),a=new fi(p,g);break;case"InstancedMesh":p=c(e.geometry),g=d(e.material);const v=e.count,y=e.instanceMatrix,E=e.instanceColor;a=new Ed(p,g,v),a.instanceMatrix=new Nu(new Float32Array(y.array),16),E!==void 0&&(a.instanceColor=new Nu(new Float32Array(E.array),E.itemSize));break;case"BatchedMesh":p=c(e.geometry),g=d(e.material),a=new Mw(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,g),a.geometry=p,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(T=>{const w=new ir;w.min.fromArray(T.boxMin),w.max.fromArray(T.boxMax);const _=new rr;return _.radius=T.sphereRadius,_.center.fromArray(T.sphereCenter),{boxInitialized:T.boxInitialized,box:w,sphereInitialized:T.sphereInitialized,sphere:_}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=f(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=f(e.colorsTexture.uuid));break;case"LOD":a=new Sw;break;case"Line":a=new sc(c(e.geometry),d(e.material));break;case"LineLoop":a=new ww(c(e.geometry),d(e.material));break;case"LineSegments":a=new pa(c(e.geometry),d(e.material));break;case"PointCloud":case"Points":a=new Tw(c(e.geometry),d(e.material));break;case"Sprite":a=new xw(d(e.material));break;case"Group":a=new dd;break;case"Bone":a=new ux;break;default:a=new Cn}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const v=e.children;for(let y=0;y<v.length;y++)a.add(this.parseObject(v[y],t,n,r,s))}if(e.animations!==void 0){const v=e.animations;for(let y=0;y<v.length;y++){const E=v[y];a.animations.push(s[E])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const v=e.levels;for(let y=0;y<v.length;y++){const E=v[y],T=a.getObjectByProperty("uuid",E.object);T!==void 0&&a.addLevel(T,E.distance,E.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const r=t[n.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new Cn}})}}const bR={UVMapping:tc,CubeReflectionMapping:da,CubeRefractionMapping:nc,EquirectangularReflectionMapping:_d,EquirectangularRefractionMapping:cp,CubeUVReflectionMapping:Ad},b1={RepeatWrapping:up,ClampToEdgeWrapping:ji,MirroredRepeatWrapping:hp},R1={NearestFilter:Ui,NearestMipmapNearestFilter:qy,NearestMipmapLinearFilter:ud,LinearFilter:On,LinearMipmapNearestFilter:Jf,LinearMipmapLinearFilter:ca};class RR extends as{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=nl.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(f=>{t&&t(f),s.manager.itemEnd(e)}).catch(f=>{r&&r(f)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",c.headers=this.requestHeader;const d=fetch(e,c).then(function(f){return f.blob()}).then(function(f){return createImageBitmap(f,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(f){return nl.add(e,f),t&&t(f),s.manager.itemEnd(e),f}).catch(function(f){r&&r(f),nl.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});nl.add(e,d),s.manager.itemStart(e)}}let Sg;class bx{static getContext(){return Sg===void 0&&(Sg=new(window.AudioContext||window.webkitAudioContext)),Sg}static setContext(e){Sg=e}}class IR extends as{constructor(e){super(e)}load(e,t,n,r){const s=this,a=new Hs(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(d){try{const f=d.slice(0);bx.getContext().decodeAudioData(f,function(g){t(g)}).catch(c)}catch(f){c(f)}},n,r);function c(d){r?r(d):console.error(d),s.manager.itemError(e)}}}const I1=new qt,P1=new qt,ou=new qt;class PR{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Di,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,ou.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,a=t.near*Math.tan(bu*t.fov*.5)/t.zoom;let c,d;P1.elements[12]=-r,I1.elements[12]=r,c=-a*t.aspect+s,d=a*t.aspect+s,ou.elements[0]=2*t.near/(d-c),ou.elements[8]=(d+c)/(d-c),this.cameraL.projectionMatrix.copy(ou),c=-a*t.aspect-s,d=a*t.aspect-s,ou.elements[0]=2*t.near/(d-c),ou.elements[8]=(d+c)/(d-c),this.cameraR.projectionMatrix.copy(ou)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(P1),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(I1)}}class sT extends Di{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Rx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=L1(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=L1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function L1(){return performance.now()}const au=new X,D1=new ss,LR=new X,lu=new X;class DR extends Cn{constructor(){super(),this.type="AudioListener",this.context=bx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Rx}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(au,D1,LR),lu.set(0,0,-1).applyQuaternion(D1),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(au.x,r),t.positionY.linearRampToValueAtTime(au.y,r),t.positionZ.linearRampToValueAtTime(au.z,r),t.forwardX.linearRampToValueAtTime(lu.x,r),t.forwardY.linearRampToValueAtTime(lu.y,r),t.forwardZ.linearRampToValueAtTime(lu.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(au.x,au.y,au.z),t.setOrientation(lu.x,lu.y,lu.z,n.x,n.y,n.z)}}class oT extends Cn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const cu=new X,N1=new ss,NR=new X,uu=new X;class UR extends oT{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(cu,N1,NR),uu.set(0,0,1).applyQuaternion(N1);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(cu.x,n),t.positionY.linearRampToValueAtTime(cu.y,n),t.positionZ.linearRampToValueAtTime(cu.z,n),t.orientationX.linearRampToValueAtTime(uu.x,n),t.orientationY.linearRampToValueAtTime(uu.y,n),t.orientationZ.linearRampToValueAtTime(uu.z,n)}else t.setPosition(cu.x,cu.y,cu.z),t.setOrientation(uu.x,uu.y,uu.z)}}class OR{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class aT{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let c=0;c!==r;++c)n[s+c]=n[c];a=t}else{a+=t;const c=t/a;this._mixBufferRegion(n,s,0,c,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const d=t*this._origIndex;this._mixBufferRegion(n,r,d,1-s,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let d=t,f=t+t;d!==f;++d)if(n[d]!==n[d+t]){c.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,a=r;s!==a;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){ss.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){const a=this._workIndex*s;ss.multiplyQuaternionsFlat(e,a,e,t,e,n),ss.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,s){const a=1-r;for(let c=0;c!==s;++c){const d=t+c;e[d]=e[d]*a+e[n+c]*r}}_lerpAdditive(e,t,n,r,s){for(let a=0;a!==s;++a){const c=t+a;e[c]=e[c]+e[n+a]*r}}}const Ix="\\[\\]\\.:\\/",FR=new RegExp("["+Ix+"]","g"),Px="[^"+Ix+"]",BR="[^"+Ix.replace("\\.","")+"]",zR=/((?:WC+[\/:])*)/.source.replace("WC",Px),kR=/(WCOD+)?/.source.replace("WCOD",BR),HR=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Px),VR=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Px),GR=new RegExp("^"+zR+kR+HR+VR+"$"),WR=["material","materials","bones","map"];class jR{constructor(e,t,n){const r=n||Un.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Un{constructor(e,t,n){this.path=t,this.parsedPath=n||Un.parseTrackName(t),this.node=Un.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Un.Composite(e,t,n):new Un(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(FR,"")}static parseTrackName(e){const t=GR.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);WR.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const c=s[a];if(c.name===t||c.uuid===t)return c;const d=n(c.children);if(d)return d}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Un.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let f=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let p=0;p<e.length;p++)if(e[p].name===f){f=p;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(f!==void 0){if(e[f]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[f]}}const a=e[r];if(a===void 0){const f=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+f+"."+r+" but it wasn't found.",e);return}let c=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?c=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(c=this.Versioning.MatrixWorldNeedsUpdate);let d=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}d=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(d=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(d=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[d],this.setValue=this.SetterByBindingTypeAndVersioning[d][c]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Un.Composite=jR;Un.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Un.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Un.prototype.GetterByBindingType=[Un.prototype._getValue_direct,Un.prototype._getValue_array,Un.prototype._getValue_arrayElement,Un.prototype._getValue_toArray];Un.prototype.SetterByBindingTypeAndVersioning=[[Un.prototype._setValue_direct,Un.prototype._setValue_direct_setNeedsUpdate,Un.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Un.prototype._setValue_array,Un.prototype._setValue_array_setNeedsUpdate,Un.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Un.prototype._setValue_arrayElement,Un.prototype._setValue_arrayElement_setNeedsUpdate,Un.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Un.prototype._setValue_fromArray,Un.prototype._setValue_fromArray_setNeedsUpdate,Un.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class XR{constructor(){this.isAnimationObjectGroup=!0,this.uuid=ks(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let c,d=e.length,f=this.nCachedObjects_;for(let p=0,g=arguments.length;p!==g;++p){const v=arguments[p],y=v.uuid;let E=t[y];if(E===void 0){E=d++,t[y]=E,e.push(v);for(let T=0,w=a;T!==w;++T)s[T].push(new Un(v,n[T],r[T]))}else if(E<f){c=e[E];const T=--f,w=e[T];t[w.uuid]=E,e[E]=w,t[y]=T,e[T]=v;for(let _=0,C=a;_!==C;++_){const b=s[_],I=b[T];let N=b[E];b[E]=I,N===void 0&&(N=new Un(v,n[_],r[_])),b[T]=N}}else e[E]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=f}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_;for(let a=0,c=arguments.length;a!==c;++a){const d=arguments[a],f=d.uuid,p=t[f];if(p!==void 0&&p>=s){const g=s++,v=e[g];t[v.uuid]=p,e[p]=v,t[f]=g,e[g]=d;for(let y=0,E=r;y!==E;++y){const T=n[y],w=T[g],_=T[p];T[p]=w,T[g]=_}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let s=this.nCachedObjects_,a=e.length;for(let c=0,d=arguments.length;c!==d;++c){const f=arguments[c],p=f.uuid,g=t[p];if(g!==void 0)if(delete t[p],g<s){const v=--s,y=e[v],E=--a,T=e[E];t[y.uuid]=g,e[g]=y,t[T.uuid]=v,e[v]=T,e.pop();for(let w=0,_=r;w!==_;++w){const C=n[w],b=C[v],I=C[E];C[g]=b,C[v]=I,C.pop()}}else{const v=--a,y=e[v];v>0&&(t[y.uuid]=g),e[g]=y,e.pop();for(let E=0,T=r;E!==T;++E){const w=n[E];w[g]=w[v],w.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,c=this._parsedPaths,d=this._objects,f=d.length,p=this.nCachedObjects_,g=new Array(f);r=s.length,n[e]=r,a.push(e),c.push(t),s.push(g);for(let v=p,y=d.length;v!==y;++v){const E=d[v];g[v]=new Un(E,e,t)}return g}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,c=a.length-1,d=a[c],f=e[c];t[f]=n,a[n]=d,a.pop(),s[n]=s[c],s.pop(),r[n]=r[c],r.pop()}}}class lT{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const s=t.tracks,a=s.length,c=new Array(a),d={endingStart:xu,endingEnd:xu};for(let f=0;f!==a;++f){const p=s[f].createInterpolant(null);c[f]=p,p.settings=d}this._interpolantSettings=d,this._interpolants=c,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=nw,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const r=this._clip.duration,s=e._clip.duration,a=s/r,c=r/s;e.warp(1,a,t),this.warp(c,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,s=r.time,a=this.timeScale;let c=this._timeScaleInterpolant;c===null&&(c=r._lendControlInterpolant(),this._timeScaleInterpolant=c);const d=c.parameterPositions,f=c.sampleValues;return d[0]=s,d[1]=s+n,f[0]=e/a,f[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const d=(e-s)*n;d<0||n===0?t=0:(this._startTime=null,t=n*d)}t*=this._updateTimeScale(e);const a=this._updateTime(t),c=this._updateWeight(e);if(c>0){const d=this._interpolants,f=this._propertyBindings;switch(this.blendMode){case ix:for(let p=0,g=d.length;p!==g;++p)d[p].evaluate(a),f[p].accumulateAdditive(c);break;case jv:default:for(let p=0,g=d.length;p!==g;++p)d[p].evaluate(a),f[p].accumulate(r,c)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,s=this._loopCount;const a=n===iw;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(n===tw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const c=Math.floor(r/t);r-=t*c,s+=Math.abs(c);const d=this.repetitions-s;if(d<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(d===1){const f=e<0;this._setEndings(f,!f,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:c})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=Su,r.endingEnd=Su):(e?r.endingStart=this.zeroSlopeAtStart?Su:xu:r.endingStart=fp,t?r.endingEnd=this.zeroSlopeAtEnd?Su:xu:r.endingEnd=fp)}_scheduleFading(e,t,n){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const c=a.parameterPositions,d=a.sampleValues;return c[0]=s,d[0]=t,c[1]=s+e,d[1]=n,this}}const YR=new Float32Array(1);class ZR extends Gs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,c=e._interpolants,d=n.uuid,f=this._bindingsByRootAndName;let p=f[d];p===void 0&&(p={},f[d]=p);for(let g=0;g!==s;++g){const v=r[g],y=v.name;let E=p[y];if(E!==void 0)++E.referenceCount,a[g]=E;else{if(E=a[g],E!==void 0){E._cacheIndex===null&&(++E.referenceCount,this._addInactiveBinding(E,d,y));continue}const T=t&&t._propertyBindings[g].binding.parsedPath;E=new aT(Un.create(n,y,T),v.ValueTypeName,v.getValueSize()),++E.referenceCount,this._addInactiveBinding(E,d,y),a[g]=E}c[g].resultBuffer=E.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const c=a.knownActions;e._byClipCacheIndex=c.length,c.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,c=a[s],d=c.knownActions,f=d[d.length-1],p=e._byClipCacheIndex;f._byClipCacheIndex=p,d[p]=f,d.pop(),e._byClipCacheIndex=null;const g=c.actionByRoot,v=(e._localRoot||this._root).uuid;delete g[v],d.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,a=this._bindingsByRootAndName,c=a[r],d=t[t.length-1],f=e._cacheIndex;d._cacheIndex=f,t[f]=d,t.pop(),delete c[s],Object.keys(c).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Mx(new Float32Array(2),new Float32Array(2),1,YR),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?Tp.findByName(r,e):e;const c=a!==null?a.uuid:e,d=this._actionsByClip[c];let f=null;if(n===void 0&&(a!==null?n=a.blendMode:n=jv),d!==void 0){const g=d.actionByRoot[s];if(g!==void 0&&g.blendMode===n)return g;f=d.knownActions[0],a===null&&(a=f._clip)}if(a===null)return null;const p=new lT(this,a,t,n);return this._bindAction(p,f),this._addInactiveAction(p,c,s),p}existingAction(e,t){const n=t||this._root,r=n.uuid,s=typeof e=="string"?Tp.findByName(n,e):e,a=s?s.uuid:e,c=this._actionsByClip[a];return c!==void 0&&c.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let f=0;f!==n;++f)t[f]._update(r,e,s,a);const c=this._bindings,d=this._nActiveBindings;for(let f=0;f!==d;++f)c[f].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){const a=s.knownActions;for(let c=0,d=a.length;c!==d;++c){const f=a[c];this._deactivateAction(f);const p=f._cacheIndex,g=t[t.length-1];f._cacheIndex=null,f._byClipCacheIndex=null,g._cacheIndex=p,t[p]=g,t.pop(),this._removeInactiveBindingsForAction(f)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const c=n[a].actionByRoot,d=c[t];d!==void 0&&(this._deactivateAction(d),this._removeInactiveAction(d))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const c=s[a];c.restoreOriginalState(),this._removeInactiveBinding(c)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class qR extends Yv{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Zv(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class KR extends Yv{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTargetArray=!0,this.depth=n,this.texture=new Dp(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class bn{constructor(e){this.value=e}clone(){return new bn(this.value.clone===void 0?this.value:this.value.clone())}}let QR=0;class JR extends Gs{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:QR++}),this.name="",this.usage=mp,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){const s=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Lv extends Qv{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class $R{constructor(e,t,n,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const U1=new qt;class m0{constructor(e,t,n=0,r=1/0){this.ray=new Cd(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Ru,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return U1.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(U1),this}intersectObject(e,t=!0,n=[]){return Py(e,this,n,t),n.sort(O1),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Py(e[r],this,n,t);return n.sort(O1),n}}function O1(i,e){return i.distance-e.distance}function Py(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,c=s.length;a<c;a++)Py(s[a],e,t,!0)}}class cT{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=un(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(un(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class e2{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class Lx{constructor(e,t,n,r){Lx.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}}const F1=new ke;class t2{constructor(e=new ke(1/0,1/0),t=new ke(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=F1.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,F1).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const B1=new X,Eg=new X;class uT{constructor(e=new X,t=new X){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){B1.subVectors(e,this.start),Eg.subVectors(this.end,this.start);const n=Eg.dot(Eg);let s=Eg.dot(B1)/n;return t&&(s=un(s,0,1)),s}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const z1=new X;class n2 extends Cn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new yn,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,c=1,d=32;a<d;a++,c++){const f=a/d*Math.PI*2,p=c/d*Math.PI*2;r.push(Math.cos(f),Math.sin(f),1,Math.cos(p),Math.sin(p),1)}n.setAttribute("position",new Ut(r,3));const s=new os({fog:!1,toneMapped:!1});this.cone=new pa(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),z1.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(z1),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Yl=new X,Mg=new qt,N_=new qt;class i2 extends pa{constructor(e){const t=hT(e),n=new yn,r=[],s=[],a=new yt(0,0,1),c=new yt(0,1,0);for(let f=0;f<t.length;f++){const p=t[f];p.parent&&p.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(c.r,c.g,c.b))}n.setAttribute("position",new Ut(r,3)),n.setAttribute("color",new Ut(s,3));const d=new os({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,d),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");N_.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const c=t[s];c.parent&&c.parent.isBone&&(Mg.multiplyMatrices(N_,c.matrixWorld),Yl.setFromMatrixPosition(Mg),r.setXYZ(a,Yl.x,Yl.y,Yl.z),Mg.multiplyMatrices(N_,c.parent.matrixWorld),Yl.setFromMatrixPosition(Mg),r.setXYZ(a+1,Yl.x,Yl.y,Yl.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function hT(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push.apply(e,hT(i.children[t]));return e}class r2 extends fi{constructor(e,t,n){const r=new bd(t,4,2),s=new ll({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const s2=new X,k1=new yt,H1=new yt;class o2 extends Cn{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const r=new kp(t);r.rotateY(Math.PI*.5),this.material=new ll({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new jn(a,3)),this.add(new fi(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");k1.copy(this.light.color),H1.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){const s=n<r/2?k1:H1;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(s2.setFromMatrixPosition(this.light.matrixWorld).negate())}}class a2 extends pa{constructor(e=10,t=10,n=4473924,r=8947848){n=new yt(n),r=new yt(r);const s=t/2,a=e/t,c=e/2,d=[],f=[];for(let v=0,y=0,E=-c;v<=t;v++,E+=a){d.push(-c,0,E,c,0,E),d.push(E,0,-c,E,0,c);const T=v===s?n:r;T.toArray(f,y),y+=3,T.toArray(f,y),y+=3,T.toArray(f,y),y+=3,T.toArray(f,y),y+=3}const p=new yn;p.setAttribute("position",new Ut(d,3)),p.setAttribute("color",new Ut(f,3));const g=new os({vertexColors:!0,toneMapped:!1});super(p,g),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class l2 extends pa{constructor(e=10,t=16,n=8,r=64,s=4473924,a=8947848){s=new yt(s),a=new yt(a);const c=[],d=[];if(t>1)for(let g=0;g<t;g++){const v=g/t*(Math.PI*2),y=Math.sin(v)*e,E=Math.cos(v)*e;c.push(0,0,0),c.push(y,0,E);const T=g&1?s:a;d.push(T.r,T.g,T.b),d.push(T.r,T.g,T.b)}for(let g=0;g<n;g++){const v=g&1?s:a,y=e-e/n*g;for(let E=0;E<r;E++){let T=E/r*(Math.PI*2),w=Math.sin(T)*y,_=Math.cos(T)*y;c.push(w,0,_),d.push(v.r,v.g,v.b),T=(E+1)/r*(Math.PI*2),w=Math.sin(T)*y,_=Math.cos(T)*y,c.push(w,0,_),d.push(v.r,v.g,v.b)}}const f=new yn;f.setAttribute("position",new Ut(c,3)),f.setAttribute("color",new Ut(d,3));const p=new os({vertexColors:!0,toneMapped:!1});super(f,p),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const V1=new X,wg=new X,G1=new X;class c2 extends Cn{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new yn;r.setAttribute("position",new Ut([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new os({fog:!1,toneMapped:!1});this.lightPlane=new sc(r,s),this.add(this.lightPlane),r=new yn,r.setAttribute("position",new Ut([0,0,0,0,0,1],3)),this.targetLine=new sc(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),V1.setFromMatrixPosition(this.light.matrixWorld),wg.setFromMatrixPosition(this.light.target.matrixWorld),G1.subVectors(wg,V1),this.lightPlane.lookAt(wg),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(wg),this.targetLine.scale.z=G1.length()}}const Tg=new X,bi=new Np;class u2 extends pa{constructor(e){const t=new yn,n=new os({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};c("n1","n2"),c("n2","n4"),c("n4","n3"),c("n3","n1"),c("f1","f2"),c("f2","f4"),c("f4","f3"),c("f3","f1"),c("n1","f1"),c("n2","f2"),c("n3","f3"),c("n4","f4"),c("p","n1"),c("p","n2"),c("p","n3"),c("p","n4"),c("u1","u2"),c("u2","u3"),c("u3","u1"),c("c","t"),c("p","c"),c("cn1","cn2"),c("cn3","cn4"),c("cf1","cf2"),c("cf3","cf4");function c(E,T){d(E),d(T)}function d(E){r.push(0,0,0),s.push(0,0,0),a[E]===void 0&&(a[E]=[]),a[E].push(r.length/3-1)}t.setAttribute("position",new Ut(r,3)),t.setAttribute("color",new Ut(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const f=new yt(16755200),p=new yt(16711680),g=new yt(43775),v=new yt(16777215),y=new yt(3355443);this.setColors(f,p,g,v,y)}setColors(e,t,n,r,s){const c=this.geometry.getAttribute("color");c.setXYZ(0,e.r,e.g,e.b),c.setXYZ(1,e.r,e.g,e.b),c.setXYZ(2,e.r,e.g,e.b),c.setXYZ(3,e.r,e.g,e.b),c.setXYZ(4,e.r,e.g,e.b),c.setXYZ(5,e.r,e.g,e.b),c.setXYZ(6,e.r,e.g,e.b),c.setXYZ(7,e.r,e.g,e.b),c.setXYZ(8,e.r,e.g,e.b),c.setXYZ(9,e.r,e.g,e.b),c.setXYZ(10,e.r,e.g,e.b),c.setXYZ(11,e.r,e.g,e.b),c.setXYZ(12,e.r,e.g,e.b),c.setXYZ(13,e.r,e.g,e.b),c.setXYZ(14,e.r,e.g,e.b),c.setXYZ(15,e.r,e.g,e.b),c.setXYZ(16,e.r,e.g,e.b),c.setXYZ(17,e.r,e.g,e.b),c.setXYZ(18,e.r,e.g,e.b),c.setXYZ(19,e.r,e.g,e.b),c.setXYZ(20,e.r,e.g,e.b),c.setXYZ(21,e.r,e.g,e.b),c.setXYZ(22,e.r,e.g,e.b),c.setXYZ(23,e.r,e.g,e.b),c.setXYZ(24,t.r,t.g,t.b),c.setXYZ(25,t.r,t.g,t.b),c.setXYZ(26,t.r,t.g,t.b),c.setXYZ(27,t.r,t.g,t.b),c.setXYZ(28,t.r,t.g,t.b),c.setXYZ(29,t.r,t.g,t.b),c.setXYZ(30,t.r,t.g,t.b),c.setXYZ(31,t.r,t.g,t.b),c.setXYZ(32,n.r,n.g,n.b),c.setXYZ(33,n.r,n.g,n.b),c.setXYZ(34,n.r,n.g,n.b),c.setXYZ(35,n.r,n.g,n.b),c.setXYZ(36,n.r,n.g,n.b),c.setXYZ(37,n.r,n.g,n.b),c.setXYZ(38,r.r,r.g,r.b),c.setXYZ(39,r.r,r.g,r.b),c.setXYZ(40,s.r,s.g,s.b),c.setXYZ(41,s.r,s.g,s.b),c.setXYZ(42,s.r,s.g,s.b),c.setXYZ(43,s.r,s.g,s.b),c.setXYZ(44,s.r,s.g,s.b),c.setXYZ(45,s.r,s.g,s.b),c.setXYZ(46,s.r,s.g,s.b),c.setXYZ(47,s.r,s.g,s.b),c.setXYZ(48,s.r,s.g,s.b),c.setXYZ(49,s.r,s.g,s.b),c.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,r=1;bi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const s=this.camera.coordinateSystem===Bo?-1:0;Li("c",t,e,bi,0,0,s),Li("t",t,e,bi,0,0,1),Li("n1",t,e,bi,-n,-r,s),Li("n2",t,e,bi,n,-r,s),Li("n3",t,e,bi,-n,r,s),Li("n4",t,e,bi,n,r,s),Li("f1",t,e,bi,-n,-r,1),Li("f2",t,e,bi,n,-r,1),Li("f3",t,e,bi,-n,r,1),Li("f4",t,e,bi,n,r,1),Li("u1",t,e,bi,n*.7,r*1.1,s),Li("u2",t,e,bi,-n*.7,r*1.1,s),Li("u3",t,e,bi,0,r*2,s),Li("cf1",t,e,bi,-n,0,1),Li("cf2",t,e,bi,n,0,1),Li("cf3",t,e,bi,0,-r,1),Li("cf4",t,e,bi,0,r,1),Li("cn1",t,e,bi,-n,0,s),Li("cn2",t,e,bi,n,0,s),Li("cn3",t,e,bi,0,-r,s),Li("cn4",t,e,bi,0,r,s),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Li(i,e,t,n,r,s,a){Tg.set(r,s,a).unproject(n);const c=e[i];if(c!==void 0){const d=t.getAttribute("position");for(let f=0,p=c.length;f<p;f++)d.setXYZ(c[f],Tg.x,Tg.y,Tg.z)}}const Ag=new ir;class h2 extends pa{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new yn;s.setIndex(new jn(n,1)),s.setAttribute("position",new jn(r,3)),super(s,new os({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Ag.setFromObject(this.object),Ag.isEmpty())return;const t=Ag.min,n=Ag.max,r=this.geometry.attributes.position,s=r.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class d2 extends pa{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new yn;s.setIndex(new jn(n,1)),s.setAttribute("position",new Ut(r,3)),super(s,new os({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class f2 extends sc{constructor(e,t=1,n=16776960){const r=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new yn;a.setAttribute("position",new Ut(s,3)),a.computeBoundingSphere(),super(a,new os({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const c=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],d=new yn;d.setAttribute("position",new Ut(c,3)),d.computeBoundingSphere(),this.add(new fi(d,new ll({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const W1=new X;let Cg,U_;class p2 extends Cn{constructor(e=new X(0,0,1),t=new X(0,0,0),n=1,r=16776960,s=n*.2,a=s*.2){super(),this.type="ArrowHelper",Cg===void 0&&(Cg=new yn,Cg.setAttribute("position",new Ut([0,0,0,0,1,0],3)),U_=new uc(0,.5,1,5,1),U_.translate(0,-.5,0)),this.position.copy(t),this.line=new sc(Cg,new os({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new fi(U_,new ll({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{W1.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(W1,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class m2 extends pa{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new yn;r.setAttribute("position",new Ut(t,3)),r.setAttribute("color",new Ut(n,3));const s=new os({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){const r=new yt,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class g2{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new yp,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,a){return this.currentPath.bezierCurveTo(e,t,n,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(_){const C=[];for(let b=0,I=_.length;b<I;b++){const N=_[b],O=new Iu;O.curves=N.curves,C.push(O)}return C}function n(_,C){const b=C.length;let I=!1;for(let N=b-1,O=0;O<b;N=O++){let H=C[N],B=C[O],D=B.x-H.x,U=B.y-H.y;if(Math.abs(U)>Number.EPSILON){if(U<0&&(H=C[O],D=-D,B=C[N],U=-U),_.y<H.y||_.y>B.y)continue;if(_.y===H.y){if(_.x===H.x)return!0}else{const W=U*(_.x-H.x)-D*(_.y-H.y);if(W===0)return!0;if(W<0)continue;I=!I}}else{if(_.y!==H.y)continue;if(B.x<=_.x&&_.x<=H.x||H.x<=_.x&&_.x<=B.x)return!0}}return I}const r=ua.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,c,d;const f=[];if(s.length===1)return c=s[0],d=new Iu,d.curves=c.curves,f.push(d),f;let p=!r(s[0].getPoints());p=e?!p:p;const g=[],v=[];let y=[],E=0,T;v[E]=void 0,y[E]=[];for(let _=0,C=s.length;_<C;_++)c=s[_],T=c.getPoints(),a=r(T),a=e?!a:a,a?(!p&&v[E]&&E++,v[E]={s:new Iu,p:T},v[E].s.curves=c.curves,p&&E++,y[E]=[]):y[E].push({h:c,p:T[0]});if(!v[0])return t(s);if(v.length>1){let _=!1,C=0;for(let b=0,I=v.length;b<I;b++)g[b]=[];for(let b=0,I=v.length;b<I;b++){const N=y[b];for(let O=0;O<N.length;O++){const H=N[O];let B=!0;for(let D=0;D<v.length;D++)n(H.p,v[D].p)&&(b!==D&&C++,B?(B=!1,g[D].push(H)):_=!0);B&&g[b].push(H)}}C>0&&_===!1&&(y=g)}let w;for(let _=0,C=v.length;_<C;_++){d=v[_].s,f.push(d),w=y[_];for(let b=0,I=w.length;b<I;b++)d.holes.push(w[b].h)}return f}}class v2 extends Gs{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function _2(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function y2(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function x2(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function Ly(i,e,t,n){const r=S2(n);switch(t){case Qy:return i*e;case $y:return i*e;case ex:return i*e*2;case Pp:return i*e/r.components*r.byteLength;case Lp:return i*e/r.components*r.byteLength;case tx:return i*e*2/r.components*r.byteLength;case Gv:return i*e*2/r.components*r.byteLength;case Jy:return i*e*3/r.components*r.byteLength;case Ni:return i*e*4/r.components*r.byteLength;case Wv:return i*e*4/r.components*r.byteLength;case $f:case ep:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case tp:case np:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case iv:case sv:return Math.max(i,16)*Math.max(e,8)/4;case nv:case rv:return Math.max(i,8)*Math.max(e,8)/2;case ov:case av:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case lv:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case cv:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case uv:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case hv:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case dv:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case fv:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case pv:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case mv:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case gv:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case vv:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case _v:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case yv:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case xv:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Sv:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ev:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case ip:case Mv:case wv:return Math.ceil(i/4)*Math.ceil(e/4)*16;case nx:case Tv:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Av:case Cv:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function S2(i){switch(i){case Oi:case zv:return{byteLength:1,components:1};case yd:case kv:case nr:return{byteLength:2,components:1};case Hv:case Vv:return{byteLength:2,components:4};case fa:case Ip:case di:return{byteLength:4,components:1};case Ky:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}const E2={contain:_2,cover:y2,fill:x2,getByteLength:Ly};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:oc}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=oc);/**
84
84
  * @license
85
85
  * Copyright 2010-2024 Three.js Authors
86
86
  * SPDX-License-Identifier: MIT
87
- */function dT(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function MR(i){const e=new WeakMap;function t(c,d){const f=c.array,p=c.usage,g=f.byteLength,v=i.createBuffer();i.bindBuffer(d,v),i.bufferData(d,f,p),c.onUploadCallback();let y;if(f instanceof Float32Array)y=i.FLOAT;else if(f instanceof Uint16Array)c.isFloat16BufferAttribute?y=i.HALF_FLOAT:y=i.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=i.SHORT;else if(f instanceof Uint32Array)y=i.UNSIGNED_INT;else if(f instanceof Int32Array)y=i.INT;else if(f instanceof Int8Array)y=i.BYTE;else if(f instanceof Uint8Array)y=i.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:v,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:g}}function n(c,d,f){const p=d.array,g=d.updateRanges;if(i.bindBuffer(f,c),g.length===0)i.bufferSubData(f,0,p);else{g.sort((y,E)=>y.start-E.start);let v=0;for(let y=1;y<g.length;y++){const E=g[v],T=g[y];T.start<=E.start+E.count+1?E.count=Math.max(E.count,T.start+T.count-E.start):(++v,g[v]=T)}g.length=v+1;for(let y=0,E=g.length;y<E;y++){const T=g[y];i.bufferSubData(f,T.start*p.BYTES_PER_ELEMENT,p,T.start,T.count)}d.clearUpdateRanges()}d.onUploadCallback()}function r(c){return c.isInterleavedBufferAttribute&&(c=c.data),e.get(c)}function s(c){c.isInterleavedBufferAttribute&&(c=c.data);const d=e.get(c);d&&(i.deleteBuffer(d.buffer),e.delete(c))}function a(c,d){if(c.isInterleavedBufferAttribute&&(c=c.data),c.isGLBufferAttribute){const p=e.get(c);(!p||p.version<c.version)&&e.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}const f=e.get(c);if(f===void 0)e.set(c,t(c,d));else if(f.version<c.version){if(f.size!==c.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(f.buffer,c,d),f.version=c.version}}return{get:r,remove:s,update:a}}var wR=`#ifdef USE_ALPHAHASH
87
+ */function dT(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function M2(i){const e=new WeakMap;function t(c,d){const f=c.array,p=c.usage,g=f.byteLength,v=i.createBuffer();i.bindBuffer(d,v),i.bufferData(d,f,p),c.onUploadCallback();let y;if(f instanceof Float32Array)y=i.FLOAT;else if(f instanceof Uint16Array)c.isFloat16BufferAttribute?y=i.HALF_FLOAT:y=i.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=i.SHORT;else if(f instanceof Uint32Array)y=i.UNSIGNED_INT;else if(f instanceof Int32Array)y=i.INT;else if(f instanceof Int8Array)y=i.BYTE;else if(f instanceof Uint8Array)y=i.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:v,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:g}}function n(c,d,f){const p=d.array,g=d.updateRanges;if(i.bindBuffer(f,c),g.length===0)i.bufferSubData(f,0,p);else{g.sort((y,E)=>y.start-E.start);let v=0;for(let y=1;y<g.length;y++){const E=g[v],T=g[y];T.start<=E.start+E.count+1?E.count=Math.max(E.count,T.start+T.count-E.start):(++v,g[v]=T)}g.length=v+1;for(let y=0,E=g.length;y<E;y++){const T=g[y];i.bufferSubData(f,T.start*p.BYTES_PER_ELEMENT,p,T.start,T.count)}d.clearUpdateRanges()}d.onUploadCallback()}function r(c){return c.isInterleavedBufferAttribute&&(c=c.data),e.get(c)}function s(c){c.isInterleavedBufferAttribute&&(c=c.data);const d=e.get(c);d&&(i.deleteBuffer(d.buffer),e.delete(c))}function a(c,d){if(c.isInterleavedBufferAttribute&&(c=c.data),c.isGLBufferAttribute){const p=e.get(c);(!p||p.version<c.version)&&e.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}const f=e.get(c);if(f===void 0)e.set(c,t(c,d));else if(f.version<c.version){if(f.size!==c.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(f.buffer,c,d),f.version=c.version}}return{get:r,remove:s,update:a}}var w2=`#ifdef USE_ALPHAHASH
88
88
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
89
- #endif`,TR=`#ifdef USE_ALPHAHASH
89
+ #endif`,T2=`#ifdef USE_ALPHAHASH
90
90
  const float ALPHA_HASH_SCALE = 0.05;
91
91
  float hash2D( vec2 value ) {
92
92
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -121,20 +121,20 @@ Error generating stack: `+P.message+`
121
121
  : cases.z;
122
122
  return clamp( threshold , 1.0e-6, 1.0 );
123
123
  }
124
- #endif`,AR=`#ifdef USE_ALPHAMAP
124
+ #endif`,A2=`#ifdef USE_ALPHAMAP
125
125
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
126
- #endif`,CR=`#ifdef USE_ALPHAMAP
126
+ #endif`,C2=`#ifdef USE_ALPHAMAP
127
127
  uniform sampler2D alphaMap;
128
- #endif`,bR=`#ifdef USE_ALPHATEST
128
+ #endif`,b2=`#ifdef USE_ALPHATEST
129
129
  #ifdef ALPHA_TO_COVERAGE
130
130
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
131
131
  if ( diffuseColor.a == 0.0 ) discard;
132
132
  #else
133
133
  if ( diffuseColor.a < alphaTest ) discard;
134
134
  #endif
135
- #endif`,RR=`#ifdef USE_ALPHATEST
135
+ #endif`,R2=`#ifdef USE_ALPHATEST
136
136
  uniform float alphaTest;
137
- #endif`,IR=`#ifdef USE_AOMAP
137
+ #endif`,I2=`#ifdef USE_AOMAP
138
138
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
139
139
  reflectedLight.indirectDiffuse *= ambientOcclusion;
140
140
  #if defined( USE_CLEARCOAT )
@@ -147,10 +147,10 @@ Error generating stack: `+P.message+`
147
147
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
148
148
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
149
149
  #endif
150
- #endif`,PR=`#ifdef USE_AOMAP
150
+ #endif`,P2=`#ifdef USE_AOMAP
151
151
  uniform sampler2D aoMap;
152
152
  uniform float aoMapIntensity;
153
- #endif`,LR=`#ifdef USE_BATCHING
153
+ #endif`,L2=`#ifdef USE_BATCHING
154
154
  #if ! defined( GL_ANGLE_multi_draw )
155
155
  #define gl_DrawID _gl_DrawID
156
156
  uniform int _gl_DrawID;
@@ -184,15 +184,15 @@ Error generating stack: `+P.message+`
184
184
  int y = j / size;
185
185
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
186
186
  }
187
- #endif`,DR=`#ifdef USE_BATCHING
187
+ #endif`,D2=`#ifdef USE_BATCHING
188
188
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
189
- #endif`,NR=`vec3 transformed = vec3( position );
189
+ #endif`,N2=`vec3 transformed = vec3( position );
190
190
  #ifdef USE_ALPHAHASH
191
191
  vPosition = vec3( position );
192
- #endif`,UR=`vec3 objectNormal = vec3( normal );
192
+ #endif`,U2=`vec3 objectNormal = vec3( normal );
193
193
  #ifdef USE_TANGENT
194
194
  vec3 objectTangent = vec3( tangent.xyz );
195
- #endif`,OR=`float G_BlinnPhong_Implicit( ) {
195
+ #endif`,O2=`float G_BlinnPhong_Implicit( ) {
196
196
  return 0.25;
197
197
  }
198
198
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -206,7 +206,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
206
206
  float G = G_BlinnPhong_Implicit( );
207
207
  float D = D_BlinnPhong( shininess, dotNH );
208
208
  return F * ( G * D );
209
- } // validated`,FR=`#ifdef USE_IRIDESCENCE
209
+ } // validated`,F2=`#ifdef USE_IRIDESCENCE
210
210
  const mat3 XYZ_TO_REC709 = mat3(
211
211
  3.2404542, -0.9692660, 0.0556434,
212
212
  -1.5371385, 1.8760108, -0.2040259,
@@ -269,7 +269,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
269
269
  }
270
270
  return max( I, vec3( 0.0 ) );
271
271
  }
272
- #endif`,BR=`#ifdef USE_BUMPMAP
272
+ #endif`,B2=`#ifdef USE_BUMPMAP
273
273
  uniform sampler2D bumpMap;
274
274
  uniform float bumpScale;
275
275
  vec2 dHdxy_fwd() {
@@ -290,7 +290,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
290
290
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
291
291
  return normalize( abs( fDet ) * surf_norm - vGrad );
292
292
  }
293
- #endif`,zR=`#if NUM_CLIPPING_PLANES > 0
293
+ #endif`,z2=`#if NUM_CLIPPING_PLANES > 0
294
294
  vec4 plane;
295
295
  #ifdef ALPHA_TO_COVERAGE
296
296
  float distanceToPlane, distanceGradient;
@@ -336,26 +336,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
336
336
  if ( clipped ) discard;
337
337
  #endif
338
338
  #endif
339
- #endif`,kR=`#if NUM_CLIPPING_PLANES > 0
339
+ #endif`,k2=`#if NUM_CLIPPING_PLANES > 0
340
340
  varying vec3 vClipPosition;
341
341
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
342
- #endif`,HR=`#if NUM_CLIPPING_PLANES > 0
342
+ #endif`,H2=`#if NUM_CLIPPING_PLANES > 0
343
343
  varying vec3 vClipPosition;
344
- #endif`,VR=`#if NUM_CLIPPING_PLANES > 0
344
+ #endif`,V2=`#if NUM_CLIPPING_PLANES > 0
345
345
  vClipPosition = - mvPosition.xyz;
346
- #endif`,GR=`#if defined( USE_COLOR_ALPHA )
346
+ #endif`,G2=`#if defined( USE_COLOR_ALPHA )
347
347
  diffuseColor *= vColor;
348
348
  #elif defined( USE_COLOR )
349
349
  diffuseColor.rgb *= vColor;
350
- #endif`,WR=`#if defined( USE_COLOR_ALPHA )
350
+ #endif`,W2=`#if defined( USE_COLOR_ALPHA )
351
351
  varying vec4 vColor;
352
352
  #elif defined( USE_COLOR )
353
353
  varying vec3 vColor;
354
- #endif`,jR=`#if defined( USE_COLOR_ALPHA )
354
+ #endif`,j2=`#if defined( USE_COLOR_ALPHA )
355
355
  varying vec4 vColor;
356
356
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
357
357
  varying vec3 vColor;
358
- #endif`,XR=`#if defined( USE_COLOR_ALPHA )
358
+ #endif`,X2=`#if defined( USE_COLOR_ALPHA )
359
359
  vColor = vec4( 1.0 );
360
360
  #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
361
361
  vColor = vec3( 1.0 );
@@ -369,7 +369,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
369
369
  #ifdef USE_BATCHING_COLOR
370
370
  vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
371
371
  vColor.xyz *= batchingColor.xyz;
372
- #endif`,YR=`#define PI 3.141592653589793
372
+ #endif`,Y2=`#define PI 3.141592653589793
373
373
  #define PI2 6.283185307179586
374
374
  #define PI_HALF 1.5707963267948966
375
375
  #define RECIPROCAL_PI 0.3183098861837907
@@ -443,7 +443,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
443
443
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
444
444
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
445
445
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
446
- } // validated`,ZR=`#ifdef ENVMAP_TYPE_CUBE_UV
446
+ } // validated`,Z2=`#ifdef ENVMAP_TYPE_CUBE_UV
447
447
  #define cubeUV_minMipLevel 4.0
448
448
  #define cubeUV_minTileSize 16.0
449
449
  float getFace( vec3 direction ) {
@@ -536,7 +536,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
536
536
  return vec4( mix( color0, color1, mipF ), 1.0 );
537
537
  }
538
538
  }
539
- #endif`,qR=`vec3 transformedNormal = objectNormal;
539
+ #endif`,q2=`vec3 transformedNormal = objectNormal;
540
540
  #ifdef USE_TANGENT
541
541
  vec3 transformedTangent = objectTangent;
542
542
  #endif
@@ -565,19 +565,19 @@ transformedNormal = normalMatrix * transformedNormal;
565
565
  #ifdef FLIP_SIDED
566
566
  transformedTangent = - transformedTangent;
567
567
  #endif
568
- #endif`,KR=`#ifdef USE_DISPLACEMENTMAP
568
+ #endif`,K2=`#ifdef USE_DISPLACEMENTMAP
569
569
  uniform sampler2D displacementMap;
570
570
  uniform float displacementScale;
571
571
  uniform float displacementBias;
572
- #endif`,QR=`#ifdef USE_DISPLACEMENTMAP
572
+ #endif`,Q2=`#ifdef USE_DISPLACEMENTMAP
573
573
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
574
- #endif`,JR=`#ifdef USE_EMISSIVEMAP
574
+ #endif`,J2=`#ifdef USE_EMISSIVEMAP
575
575
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
576
576
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
577
577
  emissiveColor = sRGBTransferEOTF( emissiveColor );
578
578
  #endif
579
579
  totalEmissiveRadiance *= emissiveColor.rgb;
580
- #endif`,$R=`#ifdef USE_EMISSIVEMAP
580
+ #endif`,$2=`#ifdef USE_EMISSIVEMAP
581
581
  uniform sampler2D emissiveMap;
582
582
  #endif`,eI="gl_FragColor = linearToOutputTexel( gl_FragColor );",tI=`vec4 LinearTransferOETF( in vec4 value ) {
583
583
  return value;
@@ -3610,7 +3610,7 @@ void main() {
3610
3610
  #include <tonemapping_fragment>
3611
3611
  #include <colorspace_fragment>
3612
3612
  #include <fog_fragment>
3613
- }`,En={alphahash_fragment:wR,alphahash_pars_fragment:TR,alphamap_fragment:AR,alphamap_pars_fragment:CR,alphatest_fragment:bR,alphatest_pars_fragment:RR,aomap_fragment:IR,aomap_pars_fragment:PR,batching_pars_vertex:LR,batching_vertex:DR,begin_vertex:NR,beginnormal_vertex:UR,bsdfs:OR,iridescence_fragment:FR,bumpmap_pars_fragment:BR,clipping_planes_fragment:zR,clipping_planes_pars_fragment:kR,clipping_planes_pars_vertex:HR,clipping_planes_vertex:VR,color_fragment:GR,color_pars_fragment:WR,color_pars_vertex:jR,color_vertex:XR,common:YR,cube_uv_reflection_fragment:ZR,defaultnormal_vertex:qR,displacementmap_pars_vertex:KR,displacementmap_vertex:QR,emissivemap_fragment:JR,emissivemap_pars_fragment:$R,colorspace_fragment:eI,colorspace_pars_fragment:tI,envmap_fragment:nI,envmap_common_pars_fragment:iI,envmap_pars_fragment:rI,envmap_pars_vertex:sI,envmap_physical_pars_fragment:gI,envmap_vertex:oI,fog_vertex:aI,fog_pars_vertex:lI,fog_fragment:cI,fog_pars_fragment:uI,gradientmap_pars_fragment:hI,lightmap_pars_fragment:dI,lights_lambert_fragment:fI,lights_lambert_pars_fragment:pI,lights_pars_begin:mI,lights_toon_fragment:vI,lights_toon_pars_fragment:_I,lights_phong_fragment:yI,lights_phong_pars_fragment:xI,lights_physical_fragment:SI,lights_physical_pars_fragment:EI,lights_fragment_begin:MI,lights_fragment_maps:wI,lights_fragment_end:TI,logdepthbuf_fragment:AI,logdepthbuf_pars_fragment:CI,logdepthbuf_pars_vertex:bI,logdepthbuf_vertex:RI,map_fragment:II,map_pars_fragment:PI,map_particle_fragment:LI,map_particle_pars_fragment:DI,metalnessmap_fragment:NI,metalnessmap_pars_fragment:UI,morphinstance_vertex:OI,morphcolor_vertex:FI,morphnormal_vertex:BI,morphtarget_pars_vertex:zI,morphtarget_vertex:kI,normal_fragment_begin:HI,normal_fragment_maps:VI,normal_pars_fragment:GI,normal_pars_vertex:WI,normal_vertex:jI,normalmap_pars_fragment:XI,clearcoat_normal_fragment_begin:YI,clearcoat_normal_fragment_maps:ZI,clearcoat_pars_fragment:qI,iridescence_pars_fragment:KI,opaque_fragment:QI,packing:JI,premultiplied_alpha_fragment:$I,project_vertex:eP,dithering_fragment:tP,dithering_pars_fragment:nP,roughnessmap_fragment:iP,roughnessmap_pars_fragment:rP,shadowmap_pars_fragment:sP,shadowmap_pars_vertex:oP,shadowmap_vertex:aP,shadowmask_pars_fragment:lP,skinbase_vertex:cP,skinning_pars_vertex:uP,skinning_vertex:hP,skinnormal_vertex:dP,specularmap_fragment:fP,specularmap_pars_fragment:pP,tonemapping_fragment:mP,tonemapping_pars_fragment:gP,transmission_fragment:vP,transmission_pars_fragment:_P,uv_pars_fragment:yP,uv_pars_vertex:xP,uv_vertex:SP,worldpos_vertex:EP,background_vert:MP,background_frag:wP,backgroundCube_vert:TP,backgroundCube_frag:AP,cube_vert:CP,cube_frag:bP,depth_vert:RP,depth_frag:IP,distanceRGBA_vert:PP,distanceRGBA_frag:LP,equirect_vert:DP,equirect_frag:NP,linedashed_vert:UP,linedashed_frag:OP,meshbasic_vert:FP,meshbasic_frag:BP,meshlambert_vert:zP,meshlambert_frag:kP,meshmatcap_vert:HP,meshmatcap_frag:VP,meshnormal_vert:GP,meshnormal_frag:WP,meshphong_vert:jP,meshphong_frag:XP,meshphysical_vert:YP,meshphysical_frag:ZP,meshtoon_vert:qP,meshtoon_frag:KP,points_vert:QP,points_frag:JP,shadow_vert:$P,shadow_frag:e3,sprite_vert:t3,sprite_frag:n3},_t={common:{diffuse:{value:new yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new pn},alphaMap:{value:null},alphaMapTransform:{value:new pn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new pn}},envmap:{envMap:{value:null},envMapRotation:{value:new pn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new pn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new pn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new pn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new pn},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new pn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new pn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new pn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new pn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new pn},alphaTest:{value:0},uvTransform:{value:new pn}},sprite:{diffuse:{value:new yt(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new pn},alphaMap:{value:null},alphaMapTransform:{value:new pn},alphaTest:{value:0}}},Oo={basic:{uniforms:ns([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.fog]),vertexShader:En.meshbasic_vert,fragmentShader:En.meshbasic_frag},lambert:{uniforms:ns([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new yt(0)}}]),vertexShader:En.meshlambert_vert,fragmentShader:En.meshlambert_frag},phong:{uniforms:ns([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new yt(0)},specular:{value:new yt(1118481)},shininess:{value:30}}]),vertexShader:En.meshphong_vert,fragmentShader:En.meshphong_frag},standard:{uniforms:ns([_t.common,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.roughnessmap,_t.metalnessmap,_t.fog,_t.lights,{emissive:{value:new yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag},toon:{uniforms:ns([_t.common,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.gradientmap,_t.fog,_t.lights,{emissive:{value:new yt(0)}}]),vertexShader:En.meshtoon_vert,fragmentShader:En.meshtoon_frag},matcap:{uniforms:ns([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,{matcap:{value:null}}]),vertexShader:En.meshmatcap_vert,fragmentShader:En.meshmatcap_frag},points:{uniforms:ns([_t.points,_t.fog]),vertexShader:En.points_vert,fragmentShader:En.points_frag},dashed:{uniforms:ns([_t.common,_t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:En.linedashed_vert,fragmentShader:En.linedashed_frag},depth:{uniforms:ns([_t.common,_t.displacementmap]),vertexShader:En.depth_vert,fragmentShader:En.depth_frag},normal:{uniforms:ns([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,{opacity:{value:1}}]),vertexShader:En.meshnormal_vert,fragmentShader:En.meshnormal_frag},sprite:{uniforms:ns([_t.sprite,_t.fog]),vertexShader:En.sprite_vert,fragmentShader:En.sprite_frag},background:{uniforms:{uvTransform:{value:new pn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:En.background_vert,fragmentShader:En.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new pn}},vertexShader:En.backgroundCube_vert,fragmentShader:En.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:En.cube_vert,fragmentShader:En.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:En.equirect_vert,fragmentShader:En.equirect_frag},distanceRGBA:{uniforms:ns([_t.common,_t.displacementmap,{referencePosition:{value:new X},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:En.distanceRGBA_vert,fragmentShader:En.distanceRGBA_frag},shadow:{uniforms:ns([_t.lights,_t.fog,{color:{value:new yt(0)},opacity:{value:1}}]),vertexShader:En.shadow_vert,fragmentShader:En.shadow_frag}};Oo.physical={uniforms:ns([Oo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new pn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new pn},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new pn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new pn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new pn},sheen:{value:0},sheenColor:{value:new yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new pn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new pn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new pn},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new pn},attenuationDistance:{value:0},attenuationColor:{value:new yt(0)},specularColor:{value:new yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new pn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new pn},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new pn}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag};const bg={r:0,b:0,g:0},hu=new Vs,i3=new qt;function r3(i,e,t,n,r,s,a){const c=new yt(0);let d=s===!0?0:1,f,p,g=null,v=0,y=null;function E(b){let I=b.isScene===!0?b.background:null;return I&&I.isTexture&&(I=(b.backgroundBlurriness>0?t:e).get(I)),I}function T(b){let I=!1;const N=E(b);N===null?_(c,d):N&&N.isColor&&(_(N,1),I=!0);const O=i.xr.getEnvironmentBlendMode();O==="additive"?n.buffers.color.setClear(0,0,0,1,a):O==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function w(b,I){const N=E(I);N&&(N.isCubeTexture||N.mapping===Ad)?(p===void 0&&(p=new fi(new cc(1,1,1),new li({name:"BackgroundCubeMaterial",uniforms:Sd(Oo.backgroundCube.uniforms),vertexShader:Oo.backgroundCube.vertexShader,fragmentShader:Oo.backgroundCube.fragmentShader,side:Wi,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(O,H,B){this.matrixWorld.copyPosition(B.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(p)),hu.copy(I.backgroundRotation),hu.x*=-1,hu.y*=-1,hu.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(hu.y*=-1,hu.z*=-1),p.material.uniforms.envMap.value=N,p.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(i3.makeRotationFromEuler(hu)),p.material.toneMapped=Dn.getTransfer(N.colorSpace)!==Zn,(g!==N||v!==N.version||y!==i.toneMapping)&&(p.material.needsUpdate=!0,g=N,v=N.version,y=i.toneMapping),p.layers.enableAll(),b.unshift(p,p.geometry,p.material,0,0,null)):N&&N.isTexture&&(f===void 0&&(f=new fi(new cl(2,2),new li({name:"BackgroundMaterial",uniforms:Sd(Oo.background.uniforms),vertexShader:Oo.background.vertexShader,fragmentShader:Oo.background.fragmentShader,side:ha,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(f)),f.material.uniforms.t2D.value=N,f.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,f.material.toneMapped=Dn.getTransfer(N.colorSpace)!==Zn,N.matrixAutoUpdate===!0&&N.updateMatrix(),f.material.uniforms.uvTransform.value.copy(N.matrix),(g!==N||v!==N.version||y!==i.toneMapping)&&(f.material.needsUpdate=!0,g=N,v=N.version,y=i.toneMapping),f.layers.enableAll(),b.unshift(f,f.geometry,f.material,0,0,null))}function _(b,I){b.getRGB(bg,vw(i)),n.buffers.color.setClear(bg.r,bg.g,bg.b,I,a)}function C(){p!==void 0&&(p.geometry.dispose(),p.material.dispose()),f!==void 0&&(f.geometry.dispose(),f.material.dispose())}return{getClearColor:function(){return c},setClearColor:function(b,I=1){c.set(b),d=I,_(c,d)},getClearAlpha:function(){return d},setClearAlpha:function(b){d=b,_(c,d)},render:T,addToRenderList:w,dispose:C}}function s3(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=v(null);let s=r,a=!1;function c(U,W,ne,re,he){let fe=!1;const ce=g(re,ne,W);s!==ce&&(s=ce,f(s.object)),fe=y(U,re,ne,he),fe&&E(U,re,ne,he),he!==null&&e.update(he,i.ELEMENT_ARRAY_BUFFER),(fe||a)&&(a=!1,I(U,W,ne,re),he!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(he).buffer))}function d(){return i.createVertexArray()}function f(U){return i.bindVertexArray(U)}function p(U){return i.deleteVertexArray(U)}function g(U,W,ne){const re=ne.wireframe===!0;let he=n[U.id];he===void 0&&(he={},n[U.id]=he);let fe=he[W.id];fe===void 0&&(fe={},he[W.id]=fe);let ce=fe[re];return ce===void 0&&(ce=v(d()),fe[re]=ce),ce}function v(U){const W=[],ne=[],re=[];for(let he=0;he<t;he++)W[he]=0,ne[he]=0,re[he]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:ne,attributeDivisors:re,object:U,attributes:{},index:null}}function y(U,W,ne,re){const he=s.attributes,fe=W.attributes;let ce=0;const xe=ne.getAttributes();for(const q in xe)if(xe[q].location>=0){const se=he[q];let Y=fe[q];if(Y===void 0&&(q==="instanceMatrix"&&U.instanceMatrix&&(Y=U.instanceMatrix),q==="instanceColor"&&U.instanceColor&&(Y=U.instanceColor)),se===void 0||se.attribute!==Y||Y&&se.data!==Y.data)return!0;ce++}return s.attributesNum!==ce||s.index!==re}function E(U,W,ne,re){const he={},fe=W.attributes;let ce=0;const xe=ne.getAttributes();for(const q in xe)if(xe[q].location>=0){let se=fe[q];se===void 0&&(q==="instanceMatrix"&&U.instanceMatrix&&(se=U.instanceMatrix),q==="instanceColor"&&U.instanceColor&&(se=U.instanceColor));const Y={};Y.attribute=se,se&&se.data&&(Y.data=se.data),he[q]=Y,ce++}s.attributes=he,s.attributesNum=ce,s.index=re}function T(){const U=s.newAttributes;for(let W=0,ne=U.length;W<ne;W++)U[W]=0}function w(U){_(U,0)}function _(U,W){const ne=s.newAttributes,re=s.enabledAttributes,he=s.attributeDivisors;ne[U]=1,re[U]===0&&(i.enableVertexAttribArray(U),re[U]=1),he[U]!==W&&(i.vertexAttribDivisor(U,W),he[U]=W)}function C(){const U=s.newAttributes,W=s.enabledAttributes;for(let ne=0,re=W.length;ne<re;ne++)W[ne]!==U[ne]&&(i.disableVertexAttribArray(ne),W[ne]=0)}function b(U,W,ne,re,he,fe,ce){ce===!0?i.vertexAttribIPointer(U,W,ne,he,fe):i.vertexAttribPointer(U,W,ne,re,he,fe)}function I(U,W,ne,re){T();const he=re.attributes,fe=ne.getAttributes(),ce=W.defaultAttributeValues;for(const xe in fe){const q=fe[xe];if(q.location>=0){let de=he[xe];if(de===void 0&&(xe==="instanceMatrix"&&U.instanceMatrix&&(de=U.instanceMatrix),xe==="instanceColor"&&U.instanceColor&&(de=U.instanceColor)),de!==void 0){const se=de.normalized,Y=de.itemSize,le=e.get(de);if(le===void 0)continue;const ze=le.buffer,ve=le.type,Pe=le.bytesPerElement,Le=ve===i.INT||ve===i.UNSIGNED_INT||de.gpuType===Ip;if(de.isInterleavedBufferAttribute){const Be=de.data,Ke=Be.stride,ft=de.offset;if(Be.isInstancedInterleavedBuffer){for(let ht=0;ht<q.locationSize;ht++)_(q.location+ht,Be.meshPerAttribute);U.isInstancedMesh!==!0&&re._maxInstanceCount===void 0&&(re._maxInstanceCount=Be.meshPerAttribute*Be.count)}else for(let ht=0;ht<q.locationSize;ht++)w(q.location+ht);i.bindBuffer(i.ARRAY_BUFFER,ze);for(let ht=0;ht<q.locationSize;ht++)b(q.location+ht,Y/q.locationSize,ve,se,Ke*Pe,(ft+Y/q.locationSize*ht)*Pe,Le)}else{if(de.isInstancedBufferAttribute){for(let Be=0;Be<q.locationSize;Be++)_(q.location+Be,de.meshPerAttribute);U.isInstancedMesh!==!0&&re._maxInstanceCount===void 0&&(re._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let Be=0;Be<q.locationSize;Be++)w(q.location+Be);i.bindBuffer(i.ARRAY_BUFFER,ze);for(let Be=0;Be<q.locationSize;Be++)b(q.location+Be,Y/q.locationSize,ve,se,Y*Pe,Y/q.locationSize*Be*Pe,Le)}}else if(ce!==void 0){const se=ce[xe];if(se!==void 0)switch(se.length){case 2:i.vertexAttrib2fv(q.location,se);break;case 3:i.vertexAttrib3fv(q.location,se);break;case 4:i.vertexAttrib4fv(q.location,se);break;default:i.vertexAttrib1fv(q.location,se)}}}}C()}function N(){B();for(const U in n){const W=n[U];for(const ne in W){const re=W[ne];for(const he in re)p(re[he].object),delete re[he];delete W[ne]}delete n[U]}}function O(U){if(n[U.id]===void 0)return;const W=n[U.id];for(const ne in W){const re=W[ne];for(const he in re)p(re[he].object),delete re[he];delete W[ne]}delete n[U.id]}function H(U){for(const W in n){const ne=n[W];if(ne[U.id]===void 0)continue;const re=ne[U.id];for(const he in re)p(re[he].object),delete re[he];delete ne[U.id]}}function B(){D(),a=!0,s!==r&&(s=r,f(s.object))}function D(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:c,reset:B,resetDefaultState:D,dispose:N,releaseStatesOfGeometry:O,releaseStatesOfProgram:H,initAttributes:T,enableAttribute:w,disableUnusedAttributes:C}}function o3(i,e,t){let n;function r(f){n=f}function s(f,p){i.drawArrays(n,f,p),t.update(p,n,1)}function a(f,p,g){g!==0&&(i.drawArraysInstanced(n,f,p,g),t.update(p,n,g))}function c(f,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,f,0,p,0,g);let y=0;for(let E=0;E<g;E++)y+=p[E];t.update(y,n,1)}function d(f,p,g,v){if(g===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let E=0;E<f.length;E++)a(f[E],p[E],v[E]);else{y.multiDrawArraysInstancedWEBGL(n,f,0,p,0,v,0,g);let E=0;for(let T=0;T<g;T++)E+=p[T]*v[T];t.update(E,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=c,this.renderMultiDrawInstances=d}function a3(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const H=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(H.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(H){return!(H!==Ni&&n.convert(H)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function c(H){const B=H===nr&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(H!==Oi&&n.convert(H)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&H!==di&&!B)}function d(H){if(H==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";H="mediump"}return H==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let f=t.precision!==void 0?t.precision:"highp";const p=d(f);p!==f&&(console.warn("THREE.WebGLRenderer:",f,"not supported, using",p,"instead."),f=p);const g=t.logarithmicDepthBuffer===!0,v=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),y=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),E=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_TEXTURE_SIZE),w=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),_=i.getParameter(i.MAX_VERTEX_ATTRIBS),C=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),N=E>0,O=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:d,textureFormatReadable:a,textureTypeReadable:c,precision:f,logarithmicDepthBuffer:g,reverseDepthBuffer:v,maxTextures:y,maxVertexTextures:E,maxTextureSize:T,maxCubemapSize:w,maxAttributes:_,maxVertexUniforms:C,maxVaryings:b,maxFragmentUniforms:I,vertexTextures:N,maxSamples:O}}function l3(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new el,c=new pn,d={value:null,needsUpdate:!1};this.uniform=d,this.numPlanes=0,this.numIntersection=0,this.init=function(g,v){const y=g.length!==0||v||n!==0||r;return r=v,n=g.length,y},this.beginShadows=function(){s=!0,p(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(g,v){t=p(g,v,0)},this.setState=function(g,v,y){const E=g.clippingPlanes,T=g.clipIntersection,w=g.clipShadows,_=i.get(g);if(!r||E===null||E.length===0||s&&!w)s?p(null):f();else{const C=s?0:n,b=C*4;let I=_.clippingState||null;d.value=I,I=p(E,v,b,y);for(let N=0;N!==b;++N)I[N]=t[N];_.clippingState=I,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=C}};function f(){d.value!==t&&(d.value=t,d.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function p(g,v,y,E){const T=g!==null?g.length:0;let w=null;if(T!==0){if(w=d.value,E!==!0||w===null){const _=y+T*4,C=v.matrixWorldInverse;c.getNormalMatrix(C),(w===null||w.length<_)&&(w=new Float32Array(_));for(let b=0,I=y;b!==T;++b,I+=4)a.copy(g[b]).applyMatrix4(C,c),a.normal.toArray(w,I),w[I+3]=a.constant}d.value=w,d.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,w}}function c3(i){let e=new WeakMap;function t(a,c){return c===_d?a.mapping=da:c===cp&&(a.mapping=nc),a}function n(a){if(a&&a.isTexture){const c=a.mapping;if(c===_d||c===cp)if(e.has(a)){const d=e.get(a).texture;return t(d,a.mapping)}else{const d=a.image;if(d&&d.height>0){const f=new lx(d.height);return f.fromEquirectangularTexture(i,a),e.set(a,f),a.addEventListener("dispose",r),t(f.texture,a.mapping)}else return null}}return a}function r(a){const c=a.target;c.removeEventListener("dispose",r);const d=e.get(c);d!==void 0&&(e.delete(c),d.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const pd=4,j1=[.125,.215,.35,.446,.526,.582],vu=20,O_=new ul,X1=new yt;let F_=null,B_=0,z_=0,k_=!1;const gu=(1+Math.sqrt(5))/2,ed=1/gu,Y1=[new X(-gu,ed,0),new X(gu,ed,0),new X(-ed,0,gu),new X(ed,0,gu),new X(0,gu,-ed),new X(0,gu,ed),new X(-1,1,-1),new X(1,1,-1),new X(-1,1,1),new X(1,1,1)];class Dy{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){F_=this._renderer.getRenderTarget(),B_=this._renderer.getActiveCubeFace(),z_=this._renderer.getActiveMipmapLevel(),k_=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=K1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=q1(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(F_,B_,z_),this._renderer.xr.enabled=k_,e.scissorTest=!1,Rg(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===da||e.mapping===nc?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),F_=this._renderer.getRenderTarget(),B_=this._renderer.getActiveCubeFace(),z_=this._renderer.getActiveMipmapLevel(),k_=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:On,minFilter:On,generateMipmaps:!1,type:nr,format:Ni,colorSpace:ro,depthBuffer:!1},r=Z1(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Z1(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=u3(s)),this._blurMaterial=h3(s,e,t)}return r}_compileMaterial(e){const t=new fi(this._lodPlanes[0],e);this._renderer.compile(t,O_)}_sceneToCubeUV(e,t,n,r){const c=new Di(90,1,t,n),d=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],p=this._renderer,g=p.autoClear,v=p.toneMapping;p.getClearColor(X1),p.toneMapping=zo,p.autoClear=!1;const y=new ll({name:"PMREM.Background",side:Wi,depthWrite:!1,depthTest:!1}),E=new fi(new cc,y);let T=!1;const w=e.background;w?w.isColor&&(y.color.copy(w),e.background=null,T=!0):(y.color.copy(X1),T=!0);for(let _=0;_<6;_++){const C=_%3;C===0?(c.up.set(0,d[_],0),c.lookAt(f[_],0,0)):C===1?(c.up.set(0,0,d[_]),c.lookAt(0,f[_],0)):(c.up.set(0,d[_],0),c.lookAt(0,0,f[_]));const b=this._cubeSize;Rg(r,C*b,_>2?b:0,b,b),p.setRenderTarget(r),T&&p.render(E,c),p.render(e,c)}E.geometry.dispose(),E.material.dispose(),p.toneMapping=v,p.autoClear=g,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===da||e.mapping===nc;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=K1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=q1());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new fi(this._lodPlanes[0],s),c=s.uniforms;c.envMap.value=e;const d=this._cubeSize;Rg(t,0,0,3*d,2*d),n.setRenderTarget(t),n.render(a,O_)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),c=Y1[(r-s-1)%Y1.length];this._blur(e,s-1,s,a,c)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,c){const d=this._renderer,f=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const p=3,g=new fi(this._lodPlanes[r],f),v=f.uniforms,y=this._sizeLods[n]-1,E=isFinite(s)?Math.PI/(2*y):2*Math.PI/(2*vu-1),T=s/E,w=isFinite(s)?1+Math.floor(p*T):vu;w>vu&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${w} samples when the maximum is set to ${vu}`);const _=[];let C=0;for(let H=0;H<vu;++H){const B=H/T,D=Math.exp(-B*B/2);_.push(D),H===0?C+=D:H<w&&(C+=2*D)}for(let H=0;H<_.length;H++)_[H]=_[H]/C;v.envMap.value=e.texture,v.samples.value=w,v.weights.value=_,v.latitudinal.value=a==="latitudinal",c&&(v.poleAxis.value=c);const{_lodMax:b}=this;v.dTheta.value=E,v.mipInt.value=b-n;const I=this._sizeLods[r],N=3*I*(r>b-pd?r-b+pd:0),O=4*(this._cubeSize-I);Rg(t,N,O,3*I,2*I),d.setRenderTarget(t),d.render(g,O_)}}function u3(i){const e=[],t=[],n=[];let r=i;const s=i-pd+1+j1.length;for(let a=0;a<s;a++){const c=Math.pow(2,r);t.push(c);let d=1/c;a>i-pd?d=j1[a-i+pd-1]:a===0&&(d=0),n.push(d);const f=1/(c-2),p=-f,g=1+f,v=[p,p,g,p,g,g,p,p,g,g,p,g],y=6,E=6,T=3,w=2,_=1,C=new Float32Array(T*E*y),b=new Float32Array(w*E*y),I=new Float32Array(_*E*y);for(let O=0;O<y;O++){const H=O%3*2/3-1,B=O>2?0:-1,D=[H,B,0,H+2/3,B,0,H+2/3,B+1,0,H,B,0,H+2/3,B+1,0,H,B+1,0];C.set(D,T*E*O),b.set(v,w*E*O);const U=[O,O,O,O,O,O];I.set(U,_*E*O)}const N=new yn;N.setAttribute("position",new jn(C,T)),N.setAttribute("uv",new jn(b,w)),N.setAttribute("faceIndex",new jn(I,_)),e.push(N),r>pd&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Z1(i,e,t){const n=new Mi(i,e,t);return n.texture.mapping=Ad,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Rg(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function h3(i,e,t){const n=new Float32Array(vu),r=new X(0,1,0);return new li({name:"SphericalGaussianBlur",defines:{n:vu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Dx(),fragmentShader:`
3613
+ }`,En={alphahash_fragment:w2,alphahash_pars_fragment:T2,alphamap_fragment:A2,alphamap_pars_fragment:C2,alphatest_fragment:b2,alphatest_pars_fragment:R2,aomap_fragment:I2,aomap_pars_fragment:P2,batching_pars_vertex:L2,batching_vertex:D2,begin_vertex:N2,beginnormal_vertex:U2,bsdfs:O2,iridescence_fragment:F2,bumpmap_pars_fragment:B2,clipping_planes_fragment:z2,clipping_planes_pars_fragment:k2,clipping_planes_pars_vertex:H2,clipping_planes_vertex:V2,color_fragment:G2,color_pars_fragment:W2,color_pars_vertex:j2,color_vertex:X2,common:Y2,cube_uv_reflection_fragment:Z2,defaultnormal_vertex:q2,displacementmap_pars_vertex:K2,displacementmap_vertex:Q2,emissivemap_fragment:J2,emissivemap_pars_fragment:$2,colorspace_fragment:eI,colorspace_pars_fragment:tI,envmap_fragment:nI,envmap_common_pars_fragment:iI,envmap_pars_fragment:rI,envmap_pars_vertex:sI,envmap_physical_pars_fragment:gI,envmap_vertex:oI,fog_vertex:aI,fog_pars_vertex:lI,fog_fragment:cI,fog_pars_fragment:uI,gradientmap_pars_fragment:hI,lightmap_pars_fragment:dI,lights_lambert_fragment:fI,lights_lambert_pars_fragment:pI,lights_pars_begin:mI,lights_toon_fragment:vI,lights_toon_pars_fragment:_I,lights_phong_fragment:yI,lights_phong_pars_fragment:xI,lights_physical_fragment:SI,lights_physical_pars_fragment:EI,lights_fragment_begin:MI,lights_fragment_maps:wI,lights_fragment_end:TI,logdepthbuf_fragment:AI,logdepthbuf_pars_fragment:CI,logdepthbuf_pars_vertex:bI,logdepthbuf_vertex:RI,map_fragment:II,map_pars_fragment:PI,map_particle_fragment:LI,map_particle_pars_fragment:DI,metalnessmap_fragment:NI,metalnessmap_pars_fragment:UI,morphinstance_vertex:OI,morphcolor_vertex:FI,morphnormal_vertex:BI,morphtarget_pars_vertex:zI,morphtarget_vertex:kI,normal_fragment_begin:HI,normal_fragment_maps:VI,normal_pars_fragment:GI,normal_pars_vertex:WI,normal_vertex:jI,normalmap_pars_fragment:XI,clearcoat_normal_fragment_begin:YI,clearcoat_normal_fragment_maps:ZI,clearcoat_pars_fragment:qI,iridescence_pars_fragment:KI,opaque_fragment:QI,packing:JI,premultiplied_alpha_fragment:$I,project_vertex:eP,dithering_fragment:tP,dithering_pars_fragment:nP,roughnessmap_fragment:iP,roughnessmap_pars_fragment:rP,shadowmap_pars_fragment:sP,shadowmap_pars_vertex:oP,shadowmap_vertex:aP,shadowmask_pars_fragment:lP,skinbase_vertex:cP,skinning_pars_vertex:uP,skinning_vertex:hP,skinnormal_vertex:dP,specularmap_fragment:fP,specularmap_pars_fragment:pP,tonemapping_fragment:mP,tonemapping_pars_fragment:gP,transmission_fragment:vP,transmission_pars_fragment:_P,uv_pars_fragment:yP,uv_pars_vertex:xP,uv_vertex:SP,worldpos_vertex:EP,background_vert:MP,background_frag:wP,backgroundCube_vert:TP,backgroundCube_frag:AP,cube_vert:CP,cube_frag:bP,depth_vert:RP,depth_frag:IP,distanceRGBA_vert:PP,distanceRGBA_frag:LP,equirect_vert:DP,equirect_frag:NP,linedashed_vert:UP,linedashed_frag:OP,meshbasic_vert:FP,meshbasic_frag:BP,meshlambert_vert:zP,meshlambert_frag:kP,meshmatcap_vert:HP,meshmatcap_frag:VP,meshnormal_vert:GP,meshnormal_frag:WP,meshphong_vert:jP,meshphong_frag:XP,meshphysical_vert:YP,meshphysical_frag:ZP,meshtoon_vert:qP,meshtoon_frag:KP,points_vert:QP,points_frag:JP,shadow_vert:$P,shadow_frag:e3,sprite_vert:t3,sprite_frag:n3},_t={common:{diffuse:{value:new yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new pn},alphaMap:{value:null},alphaMapTransform:{value:new pn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new pn}},envmap:{envMap:{value:null},envMapRotation:{value:new pn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new pn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new pn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new pn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new pn},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new pn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new pn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new pn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new pn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new pn},alphaTest:{value:0},uvTransform:{value:new pn}},sprite:{diffuse:{value:new yt(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new pn},alphaMap:{value:null},alphaMapTransform:{value:new pn},alphaTest:{value:0}}},Oo={basic:{uniforms:ns([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.fog]),vertexShader:En.meshbasic_vert,fragmentShader:En.meshbasic_frag},lambert:{uniforms:ns([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new yt(0)}}]),vertexShader:En.meshlambert_vert,fragmentShader:En.meshlambert_frag},phong:{uniforms:ns([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new yt(0)},specular:{value:new yt(1118481)},shininess:{value:30}}]),vertexShader:En.meshphong_vert,fragmentShader:En.meshphong_frag},standard:{uniforms:ns([_t.common,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.roughnessmap,_t.metalnessmap,_t.fog,_t.lights,{emissive:{value:new yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag},toon:{uniforms:ns([_t.common,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.gradientmap,_t.fog,_t.lights,{emissive:{value:new yt(0)}}]),vertexShader:En.meshtoon_vert,fragmentShader:En.meshtoon_frag},matcap:{uniforms:ns([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,{matcap:{value:null}}]),vertexShader:En.meshmatcap_vert,fragmentShader:En.meshmatcap_frag},points:{uniforms:ns([_t.points,_t.fog]),vertexShader:En.points_vert,fragmentShader:En.points_frag},dashed:{uniforms:ns([_t.common,_t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:En.linedashed_vert,fragmentShader:En.linedashed_frag},depth:{uniforms:ns([_t.common,_t.displacementmap]),vertexShader:En.depth_vert,fragmentShader:En.depth_frag},normal:{uniforms:ns([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,{opacity:{value:1}}]),vertexShader:En.meshnormal_vert,fragmentShader:En.meshnormal_frag},sprite:{uniforms:ns([_t.sprite,_t.fog]),vertexShader:En.sprite_vert,fragmentShader:En.sprite_frag},background:{uniforms:{uvTransform:{value:new pn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:En.background_vert,fragmentShader:En.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new pn}},vertexShader:En.backgroundCube_vert,fragmentShader:En.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:En.cube_vert,fragmentShader:En.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:En.equirect_vert,fragmentShader:En.equirect_frag},distanceRGBA:{uniforms:ns([_t.common,_t.displacementmap,{referencePosition:{value:new X},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:En.distanceRGBA_vert,fragmentShader:En.distanceRGBA_frag},shadow:{uniforms:ns([_t.lights,_t.fog,{color:{value:new yt(0)},opacity:{value:1}}]),vertexShader:En.shadow_vert,fragmentShader:En.shadow_frag}};Oo.physical={uniforms:ns([Oo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new pn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new pn},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new pn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new pn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new pn},sheen:{value:0},sheenColor:{value:new yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new pn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new pn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new pn},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new pn},attenuationDistance:{value:0},attenuationColor:{value:new yt(0)},specularColor:{value:new yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new pn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new pn},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new pn}}]),vertexShader:En.meshphysical_vert,fragmentShader:En.meshphysical_frag};const bg={r:0,b:0,g:0},hu=new Vs,i3=new qt;function r3(i,e,t,n,r,s,a){const c=new yt(0);let d=s===!0?0:1,f,p,g=null,v=0,y=null;function E(b){let I=b.isScene===!0?b.background:null;return I&&I.isTexture&&(I=(b.backgroundBlurriness>0?t:e).get(I)),I}function T(b){let I=!1;const N=E(b);N===null?_(c,d):N&&N.isColor&&(_(N,1),I=!0);const O=i.xr.getEnvironmentBlendMode();O==="additive"?n.buffers.color.setClear(0,0,0,1,a):O==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function w(b,I){const N=E(I);N&&(N.isCubeTexture||N.mapping===Ad)?(p===void 0&&(p=new fi(new cc(1,1,1),new li({name:"BackgroundCubeMaterial",uniforms:Sd(Oo.backgroundCube.uniforms),vertexShader:Oo.backgroundCube.vertexShader,fragmentShader:Oo.backgroundCube.fragmentShader,side:Wi,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(O,H,B){this.matrixWorld.copyPosition(B.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(p)),hu.copy(I.backgroundRotation),hu.x*=-1,hu.y*=-1,hu.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(hu.y*=-1,hu.z*=-1),p.material.uniforms.envMap.value=N,p.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(i3.makeRotationFromEuler(hu)),p.material.toneMapped=Dn.getTransfer(N.colorSpace)!==Zn,(g!==N||v!==N.version||y!==i.toneMapping)&&(p.material.needsUpdate=!0,g=N,v=N.version,y=i.toneMapping),p.layers.enableAll(),b.unshift(p,p.geometry,p.material,0,0,null)):N&&N.isTexture&&(f===void 0&&(f=new fi(new cl(2,2),new li({name:"BackgroundMaterial",uniforms:Sd(Oo.background.uniforms),vertexShader:Oo.background.vertexShader,fragmentShader:Oo.background.fragmentShader,side:ha,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(f)),f.material.uniforms.t2D.value=N,f.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,f.material.toneMapped=Dn.getTransfer(N.colorSpace)!==Zn,N.matrixAutoUpdate===!0&&N.updateMatrix(),f.material.uniforms.uvTransform.value.copy(N.matrix),(g!==N||v!==N.version||y!==i.toneMapping)&&(f.material.needsUpdate=!0,g=N,v=N.version,y=i.toneMapping),f.layers.enableAll(),b.unshift(f,f.geometry,f.material,0,0,null))}function _(b,I){b.getRGB(bg,vw(i)),n.buffers.color.setClear(bg.r,bg.g,bg.b,I,a)}function C(){p!==void 0&&(p.geometry.dispose(),p.material.dispose()),f!==void 0&&(f.geometry.dispose(),f.material.dispose())}return{getClearColor:function(){return c},setClearColor:function(b,I=1){c.set(b),d=I,_(c,d)},getClearAlpha:function(){return d},setClearAlpha:function(b){d=b,_(c,d)},render:T,addToRenderList:w,dispose:C}}function s3(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=v(null);let s=r,a=!1;function c(U,W,ne,re,he){let fe=!1;const ce=g(re,ne,W);s!==ce&&(s=ce,f(s.object)),fe=y(U,re,ne,he),fe&&E(U,re,ne,he),he!==null&&e.update(he,i.ELEMENT_ARRAY_BUFFER),(fe||a)&&(a=!1,I(U,W,ne,re),he!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(he).buffer))}function d(){return i.createVertexArray()}function f(U){return i.bindVertexArray(U)}function p(U){return i.deleteVertexArray(U)}function g(U,W,ne){const re=ne.wireframe===!0;let he=n[U.id];he===void 0&&(he={},n[U.id]=he);let fe=he[W.id];fe===void 0&&(fe={},he[W.id]=fe);let ce=fe[re];return ce===void 0&&(ce=v(d()),fe[re]=ce),ce}function v(U){const W=[],ne=[],re=[];for(let he=0;he<t;he++)W[he]=0,ne[he]=0,re[he]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:ne,attributeDivisors:re,object:U,attributes:{},index:null}}function y(U,W,ne,re){const he=s.attributes,fe=W.attributes;let ce=0;const xe=ne.getAttributes();for(const q in xe)if(xe[q].location>=0){const se=he[q];let Y=fe[q];if(Y===void 0&&(q==="instanceMatrix"&&U.instanceMatrix&&(Y=U.instanceMatrix),q==="instanceColor"&&U.instanceColor&&(Y=U.instanceColor)),se===void 0||se.attribute!==Y||Y&&se.data!==Y.data)return!0;ce++}return s.attributesNum!==ce||s.index!==re}function E(U,W,ne,re){const he={},fe=W.attributes;let ce=0;const xe=ne.getAttributes();for(const q in xe)if(xe[q].location>=0){let se=fe[q];se===void 0&&(q==="instanceMatrix"&&U.instanceMatrix&&(se=U.instanceMatrix),q==="instanceColor"&&U.instanceColor&&(se=U.instanceColor));const Y={};Y.attribute=se,se&&se.data&&(Y.data=se.data),he[q]=Y,ce++}s.attributes=he,s.attributesNum=ce,s.index=re}function T(){const U=s.newAttributes;for(let W=0,ne=U.length;W<ne;W++)U[W]=0}function w(U){_(U,0)}function _(U,W){const ne=s.newAttributes,re=s.enabledAttributes,he=s.attributeDivisors;ne[U]=1,re[U]===0&&(i.enableVertexAttribArray(U),re[U]=1),he[U]!==W&&(i.vertexAttribDivisor(U,W),he[U]=W)}function C(){const U=s.newAttributes,W=s.enabledAttributes;for(let ne=0,re=W.length;ne<re;ne++)W[ne]!==U[ne]&&(i.disableVertexAttribArray(ne),W[ne]=0)}function b(U,W,ne,re,he,fe,ce){ce===!0?i.vertexAttribIPointer(U,W,ne,he,fe):i.vertexAttribPointer(U,W,ne,re,he,fe)}function I(U,W,ne,re){T();const he=re.attributes,fe=ne.getAttributes(),ce=W.defaultAttributeValues;for(const xe in fe){const q=fe[xe];if(q.location>=0){let de=he[xe];if(de===void 0&&(xe==="instanceMatrix"&&U.instanceMatrix&&(de=U.instanceMatrix),xe==="instanceColor"&&U.instanceColor&&(de=U.instanceColor)),de!==void 0){const se=de.normalized,Y=de.itemSize,le=e.get(de);if(le===void 0)continue;const ze=le.buffer,ve=le.type,Pe=le.bytesPerElement,Le=ve===i.INT||ve===i.UNSIGNED_INT||de.gpuType===Ip;if(de.isInterleavedBufferAttribute){const Be=de.data,Ke=Be.stride,ft=de.offset;if(Be.isInstancedInterleavedBuffer){for(let ht=0;ht<q.locationSize;ht++)_(q.location+ht,Be.meshPerAttribute);U.isInstancedMesh!==!0&&re._maxInstanceCount===void 0&&(re._maxInstanceCount=Be.meshPerAttribute*Be.count)}else for(let ht=0;ht<q.locationSize;ht++)w(q.location+ht);i.bindBuffer(i.ARRAY_BUFFER,ze);for(let ht=0;ht<q.locationSize;ht++)b(q.location+ht,Y/q.locationSize,ve,se,Ke*Pe,(ft+Y/q.locationSize*ht)*Pe,Le)}else{if(de.isInstancedBufferAttribute){for(let Be=0;Be<q.locationSize;Be++)_(q.location+Be,de.meshPerAttribute);U.isInstancedMesh!==!0&&re._maxInstanceCount===void 0&&(re._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let Be=0;Be<q.locationSize;Be++)w(q.location+Be);i.bindBuffer(i.ARRAY_BUFFER,ze);for(let Be=0;Be<q.locationSize;Be++)b(q.location+Be,Y/q.locationSize,ve,se,Y*Pe,Y/q.locationSize*Be*Pe,Le)}}else if(ce!==void 0){const se=ce[xe];if(se!==void 0)switch(se.length){case 2:i.vertexAttrib2fv(q.location,se);break;case 3:i.vertexAttrib3fv(q.location,se);break;case 4:i.vertexAttrib4fv(q.location,se);break;default:i.vertexAttrib1fv(q.location,se)}}}}C()}function N(){B();for(const U in n){const W=n[U];for(const ne in W){const re=W[ne];for(const he in re)p(re[he].object),delete re[he];delete W[ne]}delete n[U]}}function O(U){if(n[U.id]===void 0)return;const W=n[U.id];for(const ne in W){const re=W[ne];for(const he in re)p(re[he].object),delete re[he];delete W[ne]}delete n[U.id]}function H(U){for(const W in n){const ne=n[W];if(ne[U.id]===void 0)continue;const re=ne[U.id];for(const he in re)p(re[he].object),delete re[he];delete ne[U.id]}}function B(){D(),a=!0,s!==r&&(s=r,f(s.object))}function D(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:c,reset:B,resetDefaultState:D,dispose:N,releaseStatesOfGeometry:O,releaseStatesOfProgram:H,initAttributes:T,enableAttribute:w,disableUnusedAttributes:C}}function o3(i,e,t){let n;function r(f){n=f}function s(f,p){i.drawArrays(n,f,p),t.update(p,n,1)}function a(f,p,g){g!==0&&(i.drawArraysInstanced(n,f,p,g),t.update(p,n,g))}function c(f,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,f,0,p,0,g);let y=0;for(let E=0;E<g;E++)y+=p[E];t.update(y,n,1)}function d(f,p,g,v){if(g===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let E=0;E<f.length;E++)a(f[E],p[E],v[E]);else{y.multiDrawArraysInstancedWEBGL(n,f,0,p,0,v,0,g);let E=0;for(let T=0;T<g;T++)E+=p[T]*v[T];t.update(E,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=c,this.renderMultiDrawInstances=d}function a3(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const H=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(H.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(H){return!(H!==Ni&&n.convert(H)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function c(H){const B=H===nr&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(H!==Oi&&n.convert(H)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&H!==di&&!B)}function d(H){if(H==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";H="mediump"}return H==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let f=t.precision!==void 0?t.precision:"highp";const p=d(f);p!==f&&(console.warn("THREE.WebGLRenderer:",f,"not supported, using",p,"instead."),f=p);const g=t.logarithmicDepthBuffer===!0,v=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),y=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),E=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_TEXTURE_SIZE),w=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),_=i.getParameter(i.MAX_VERTEX_ATTRIBS),C=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),N=E>0,O=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:d,textureFormatReadable:a,textureTypeReadable:c,precision:f,logarithmicDepthBuffer:g,reverseDepthBuffer:v,maxTextures:y,maxVertexTextures:E,maxTextureSize:T,maxCubemapSize:w,maxAttributes:_,maxVertexUniforms:C,maxVaryings:b,maxFragmentUniforms:I,vertexTextures:N,maxSamples:O}}function l3(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new el,c=new pn,d={value:null,needsUpdate:!1};this.uniform=d,this.numPlanes=0,this.numIntersection=0,this.init=function(g,v){const y=g.length!==0||v||n!==0||r;return r=v,n=g.length,y},this.beginShadows=function(){s=!0,p(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(g,v){t=p(g,v,0)},this.setState=function(g,v,y){const E=g.clippingPlanes,T=g.clipIntersection,w=g.clipShadows,_=i.get(g);if(!r||E===null||E.length===0||s&&!w)s?p(null):f();else{const C=s?0:n,b=C*4;let I=_.clippingState||null;d.value=I,I=p(E,v,b,y);for(let N=0;N!==b;++N)I[N]=t[N];_.clippingState=I,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=C}};function f(){d.value!==t&&(d.value=t,d.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function p(g,v,y,E){const T=g!==null?g.length:0;let w=null;if(T!==0){if(w=d.value,E!==!0||w===null){const _=y+T*4,C=v.matrixWorldInverse;c.getNormalMatrix(C),(w===null||w.length<_)&&(w=new Float32Array(_));for(let b=0,I=y;b!==T;++b,I+=4)a.copy(g[b]).applyMatrix4(C,c),a.normal.toArray(w,I),w[I+3]=a.constant}d.value=w,d.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,w}}function c3(i){let e=new WeakMap;function t(a,c){return c===_d?a.mapping=da:c===cp&&(a.mapping=nc),a}function n(a){if(a&&a.isTexture){const c=a.mapping;if(c===_d||c===cp)if(e.has(a)){const d=e.get(a).texture;return t(d,a.mapping)}else{const d=a.image;if(d&&d.height>0){const f=new lx(d.height);return f.fromEquirectangularTexture(i,a),e.set(a,f),a.addEventListener("dispose",r),t(f.texture,a.mapping)}else return null}}return a}function r(a){const c=a.target;c.removeEventListener("dispose",r);const d=e.get(c);d!==void 0&&(e.delete(c),d.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const pd=4,j1=[.125,.215,.35,.446,.526,.582],vu=20,O_=new ul,X1=new yt;let F_=null,B_=0,z_=0,k_=!1;const gu=(1+Math.sqrt(5))/2,ed=1/gu,Y1=[new X(-gu,ed,0),new X(gu,ed,0),new X(-ed,0,gu),new X(ed,0,gu),new X(0,gu,-ed),new X(0,gu,ed),new X(-1,1,-1),new X(1,1,-1),new X(-1,1,1),new X(1,1,1)];class Dy{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){F_=this._renderer.getRenderTarget(),B_=this._renderer.getActiveCubeFace(),z_=this._renderer.getActiveMipmapLevel(),k_=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=K1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=q1(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(F_,B_,z_),this._renderer.xr.enabled=k_,e.scissorTest=!1,Rg(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===da||e.mapping===nc?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),F_=this._renderer.getRenderTarget(),B_=this._renderer.getActiveCubeFace(),z_=this._renderer.getActiveMipmapLevel(),k_=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:On,minFilter:On,generateMipmaps:!1,type:nr,format:Ni,colorSpace:ro,depthBuffer:!1},r=Z1(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Z1(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=u3(s)),this._blurMaterial=h3(s,e,t)}return r}_compileMaterial(e){const t=new fi(this._lodPlanes[0],e);this._renderer.compile(t,O_)}_sceneToCubeUV(e,t,n,r){const c=new Di(90,1,t,n),d=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],p=this._renderer,g=p.autoClear,v=p.toneMapping;p.getClearColor(X1),p.toneMapping=zo,p.autoClear=!1;const y=new ll({name:"PMREM.Background",side:Wi,depthWrite:!1,depthTest:!1}),E=new fi(new cc,y);let T=!1;const w=e.background;w?w.isColor&&(y.color.copy(w),e.background=null,T=!0):(y.color.copy(X1),T=!0);for(let _=0;_<6;_++){const C=_%3;C===0?(c.up.set(0,d[_],0),c.lookAt(f[_],0,0)):C===1?(c.up.set(0,0,d[_]),c.lookAt(0,f[_],0)):(c.up.set(0,d[_],0),c.lookAt(0,0,f[_]));const b=this._cubeSize;Rg(r,C*b,_>2?b:0,b,b),p.setRenderTarget(r),T&&p.render(E,c),p.render(e,c)}E.geometry.dispose(),E.material.dispose(),p.toneMapping=v,p.autoClear=g,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===da||e.mapping===nc;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=K1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=q1());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new fi(this._lodPlanes[0],s),c=s.uniforms;c.envMap.value=e;const d=this._cubeSize;Rg(t,0,0,3*d,2*d),n.setRenderTarget(t),n.render(a,O_)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),c=Y1[(r-s-1)%Y1.length];this._blur(e,s-1,s,a,c)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,c){const d=this._renderer,f=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const p=3,g=new fi(this._lodPlanes[r],f),v=f.uniforms,y=this._sizeLods[n]-1,E=isFinite(s)?Math.PI/(2*y):2*Math.PI/(2*vu-1),T=s/E,w=isFinite(s)?1+Math.floor(p*T):vu;w>vu&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${w} samples when the maximum is set to ${vu}`);const _=[];let C=0;for(let H=0;H<vu;++H){const B=H/T,D=Math.exp(-B*B/2);_.push(D),H===0?C+=D:H<w&&(C+=2*D)}for(let H=0;H<_.length;H++)_[H]=_[H]/C;v.envMap.value=e.texture,v.samples.value=w,v.weights.value=_,v.latitudinal.value=a==="latitudinal",c&&(v.poleAxis.value=c);const{_lodMax:b}=this;v.dTheta.value=E,v.mipInt.value=b-n;const I=this._sizeLods[r],N=3*I*(r>b-pd?r-b+pd:0),O=4*(this._cubeSize-I);Rg(t,N,O,3*I,2*I),d.setRenderTarget(t),d.render(g,O_)}}function u3(i){const e=[],t=[],n=[];let r=i;const s=i-pd+1+j1.length;for(let a=0;a<s;a++){const c=Math.pow(2,r);t.push(c);let d=1/c;a>i-pd?d=j1[a-i+pd-1]:a===0&&(d=0),n.push(d);const f=1/(c-2),p=-f,g=1+f,v=[p,p,g,p,g,g,p,p,g,g,p,g],y=6,E=6,T=3,w=2,_=1,C=new Float32Array(T*E*y),b=new Float32Array(w*E*y),I=new Float32Array(_*E*y);for(let O=0;O<y;O++){const H=O%3*2/3-1,B=O>2?0:-1,D=[H,B,0,H+2/3,B,0,H+2/3,B+1,0,H,B,0,H+2/3,B+1,0,H,B+1,0];C.set(D,T*E*O),b.set(v,w*E*O);const U=[O,O,O,O,O,O];I.set(U,_*E*O)}const N=new yn;N.setAttribute("position",new jn(C,T)),N.setAttribute("uv",new jn(b,w)),N.setAttribute("faceIndex",new jn(I,_)),e.push(N),r>pd&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Z1(i,e,t){const n=new Mi(i,e,t);return n.texture.mapping=Ad,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Rg(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function h3(i,e,t){const n=new Float32Array(vu),r=new X(0,1,0);return new li({name:"SphericalGaussianBlur",defines:{n:vu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Dx(),fragmentShader:`
3614
3614
 
3615
3615
  precision mediump float;
3616
3616
  precision mediump int;
@@ -3863,7 +3863,7 @@ void main() {
3863
3863
 
3864
3864
  }
3865
3865
 
3866
- }`;class JL{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Wn,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new li({vertexShader:KL,fragmentShader:QL,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new fi(new cl(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $L extends Gs{constructor(e,t){super();const n=this;let r=null,s=1,a=null,c="local-floor",d=1,f=null,p=null,g=null,v=null,y=null,E=null;const T=new JL,w=t.getContextAttributes();let _=null,C=null;const b=[],I=[],N=new ke;let O=null;const H=new Di;H.viewport=new _n;const B=new Di;B.viewport=new _n;const D=[H,B],U=new sT;let W=null,ne=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ve){let Pe=b[ve];return Pe===void 0&&(Pe=new V_,b[ve]=Pe),Pe.getTargetRaySpace()},this.getControllerGrip=function(ve){let Pe=b[ve];return Pe===void 0&&(Pe=new V_,b[ve]=Pe),Pe.getGripSpace()},this.getHand=function(ve){let Pe=b[ve];return Pe===void 0&&(Pe=new V_,b[ve]=Pe),Pe.getHandSpace()};function re(ve){const Pe=I.indexOf(ve.inputSource);if(Pe===-1)return;const Le=b[Pe];Le!==void 0&&(Le.update(ve.inputSource,ve.frame,f||a),Le.dispatchEvent({type:ve.type,data:ve.inputSource}))}function he(){r.removeEventListener("select",re),r.removeEventListener("selectstart",re),r.removeEventListener("selectend",re),r.removeEventListener("squeeze",re),r.removeEventListener("squeezestart",re),r.removeEventListener("squeezeend",re),r.removeEventListener("end",he),r.removeEventListener("inputsourceschange",fe);for(let ve=0;ve<b.length;ve++){const Pe=I[ve];Pe!==null&&(I[ve]=null,b[ve].disconnect(Pe))}W=null,ne=null,T.reset(),e.setRenderTarget(_),y=null,v=null,g=null,r=null,C=null,ze.stop(),n.isPresenting=!1,e.setPixelRatio(O),e.setSize(N.width,N.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ve){s=ve,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ve){c=ve,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return f||a},this.setReferenceSpace=function(ve){f=ve},this.getBaseLayer=function(){return v!==null?v:y},this.getBinding=function(){return g},this.getFrame=function(){return E},this.getSession=function(){return r},this.setSession=async function(ve){if(r=ve,r!==null){if(_=e.getRenderTarget(),r.addEventListener("select",re),r.addEventListener("selectstart",re),r.addEventListener("selectend",re),r.addEventListener("squeeze",re),r.addEventListener("squeezestart",re),r.addEventListener("squeezeend",re),r.addEventListener("end",he),r.addEventListener("inputsourceschange",fe),w.xrCompatible!==!0&&await t.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(N),r.enabledFeatures!==void 0&&r.enabledFeatures.includes("layers")){let Le=null,Be=null,Ke=null;w.depth&&(Ke=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Le=w.stencil?rc:Cu,Be=w.stencil?ic:fa);const ft={colorFormat:t.RGBA8,depthFormat:Ke,scaleFactor:s};g=new XRWebGLBinding(r,t),v=g.createProjectionLayer(ft),r.updateRenderState({layers:[v]}),e.setPixelRatio(1),e.setSize(v.textureWidth,v.textureHeight,!1),C=new Mi(v.textureWidth,v.textureHeight,{format:Ni,type:Oi,depthTexture:new e0(v.textureWidth,v.textureHeight,Be,void 0,void 0,void 0,void 0,void 0,void 0,Le),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:v.ignoreDepthValues===!1})}else{const Le={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};y=new XRWebGLLayer(r,t,Le),r.updateRenderState({baseLayer:y}),e.setPixelRatio(1),e.setSize(y.framebufferWidth,y.framebufferHeight,!1),C=new Mi(y.framebufferWidth,y.framebufferHeight,{format:Ni,type:Oi,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil})}C.isXRRenderTarget=!0,this.setFoveation(d),f=null,a=await r.requestReferenceSpace(c),ze.setContext(r),ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function fe(ve){for(let Pe=0;Pe<ve.removed.length;Pe++){const Le=ve.removed[Pe],Be=I.indexOf(Le);Be>=0&&(I[Be]=null,b[Be].disconnect(Le))}for(let Pe=0;Pe<ve.added.length;Pe++){const Le=ve.added[Pe];let Be=I.indexOf(Le);if(Be===-1){for(let ft=0;ft<b.length;ft++)if(ft>=I.length){I.push(Le),Be=ft;break}else if(I[ft]===null){I[ft]=Le,Be=ft;break}if(Be===-1)break}const Ke=b[Be];Ke&&Ke.connect(Le)}}const ce=new X,xe=new X;function q(ve,Pe,Le){ce.setFromMatrixPosition(Pe.matrixWorld),xe.setFromMatrixPosition(Le.matrixWorld);const Be=ce.distanceTo(xe),Ke=Pe.projectionMatrix.elements,ft=Le.projectionMatrix.elements,ht=Ke[14]/(Ke[10]-1),pt=Ke[14]/(Ke[10]+1),Ve=(Ke[9]+1)/Ke[5],Ge=(Ke[9]-1)/Ke[5],K=(Ke[8]-1)/Ke[0],At=(ft[8]+1)/ft[0],Je=ht*K,dt=ht*At,it=Be/(-K+At),zt=it*-K;if(Pe.matrixWorld.decompose(ve.position,ve.quaternion,ve.scale),ve.translateX(zt),ve.translateZ(it),ve.matrixWorld.compose(ve.position,ve.quaternion,ve.scale),ve.matrixWorldInverse.copy(ve.matrixWorld).invert(),Ke[10]===-1)ve.projectionMatrix.copy(Pe.projectionMatrix),ve.projectionMatrixInverse.copy(Pe.projectionMatrixInverse);else{const ot=ht+it,Z=pt+it,G=Je-zt,Se=dt+(Be-zt),Fe=Ve*pt/Z*ot,Xe=Ge*pt/Z*ot;ve.projectionMatrix.makePerspective(G,Se,Fe,Xe,ot,Z),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert()}}function de(ve,Pe){Pe===null?ve.matrixWorld.copy(ve.matrix):ve.matrixWorld.multiplyMatrices(Pe.matrixWorld,ve.matrix),ve.matrixWorldInverse.copy(ve.matrixWorld).invert()}this.updateCamera=function(ve){if(r===null)return;let Pe=ve.near,Le=ve.far;T.texture!==null&&(T.depthNear>0&&(Pe=T.depthNear),T.depthFar>0&&(Le=T.depthFar)),U.near=B.near=H.near=Pe,U.far=B.far=H.far=Le,(W!==U.near||ne!==U.far)&&(r.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,ne=U.far),H.layers.mask=ve.layers.mask|2,B.layers.mask=ve.layers.mask|4,U.layers.mask=H.layers.mask|B.layers.mask;const Be=ve.parent,Ke=U.cameras;de(U,Be);for(let ft=0;ft<Ke.length;ft++)de(Ke[ft],Be);Ke.length===2?q(U,H,B):U.projectionMatrix.copy(H.projectionMatrix),se(ve,U,Be)};function se(ve,Pe,Le){Le===null?ve.matrix.copy(Pe.matrixWorld):(ve.matrix.copy(Le.matrixWorld),ve.matrix.invert(),ve.matrix.multiply(Pe.matrixWorld)),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.updateMatrixWorld(!0),ve.projectionMatrix.copy(Pe.projectionMatrix),ve.projectionMatrixInverse.copy(Pe.projectionMatrixInverse),ve.isPerspectiveCamera&&(ve.fov=xd*2*Math.atan(1/ve.projectionMatrix.elements[5]),ve.zoom=1)}this.getCamera=function(){return U},this.getFoveation=function(){if(!(v===null&&y===null))return d},this.setFoveation=function(ve){d=ve,v!==null&&(v.fixedFoveation=ve),y!==null&&y.fixedFoveation!==void 0&&(y.fixedFoveation=ve)},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(U)};let Y=null;function le(ve,Pe){if(p=Pe.getViewerPose(f||a),E=Pe,p!==null){const Le=p.views;y!==null&&(e.setRenderTargetFramebuffer(C,y.framebuffer),e.setRenderTarget(C));let Be=!1;Le.length!==U.cameras.length&&(U.cameras.length=0,Be=!0);for(let ft=0;ft<Le.length;ft++){const ht=Le[ft];let pt=null;if(y!==null)pt=y.getViewport(ht);else{const Ge=g.getViewSubImage(v,ht);pt=Ge.viewport,ft===0&&(e.setRenderTargetTextures(C,Ge.colorTexture,v.ignoreDepthValues?void 0:Ge.depthStencilTexture),e.setRenderTarget(C))}let Ve=D[ft];Ve===void 0&&(Ve=new Di,Ve.layers.enable(ft),Ve.viewport=new _n,D[ft]=Ve),Ve.matrix.fromArray(ht.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(ht.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(pt.x,pt.y,pt.width,pt.height),ft===0&&(U.matrix.copy(Ve.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale)),Be===!0&&U.cameras.push(Ve)}const Ke=r.enabledFeatures;if(Ke&&Ke.includes("depth-sensing")){const ft=g.getDepthInformation(Le[0]);ft&&ft.isValid&&ft.texture&&T.init(e,ft,r.renderState)}}for(let Le=0;Le<b.length;Le++){const Be=I[Le],Ke=b[Le];Be!==null&&Ke!==void 0&&Ke.update(Be,Pe,f||a)}Y&&Y(ve,Pe),Pe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Pe}),E=null}const ze=new dT;ze.setAnimationLoop(le),this.setAnimationLoop=function(ve){Y=ve},this.dispose=function(){}}}const du=new Vs,eD=new qt;function tD(i,e){function t(w,_){w.matrixAutoUpdate===!0&&w.updateMatrix(),_.value.copy(w.matrix)}function n(w,_){_.color.getRGB(w.fogColor.value,vw(i)),_.isFog?(w.fogNear.value=_.near,w.fogFar.value=_.far):_.isFogExp2&&(w.fogDensity.value=_.density)}function r(w,_,C,b,I){_.isMeshBasicMaterial||_.isMeshLambertMaterial?s(w,_):_.isMeshToonMaterial?(s(w,_),g(w,_)):_.isMeshPhongMaterial?(s(w,_),p(w,_)):_.isMeshStandardMaterial?(s(w,_),v(w,_),_.isMeshPhysicalMaterial&&y(w,_,I)):_.isMeshMatcapMaterial?(s(w,_),E(w,_)):_.isMeshDepthMaterial?s(w,_):_.isMeshDistanceMaterial?(s(w,_),T(w,_)):_.isMeshNormalMaterial?s(w,_):_.isLineBasicMaterial?(a(w,_),_.isLineDashedMaterial&&c(w,_)):_.isPointsMaterial?d(w,_,C,b):_.isSpriteMaterial?f(w,_):_.isShadowMaterial?(w.color.value.copy(_.color),w.opacity.value=_.opacity):_.isShaderMaterial&&(_.uniformsNeedUpdate=!1)}function s(w,_){w.opacity.value=_.opacity,_.color&&w.diffuse.value.copy(_.color),_.emissive&&w.emissive.value.copy(_.emissive).multiplyScalar(_.emissiveIntensity),_.map&&(w.map.value=_.map,t(_.map,w.mapTransform)),_.alphaMap&&(w.alphaMap.value=_.alphaMap,t(_.alphaMap,w.alphaMapTransform)),_.bumpMap&&(w.bumpMap.value=_.bumpMap,t(_.bumpMap,w.bumpMapTransform),w.bumpScale.value=_.bumpScale,_.side===Wi&&(w.bumpScale.value*=-1)),_.normalMap&&(w.normalMap.value=_.normalMap,t(_.normalMap,w.normalMapTransform),w.normalScale.value.copy(_.normalScale),_.side===Wi&&w.normalScale.value.negate()),_.displacementMap&&(w.displacementMap.value=_.displacementMap,t(_.displacementMap,w.displacementMapTransform),w.displacementScale.value=_.displacementScale,w.displacementBias.value=_.displacementBias),_.emissiveMap&&(w.emissiveMap.value=_.emissiveMap,t(_.emissiveMap,w.emissiveMapTransform)),_.specularMap&&(w.specularMap.value=_.specularMap,t(_.specularMap,w.specularMapTransform)),_.alphaTest>0&&(w.alphaTest.value=_.alphaTest);const C=e.get(_),b=C.envMap,I=C.envMapRotation;b&&(w.envMap.value=b,du.copy(I),du.x*=-1,du.y*=-1,du.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(du.y*=-1,du.z*=-1),w.envMapRotation.value.setFromMatrix4(eD.makeRotationFromEuler(du)),w.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,w.reflectivity.value=_.reflectivity,w.ior.value=_.ior,w.refractionRatio.value=_.refractionRatio),_.lightMap&&(w.lightMap.value=_.lightMap,w.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,w.lightMapTransform)),_.aoMap&&(w.aoMap.value=_.aoMap,w.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,w.aoMapTransform))}function a(w,_){w.diffuse.value.copy(_.color),w.opacity.value=_.opacity,_.map&&(w.map.value=_.map,t(_.map,w.mapTransform))}function c(w,_){w.dashSize.value=_.dashSize,w.totalSize.value=_.dashSize+_.gapSize,w.scale.value=_.scale}function d(w,_,C,b){w.diffuse.value.copy(_.color),w.opacity.value=_.opacity,w.size.value=_.size*C,w.scale.value=b*.5,_.map&&(w.map.value=_.map,t(_.map,w.uvTransform)),_.alphaMap&&(w.alphaMap.value=_.alphaMap,t(_.alphaMap,w.alphaMapTransform)),_.alphaTest>0&&(w.alphaTest.value=_.alphaTest)}function f(w,_){w.diffuse.value.copy(_.color),w.opacity.value=_.opacity,w.rotation.value=_.rotation,_.map&&(w.map.value=_.map,t(_.map,w.mapTransform)),_.alphaMap&&(w.alphaMap.value=_.alphaMap,t(_.alphaMap,w.alphaMapTransform)),_.alphaTest>0&&(w.alphaTest.value=_.alphaTest)}function p(w,_){w.specular.value.copy(_.specular),w.shininess.value=Math.max(_.shininess,1e-4)}function g(w,_){_.gradientMap&&(w.gradientMap.value=_.gradientMap)}function v(w,_){w.metalness.value=_.metalness,_.metalnessMap&&(w.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,w.metalnessMapTransform)),w.roughness.value=_.roughness,_.roughnessMap&&(w.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,w.roughnessMapTransform)),_.envMap&&(w.envMapIntensity.value=_.envMapIntensity)}function y(w,_,C){w.ior.value=_.ior,_.sheen>0&&(w.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),w.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(w.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,w.sheenColorMapTransform)),_.sheenRoughnessMap&&(w.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,w.sheenRoughnessMapTransform))),_.clearcoat>0&&(w.clearcoat.value=_.clearcoat,w.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(w.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,w.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(w.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,w.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(w.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,w.clearcoatNormalMapTransform),w.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===Wi&&w.clearcoatNormalScale.value.negate())),_.dispersion>0&&(w.dispersion.value=_.dispersion),_.iridescence>0&&(w.iridescence.value=_.iridescence,w.iridescenceIOR.value=_.iridescenceIOR,w.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],w.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(w.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,w.iridescenceMapTransform)),_.iridescenceThicknessMap&&(w.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,w.iridescenceThicknessMapTransform))),_.transmission>0&&(w.transmission.value=_.transmission,w.transmissionSamplerMap.value=C.texture,w.transmissionSamplerSize.value.set(C.width,C.height),_.transmissionMap&&(w.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,w.transmissionMapTransform)),w.thickness.value=_.thickness,_.thicknessMap&&(w.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,w.thicknessMapTransform)),w.attenuationDistance.value=_.attenuationDistance,w.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(w.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(w.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,w.anisotropyMapTransform))),w.specularIntensity.value=_.specularIntensity,w.specularColor.value.copy(_.specularColor),_.specularColorMap&&(w.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,w.specularColorMapTransform)),_.specularIntensityMap&&(w.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,w.specularIntensityMapTransform))}function E(w,_){_.matcap&&(w.matcap.value=_.matcap)}function T(w,_){const C=e.get(_).light;w.referencePosition.value.setFromMatrixPosition(C.matrixWorld),w.nearDistance.value=C.shadow.camera.near,w.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function nD(i,e,t,n){let r={},s={},a=[];const c=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function d(C,b){const I=b.program;n.uniformBlockBinding(C,I)}function f(C,b){let I=r[C.id];I===void 0&&(E(C),I=p(C),r[C.id]=I,C.addEventListener("dispose",w));const N=b.program;n.updateUBOMapping(C,N);const O=e.render.frame;s[C.id]!==O&&(v(C),s[C.id]=O)}function p(C){const b=g();C.__bindingPointIndex=b;const I=i.createBuffer(),N=C.__size,O=C.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,N,O),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,I),I}function g(){for(let C=0;C<c;C++)if(a.indexOf(C)===-1)return a.push(C),C;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function v(C){const b=r[C.id],I=C.uniforms,N=C.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let O=0,H=I.length;O<H;O++){const B=Array.isArray(I[O])?I[O]:[I[O]];for(let D=0,U=B.length;D<U;D++){const W=B[D];if(y(W,O,D,N)===!0){const ne=W.__offset,re=Array.isArray(W.value)?W.value:[W.value];let he=0;for(let fe=0;fe<re.length;fe++){const ce=re[fe],xe=T(ce);typeof ce=="number"||typeof ce=="boolean"?(W.__data[0]=ce,i.bufferSubData(i.UNIFORM_BUFFER,ne+he,W.__data)):ce.isMatrix3?(W.__data[0]=ce.elements[0],W.__data[1]=ce.elements[1],W.__data[2]=ce.elements[2],W.__data[3]=0,W.__data[4]=ce.elements[3],W.__data[5]=ce.elements[4],W.__data[6]=ce.elements[5],W.__data[7]=0,W.__data[8]=ce.elements[6],W.__data[9]=ce.elements[7],W.__data[10]=ce.elements[8],W.__data[11]=0):(ce.toArray(W.__data,he),he+=xe.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,ne,W.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function y(C,b,I,N){const O=C.value,H=b+"_"+I;if(N[H]===void 0)return typeof O=="number"||typeof O=="boolean"?N[H]=O:N[H]=O.clone(),!0;{const B=N[H];if(typeof O=="number"||typeof O=="boolean"){if(B!==O)return N[H]=O,!0}else if(B.equals(O)===!1)return B.copy(O),!0}return!1}function E(C){const b=C.uniforms;let I=0;const N=16;for(let H=0,B=b.length;H<B;H++){const D=Array.isArray(b[H])?b[H]:[b[H]];for(let U=0,W=D.length;U<W;U++){const ne=D[U],re=Array.isArray(ne.value)?ne.value:[ne.value];for(let he=0,fe=re.length;he<fe;he++){const ce=re[he],xe=T(ce),q=I%N,de=q%xe.boundary,se=q+de;I+=de,se!==0&&N-se<xe.storage&&(I+=N-se),ne.__data=new Float32Array(xe.storage/Float32Array.BYTES_PER_ELEMENT),ne.__offset=I,I+=xe.storage}}}const O=I%N;return O>0&&(I+=N-O),C.__size=I,C.__cache={},this}function T(C){const b={boundary:0,storage:0};return typeof C=="number"||typeof C=="boolean"?(b.boundary=4,b.storage=4):C.isVector2?(b.boundary=8,b.storage=8):C.isVector3||C.isColor?(b.boundary=16,b.storage=12):C.isVector4?(b.boundary=16,b.storage=16):C.isMatrix3?(b.boundary=48,b.storage=48):C.isMatrix4?(b.boundary=64,b.storage=64):C.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",C),b}function w(C){const b=C.target;b.removeEventListener("dispose",w);const I=a.indexOf(b.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function _(){for(const C in r)i.deleteBuffer(r[C]);a=[],r={},s={}}return{bind:d,update:f,dispose:_}}class Nx{constructor(e={}){const{canvas:t=pw(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:c=!1,premultipliedAlpha:d=!0,preserveDrawingBuffer:f=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:g=!1,reverseDepthBuffer:v=!1}=e;this.isWebGLRenderer=!0;let y;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");y=n.getContextAttributes().alpha}else y=a;const E=new Uint32Array(4),T=new Int32Array(4);let w=null,_=null;const C=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=kn,this.toneMapping=zo,this.toneMappingExposure=1;const I=this;let N=!1,O=0,H=0,B=null,D=-1,U=null;const W=new _n,ne=new _n;let re=null;const he=new yt(0);let fe=0,ce=t.width,xe=t.height,q=1,de=null,se=null;const Y=new _n(0,0,ce,xe),le=new _n(0,0,ce,xe);let ze=!1;const ve=new Op;let Pe=!1,Le=!1;this.transmissionResolutionScale=1;const Be=new qt,Ke=new qt,ft=new X,ht=new _n,pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ve=!1;function Ge(){return B===null?q:1}let K=n;function At(k,J){return t.getContext(k,J)}try{const k={alpha:!0,depth:r,stencil:s,antialias:c,premultipliedAlpha:d,preserveDrawingBuffer:f,powerPreference:p,failIfMajorPerformanceCaveat:g};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${oc}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",St,!1),t.addEventListener("webglcontextcreationerror",mt,!1),K===null){const J="webgl2";if(K=At(J,k),K===null)throw At(J)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let Je,dt,it,zt,ot,Z,G,Se,Fe,Xe,He,Mt,ct,xt,rn,et,Rt,kt,Lt,Ct,Jt,Ht,Kt,me;function be(){Je=new f3(K),Je.init(),Ht=new vT(K,Je),dt=new a3(K,Je,e,Ht),it=new YL(K,Je),dt.reverseDepthBuffer&&v&&it.buffers.depth.setReversed(!0),zt=new g3(K),ot=new NL,Z=new ZL(K,Je,it,ot,dt,Ht,zt),G=new c3(I),Se=new d3(I),Fe=new MR(K),Kt=new s3(K,Fe),Xe=new p3(K,Fe,zt,Kt),He=new _3(K,Xe,Fe,zt),Lt=new v3(K,dt,Z),et=new l3(ot),Mt=new DL(I,G,Se,Je,dt,Kt,et),ct=new tD(I,ot),xt=new OL,rn=new VL(Je),kt=new r3(I,G,Se,it,He,y,d),Rt=new jL(I,He,dt),me=new nD(K,zt,dt,it),Ct=new o3(K,Je,zt),Jt=new m3(K,Je,zt),zt.programs=Mt.programs,I.capabilities=dt,I.extensions=Je,I.properties=ot,I.renderLists=xt,I.shadowMap=Rt,I.state=it,I.info=zt}be();const Re=new $L(I,K);this.xr=Re,this.getContext=function(){return K},this.getContextAttributes=function(){return K.getContextAttributes()},this.forceContextLoss=function(){const k=Je.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){const k=Je.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(k){k!==void 0&&(q=k,this.setSize(ce,xe,!1))},this.getSize=function(k){return k.set(ce,xe)},this.setSize=function(k,J,ie=!0){if(Re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ce=k,xe=J,t.width=Math.floor(k*q),t.height=Math.floor(J*q),ie===!0&&(t.style.width=k+"px",t.style.height=J+"px"),this.setViewport(0,0,k,J)},this.getDrawingBufferSize=function(k){return k.set(ce*q,xe*q).floor()},this.setDrawingBufferSize=function(k,J,ie){ce=k,xe=J,q=ie,t.width=Math.floor(k*ie),t.height=Math.floor(J*ie),this.setViewport(0,0,k,J)},this.getCurrentViewport=function(k){return k.copy(W)},this.getViewport=function(k){return k.copy(Y)},this.setViewport=function(k,J,ie,$){k.isVector4?Y.set(k.x,k.y,k.z,k.w):Y.set(k,J,ie,$),it.viewport(W.copy(Y).multiplyScalar(q).round())},this.getScissor=function(k){return k.copy(le)},this.setScissor=function(k,J,ie,$){k.isVector4?le.set(k.x,k.y,k.z,k.w):le.set(k,J,ie,$),it.scissor(ne.copy(le).multiplyScalar(q).round())},this.getScissorTest=function(){return ze},this.setScissorTest=function(k){it.setScissorTest(ze=k)},this.setOpaqueSort=function(k){de=k},this.setTransparentSort=function(k){se=k},this.getClearColor=function(k){return k.copy(kt.getClearColor())},this.setClearColor=function(){kt.setClearColor.apply(kt,arguments)},this.getClearAlpha=function(){return kt.getClearAlpha()},this.setClearAlpha=function(){kt.setClearAlpha.apply(kt,arguments)},this.clear=function(k=!0,J=!0,ie=!0){let $=0;if(k){let ue=!1;if(B!==null){const Ee=B.texture.format;ue=Ee===Wv||Ee===Gv||Ee===Lp}if(ue){const Ee=B.texture.type,Ue=Ee===Oi||Ee===fa||Ee===yd||Ee===ic||Ee===Hv||Ee===Vv,je=kt.getClearColor(),Ze=kt.getClearAlpha(),ut=je.r,at=je.g,Ye=je.b;Ue?(E[0]=ut,E[1]=at,E[2]=Ye,E[3]=Ze,K.clearBufferuiv(K.COLOR,0,E)):(T[0]=ut,T[1]=at,T[2]=Ye,T[3]=Ze,K.clearBufferiv(K.COLOR,0,T))}else $|=K.COLOR_BUFFER_BIT}J&&($|=K.DEPTH_BUFFER_BIT),ie&&($|=K.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),K.clear($)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",We,!1),t.removeEventListener("webglcontextrestored",St,!1),t.removeEventListener("webglcontextcreationerror",mt,!1),kt.dispose(),xt.dispose(),rn.dispose(),ot.dispose(),G.dispose(),Se.dispose(),He.dispose(),Kt.dispose(),me.dispose(),Mt.dispose(),Re.dispose(),Re.removeEventListener("sessionstart",Go),Re.removeEventListener("sessionend",Ws),mr.stop()};function We(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function St(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const k=zt.autoReset,J=Rt.enabled,ie=Rt.autoUpdate,$=Rt.needsUpdate,ue=Rt.type;be(),zt.autoReset=k,Rt.enabled=J,Rt.autoUpdate=ie,Rt.needsUpdate=$,Rt.type=ue}function mt(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function Qt(k){const J=k.target;J.removeEventListener("dispose",Qt),Xn(J)}function Xn(k){pi(k),ot.remove(k)}function pi(k){const J=ot.get(k).programs;J!==void 0&&(J.forEach(function(ie){Mt.releaseProgram(ie)}),k.isShaderMaterial&&Mt.releaseShaderCache(k))}this.renderBufferDirect=function(k,J,ie,$,ue,Ee){J===null&&(J=pt);const Ue=ue.isMesh&&ue.matrixWorld.determinant()<0,je=oe(k,J,ie,$,ue);it.setMaterial($,Ue);let Ze=ie.index,ut=1;if($.wireframe===!0){if(Ze=Xe.getWireframeAttribute(ie),Ze===void 0)return;ut=2}const at=ie.drawRange,Ye=ie.attributes.position;let gt=at.start*ut,vt=(at.start+at.count)*ut;Ee!==null&&(gt=Math.max(gt,Ee.start*ut),vt=Math.min(vt,(Ee.start+Ee.count)*ut)),Ze!==null?(gt=Math.max(gt,0),vt=Math.min(vt,Ze.count)):Ye!=null&&(gt=Math.max(gt,0),vt=Math.min(vt,Ye.count));const Zt=vt-gt;if(Zt<0||Zt===1/0)return;Kt.setup(ue,$,je,ie,Ze);let Dt,Ft=Ct;if(Ze!==null&&(Dt=Fe.get(Ze),Ft=Jt,Ft.setIndex(Dt)),ue.isMesh)$.wireframe===!0?(it.setLineWidth($.wireframeLinewidth*Ge()),Ft.setMode(K.LINES)):Ft.setMode(K.TRIANGLES);else if(ue.isLine){let wt=$.linewidth;wt===void 0&&(wt=1),it.setLineWidth(wt*Ge()),ue.isLineSegments?Ft.setMode(K.LINES):ue.isLineLoop?Ft.setMode(K.LINE_LOOP):Ft.setMode(K.LINE_STRIP)}else ue.isPoints?Ft.setMode(K.POINTS):ue.isSprite&&Ft.setMode(K.TRIANGLES);if(ue.isBatchedMesh)if(ue._multiDrawInstances!==null)Ft.renderMultiDrawInstances(ue._multiDrawStarts,ue._multiDrawCounts,ue._multiDrawCount,ue._multiDrawInstances);else if(Je.get("WEBGL_multi_draw"))Ft.renderMultiDraw(ue._multiDrawStarts,ue._multiDrawCounts,ue._multiDrawCount);else{const wt=ue._multiDrawStarts,dn=ue._multiDrawCounts,Gt=ue._multiDrawCount,$t=Ze?Fe.get(Ze).bytesPerElement:1,qn=ot.get($).currentProgram.getUniforms();for(let ln=0;ln<Gt;ln++)qn.setValue(K,"_gl_DrawID",ln),Ft.render(wt[ln]/$t,dn[ln])}else if(ue.isInstancedMesh)Ft.renderInstances(gt,Zt,ue.count);else if(ie.isInstancedBufferGeometry){const wt=ie._maxInstanceCount!==void 0?ie._maxInstanceCount:1/0,dn=Math.min(ie.instanceCount,wt);Ft.renderInstances(gt,Zt,dn)}else Ft.render(gt,Zt)};function Mn(k,J,ie){k.transparent===!0&&k.side===Hr&&k.forceSinglePass===!1?(k.side=Wi,k.needsUpdate=!0,Wo(k,J,ie),k.side=ha,k.needsUpdate=!0,Wo(k,J,ie),k.side=Hr):Wo(k,J,ie)}this.compile=function(k,J,ie=null){ie===null&&(ie=k),_=rn.get(ie),_.init(J),b.push(_),ie.traverseVisible(function(ue){ue.isLight&&ue.layers.test(J.layers)&&(_.pushLight(ue),ue.castShadow&&_.pushShadow(ue))}),k!==ie&&k.traverseVisible(function(ue){ue.isLight&&ue.layers.test(J.layers)&&(_.pushLight(ue),ue.castShadow&&_.pushShadow(ue))}),_.setupLights();const $=new Set;return k.traverse(function(ue){if(!(ue.isMesh||ue.isPoints||ue.isLine||ue.isSprite))return;const Ee=ue.material;if(Ee)if(Array.isArray(Ee))for(let Ue=0;Ue<Ee.length;Ue++){const je=Ee[Ue];Mn(je,ie,ue),$.add(je)}else Mn(Ee,ie,ue),$.add(Ee)}),b.pop(),_=null,$},this.compileAsync=function(k,J,ie=null){const $=this.compile(k,J,ie);return new Promise(ue=>{function Ee(){if($.forEach(function(Ue){ot.get(Ue).currentProgram.isReady()&&$.delete(Ue)}),$.size===0){ue(k);return}setTimeout(Ee,10)}Je.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let Xi=null;function Yi(k){Xi&&Xi(k)}function Go(){mr.stop()}function Ws(){mr.start()}const mr=new dT;mr.setAnimationLoop(Yi),typeof self<"u"&&mr.setContext(self),this.setAnimationLoop=function(k){Xi=k,Re.setAnimationLoop(k),k===null?mr.stop():mr.start()},Re.addEventListener("sessionstart",Go),Re.addEventListener("sessionend",Ws),this.render=function(k,J){if(J!==void 0&&J.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),J.parent===null&&J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Re.enabled===!0&&Re.isPresenting===!0&&(Re.cameraAutoUpdate===!0&&Re.updateCamera(J),J=Re.getCamera()),k.isScene===!0&&k.onBeforeRender(I,k,J,B),_=rn.get(k,b.length),_.init(J),b.push(_),Ke.multiplyMatrices(J.projectionMatrix,J.matrixWorldInverse),ve.setFromProjectionMatrix(Ke),Le=this.localClippingEnabled,Pe=et.init(this.clippingPlanes,Le),w=xt.get(k,C.length),w.init(),C.push(w),Re.enabled===!0&&Re.isPresenting===!0){const Ee=I.xr.getDepthSensingMesh();Ee!==null&&Gr(Ee,J,-1/0,I.sortObjects)}Gr(k,J,0,I.sortObjects),w.finish(),I.sortObjects===!0&&w.sort(de,se),Ve=Re.enabled===!1||Re.isPresenting===!1||Re.hasDepthSensing()===!1,Ve&&kt.addToRenderList(w,k),this.info.render.frame++,Pe===!0&&et.beginShadows();const ie=_.state.shadowsArray;Rt.render(ie,k,J),Pe===!0&&et.endShadows(),this.info.autoReset===!0&&this.info.reset();const $=w.opaque,ue=w.transmissive;if(_.setupLights(),J.isArrayCamera){const Ee=J.cameras;if(ue.length>0)for(let Ue=0,je=Ee.length;Ue<je;Ue++){const Ze=Ee[Ue];Zi($,ue,k,Ze)}Ve&&kt.render(k);for(let Ue=0,je=Ee.length;Ue<je;Ue++){const Ze=Ee[Ue];Wr(w,k,Ze,Ze.viewport)}}else ue.length>0&&Zi($,ue,k,J),Ve&&kt.render(k),Wr(w,k,J);B!==null&&H===0&&(Z.updateMultisampleRenderTarget(B),Z.updateRenderTargetMipmap(B)),k.isScene===!0&&k.onAfterRender(I,k,J),Kt.resetDefaultState(),D=-1,U=null,b.pop(),b.length>0?(_=b[b.length-1],Pe===!0&&et.setGlobalState(I.clippingPlanes,_.state.camera)):_=null,C.pop(),C.length>0?w=C[C.length-1]:w=null};function Gr(k,J,ie,$){if(k.visible===!1)return;if(k.layers.test(J.layers)){if(k.isGroup)ie=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(J);else if(k.isLight)_.pushLight(k),k.castShadow&&_.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||ve.intersectsSprite(k)){$&&ht.setFromMatrixPosition(k.matrixWorld).applyMatrix4(Ke);const Ue=He.update(k),je=k.material;je.visible&&w.push(k,Ue,je,ie,ht.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||ve.intersectsObject(k))){const Ue=He.update(k),je=k.material;if($&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),ht.copy(k.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),ht.copy(Ue.boundingSphere.center)),ht.applyMatrix4(k.matrixWorld).applyMatrix4(Ke)),Array.isArray(je)){const Ze=Ue.groups;for(let ut=0,at=Ze.length;ut<at;ut++){const Ye=Ze[ut],gt=je[Ye.materialIndex];gt&&gt.visible&&w.push(k,Ue,gt,ie,ht.z,Ye)}}else je.visible&&w.push(k,Ue,je,ie,ht.z,null)}}const Ee=k.children;for(let Ue=0,je=Ee.length;Ue<je;Ue++)Gr(Ee[Ue],J,ie,$)}function Wr(k,J,ie,$){const ue=k.opaque,Ee=k.transmissive,Ue=k.transparent;_.setupLightsView(ie),Pe===!0&&et.setGlobalState(I.clippingPlanes,ie),$&&it.viewport(W.copy($)),ue.length>0&&sn(ue,J,ie),Ee.length>0&&sn(Ee,J,ie),Ue.length>0&&sn(Ue,J,ie),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function Zi(k,J,ie,$){if((ie.isScene===!0?ie.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[$.id]===void 0&&(_.state.transmissionRenderTarget[$.id]=new Mi(1,1,{generateMipmaps:!0,type:Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float")?nr:Oi,minFilter:ca,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Dn.workingColorSpace}));const Ee=_.state.transmissionRenderTarget[$.id],Ue=$.viewport||W;Ee.setSize(Ue.z*I.transmissionResolutionScale,Ue.w*I.transmissionResolutionScale);const je=I.getRenderTarget();I.setRenderTarget(Ee),I.getClearColor(he),fe=I.getClearAlpha(),fe<1&&I.setClearColor(16777215,.5),I.clear(),Ve&&kt.render(ie);const Ze=I.toneMapping;I.toneMapping=zo;const ut=$.viewport;if($.viewport!==void 0&&($.viewport=void 0),_.setupLightsView($),Pe===!0&&et.setGlobalState(I.clippingPlanes,$),sn(k,ie,$),Z.updateMultisampleRenderTarget(Ee),Z.updateRenderTargetMipmap(Ee),Je.has("WEBGL_multisampled_render_to_texture")===!1){let at=!1;for(let Ye=0,gt=J.length;Ye<gt;Ye++){const vt=J[Ye],Zt=vt.object,Dt=vt.geometry,Ft=vt.material,wt=vt.group;if(Ft.side===Hr&&Zt.layers.test($.layers)){const dn=Ft.side;Ft.side=Wi,Ft.needsUpdate=!0,ma(Zt,ie,$,Dt,Ft,wt),Ft.side=dn,Ft.needsUpdate=!0,at=!0}}at===!0&&(Z.updateMultisampleRenderTarget(Ee),Z.updateRenderTargetMipmap(Ee))}I.setRenderTarget(je),I.setClearColor(he,fe),ut!==void 0&&($.viewport=ut),I.toneMapping=Ze}function sn(k,J,ie){const $=J.isScene===!0?J.overrideMaterial:null;for(let ue=0,Ee=k.length;ue<Ee;ue++){const Ue=k[ue],je=Ue.object,Ze=Ue.geometry,ut=$===null?Ue.material:$,at=Ue.group;je.layers.test(ie.layers)&&ma(je,J,ie,Ze,ut,at)}}function ma(k,J,ie,$,ue,Ee){k.onBeforeRender(I,J,ie,$,ue,Ee),k.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),ue.onBeforeRender(I,J,ie,$,k,Ee),ue.transparent===!0&&ue.side===Hr&&ue.forceSinglePass===!1?(ue.side=Wi,ue.needsUpdate=!0,I.renderBufferDirect(ie,J,$,ue,k,Ee),ue.side=ha,ue.needsUpdate=!0,I.renderBufferDirect(ie,J,$,ue,k,Ee),ue.side=Hr):I.renderBufferDirect(ie,J,$,ue,k,Ee),k.onAfterRender(I,J,ie,$,ue,Ee)}function Wo(k,J,ie){J.isScene!==!0&&(J=pt);const $=ot.get(k),ue=_.state.lights,Ee=_.state.shadowsArray,Ue=ue.state.version,je=Mt.getParameters(k,ue.state,Ee,J,ie),Ze=Mt.getProgramCacheKey(je);let ut=$.programs;$.environment=k.isMeshStandardMaterial?J.environment:null,$.fog=J.fog,$.envMap=(k.isMeshStandardMaterial?Se:G).get(k.envMap||$.environment),$.envMapRotation=$.environment!==null&&k.envMap===null?J.environmentRotation:k.envMapRotation,ut===void 0&&(k.addEventListener("dispose",Qt),ut=new Map,$.programs=ut);let at=ut.get(Ze);if(at!==void 0){if($.currentProgram===at&&$.lightsStateVersion===Ue)return j(k,je),at}else je.uniforms=Mt.getUniforms(k),k.onBeforeCompile(je,I),at=Mt.acquireProgram(je,Ze),ut.set(Ze,at),$.uniforms=je.uniforms;const Ye=$.uniforms;return(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(Ye.clippingPlanes=et.uniform),j(k,je),$.needsLights=De(k),$.lightsStateVersion=Ue,$.needsLights&&(Ye.ambientLightColor.value=ue.state.ambient,Ye.lightProbe.value=ue.state.probe,Ye.directionalLights.value=ue.state.directional,Ye.directionalLightShadows.value=ue.state.directionalShadow,Ye.spotLights.value=ue.state.spot,Ye.spotLightShadows.value=ue.state.spotShadow,Ye.rectAreaLights.value=ue.state.rectArea,Ye.ltc_1.value=ue.state.rectAreaLTC1,Ye.ltc_2.value=ue.state.rectAreaLTC2,Ye.pointLights.value=ue.state.point,Ye.pointLightShadows.value=ue.state.pointShadow,Ye.hemisphereLights.value=ue.state.hemi,Ye.directionalShadowMap.value=ue.state.directionalShadowMap,Ye.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,Ye.spotShadowMap.value=ue.state.spotShadowMap,Ye.spotLightMatrix.value=ue.state.spotLightMatrix,Ye.spotLightMap.value=ue.state.spotLightMap,Ye.pointShadowMap.value=ue.state.pointShadowMap,Ye.pointShadowMatrix.value=ue.state.pointShadowMatrix),$.currentProgram=at,$.uniformsList=null,at}function F(k){if(k.uniformsList===null){const J=k.currentProgram.getUniforms();k.uniformsList=Xg.seqWithValue(J.seq,k.uniforms)}return k.uniformsList}function j(k,J){const ie=ot.get(k);ie.outputColorSpace=J.outputColorSpace,ie.batching=J.batching,ie.batchingColor=J.batchingColor,ie.instancing=J.instancing,ie.instancingColor=J.instancingColor,ie.instancingMorph=J.instancingMorph,ie.skinning=J.skinning,ie.morphTargets=J.morphTargets,ie.morphNormals=J.morphNormals,ie.morphColors=J.morphColors,ie.morphTargetsCount=J.morphTargetsCount,ie.numClippingPlanes=J.numClippingPlanes,ie.numIntersection=J.numClipIntersection,ie.vertexAlphas=J.vertexAlphas,ie.vertexTangents=J.vertexTangents,ie.toneMapping=J.toneMapping}function oe(k,J,ie,$,ue){J.isScene!==!0&&(J=pt),Z.resetTextureUnits();const Ee=J.fog,Ue=$.isMeshStandardMaterial?J.environment:null,je=B===null?I.outputColorSpace:B.isXRRenderTarget===!0?B.texture.colorSpace:ro,Ze=($.isMeshStandardMaterial?Se:G).get($.envMap||Ue),ut=$.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,at=!!ie.attributes.tangent&&(!!$.normalMap||$.anisotropy>0),Ye=!!ie.morphAttributes.position,gt=!!ie.morphAttributes.normal,vt=!!ie.morphAttributes.color;let Zt=zo;$.toneMapped&&(B===null||B.isXRRenderTarget===!0)&&(Zt=I.toneMapping);const Dt=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Ft=Dt!==void 0?Dt.length:0,wt=ot.get($),dn=_.state.lights;if(Pe===!0&&(Le===!0||k!==U)){const Kn=k===U&&$.id===D;et.setState($,k,Kn)}let Gt=!1;$.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==dn.state.version||wt.outputColorSpace!==je||ue.isBatchedMesh&&wt.batching===!1||!ue.isBatchedMesh&&wt.batching===!0||ue.isBatchedMesh&&wt.batchingColor===!0&&ue.colorTexture===null||ue.isBatchedMesh&&wt.batchingColor===!1&&ue.colorTexture!==null||ue.isInstancedMesh&&wt.instancing===!1||!ue.isInstancedMesh&&wt.instancing===!0||ue.isSkinnedMesh&&wt.skinning===!1||!ue.isSkinnedMesh&&wt.skinning===!0||ue.isInstancedMesh&&wt.instancingColor===!0&&ue.instanceColor===null||ue.isInstancedMesh&&wt.instancingColor===!1&&ue.instanceColor!==null||ue.isInstancedMesh&&wt.instancingMorph===!0&&ue.morphTexture===null||ue.isInstancedMesh&&wt.instancingMorph===!1&&ue.morphTexture!==null||wt.envMap!==Ze||$.fog===!0&&wt.fog!==Ee||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==et.numPlanes||wt.numIntersection!==et.numIntersection)||wt.vertexAlphas!==ut||wt.vertexTangents!==at||wt.morphTargets!==Ye||wt.morphNormals!==gt||wt.morphColors!==vt||wt.toneMapping!==Zt||wt.morphTargetsCount!==Ft)&&(Gt=!0):(Gt=!0,wt.__version=$.version);let $t=wt.currentProgram;Gt===!0&&($t=Wo($,J,ue));let qn=!1,ln=!1,mn=!1;const jt=$t.getUniforms(),ii=wt.uniforms;if(it.useProgram($t.program)&&(qn=!0,ln=!0,mn=!0),$.id!==D&&(D=$.id,ln=!0),qn||U!==k){it.buffers.depth.getReversed()?(Be.copy(k.projectionMatrix),eb(Be),tb(Be),jt.setValue(K,"projectionMatrix",Be)):jt.setValue(K,"projectionMatrix",k.projectionMatrix),jt.setValue(K,"viewMatrix",k.matrixWorldInverse);const _i=jt.map.cameraPosition;_i!==void 0&&_i.setValue(K,ft.setFromMatrixPosition(k.matrixWorld)),dt.logarithmicDepthBuffer&&jt.setValue(K,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&jt.setValue(K,"isOrthographic",k.isOrthographicCamera===!0),U!==k&&(U=k,ln=!0,mn=!0)}if(ue.isSkinnedMesh){jt.setOptional(K,ue,"bindMatrix"),jt.setOptional(K,ue,"bindMatrixInverse");const Kn=ue.skeleton;Kn&&(Kn.boneTexture===null&&Kn.computeBoneTexture(),jt.setValue(K,"boneTexture",Kn.boneTexture,Z))}ue.isBatchedMesh&&(jt.setOptional(K,ue,"batchingTexture"),jt.setValue(K,"batchingTexture",ue._matricesTexture,Z),jt.setOptional(K,ue,"batchingIdTexture"),jt.setValue(K,"batchingIdTexture",ue._indirectTexture,Z),jt.setOptional(K,ue,"batchingColorTexture"),ue._colorsTexture!==null&&jt.setValue(K,"batchingColorTexture",ue._colorsTexture,Z));const Pn=ie.morphAttributes;if((Pn.position!==void 0||Pn.normal!==void 0||Pn.color!==void 0)&&Lt.update(ue,ie,$t),(ln||wt.receiveShadow!==ue.receiveShadow)&&(wt.receiveShadow=ue.receiveShadow,jt.setValue(K,"receiveShadow",ue.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(ii.envMap.value=Ze,ii.flipEnvMap.value=Ze.isCubeTexture&&Ze.isRenderTargetTexture===!1?-1:1),$.isMeshStandardMaterial&&$.envMap===null&&J.environment!==null&&(ii.envMapIntensity.value=J.environmentIntensity),ln&&(jt.setValue(K,"toneMappingExposure",I.toneMappingExposure),wt.needsLights&&Te(ii,mn),Ee&&$.fog===!0&&ct.refreshFogUniforms(ii,Ee),ct.refreshMaterialUniforms(ii,$,q,xe,_.state.transmissionRenderTarget[k.id]),Xg.upload(K,F(wt),ii,Z)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Xg.upload(K,F(wt),ii,Z),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&jt.setValue(K,"center",ue.center),jt.setValue(K,"modelViewMatrix",ue.modelViewMatrix),jt.setValue(K,"normalMatrix",ue.normalMatrix),jt.setValue(K,"modelMatrix",ue.matrixWorld),$.isShaderMaterial||$.isRawShaderMaterial){const Kn=$.uniformsGroups;for(let _i=0,wn=Kn.length;_i<wn;_i++){const Ir=Kn[_i];me.update(Ir,$t),me.bind(Ir,$t)}}return $t}function Te(k,J){k.ambientLightColor.needsUpdate=J,k.lightProbe.needsUpdate=J,k.directionalLights.needsUpdate=J,k.directionalLightShadows.needsUpdate=J,k.pointLights.needsUpdate=J,k.pointLightShadows.needsUpdate=J,k.spotLights.needsUpdate=J,k.spotLightShadows.needsUpdate=J,k.rectAreaLights.needsUpdate=J,k.hemisphereLights.needsUpdate=J}function De(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return B},this.setRenderTargetTextures=function(k,J,ie){ot.get(k.texture).__webglTexture=J,ot.get(k.depthTexture).__webglTexture=ie;const $=ot.get(k);$.__hasExternalTextures=!0,$.__autoAllocateDepthBuffer=ie===void 0,$.__autoAllocateDepthBuffer||Je.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(k,J){const ie=ot.get(k);ie.__webglFramebuffer=J,ie.__useDefaultFramebuffer=J===void 0};const Ne=K.createFramebuffer();this.setRenderTarget=function(k,J=0,ie=0){B=k,O=J,H=ie;let $=!0,ue=null,Ee=!1,Ue=!1;if(k){const Ze=ot.get(k);if(Ze.__useDefaultFramebuffer!==void 0)it.bindFramebuffer(K.FRAMEBUFFER,null),$=!1;else if(Ze.__webglFramebuffer===void 0)Z.setupRenderTarget(k);else if(Ze.__hasExternalTextures)Z.rebindTextures(k,ot.get(k.texture).__webglTexture,ot.get(k.depthTexture).__webglTexture);else if(k.depthBuffer){const Ye=k.depthTexture;if(Ze.__boundDepthTexture!==Ye){if(Ye!==null&&ot.has(Ye)&&(k.width!==Ye.image.width||k.height!==Ye.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Z.setupDepthRenderbuffer(k)}}const ut=k.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(Ue=!0);const at=ot.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(Array.isArray(at[J])?ue=at[J][ie]:ue=at[J],Ee=!0):k.samples>0&&Z.useMultisampledRTT(k)===!1?ue=ot.get(k).__webglMultisampledFramebuffer:Array.isArray(at)?ue=at[ie]:ue=at,W.copy(k.viewport),ne.copy(k.scissor),re=k.scissorTest}else W.copy(Y).multiplyScalar(q).floor(),ne.copy(le).multiplyScalar(q).floor(),re=ze;if(ie!==0&&(ue=Ne),it.bindFramebuffer(K.FRAMEBUFFER,ue)&&$&&it.drawBuffers(k,ue),it.viewport(W),it.scissor(ne),it.setScissorTest(re),Ee){const Ze=ot.get(k.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ze.__webglTexture,ie)}else if(Ue){const Ze=ot.get(k.texture),ut=J;K.framebufferTextureLayer(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,Ze.__webglTexture,ie,ut)}else if(k!==null&&ie!==0){const Ze=ot.get(k.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Ze.__webglTexture,ie)}D=-1},this.readRenderTargetPixels=function(k,J,ie,$,ue,Ee,Ue){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let je=ot.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je){it.bindFramebuffer(K.FRAMEBUFFER,je);try{const Ze=k.texture,ut=Ze.format,at=Ze.type;if(!dt.textureFormatReadable(ut)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!dt.textureTypeReadable(at)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}J>=0&&J<=k.width-$&&ie>=0&&ie<=k.height-ue&&K.readPixels(J,ie,$,ue,Ht.convert(ut),Ht.convert(at),Ee)}finally{const Ze=B!==null?ot.get(B).__webglFramebuffer:null;it.bindFramebuffer(K.FRAMEBUFFER,Ze)}}},this.readRenderTargetPixelsAsync=async function(k,J,ie,$,ue,Ee,Ue){if(!(k&&k.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let je=ot.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je){const Ze=k.texture,ut=Ze.format,at=Ze.type;if(!dt.textureFormatReadable(ut))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!dt.textureTypeReadable(at))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(J>=0&&J<=k.width-$&&ie>=0&&ie<=k.height-ue){it.bindFramebuffer(K.FRAMEBUFFER,je);const Ye=K.createBuffer();K.bindBuffer(K.PIXEL_PACK_BUFFER,Ye),K.bufferData(K.PIXEL_PACK_BUFFER,Ee.byteLength,K.STREAM_READ),K.readPixels(J,ie,$,ue,Ht.convert(ut),Ht.convert(at),0);const gt=B!==null?ot.get(B).__webglFramebuffer:null;it.bindFramebuffer(K.FRAMEBUFFER,gt);const vt=K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE,0);return K.flush(),await $C(K,vt,4),K.bindBuffer(K.PIXEL_PACK_BUFFER,Ye),K.getBufferSubData(K.PIXEL_PACK_BUFFER,0,Ee),K.deleteBuffer(Ye),K.deleteSync(vt),Ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(k,J=null,ie=0){k.isTexture!==!0&&(ad("WebGLRenderer: copyFramebufferToTexture function signature has changed."),J=arguments[0]||null,k=arguments[1]);const $=Math.pow(2,-ie),ue=Math.floor(k.image.width*$),Ee=Math.floor(k.image.height*$),Ue=J!==null?J.x:0,je=J!==null?J.y:0;Z.setTexture2D(k,0),K.copyTexSubImage2D(K.TEXTURE_2D,ie,0,0,Ue,je,ue,Ee),it.unbindTexture()};const nt=K.createFramebuffer(),Qe=K.createFramebuffer();this.copyTextureToTexture=function(k,J,ie=null,$=null,ue=0,Ee=null){k.isTexture!==!0&&(ad("WebGLRenderer: copyTextureToTexture function signature has changed."),$=arguments[0]||null,k=arguments[1],J=arguments[2],Ee=arguments[3]||0,ie=null),Ee===null&&(ue!==0?(ad("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ee=ue,ue=0):Ee=0);let Ue,je,Ze,ut,at,Ye,gt,vt,Zt;const Dt=k.isCompressedTexture?k.mipmaps[Ee]:k.image;if(ie!==null)Ue=ie.max.x-ie.min.x,je=ie.max.y-ie.min.y,Ze=ie.isBox3?ie.max.z-ie.min.z:1,ut=ie.min.x,at=ie.min.y,Ye=ie.isBox3?ie.min.z:0;else{const Pn=Math.pow(2,-ue);Ue=Math.floor(Dt.width*Pn),je=Math.floor(Dt.height*Pn),k.isDataArrayTexture?Ze=Dt.depth:k.isData3DTexture?Ze=Math.floor(Dt.depth*Pn):Ze=1,ut=0,at=0,Ye=0}$!==null?(gt=$.x,vt=$.y,Zt=$.z):(gt=0,vt=0,Zt=0);const Ft=Ht.convert(J.format),wt=Ht.convert(J.type);let dn;J.isData3DTexture?(Z.setTexture3D(J,0),dn=K.TEXTURE_3D):J.isDataArrayTexture||J.isCompressedArrayTexture?(Z.setTexture2DArray(J,0),dn=K.TEXTURE_2D_ARRAY):(Z.setTexture2D(J,0),dn=K.TEXTURE_2D),K.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,J.flipY),K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),K.pixelStorei(K.UNPACK_ALIGNMENT,J.unpackAlignment);const Gt=K.getParameter(K.UNPACK_ROW_LENGTH),$t=K.getParameter(K.UNPACK_IMAGE_HEIGHT),qn=K.getParameter(K.UNPACK_SKIP_PIXELS),ln=K.getParameter(K.UNPACK_SKIP_ROWS),mn=K.getParameter(K.UNPACK_SKIP_IMAGES);K.pixelStorei(K.UNPACK_ROW_LENGTH,Dt.width),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,Dt.height),K.pixelStorei(K.UNPACK_SKIP_PIXELS,ut),K.pixelStorei(K.UNPACK_SKIP_ROWS,at),K.pixelStorei(K.UNPACK_SKIP_IMAGES,Ye);const jt=k.isDataArrayTexture||k.isData3DTexture,ii=J.isDataArrayTexture||J.isData3DTexture;if(k.isDepthTexture){const Pn=ot.get(k),Kn=ot.get(J),_i=ot.get(Pn.__renderTarget),wn=ot.get(Kn.__renderTarget);it.bindFramebuffer(K.READ_FRAMEBUFFER,_i.__webglFramebuffer),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,wn.__webglFramebuffer);for(let Ir=0;Ir<Ze;Ir++)jt&&(K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,ot.get(k).__webglTexture,ue,Ye+Ir),K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,ot.get(J).__webglTexture,Ee,Zt+Ir)),K.blitFramebuffer(ut,at,Ue,je,gt,vt,Ue,je,K.DEPTH_BUFFER_BIT,K.NEAREST);it.bindFramebuffer(K.READ_FRAMEBUFFER,null),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else if(ue!==0||k.isRenderTargetTexture||ot.has(k)){const Pn=ot.get(k),Kn=ot.get(J);it.bindFramebuffer(K.READ_FRAMEBUFFER,nt),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,Qe);for(let _i=0;_i<Ze;_i++)jt?K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Pn.__webglTexture,ue,Ye+_i):K.framebufferTexture2D(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Pn.__webglTexture,ue),ii?K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Kn.__webglTexture,Ee,Zt+_i):K.framebufferTexture2D(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Kn.__webglTexture,Ee),ue!==0?K.blitFramebuffer(ut,at,Ue,je,gt,vt,Ue,je,K.COLOR_BUFFER_BIT,K.NEAREST):ii?K.copyTexSubImage3D(dn,Ee,gt,vt,Zt+_i,ut,at,Ue,je):K.copyTexSubImage2D(dn,Ee,gt,vt,ut,at,Ue,je);it.bindFramebuffer(K.READ_FRAMEBUFFER,null),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else ii?k.isDataTexture||k.isData3DTexture?K.texSubImage3D(dn,Ee,gt,vt,Zt,Ue,je,Ze,Ft,wt,Dt.data):J.isCompressedArrayTexture?K.compressedTexSubImage3D(dn,Ee,gt,vt,Zt,Ue,je,Ze,Ft,Dt.data):K.texSubImage3D(dn,Ee,gt,vt,Zt,Ue,je,Ze,Ft,wt,Dt):k.isDataTexture?K.texSubImage2D(K.TEXTURE_2D,Ee,gt,vt,Ue,je,Ft,wt,Dt.data):k.isCompressedTexture?K.compressedTexSubImage2D(K.TEXTURE_2D,Ee,gt,vt,Dt.width,Dt.height,Ft,Dt.data):K.texSubImage2D(K.TEXTURE_2D,Ee,gt,vt,Ue,je,Ft,wt,Dt);K.pixelStorei(K.UNPACK_ROW_LENGTH,Gt),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,$t),K.pixelStorei(K.UNPACK_SKIP_PIXELS,qn),K.pixelStorei(K.UNPACK_SKIP_ROWS,ln),K.pixelStorei(K.UNPACK_SKIP_IMAGES,mn),Ee===0&&J.generateMipmaps&&K.generateMipmap(dn),it.unbindTexture()},this.copyTextureToTexture3D=function(k,J,ie=null,$=null,ue=0){return k.isTexture!==!0&&(ad("WebGLRenderer: copyTextureToTexture3D function signature has changed."),ie=arguments[0]||null,$=arguments[1]||null,k=arguments[2],J=arguments[3],ue=arguments[4]||0),ad('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(k,J,ie,$,ue)},this.initRenderTarget=function(k){ot.get(k).__webglFramebuffer===void 0&&Z.setupRenderTarget(k)},this.initTexture=function(k){k.isCubeTexture?Z.setTextureCube(k,0):k.isData3DTexture?Z.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?Z.setTexture2DArray(k,0):Z.setTexture2D(k,0),it.unbindTexture()},this.resetState=function(){O=0,H=0,B=null,it.reset(),Kt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=Dn._getDrawingBufferColorSpace(e),t.unpackColorSpace=Dn._getUnpackColorSpace()}}const iD=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Bv,AddEquation:$l,AddOperation:YM,AdditiveAnimationBlendMode:ix,AdditiveBlending:ol,AgXToneMapping:JM,AlphaFormat:Qy,AlwaysCompare:dw,AlwaysDepth:lp,AlwaysStencilFunc:wy,AmbientLight:eT,AnimationAction:lT,AnimationClip:Tp,AnimationLoader:S2,AnimationMixer:Z2,AnimationObjectGroup:X2,AnimationUtils:v2,ArcCurve:Cw,ArrayCamera:sT,ArrowHelper:pR,AttachedBindMode:Ey,Audio:oT,AudioAnalyser:O2,AudioContext:bx,AudioListener:D2,AudioLoader:I2,AxesHelper:mR,BackSide:Wi,BasicDepthPacking:ac,BasicShadowMap:CM,BatchedMesh:Mw,Bone:ux,BooleanKeyframeTrack:Fu,Box2:tR,Box3:ir,Box3Helper:dR,BoxGeometry:cc,BoxHelper:hR,BufferAttribute:jn,BufferGeometry:yn,BufferGeometryLoader:rT,ByteType:zv,Cache:nl,Camera:Np,CameraHelper:uR,CanvasTexture:Aw,CapsuleGeometry:i0,CatmullRomCurve3:n0,CineonToneMapping:KM,CircleGeometry:r0,ClampToEdgeWrapping:ji,Clock:Rx,Color:yt,ColorKeyframeTrack:wx,ColorManagement:Dn,CompressedArrayTexture:kb,CompressedCubeTexture:Hb,CompressedTexture:$v,CompressedTextureLoader:E2,ConeGeometry:Bp,ConstantAlphaFactor:WM,ConstantColorFactor:VM,Controls:vR,CubeCamera:_w,CubeReflectionMapping:da,CubeRefractionMapping:nc,CubeTexture:Up,CubeTextureLoader:qw,CubeUVReflectionMapping:Ad,CubicBezierCurve:fx,CubicBezierCurve3:bw,CubicInterpolant:jw,CullFaceBack:yy,CullFaceFront:AM,CullFaceFrontBack:iC,CullFaceNone:TM,Curve:Ho,CurvePath:Iw,CustomBlending:bM,CustomToneMapping:QM,CylinderGeometry:uc,Cylindrical:eR,Data3DTexture:Zv,DataArrayTexture:Dp,DataTexture:ko,DataTextureLoader:Tx,DataUtils:Mu,DecrementStencilOp:gC,DecrementWrapStencilOp:_C,DefaultLoadingManager:Zw,DepthFormat:Cu,DepthStencilFormat:rc,DepthTexture:e0,DetachedBindMode:ew,DirectionalLight:$w,DirectionalLightHelper:cR,DiscreteInterpolant:Xw,DodecahedronGeometry:s0,DoubleSide:Hr,DstAlphaFactor:FM,DstColorFactor:zM,DynamicCopyUsage:DC,DynamicDrawUsage:CC,DynamicReadUsage:IC,EdgesGeometry:Pw,EllipseCurve:t0,EqualCompare:lw,EqualDepth:Jg,EqualStencilFunc:EC,EquirectangularReflectionMapping:_d,EquirectangularRefractionMapping:cp,Euler:Vs,EventDispatcher:Gs,ExtrudeGeometry:a0,FileLoader:Hs,Float16BufferAttribute:Sb,Float32BufferAttribute:Ut,FloatType:di,Fog:Kv,FogExp2:qv,FramebufferTexture:zb,FrontSide:ha,Frustum:Op,GLBufferAttribute:$2,GLSL1:UC,GLSL3:Ty,GreaterCompare:cw,GreaterDepth:ev,GreaterEqualCompare:hw,GreaterEqualDepth:$g,GreaterEqualStencilFunc:AC,GreaterStencilFunc:wC,GridHelper:aR,Group:dd,HalfFloatType:nr,HemisphereLight:Kw,HemisphereLightHelper:oR,IcosahedronGeometry:zp,ImageBitmapLoader:R2,ImageLoader:Ap,ImageUtils:mw,IncrementStencilOp:mC,IncrementWrapStencilOp:vC,InstancedBufferAttribute:Nu,InstancedBufferGeometry:Cx,InstancedInterleavedBuffer:Lv,InstancedMesh:Ed,Int16BufferAttribute:yb,Int32BufferAttribute:xb,Int8BufferAttribute:gb,IntType:Ip,InterleavedBuffer:Qv,InterleavedBufferAttribute:zs,Interpolant:Hp,InterpolateDiscrete:dp,InterpolateLinear:bv,InterpolateSmooth:jg,InvertStencilOp:yC,KeepStencilOp:mu,KeyframeTrack:Vo,LOD:Sw,LatheGeometry:Fp,Layers:Ru,LessCompare:aw,LessDepth:Qg,LessEqualCompare:rx,LessEqualDepth:Lu,LessEqualStencilFunc:MC,LessStencilFunc:SC,Light:dc,LightProbe:iT,Line:sc,Line3:uT,LineBasicMaterial:os,LineCurve:px,LineCurve3:Rw,LineDashedMaterial:Vw,LineLoop:ww,LineSegments:pa,LinearFilter:On,LinearInterpolant:Mx,LinearMipMapLinearFilter:My,LinearMipMapNearestFilter:oC,LinearMipmapLinearFilter:ca,LinearMipmapNearestFilter:Jf,LinearSRGBColorSpace:ro,LinearToneMapping:ZM,LinearTransfer:pp,Loader:as,LoaderUtils:Iy,LoadingManager:f0,LoopOnce:tw,LoopPingPong:iw,LoopRepeat:nw,LuminanceAlphaFormat:ex,LuminanceFormat:$y,MOUSE:tC,Material:pr,MaterialLoader:p0,MathUtils:Xv,Matrix2:Lx,Matrix3:pn,Matrix4:qt,MaxEquation:LM,Mesh:fi,MeshBasicMaterial:ll,MeshDepthMaterial:xx,MeshDistanceMaterial:Sx,MeshLambertMaterial:kw,MeshMatcapMaterial:Hw,MeshNormalMaterial:yx,MeshPhongMaterial:Bw,MeshPhysicalMaterial:Fw,MeshStandardMaterial:Ou,MeshToonMaterial:zw,MinEquation:PM,MirroredRepeatWrapping:hp,MixOperation:XM,MultiplyBlending:Sy,MultiplyOperation:Rp,NearestFilter:Ui,NearestMipMapLinearFilter:sC,NearestMipMapNearestFilter:rC,NearestMipmapLinearFilter:ud,NearestMipmapNearestFilter:qy,NeutralToneMapping:$M,NeverCompare:ow,NeverDepth:Kg,NeverStencilFunc:xC,NoBlending:Rr,NoColorSpace:Fo,NoToneMapping:zo,NormalAnimationBlendMode:jv,NormalBlending:Au,NotEqualCompare:uw,NotEqualDepth:tv,NotEqualStencilFunc:TC,NumberKeyframeTrack:Mp,Object3D:Cn,ObjectLoader:C2,ObjectSpaceNormalMap:sw,OctahedronGeometry:kp,OneFactor:NM,OneMinusConstantAlphaFactor:jM,OneMinusConstantColorFactor:GM,OneMinusDstAlphaFactor:BM,OneMinusDstColorFactor:kM,OneMinusSrcAlphaFactor:qg,OneMinusSrcColorFactor:OM,OrthographicCamera:ul,PCFShadowMap:Fv,PCFSoftShadowMap:Qf,PMREMGenerator:Dy,Path:yp,PerspectiveCamera:Di,Plane:el,PlaneGeometry:cl,PlaneHelper:fR,PointLight:Jw,PointLightHelper:rR,Points:Tw,PointsMaterial:hx,PolarGridHelper:lR,PolyhedronGeometry:hc,PositionalAudio:U2,PropertyBinding:Un,PropertyMixer:aT,QuadraticBezierCurve:mx,QuadraticBezierCurve3:gx,Quaternion:ss,QuaternionKeyframeTrack:Vp,QuaternionLinearInterpolant:Yw,RED_GREEN_RGTC2_Format:Av,RED_RGTC1_Format:nx,REVISION:oc,RGBADepthPacking:rw,RGBAFormat:Ni,RGBAIntegerFormat:Wv,RGBA_ASTC_10x10_Format:xv,RGBA_ASTC_10x5_Format:vv,RGBA_ASTC_10x6_Format:_v,RGBA_ASTC_10x8_Format:yv,RGBA_ASTC_12x10_Format:Sv,RGBA_ASTC_12x12_Format:Ev,RGBA_ASTC_4x4_Format:cv,RGBA_ASTC_5x4_Format:uv,RGBA_ASTC_5x5_Format:hv,RGBA_ASTC_6x5_Format:dv,RGBA_ASTC_6x6_Format:fv,RGBA_ASTC_8x5_Format:pv,RGBA_ASTC_8x6_Format:mv,RGBA_ASTC_8x8_Format:gv,RGBA_BPTC_Format:ip,RGBA_ETC2_EAC_Format:lv,RGBA_PVRTC_2BPPV1_Format:sv,RGBA_PVRTC_4BPPV1_Format:rv,RGBA_S3TC_DXT1_Format:ep,RGBA_S3TC_DXT3_Format:tp,RGBA_S3TC_DXT5_Format:np,RGBDepthPacking:hC,RGBFormat:Jy,RGBIntegerFormat:aC,RGB_BPTC_SIGNED_Format:Mv,RGB_BPTC_UNSIGNED_Format:wv,RGB_ETC1_Format:ov,RGB_ETC2_Format:av,RGB_PVRTC_2BPPV1_Format:iv,RGB_PVRTC_4BPPV1_Format:nv,RGB_S3TC_DXT1_Format:$f,RGDepthPacking:dC,RGFormat:tx,RGIntegerFormat:Gv,RawShaderMaterial:Ow,Ray:Cd,Raycaster:m0,RectAreaLight:tT,RedFormat:Pp,RedIntegerFormat:Lp,ReinhardToneMapping:qM,RenderTarget:Yv,RenderTarget3D:q2,RenderTargetArray:K2,RepeatWrapping:up,ReplaceStencilOp:pC,ReverseSubtractEquation:IM,RingGeometry:l0,SIGNED_RED_GREEN_RGTC2_Format:Cv,SIGNED_RED_RGTC1_Format:Tv,SRGBColorSpace:kn,SRGBTransfer:Zn,Scene:Du,ShaderChunk:En,ShaderLib:Oo,ShaderMaterial:li,ShadowMaterial:Uw,Shape:Iu,ShapeGeometry:c0,ShapePath:gR,ShapeUtils:ua,ShortType:kv,Skeleton:Jv,SkeletonHelper:iR,SkinnedMesh:Ew,Source:Eu,Sphere:rr,SphereGeometry:bd,Spherical:cT,SphericalHarmonics3:nT,SplineCurve:vx,SpotLight:Qw,SpotLightHelper:nR,Sprite:xw,SpriteMaterial:cx,SrcAlphaFactor:Zg,SrcAlphaSaturateFactor:HM,SrcColorFactor:UM,StaticCopyUsage:LC,StaticDrawUsage:mp,StaticReadUsage:RC,StereoCamera:P2,StreamCopyUsage:NC,StreamDrawUsage:bC,StreamReadUsage:PC,StringKeyframeTrack:Bu,SubtractEquation:RM,SubtractiveBlending:xy,TOUCH:nC,TangentSpaceNormalMap:lc,TetrahedronGeometry:u0,Texture:Wn,TextureLoader:M2,TextureUtils:ER,TorusGeometry:h0,TorusKnotGeometry:d0,Triangle:Ms,TriangleFanDrawMode:uC,TriangleStripDrawMode:cC,TrianglesDrawMode:lC,TubeGeometry:Md,UVMapping:tc,Uint16BufferAttribute:ox,Uint32BufferAttribute:ax,Uint8BufferAttribute:vb,Uint8ClampedBufferAttribute:_b,Uniform:bn,UniformsGroup:J2,UniformsLib:_t,UniformsUtils:_p,UnsignedByteType:Oi,UnsignedInt248Type:ic,UnsignedInt5999Type:Ky,UnsignedIntType:fa,UnsignedShort4444Type:Hv,UnsignedShort5551Type:Vv,UnsignedShortType:yd,VSMShadowMap:Uo,Vector2:ke,Vector3:X,Vector4:_n,VectorKeyframeTrack:wp,VideoTexture:Bb,WebGL3DRenderTarget:ob,WebGLArrayRenderTarget:sb,WebGLCoordinateSystem:Bo,WebGLCubeRenderTarget:lx,WebGLRenderTarget:Mi,WebGLRenderer:Nx,WebGLUtils:vT,WebGPUCoordinateSystem:gp,WireframeGeometry:_x,WrapAroundEnding:fp,ZeroCurvatureEnding:xu,ZeroFactor:DM,ZeroSlopeEnding:Su,ZeroStencilOp:fC,createCanvasElement:pw},Symbol.toStringTag,{value:"Module"}));var G_={exports:{}},Zl={};/**
3866
+ }`;class JL{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Wn,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new li({vertexShader:KL,fragmentShader:QL,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new fi(new cl(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $L extends Gs{constructor(e,t){super();const n=this;let r=null,s=1,a=null,c="local-floor",d=1,f=null,p=null,g=null,v=null,y=null,E=null;const T=new JL,w=t.getContextAttributes();let _=null,C=null;const b=[],I=[],N=new ke;let O=null;const H=new Di;H.viewport=new _n;const B=new Di;B.viewport=new _n;const D=[H,B],U=new sT;let W=null,ne=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ve){let Pe=b[ve];return Pe===void 0&&(Pe=new V_,b[ve]=Pe),Pe.getTargetRaySpace()},this.getControllerGrip=function(ve){let Pe=b[ve];return Pe===void 0&&(Pe=new V_,b[ve]=Pe),Pe.getGripSpace()},this.getHand=function(ve){let Pe=b[ve];return Pe===void 0&&(Pe=new V_,b[ve]=Pe),Pe.getHandSpace()};function re(ve){const Pe=I.indexOf(ve.inputSource);if(Pe===-1)return;const Le=b[Pe];Le!==void 0&&(Le.update(ve.inputSource,ve.frame,f||a),Le.dispatchEvent({type:ve.type,data:ve.inputSource}))}function he(){r.removeEventListener("select",re),r.removeEventListener("selectstart",re),r.removeEventListener("selectend",re),r.removeEventListener("squeeze",re),r.removeEventListener("squeezestart",re),r.removeEventListener("squeezeend",re),r.removeEventListener("end",he),r.removeEventListener("inputsourceschange",fe);for(let ve=0;ve<b.length;ve++){const Pe=I[ve];Pe!==null&&(I[ve]=null,b[ve].disconnect(Pe))}W=null,ne=null,T.reset(),e.setRenderTarget(_),y=null,v=null,g=null,r=null,C=null,ze.stop(),n.isPresenting=!1,e.setPixelRatio(O),e.setSize(N.width,N.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ve){s=ve,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ve){c=ve,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return f||a},this.setReferenceSpace=function(ve){f=ve},this.getBaseLayer=function(){return v!==null?v:y},this.getBinding=function(){return g},this.getFrame=function(){return E},this.getSession=function(){return r},this.setSession=async function(ve){if(r=ve,r!==null){if(_=e.getRenderTarget(),r.addEventListener("select",re),r.addEventListener("selectstart",re),r.addEventListener("selectend",re),r.addEventListener("squeeze",re),r.addEventListener("squeezestart",re),r.addEventListener("squeezeend",re),r.addEventListener("end",he),r.addEventListener("inputsourceschange",fe),w.xrCompatible!==!0&&await t.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(N),r.enabledFeatures!==void 0&&r.enabledFeatures.includes("layers")){let Le=null,Be=null,Ke=null;w.depth&&(Ke=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Le=w.stencil?rc:Cu,Be=w.stencil?ic:fa);const ft={colorFormat:t.RGBA8,depthFormat:Ke,scaleFactor:s};g=new XRWebGLBinding(r,t),v=g.createProjectionLayer(ft),r.updateRenderState({layers:[v]}),e.setPixelRatio(1),e.setSize(v.textureWidth,v.textureHeight,!1),C=new Mi(v.textureWidth,v.textureHeight,{format:Ni,type:Oi,depthTexture:new e0(v.textureWidth,v.textureHeight,Be,void 0,void 0,void 0,void 0,void 0,void 0,Le),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:v.ignoreDepthValues===!1})}else{const Le={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};y=new XRWebGLLayer(r,t,Le),r.updateRenderState({baseLayer:y}),e.setPixelRatio(1),e.setSize(y.framebufferWidth,y.framebufferHeight,!1),C=new Mi(y.framebufferWidth,y.framebufferHeight,{format:Ni,type:Oi,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil})}C.isXRRenderTarget=!0,this.setFoveation(d),f=null,a=await r.requestReferenceSpace(c),ze.setContext(r),ze.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function fe(ve){for(let Pe=0;Pe<ve.removed.length;Pe++){const Le=ve.removed[Pe],Be=I.indexOf(Le);Be>=0&&(I[Be]=null,b[Be].disconnect(Le))}for(let Pe=0;Pe<ve.added.length;Pe++){const Le=ve.added[Pe];let Be=I.indexOf(Le);if(Be===-1){for(let ft=0;ft<b.length;ft++)if(ft>=I.length){I.push(Le),Be=ft;break}else if(I[ft]===null){I[ft]=Le,Be=ft;break}if(Be===-1)break}const Ke=b[Be];Ke&&Ke.connect(Le)}}const ce=new X,xe=new X;function q(ve,Pe,Le){ce.setFromMatrixPosition(Pe.matrixWorld),xe.setFromMatrixPosition(Le.matrixWorld);const Be=ce.distanceTo(xe),Ke=Pe.projectionMatrix.elements,ft=Le.projectionMatrix.elements,ht=Ke[14]/(Ke[10]-1),pt=Ke[14]/(Ke[10]+1),Ve=(Ke[9]+1)/Ke[5],Ge=(Ke[9]-1)/Ke[5],K=(Ke[8]-1)/Ke[0],At=(ft[8]+1)/ft[0],Je=ht*K,dt=ht*At,it=Be/(-K+At),zt=it*-K;if(Pe.matrixWorld.decompose(ve.position,ve.quaternion,ve.scale),ve.translateX(zt),ve.translateZ(it),ve.matrixWorld.compose(ve.position,ve.quaternion,ve.scale),ve.matrixWorldInverse.copy(ve.matrixWorld).invert(),Ke[10]===-1)ve.projectionMatrix.copy(Pe.projectionMatrix),ve.projectionMatrixInverse.copy(Pe.projectionMatrixInverse);else{const ot=ht+it,Z=pt+it,G=Je-zt,Se=dt+(Be-zt),Fe=Ve*pt/Z*ot,Xe=Ge*pt/Z*ot;ve.projectionMatrix.makePerspective(G,Se,Fe,Xe,ot,Z),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert()}}function de(ve,Pe){Pe===null?ve.matrixWorld.copy(ve.matrix):ve.matrixWorld.multiplyMatrices(Pe.matrixWorld,ve.matrix),ve.matrixWorldInverse.copy(ve.matrixWorld).invert()}this.updateCamera=function(ve){if(r===null)return;let Pe=ve.near,Le=ve.far;T.texture!==null&&(T.depthNear>0&&(Pe=T.depthNear),T.depthFar>0&&(Le=T.depthFar)),U.near=B.near=H.near=Pe,U.far=B.far=H.far=Le,(W!==U.near||ne!==U.far)&&(r.updateRenderState({depthNear:U.near,depthFar:U.far}),W=U.near,ne=U.far),H.layers.mask=ve.layers.mask|2,B.layers.mask=ve.layers.mask|4,U.layers.mask=H.layers.mask|B.layers.mask;const Be=ve.parent,Ke=U.cameras;de(U,Be);for(let ft=0;ft<Ke.length;ft++)de(Ke[ft],Be);Ke.length===2?q(U,H,B):U.projectionMatrix.copy(H.projectionMatrix),se(ve,U,Be)};function se(ve,Pe,Le){Le===null?ve.matrix.copy(Pe.matrixWorld):(ve.matrix.copy(Le.matrixWorld),ve.matrix.invert(),ve.matrix.multiply(Pe.matrixWorld)),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.updateMatrixWorld(!0),ve.projectionMatrix.copy(Pe.projectionMatrix),ve.projectionMatrixInverse.copy(Pe.projectionMatrixInverse),ve.isPerspectiveCamera&&(ve.fov=xd*2*Math.atan(1/ve.projectionMatrix.elements[5]),ve.zoom=1)}this.getCamera=function(){return U},this.getFoveation=function(){if(!(v===null&&y===null))return d},this.setFoveation=function(ve){d=ve,v!==null&&(v.fixedFoveation=ve),y!==null&&y.fixedFoveation!==void 0&&(y.fixedFoveation=ve)},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(U)};let Y=null;function le(ve,Pe){if(p=Pe.getViewerPose(f||a),E=Pe,p!==null){const Le=p.views;y!==null&&(e.setRenderTargetFramebuffer(C,y.framebuffer),e.setRenderTarget(C));let Be=!1;Le.length!==U.cameras.length&&(U.cameras.length=0,Be=!0);for(let ft=0;ft<Le.length;ft++){const ht=Le[ft];let pt=null;if(y!==null)pt=y.getViewport(ht);else{const Ge=g.getViewSubImage(v,ht);pt=Ge.viewport,ft===0&&(e.setRenderTargetTextures(C,Ge.colorTexture,v.ignoreDepthValues?void 0:Ge.depthStencilTexture),e.setRenderTarget(C))}let Ve=D[ft];Ve===void 0&&(Ve=new Di,Ve.layers.enable(ft),Ve.viewport=new _n,D[ft]=Ve),Ve.matrix.fromArray(ht.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(ht.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(pt.x,pt.y,pt.width,pt.height),ft===0&&(U.matrix.copy(Ve.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale)),Be===!0&&U.cameras.push(Ve)}const Ke=r.enabledFeatures;if(Ke&&Ke.includes("depth-sensing")){const ft=g.getDepthInformation(Le[0]);ft&&ft.isValid&&ft.texture&&T.init(e,ft,r.renderState)}}for(let Le=0;Le<b.length;Le++){const Be=I[Le],Ke=b[Le];Be!==null&&Ke!==void 0&&Ke.update(Be,Pe,f||a)}Y&&Y(ve,Pe),Pe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Pe}),E=null}const ze=new dT;ze.setAnimationLoop(le),this.setAnimationLoop=function(ve){Y=ve},this.dispose=function(){}}}const du=new Vs,eD=new qt;function tD(i,e){function t(w,_){w.matrixAutoUpdate===!0&&w.updateMatrix(),_.value.copy(w.matrix)}function n(w,_){_.color.getRGB(w.fogColor.value,vw(i)),_.isFog?(w.fogNear.value=_.near,w.fogFar.value=_.far):_.isFogExp2&&(w.fogDensity.value=_.density)}function r(w,_,C,b,I){_.isMeshBasicMaterial||_.isMeshLambertMaterial?s(w,_):_.isMeshToonMaterial?(s(w,_),g(w,_)):_.isMeshPhongMaterial?(s(w,_),p(w,_)):_.isMeshStandardMaterial?(s(w,_),v(w,_),_.isMeshPhysicalMaterial&&y(w,_,I)):_.isMeshMatcapMaterial?(s(w,_),E(w,_)):_.isMeshDepthMaterial?s(w,_):_.isMeshDistanceMaterial?(s(w,_),T(w,_)):_.isMeshNormalMaterial?s(w,_):_.isLineBasicMaterial?(a(w,_),_.isLineDashedMaterial&&c(w,_)):_.isPointsMaterial?d(w,_,C,b):_.isSpriteMaterial?f(w,_):_.isShadowMaterial?(w.color.value.copy(_.color),w.opacity.value=_.opacity):_.isShaderMaterial&&(_.uniformsNeedUpdate=!1)}function s(w,_){w.opacity.value=_.opacity,_.color&&w.diffuse.value.copy(_.color),_.emissive&&w.emissive.value.copy(_.emissive).multiplyScalar(_.emissiveIntensity),_.map&&(w.map.value=_.map,t(_.map,w.mapTransform)),_.alphaMap&&(w.alphaMap.value=_.alphaMap,t(_.alphaMap,w.alphaMapTransform)),_.bumpMap&&(w.bumpMap.value=_.bumpMap,t(_.bumpMap,w.bumpMapTransform),w.bumpScale.value=_.bumpScale,_.side===Wi&&(w.bumpScale.value*=-1)),_.normalMap&&(w.normalMap.value=_.normalMap,t(_.normalMap,w.normalMapTransform),w.normalScale.value.copy(_.normalScale),_.side===Wi&&w.normalScale.value.negate()),_.displacementMap&&(w.displacementMap.value=_.displacementMap,t(_.displacementMap,w.displacementMapTransform),w.displacementScale.value=_.displacementScale,w.displacementBias.value=_.displacementBias),_.emissiveMap&&(w.emissiveMap.value=_.emissiveMap,t(_.emissiveMap,w.emissiveMapTransform)),_.specularMap&&(w.specularMap.value=_.specularMap,t(_.specularMap,w.specularMapTransform)),_.alphaTest>0&&(w.alphaTest.value=_.alphaTest);const C=e.get(_),b=C.envMap,I=C.envMapRotation;b&&(w.envMap.value=b,du.copy(I),du.x*=-1,du.y*=-1,du.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(du.y*=-1,du.z*=-1),w.envMapRotation.value.setFromMatrix4(eD.makeRotationFromEuler(du)),w.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,w.reflectivity.value=_.reflectivity,w.ior.value=_.ior,w.refractionRatio.value=_.refractionRatio),_.lightMap&&(w.lightMap.value=_.lightMap,w.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,w.lightMapTransform)),_.aoMap&&(w.aoMap.value=_.aoMap,w.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,w.aoMapTransform))}function a(w,_){w.diffuse.value.copy(_.color),w.opacity.value=_.opacity,_.map&&(w.map.value=_.map,t(_.map,w.mapTransform))}function c(w,_){w.dashSize.value=_.dashSize,w.totalSize.value=_.dashSize+_.gapSize,w.scale.value=_.scale}function d(w,_,C,b){w.diffuse.value.copy(_.color),w.opacity.value=_.opacity,w.size.value=_.size*C,w.scale.value=b*.5,_.map&&(w.map.value=_.map,t(_.map,w.uvTransform)),_.alphaMap&&(w.alphaMap.value=_.alphaMap,t(_.alphaMap,w.alphaMapTransform)),_.alphaTest>0&&(w.alphaTest.value=_.alphaTest)}function f(w,_){w.diffuse.value.copy(_.color),w.opacity.value=_.opacity,w.rotation.value=_.rotation,_.map&&(w.map.value=_.map,t(_.map,w.mapTransform)),_.alphaMap&&(w.alphaMap.value=_.alphaMap,t(_.alphaMap,w.alphaMapTransform)),_.alphaTest>0&&(w.alphaTest.value=_.alphaTest)}function p(w,_){w.specular.value.copy(_.specular),w.shininess.value=Math.max(_.shininess,1e-4)}function g(w,_){_.gradientMap&&(w.gradientMap.value=_.gradientMap)}function v(w,_){w.metalness.value=_.metalness,_.metalnessMap&&(w.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,w.metalnessMapTransform)),w.roughness.value=_.roughness,_.roughnessMap&&(w.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,w.roughnessMapTransform)),_.envMap&&(w.envMapIntensity.value=_.envMapIntensity)}function y(w,_,C){w.ior.value=_.ior,_.sheen>0&&(w.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),w.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(w.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,w.sheenColorMapTransform)),_.sheenRoughnessMap&&(w.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,w.sheenRoughnessMapTransform))),_.clearcoat>0&&(w.clearcoat.value=_.clearcoat,w.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(w.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,w.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(w.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,w.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(w.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,w.clearcoatNormalMapTransform),w.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===Wi&&w.clearcoatNormalScale.value.negate())),_.dispersion>0&&(w.dispersion.value=_.dispersion),_.iridescence>0&&(w.iridescence.value=_.iridescence,w.iridescenceIOR.value=_.iridescenceIOR,w.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],w.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(w.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,w.iridescenceMapTransform)),_.iridescenceThicknessMap&&(w.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,w.iridescenceThicknessMapTransform))),_.transmission>0&&(w.transmission.value=_.transmission,w.transmissionSamplerMap.value=C.texture,w.transmissionSamplerSize.value.set(C.width,C.height),_.transmissionMap&&(w.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,w.transmissionMapTransform)),w.thickness.value=_.thickness,_.thicknessMap&&(w.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,w.thicknessMapTransform)),w.attenuationDistance.value=_.attenuationDistance,w.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(w.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(w.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,w.anisotropyMapTransform))),w.specularIntensity.value=_.specularIntensity,w.specularColor.value.copy(_.specularColor),_.specularColorMap&&(w.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,w.specularColorMapTransform)),_.specularIntensityMap&&(w.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,w.specularIntensityMapTransform))}function E(w,_){_.matcap&&(w.matcap.value=_.matcap)}function T(w,_){const C=e.get(_).light;w.referencePosition.value.setFromMatrixPosition(C.matrixWorld),w.nearDistance.value=C.shadow.camera.near,w.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function nD(i,e,t,n){let r={},s={},a=[];const c=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function d(C,b){const I=b.program;n.uniformBlockBinding(C,I)}function f(C,b){let I=r[C.id];I===void 0&&(E(C),I=p(C),r[C.id]=I,C.addEventListener("dispose",w));const N=b.program;n.updateUBOMapping(C,N);const O=e.render.frame;s[C.id]!==O&&(v(C),s[C.id]=O)}function p(C){const b=g();C.__bindingPointIndex=b;const I=i.createBuffer(),N=C.__size,O=C.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,N,O),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,I),I}function g(){for(let C=0;C<c;C++)if(a.indexOf(C)===-1)return a.push(C),C;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function v(C){const b=r[C.id],I=C.uniforms,N=C.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let O=0,H=I.length;O<H;O++){const B=Array.isArray(I[O])?I[O]:[I[O]];for(let D=0,U=B.length;D<U;D++){const W=B[D];if(y(W,O,D,N)===!0){const ne=W.__offset,re=Array.isArray(W.value)?W.value:[W.value];let he=0;for(let fe=0;fe<re.length;fe++){const ce=re[fe],xe=T(ce);typeof ce=="number"||typeof ce=="boolean"?(W.__data[0]=ce,i.bufferSubData(i.UNIFORM_BUFFER,ne+he,W.__data)):ce.isMatrix3?(W.__data[0]=ce.elements[0],W.__data[1]=ce.elements[1],W.__data[2]=ce.elements[2],W.__data[3]=0,W.__data[4]=ce.elements[3],W.__data[5]=ce.elements[4],W.__data[6]=ce.elements[5],W.__data[7]=0,W.__data[8]=ce.elements[6],W.__data[9]=ce.elements[7],W.__data[10]=ce.elements[8],W.__data[11]=0):(ce.toArray(W.__data,he),he+=xe.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,ne,W.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function y(C,b,I,N){const O=C.value,H=b+"_"+I;if(N[H]===void 0)return typeof O=="number"||typeof O=="boolean"?N[H]=O:N[H]=O.clone(),!0;{const B=N[H];if(typeof O=="number"||typeof O=="boolean"){if(B!==O)return N[H]=O,!0}else if(B.equals(O)===!1)return B.copy(O),!0}return!1}function E(C){const b=C.uniforms;let I=0;const N=16;for(let H=0,B=b.length;H<B;H++){const D=Array.isArray(b[H])?b[H]:[b[H]];for(let U=0,W=D.length;U<W;U++){const ne=D[U],re=Array.isArray(ne.value)?ne.value:[ne.value];for(let he=0,fe=re.length;he<fe;he++){const ce=re[he],xe=T(ce),q=I%N,de=q%xe.boundary,se=q+de;I+=de,se!==0&&N-se<xe.storage&&(I+=N-se),ne.__data=new Float32Array(xe.storage/Float32Array.BYTES_PER_ELEMENT),ne.__offset=I,I+=xe.storage}}}const O=I%N;return O>0&&(I+=N-O),C.__size=I,C.__cache={},this}function T(C){const b={boundary:0,storage:0};return typeof C=="number"||typeof C=="boolean"?(b.boundary=4,b.storage=4):C.isVector2?(b.boundary=8,b.storage=8):C.isVector3||C.isColor?(b.boundary=16,b.storage=12):C.isVector4?(b.boundary=16,b.storage=16):C.isMatrix3?(b.boundary=48,b.storage=48):C.isMatrix4?(b.boundary=64,b.storage=64):C.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",C),b}function w(C){const b=C.target;b.removeEventListener("dispose",w);const I=a.indexOf(b.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function _(){for(const C in r)i.deleteBuffer(r[C]);a=[],r={},s={}}return{bind:d,update:f,dispose:_}}class Nx{constructor(e={}){const{canvas:t=pw(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:c=!1,premultipliedAlpha:d=!0,preserveDrawingBuffer:f=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:g=!1,reverseDepthBuffer:v=!1}=e;this.isWebGLRenderer=!0;let y;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");y=n.getContextAttributes().alpha}else y=a;const E=new Uint32Array(4),T=new Int32Array(4);let w=null,_=null;const C=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=kn,this.toneMapping=zo,this.toneMappingExposure=1;const I=this;let N=!1,O=0,H=0,B=null,D=-1,U=null;const W=new _n,ne=new _n;let re=null;const he=new yt(0);let fe=0,ce=t.width,xe=t.height,q=1,de=null,se=null;const Y=new _n(0,0,ce,xe),le=new _n(0,0,ce,xe);let ze=!1;const ve=new Op;let Pe=!1,Le=!1;this.transmissionResolutionScale=1;const Be=new qt,Ke=new qt,ft=new X,ht=new _n,pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ve=!1;function Ge(){return B===null?q:1}let K=n;function At(k,J){return t.getContext(k,J)}try{const k={alpha:!0,depth:r,stencil:s,antialias:c,premultipliedAlpha:d,preserveDrawingBuffer:f,powerPreference:p,failIfMajorPerformanceCaveat:g};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${oc}`),t.addEventListener("webglcontextlost",We,!1),t.addEventListener("webglcontextrestored",St,!1),t.addEventListener("webglcontextcreationerror",mt,!1),K===null){const J="webgl2";if(K=At(J,k),K===null)throw At(J)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let Je,dt,it,zt,ot,Z,G,Se,Fe,Xe,He,Mt,ct,xt,rn,et,Rt,kt,Lt,Ct,Jt,Ht,Kt,me;function be(){Je=new f3(K),Je.init(),Ht=new vT(K,Je),dt=new a3(K,Je,e,Ht),it=new YL(K,Je),dt.reverseDepthBuffer&&v&&it.buffers.depth.setReversed(!0),zt=new g3(K),ot=new NL,Z=new ZL(K,Je,it,ot,dt,Ht,zt),G=new c3(I),Se=new d3(I),Fe=new M2(K),Kt=new s3(K,Fe),Xe=new p3(K,Fe,zt,Kt),He=new _3(K,Xe,Fe,zt),Lt=new v3(K,dt,Z),et=new l3(ot),Mt=new DL(I,G,Se,Je,dt,Kt,et),ct=new tD(I,ot),xt=new OL,rn=new VL(Je),kt=new r3(I,G,Se,it,He,y,d),Rt=new jL(I,He,dt),me=new nD(K,zt,dt,it),Ct=new o3(K,Je,zt),Jt=new m3(K,Je,zt),zt.programs=Mt.programs,I.capabilities=dt,I.extensions=Je,I.properties=ot,I.renderLists=xt,I.shadowMap=Rt,I.state=it,I.info=zt}be();const Re=new $L(I,K);this.xr=Re,this.getContext=function(){return K},this.getContextAttributes=function(){return K.getContextAttributes()},this.forceContextLoss=function(){const k=Je.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){const k=Je.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(k){k!==void 0&&(q=k,this.setSize(ce,xe,!1))},this.getSize=function(k){return k.set(ce,xe)},this.setSize=function(k,J,ie=!0){if(Re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ce=k,xe=J,t.width=Math.floor(k*q),t.height=Math.floor(J*q),ie===!0&&(t.style.width=k+"px",t.style.height=J+"px"),this.setViewport(0,0,k,J)},this.getDrawingBufferSize=function(k){return k.set(ce*q,xe*q).floor()},this.setDrawingBufferSize=function(k,J,ie){ce=k,xe=J,q=ie,t.width=Math.floor(k*ie),t.height=Math.floor(J*ie),this.setViewport(0,0,k,J)},this.getCurrentViewport=function(k){return k.copy(W)},this.getViewport=function(k){return k.copy(Y)},this.setViewport=function(k,J,ie,$){k.isVector4?Y.set(k.x,k.y,k.z,k.w):Y.set(k,J,ie,$),it.viewport(W.copy(Y).multiplyScalar(q).round())},this.getScissor=function(k){return k.copy(le)},this.setScissor=function(k,J,ie,$){k.isVector4?le.set(k.x,k.y,k.z,k.w):le.set(k,J,ie,$),it.scissor(ne.copy(le).multiplyScalar(q).round())},this.getScissorTest=function(){return ze},this.setScissorTest=function(k){it.setScissorTest(ze=k)},this.setOpaqueSort=function(k){de=k},this.setTransparentSort=function(k){se=k},this.getClearColor=function(k){return k.copy(kt.getClearColor())},this.setClearColor=function(){kt.setClearColor.apply(kt,arguments)},this.getClearAlpha=function(){return kt.getClearAlpha()},this.setClearAlpha=function(){kt.setClearAlpha.apply(kt,arguments)},this.clear=function(k=!0,J=!0,ie=!0){let $=0;if(k){let ue=!1;if(B!==null){const Ee=B.texture.format;ue=Ee===Wv||Ee===Gv||Ee===Lp}if(ue){const Ee=B.texture.type,Ue=Ee===Oi||Ee===fa||Ee===yd||Ee===ic||Ee===Hv||Ee===Vv,je=kt.getClearColor(),Ze=kt.getClearAlpha(),ut=je.r,at=je.g,Ye=je.b;Ue?(E[0]=ut,E[1]=at,E[2]=Ye,E[3]=Ze,K.clearBufferuiv(K.COLOR,0,E)):(T[0]=ut,T[1]=at,T[2]=Ye,T[3]=Ze,K.clearBufferiv(K.COLOR,0,T))}else $|=K.COLOR_BUFFER_BIT}J&&($|=K.DEPTH_BUFFER_BIT),ie&&($|=K.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),K.clear($)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",We,!1),t.removeEventListener("webglcontextrestored",St,!1),t.removeEventListener("webglcontextcreationerror",mt,!1),kt.dispose(),xt.dispose(),rn.dispose(),ot.dispose(),G.dispose(),Se.dispose(),He.dispose(),Kt.dispose(),me.dispose(),Mt.dispose(),Re.dispose(),Re.removeEventListener("sessionstart",Go),Re.removeEventListener("sessionend",Ws),mr.stop()};function We(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function St(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const k=zt.autoReset,J=Rt.enabled,ie=Rt.autoUpdate,$=Rt.needsUpdate,ue=Rt.type;be(),zt.autoReset=k,Rt.enabled=J,Rt.autoUpdate=ie,Rt.needsUpdate=$,Rt.type=ue}function mt(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function Qt(k){const J=k.target;J.removeEventListener("dispose",Qt),Xn(J)}function Xn(k){pi(k),ot.remove(k)}function pi(k){const J=ot.get(k).programs;J!==void 0&&(J.forEach(function(ie){Mt.releaseProgram(ie)}),k.isShaderMaterial&&Mt.releaseShaderCache(k))}this.renderBufferDirect=function(k,J,ie,$,ue,Ee){J===null&&(J=pt);const Ue=ue.isMesh&&ue.matrixWorld.determinant()<0,je=oe(k,J,ie,$,ue);it.setMaterial($,Ue);let Ze=ie.index,ut=1;if($.wireframe===!0){if(Ze=Xe.getWireframeAttribute(ie),Ze===void 0)return;ut=2}const at=ie.drawRange,Ye=ie.attributes.position;let gt=at.start*ut,vt=(at.start+at.count)*ut;Ee!==null&&(gt=Math.max(gt,Ee.start*ut),vt=Math.min(vt,(Ee.start+Ee.count)*ut)),Ze!==null?(gt=Math.max(gt,0),vt=Math.min(vt,Ze.count)):Ye!=null&&(gt=Math.max(gt,0),vt=Math.min(vt,Ye.count));const Zt=vt-gt;if(Zt<0||Zt===1/0)return;Kt.setup(ue,$,je,ie,Ze);let Dt,Ft=Ct;if(Ze!==null&&(Dt=Fe.get(Ze),Ft=Jt,Ft.setIndex(Dt)),ue.isMesh)$.wireframe===!0?(it.setLineWidth($.wireframeLinewidth*Ge()),Ft.setMode(K.LINES)):Ft.setMode(K.TRIANGLES);else if(ue.isLine){let wt=$.linewidth;wt===void 0&&(wt=1),it.setLineWidth(wt*Ge()),ue.isLineSegments?Ft.setMode(K.LINES):ue.isLineLoop?Ft.setMode(K.LINE_LOOP):Ft.setMode(K.LINE_STRIP)}else ue.isPoints?Ft.setMode(K.POINTS):ue.isSprite&&Ft.setMode(K.TRIANGLES);if(ue.isBatchedMesh)if(ue._multiDrawInstances!==null)Ft.renderMultiDrawInstances(ue._multiDrawStarts,ue._multiDrawCounts,ue._multiDrawCount,ue._multiDrawInstances);else if(Je.get("WEBGL_multi_draw"))Ft.renderMultiDraw(ue._multiDrawStarts,ue._multiDrawCounts,ue._multiDrawCount);else{const wt=ue._multiDrawStarts,dn=ue._multiDrawCounts,Gt=ue._multiDrawCount,$t=Ze?Fe.get(Ze).bytesPerElement:1,qn=ot.get($).currentProgram.getUniforms();for(let ln=0;ln<Gt;ln++)qn.setValue(K,"_gl_DrawID",ln),Ft.render(wt[ln]/$t,dn[ln])}else if(ue.isInstancedMesh)Ft.renderInstances(gt,Zt,ue.count);else if(ie.isInstancedBufferGeometry){const wt=ie._maxInstanceCount!==void 0?ie._maxInstanceCount:1/0,dn=Math.min(ie.instanceCount,wt);Ft.renderInstances(gt,Zt,dn)}else Ft.render(gt,Zt)};function Mn(k,J,ie){k.transparent===!0&&k.side===Hr&&k.forceSinglePass===!1?(k.side=Wi,k.needsUpdate=!0,Wo(k,J,ie),k.side=ha,k.needsUpdate=!0,Wo(k,J,ie),k.side=Hr):Wo(k,J,ie)}this.compile=function(k,J,ie=null){ie===null&&(ie=k),_=rn.get(ie),_.init(J),b.push(_),ie.traverseVisible(function(ue){ue.isLight&&ue.layers.test(J.layers)&&(_.pushLight(ue),ue.castShadow&&_.pushShadow(ue))}),k!==ie&&k.traverseVisible(function(ue){ue.isLight&&ue.layers.test(J.layers)&&(_.pushLight(ue),ue.castShadow&&_.pushShadow(ue))}),_.setupLights();const $=new Set;return k.traverse(function(ue){if(!(ue.isMesh||ue.isPoints||ue.isLine||ue.isSprite))return;const Ee=ue.material;if(Ee)if(Array.isArray(Ee))for(let Ue=0;Ue<Ee.length;Ue++){const je=Ee[Ue];Mn(je,ie,ue),$.add(je)}else Mn(Ee,ie,ue),$.add(Ee)}),b.pop(),_=null,$},this.compileAsync=function(k,J,ie=null){const $=this.compile(k,J,ie);return new Promise(ue=>{function Ee(){if($.forEach(function(Ue){ot.get(Ue).currentProgram.isReady()&&$.delete(Ue)}),$.size===0){ue(k);return}setTimeout(Ee,10)}Je.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let Xi=null;function Yi(k){Xi&&Xi(k)}function Go(){mr.stop()}function Ws(){mr.start()}const mr=new dT;mr.setAnimationLoop(Yi),typeof self<"u"&&mr.setContext(self),this.setAnimationLoop=function(k){Xi=k,Re.setAnimationLoop(k),k===null?mr.stop():mr.start()},Re.addEventListener("sessionstart",Go),Re.addEventListener("sessionend",Ws),this.render=function(k,J){if(J!==void 0&&J.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),J.parent===null&&J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Re.enabled===!0&&Re.isPresenting===!0&&(Re.cameraAutoUpdate===!0&&Re.updateCamera(J),J=Re.getCamera()),k.isScene===!0&&k.onBeforeRender(I,k,J,B),_=rn.get(k,b.length),_.init(J),b.push(_),Ke.multiplyMatrices(J.projectionMatrix,J.matrixWorldInverse),ve.setFromProjectionMatrix(Ke),Le=this.localClippingEnabled,Pe=et.init(this.clippingPlanes,Le),w=xt.get(k,C.length),w.init(),C.push(w),Re.enabled===!0&&Re.isPresenting===!0){const Ee=I.xr.getDepthSensingMesh();Ee!==null&&Gr(Ee,J,-1/0,I.sortObjects)}Gr(k,J,0,I.sortObjects),w.finish(),I.sortObjects===!0&&w.sort(de,se),Ve=Re.enabled===!1||Re.isPresenting===!1||Re.hasDepthSensing()===!1,Ve&&kt.addToRenderList(w,k),this.info.render.frame++,Pe===!0&&et.beginShadows();const ie=_.state.shadowsArray;Rt.render(ie,k,J),Pe===!0&&et.endShadows(),this.info.autoReset===!0&&this.info.reset();const $=w.opaque,ue=w.transmissive;if(_.setupLights(),J.isArrayCamera){const Ee=J.cameras;if(ue.length>0)for(let Ue=0,je=Ee.length;Ue<je;Ue++){const Ze=Ee[Ue];Zi($,ue,k,Ze)}Ve&&kt.render(k);for(let Ue=0,je=Ee.length;Ue<je;Ue++){const Ze=Ee[Ue];Wr(w,k,Ze,Ze.viewport)}}else ue.length>0&&Zi($,ue,k,J),Ve&&kt.render(k),Wr(w,k,J);B!==null&&H===0&&(Z.updateMultisampleRenderTarget(B),Z.updateRenderTargetMipmap(B)),k.isScene===!0&&k.onAfterRender(I,k,J),Kt.resetDefaultState(),D=-1,U=null,b.pop(),b.length>0?(_=b[b.length-1],Pe===!0&&et.setGlobalState(I.clippingPlanes,_.state.camera)):_=null,C.pop(),C.length>0?w=C[C.length-1]:w=null};function Gr(k,J,ie,$){if(k.visible===!1)return;if(k.layers.test(J.layers)){if(k.isGroup)ie=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(J);else if(k.isLight)_.pushLight(k),k.castShadow&&_.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||ve.intersectsSprite(k)){$&&ht.setFromMatrixPosition(k.matrixWorld).applyMatrix4(Ke);const Ue=He.update(k),je=k.material;je.visible&&w.push(k,Ue,je,ie,ht.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||ve.intersectsObject(k))){const Ue=He.update(k),je=k.material;if($&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),ht.copy(k.boundingSphere.center)):(Ue.boundingSphere===null&&Ue.computeBoundingSphere(),ht.copy(Ue.boundingSphere.center)),ht.applyMatrix4(k.matrixWorld).applyMatrix4(Ke)),Array.isArray(je)){const Ze=Ue.groups;for(let ut=0,at=Ze.length;ut<at;ut++){const Ye=Ze[ut],gt=je[Ye.materialIndex];gt&&gt.visible&&w.push(k,Ue,gt,ie,ht.z,Ye)}}else je.visible&&w.push(k,Ue,je,ie,ht.z,null)}}const Ee=k.children;for(let Ue=0,je=Ee.length;Ue<je;Ue++)Gr(Ee[Ue],J,ie,$)}function Wr(k,J,ie,$){const ue=k.opaque,Ee=k.transmissive,Ue=k.transparent;_.setupLightsView(ie),Pe===!0&&et.setGlobalState(I.clippingPlanes,ie),$&&it.viewport(W.copy($)),ue.length>0&&sn(ue,J,ie),Ee.length>0&&sn(Ee,J,ie),Ue.length>0&&sn(Ue,J,ie),it.buffers.depth.setTest(!0),it.buffers.depth.setMask(!0),it.buffers.color.setMask(!0),it.setPolygonOffset(!1)}function Zi(k,J,ie,$){if((ie.isScene===!0?ie.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[$.id]===void 0&&(_.state.transmissionRenderTarget[$.id]=new Mi(1,1,{generateMipmaps:!0,type:Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float")?nr:Oi,minFilter:ca,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Dn.workingColorSpace}));const Ee=_.state.transmissionRenderTarget[$.id],Ue=$.viewport||W;Ee.setSize(Ue.z*I.transmissionResolutionScale,Ue.w*I.transmissionResolutionScale);const je=I.getRenderTarget();I.setRenderTarget(Ee),I.getClearColor(he),fe=I.getClearAlpha(),fe<1&&I.setClearColor(16777215,.5),I.clear(),Ve&&kt.render(ie);const Ze=I.toneMapping;I.toneMapping=zo;const ut=$.viewport;if($.viewport!==void 0&&($.viewport=void 0),_.setupLightsView($),Pe===!0&&et.setGlobalState(I.clippingPlanes,$),sn(k,ie,$),Z.updateMultisampleRenderTarget(Ee),Z.updateRenderTargetMipmap(Ee),Je.has("WEBGL_multisampled_render_to_texture")===!1){let at=!1;for(let Ye=0,gt=J.length;Ye<gt;Ye++){const vt=J[Ye],Zt=vt.object,Dt=vt.geometry,Ft=vt.material,wt=vt.group;if(Ft.side===Hr&&Zt.layers.test($.layers)){const dn=Ft.side;Ft.side=Wi,Ft.needsUpdate=!0,ma(Zt,ie,$,Dt,Ft,wt),Ft.side=dn,Ft.needsUpdate=!0,at=!0}}at===!0&&(Z.updateMultisampleRenderTarget(Ee),Z.updateRenderTargetMipmap(Ee))}I.setRenderTarget(je),I.setClearColor(he,fe),ut!==void 0&&($.viewport=ut),I.toneMapping=Ze}function sn(k,J,ie){const $=J.isScene===!0?J.overrideMaterial:null;for(let ue=0,Ee=k.length;ue<Ee;ue++){const Ue=k[ue],je=Ue.object,Ze=Ue.geometry,ut=$===null?Ue.material:$,at=Ue.group;je.layers.test(ie.layers)&&ma(je,J,ie,Ze,ut,at)}}function ma(k,J,ie,$,ue,Ee){k.onBeforeRender(I,J,ie,$,ue,Ee),k.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),ue.onBeforeRender(I,J,ie,$,k,Ee),ue.transparent===!0&&ue.side===Hr&&ue.forceSinglePass===!1?(ue.side=Wi,ue.needsUpdate=!0,I.renderBufferDirect(ie,J,$,ue,k,Ee),ue.side=ha,ue.needsUpdate=!0,I.renderBufferDirect(ie,J,$,ue,k,Ee),ue.side=Hr):I.renderBufferDirect(ie,J,$,ue,k,Ee),k.onAfterRender(I,J,ie,$,ue,Ee)}function Wo(k,J,ie){J.isScene!==!0&&(J=pt);const $=ot.get(k),ue=_.state.lights,Ee=_.state.shadowsArray,Ue=ue.state.version,je=Mt.getParameters(k,ue.state,Ee,J,ie),Ze=Mt.getProgramCacheKey(je);let ut=$.programs;$.environment=k.isMeshStandardMaterial?J.environment:null,$.fog=J.fog,$.envMap=(k.isMeshStandardMaterial?Se:G).get(k.envMap||$.environment),$.envMapRotation=$.environment!==null&&k.envMap===null?J.environmentRotation:k.envMapRotation,ut===void 0&&(k.addEventListener("dispose",Qt),ut=new Map,$.programs=ut);let at=ut.get(Ze);if(at!==void 0){if($.currentProgram===at&&$.lightsStateVersion===Ue)return j(k,je),at}else je.uniforms=Mt.getUniforms(k),k.onBeforeCompile(je,I),at=Mt.acquireProgram(je,Ze),ut.set(Ze,at),$.uniforms=je.uniforms;const Ye=$.uniforms;return(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(Ye.clippingPlanes=et.uniform),j(k,je),$.needsLights=De(k),$.lightsStateVersion=Ue,$.needsLights&&(Ye.ambientLightColor.value=ue.state.ambient,Ye.lightProbe.value=ue.state.probe,Ye.directionalLights.value=ue.state.directional,Ye.directionalLightShadows.value=ue.state.directionalShadow,Ye.spotLights.value=ue.state.spot,Ye.spotLightShadows.value=ue.state.spotShadow,Ye.rectAreaLights.value=ue.state.rectArea,Ye.ltc_1.value=ue.state.rectAreaLTC1,Ye.ltc_2.value=ue.state.rectAreaLTC2,Ye.pointLights.value=ue.state.point,Ye.pointLightShadows.value=ue.state.pointShadow,Ye.hemisphereLights.value=ue.state.hemi,Ye.directionalShadowMap.value=ue.state.directionalShadowMap,Ye.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,Ye.spotShadowMap.value=ue.state.spotShadowMap,Ye.spotLightMatrix.value=ue.state.spotLightMatrix,Ye.spotLightMap.value=ue.state.spotLightMap,Ye.pointShadowMap.value=ue.state.pointShadowMap,Ye.pointShadowMatrix.value=ue.state.pointShadowMatrix),$.currentProgram=at,$.uniformsList=null,at}function F(k){if(k.uniformsList===null){const J=k.currentProgram.getUniforms();k.uniformsList=Xg.seqWithValue(J.seq,k.uniforms)}return k.uniformsList}function j(k,J){const ie=ot.get(k);ie.outputColorSpace=J.outputColorSpace,ie.batching=J.batching,ie.batchingColor=J.batchingColor,ie.instancing=J.instancing,ie.instancingColor=J.instancingColor,ie.instancingMorph=J.instancingMorph,ie.skinning=J.skinning,ie.morphTargets=J.morphTargets,ie.morphNormals=J.morphNormals,ie.morphColors=J.morphColors,ie.morphTargetsCount=J.morphTargetsCount,ie.numClippingPlanes=J.numClippingPlanes,ie.numIntersection=J.numClipIntersection,ie.vertexAlphas=J.vertexAlphas,ie.vertexTangents=J.vertexTangents,ie.toneMapping=J.toneMapping}function oe(k,J,ie,$,ue){J.isScene!==!0&&(J=pt),Z.resetTextureUnits();const Ee=J.fog,Ue=$.isMeshStandardMaterial?J.environment:null,je=B===null?I.outputColorSpace:B.isXRRenderTarget===!0?B.texture.colorSpace:ro,Ze=($.isMeshStandardMaterial?Se:G).get($.envMap||Ue),ut=$.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,at=!!ie.attributes.tangent&&(!!$.normalMap||$.anisotropy>0),Ye=!!ie.morphAttributes.position,gt=!!ie.morphAttributes.normal,vt=!!ie.morphAttributes.color;let Zt=zo;$.toneMapped&&(B===null||B.isXRRenderTarget===!0)&&(Zt=I.toneMapping);const Dt=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,Ft=Dt!==void 0?Dt.length:0,wt=ot.get($),dn=_.state.lights;if(Pe===!0&&(Le===!0||k!==U)){const Kn=k===U&&$.id===D;et.setState($,k,Kn)}let Gt=!1;$.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==dn.state.version||wt.outputColorSpace!==je||ue.isBatchedMesh&&wt.batching===!1||!ue.isBatchedMesh&&wt.batching===!0||ue.isBatchedMesh&&wt.batchingColor===!0&&ue.colorTexture===null||ue.isBatchedMesh&&wt.batchingColor===!1&&ue.colorTexture!==null||ue.isInstancedMesh&&wt.instancing===!1||!ue.isInstancedMesh&&wt.instancing===!0||ue.isSkinnedMesh&&wt.skinning===!1||!ue.isSkinnedMesh&&wt.skinning===!0||ue.isInstancedMesh&&wt.instancingColor===!0&&ue.instanceColor===null||ue.isInstancedMesh&&wt.instancingColor===!1&&ue.instanceColor!==null||ue.isInstancedMesh&&wt.instancingMorph===!0&&ue.morphTexture===null||ue.isInstancedMesh&&wt.instancingMorph===!1&&ue.morphTexture!==null||wt.envMap!==Ze||$.fog===!0&&wt.fog!==Ee||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==et.numPlanes||wt.numIntersection!==et.numIntersection)||wt.vertexAlphas!==ut||wt.vertexTangents!==at||wt.morphTargets!==Ye||wt.morphNormals!==gt||wt.morphColors!==vt||wt.toneMapping!==Zt||wt.morphTargetsCount!==Ft)&&(Gt=!0):(Gt=!0,wt.__version=$.version);let $t=wt.currentProgram;Gt===!0&&($t=Wo($,J,ue));let qn=!1,ln=!1,mn=!1;const jt=$t.getUniforms(),ii=wt.uniforms;if(it.useProgram($t.program)&&(qn=!0,ln=!0,mn=!0),$.id!==D&&(D=$.id,ln=!0),qn||U!==k){it.buffers.depth.getReversed()?(Be.copy(k.projectionMatrix),eb(Be),tb(Be),jt.setValue(K,"projectionMatrix",Be)):jt.setValue(K,"projectionMatrix",k.projectionMatrix),jt.setValue(K,"viewMatrix",k.matrixWorldInverse);const _i=jt.map.cameraPosition;_i!==void 0&&_i.setValue(K,ft.setFromMatrixPosition(k.matrixWorld)),dt.logarithmicDepthBuffer&&jt.setValue(K,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&jt.setValue(K,"isOrthographic",k.isOrthographicCamera===!0),U!==k&&(U=k,ln=!0,mn=!0)}if(ue.isSkinnedMesh){jt.setOptional(K,ue,"bindMatrix"),jt.setOptional(K,ue,"bindMatrixInverse");const Kn=ue.skeleton;Kn&&(Kn.boneTexture===null&&Kn.computeBoneTexture(),jt.setValue(K,"boneTexture",Kn.boneTexture,Z))}ue.isBatchedMesh&&(jt.setOptional(K,ue,"batchingTexture"),jt.setValue(K,"batchingTexture",ue._matricesTexture,Z),jt.setOptional(K,ue,"batchingIdTexture"),jt.setValue(K,"batchingIdTexture",ue._indirectTexture,Z),jt.setOptional(K,ue,"batchingColorTexture"),ue._colorsTexture!==null&&jt.setValue(K,"batchingColorTexture",ue._colorsTexture,Z));const Pn=ie.morphAttributes;if((Pn.position!==void 0||Pn.normal!==void 0||Pn.color!==void 0)&&Lt.update(ue,ie,$t),(ln||wt.receiveShadow!==ue.receiveShadow)&&(wt.receiveShadow=ue.receiveShadow,jt.setValue(K,"receiveShadow",ue.receiveShadow)),$.isMeshGouraudMaterial&&$.envMap!==null&&(ii.envMap.value=Ze,ii.flipEnvMap.value=Ze.isCubeTexture&&Ze.isRenderTargetTexture===!1?-1:1),$.isMeshStandardMaterial&&$.envMap===null&&J.environment!==null&&(ii.envMapIntensity.value=J.environmentIntensity),ln&&(jt.setValue(K,"toneMappingExposure",I.toneMappingExposure),wt.needsLights&&Te(ii,mn),Ee&&$.fog===!0&&ct.refreshFogUniforms(ii,Ee),ct.refreshMaterialUniforms(ii,$,q,xe,_.state.transmissionRenderTarget[k.id]),Xg.upload(K,F(wt),ii,Z)),$.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Xg.upload(K,F(wt),ii,Z),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&jt.setValue(K,"center",ue.center),jt.setValue(K,"modelViewMatrix",ue.modelViewMatrix),jt.setValue(K,"normalMatrix",ue.normalMatrix),jt.setValue(K,"modelMatrix",ue.matrixWorld),$.isShaderMaterial||$.isRawShaderMaterial){const Kn=$.uniformsGroups;for(let _i=0,wn=Kn.length;_i<wn;_i++){const Ir=Kn[_i];me.update(Ir,$t),me.bind(Ir,$t)}}return $t}function Te(k,J){k.ambientLightColor.needsUpdate=J,k.lightProbe.needsUpdate=J,k.directionalLights.needsUpdate=J,k.directionalLightShadows.needsUpdate=J,k.pointLights.needsUpdate=J,k.pointLightShadows.needsUpdate=J,k.spotLights.needsUpdate=J,k.spotLightShadows.needsUpdate=J,k.rectAreaLights.needsUpdate=J,k.hemisphereLights.needsUpdate=J}function De(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return B},this.setRenderTargetTextures=function(k,J,ie){ot.get(k.texture).__webglTexture=J,ot.get(k.depthTexture).__webglTexture=ie;const $=ot.get(k);$.__hasExternalTextures=!0,$.__autoAllocateDepthBuffer=ie===void 0,$.__autoAllocateDepthBuffer||Je.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),$.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(k,J){const ie=ot.get(k);ie.__webglFramebuffer=J,ie.__useDefaultFramebuffer=J===void 0};const Ne=K.createFramebuffer();this.setRenderTarget=function(k,J=0,ie=0){B=k,O=J,H=ie;let $=!0,ue=null,Ee=!1,Ue=!1;if(k){const Ze=ot.get(k);if(Ze.__useDefaultFramebuffer!==void 0)it.bindFramebuffer(K.FRAMEBUFFER,null),$=!1;else if(Ze.__webglFramebuffer===void 0)Z.setupRenderTarget(k);else if(Ze.__hasExternalTextures)Z.rebindTextures(k,ot.get(k.texture).__webglTexture,ot.get(k.depthTexture).__webglTexture);else if(k.depthBuffer){const Ye=k.depthTexture;if(Ze.__boundDepthTexture!==Ye){if(Ye!==null&&ot.has(Ye)&&(k.width!==Ye.image.width||k.height!==Ye.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Z.setupDepthRenderbuffer(k)}}const ut=k.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(Ue=!0);const at=ot.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(Array.isArray(at[J])?ue=at[J][ie]:ue=at[J],Ee=!0):k.samples>0&&Z.useMultisampledRTT(k)===!1?ue=ot.get(k).__webglMultisampledFramebuffer:Array.isArray(at)?ue=at[ie]:ue=at,W.copy(k.viewport),ne.copy(k.scissor),re=k.scissorTest}else W.copy(Y).multiplyScalar(q).floor(),ne.copy(le).multiplyScalar(q).floor(),re=ze;if(ie!==0&&(ue=Ne),it.bindFramebuffer(K.FRAMEBUFFER,ue)&&$&&it.drawBuffers(k,ue),it.viewport(W),it.scissor(ne),it.setScissorTest(re),Ee){const Ze=ot.get(k.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_CUBE_MAP_POSITIVE_X+J,Ze.__webglTexture,ie)}else if(Ue){const Ze=ot.get(k.texture),ut=J;K.framebufferTextureLayer(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,Ze.__webglTexture,ie,ut)}else if(k!==null&&ie!==0){const Ze=ot.get(k.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Ze.__webglTexture,ie)}D=-1},this.readRenderTargetPixels=function(k,J,ie,$,ue,Ee,Ue){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let je=ot.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je){it.bindFramebuffer(K.FRAMEBUFFER,je);try{const Ze=k.texture,ut=Ze.format,at=Ze.type;if(!dt.textureFormatReadable(ut)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!dt.textureTypeReadable(at)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}J>=0&&J<=k.width-$&&ie>=0&&ie<=k.height-ue&&K.readPixels(J,ie,$,ue,Ht.convert(ut),Ht.convert(at),Ee)}finally{const Ze=B!==null?ot.get(B).__webglFramebuffer:null;it.bindFramebuffer(K.FRAMEBUFFER,Ze)}}},this.readRenderTargetPixelsAsync=async function(k,J,ie,$,ue,Ee,Ue){if(!(k&&k.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let je=ot.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Ue!==void 0&&(je=je[Ue]),je){const Ze=k.texture,ut=Ze.format,at=Ze.type;if(!dt.textureFormatReadable(ut))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!dt.textureTypeReadable(at))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(J>=0&&J<=k.width-$&&ie>=0&&ie<=k.height-ue){it.bindFramebuffer(K.FRAMEBUFFER,je);const Ye=K.createBuffer();K.bindBuffer(K.PIXEL_PACK_BUFFER,Ye),K.bufferData(K.PIXEL_PACK_BUFFER,Ee.byteLength,K.STREAM_READ),K.readPixels(J,ie,$,ue,Ht.convert(ut),Ht.convert(at),0);const gt=B!==null?ot.get(B).__webglFramebuffer:null;it.bindFramebuffer(K.FRAMEBUFFER,gt);const vt=K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE,0);return K.flush(),await $C(K,vt,4),K.bindBuffer(K.PIXEL_PACK_BUFFER,Ye),K.getBufferSubData(K.PIXEL_PACK_BUFFER,0,Ee),K.deleteBuffer(Ye),K.deleteSync(vt),Ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(k,J=null,ie=0){k.isTexture!==!0&&(ad("WebGLRenderer: copyFramebufferToTexture function signature has changed."),J=arguments[0]||null,k=arguments[1]);const $=Math.pow(2,-ie),ue=Math.floor(k.image.width*$),Ee=Math.floor(k.image.height*$),Ue=J!==null?J.x:0,je=J!==null?J.y:0;Z.setTexture2D(k,0),K.copyTexSubImage2D(K.TEXTURE_2D,ie,0,0,Ue,je,ue,Ee),it.unbindTexture()};const nt=K.createFramebuffer(),Qe=K.createFramebuffer();this.copyTextureToTexture=function(k,J,ie=null,$=null,ue=0,Ee=null){k.isTexture!==!0&&(ad("WebGLRenderer: copyTextureToTexture function signature has changed."),$=arguments[0]||null,k=arguments[1],J=arguments[2],Ee=arguments[3]||0,ie=null),Ee===null&&(ue!==0?(ad("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ee=ue,ue=0):Ee=0);let Ue,je,Ze,ut,at,Ye,gt,vt,Zt;const Dt=k.isCompressedTexture?k.mipmaps[Ee]:k.image;if(ie!==null)Ue=ie.max.x-ie.min.x,je=ie.max.y-ie.min.y,Ze=ie.isBox3?ie.max.z-ie.min.z:1,ut=ie.min.x,at=ie.min.y,Ye=ie.isBox3?ie.min.z:0;else{const Pn=Math.pow(2,-ue);Ue=Math.floor(Dt.width*Pn),je=Math.floor(Dt.height*Pn),k.isDataArrayTexture?Ze=Dt.depth:k.isData3DTexture?Ze=Math.floor(Dt.depth*Pn):Ze=1,ut=0,at=0,Ye=0}$!==null?(gt=$.x,vt=$.y,Zt=$.z):(gt=0,vt=0,Zt=0);const Ft=Ht.convert(J.format),wt=Ht.convert(J.type);let dn;J.isData3DTexture?(Z.setTexture3D(J,0),dn=K.TEXTURE_3D):J.isDataArrayTexture||J.isCompressedArrayTexture?(Z.setTexture2DArray(J,0),dn=K.TEXTURE_2D_ARRAY):(Z.setTexture2D(J,0),dn=K.TEXTURE_2D),K.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,J.flipY),K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),K.pixelStorei(K.UNPACK_ALIGNMENT,J.unpackAlignment);const Gt=K.getParameter(K.UNPACK_ROW_LENGTH),$t=K.getParameter(K.UNPACK_IMAGE_HEIGHT),qn=K.getParameter(K.UNPACK_SKIP_PIXELS),ln=K.getParameter(K.UNPACK_SKIP_ROWS),mn=K.getParameter(K.UNPACK_SKIP_IMAGES);K.pixelStorei(K.UNPACK_ROW_LENGTH,Dt.width),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,Dt.height),K.pixelStorei(K.UNPACK_SKIP_PIXELS,ut),K.pixelStorei(K.UNPACK_SKIP_ROWS,at),K.pixelStorei(K.UNPACK_SKIP_IMAGES,Ye);const jt=k.isDataArrayTexture||k.isData3DTexture,ii=J.isDataArrayTexture||J.isData3DTexture;if(k.isDepthTexture){const Pn=ot.get(k),Kn=ot.get(J),_i=ot.get(Pn.__renderTarget),wn=ot.get(Kn.__renderTarget);it.bindFramebuffer(K.READ_FRAMEBUFFER,_i.__webglFramebuffer),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,wn.__webglFramebuffer);for(let Ir=0;Ir<Ze;Ir++)jt&&(K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,ot.get(k).__webglTexture,ue,Ye+Ir),K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,ot.get(J).__webglTexture,Ee,Zt+Ir)),K.blitFramebuffer(ut,at,Ue,je,gt,vt,Ue,je,K.DEPTH_BUFFER_BIT,K.NEAREST);it.bindFramebuffer(K.READ_FRAMEBUFFER,null),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else if(ue!==0||k.isRenderTargetTexture||ot.has(k)){const Pn=ot.get(k),Kn=ot.get(J);it.bindFramebuffer(K.READ_FRAMEBUFFER,nt),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,Qe);for(let _i=0;_i<Ze;_i++)jt?K.framebufferTextureLayer(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Pn.__webglTexture,ue,Ye+_i):K.framebufferTexture2D(K.READ_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Pn.__webglTexture,ue),ii?K.framebufferTextureLayer(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,Kn.__webglTexture,Ee,Zt+_i):K.framebufferTexture2D(K.DRAW_FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_2D,Kn.__webglTexture,Ee),ue!==0?K.blitFramebuffer(ut,at,Ue,je,gt,vt,Ue,je,K.COLOR_BUFFER_BIT,K.NEAREST):ii?K.copyTexSubImage3D(dn,Ee,gt,vt,Zt+_i,ut,at,Ue,je):K.copyTexSubImage2D(dn,Ee,gt,vt,ut,at,Ue,je);it.bindFramebuffer(K.READ_FRAMEBUFFER,null),it.bindFramebuffer(K.DRAW_FRAMEBUFFER,null)}else ii?k.isDataTexture||k.isData3DTexture?K.texSubImage3D(dn,Ee,gt,vt,Zt,Ue,je,Ze,Ft,wt,Dt.data):J.isCompressedArrayTexture?K.compressedTexSubImage3D(dn,Ee,gt,vt,Zt,Ue,je,Ze,Ft,Dt.data):K.texSubImage3D(dn,Ee,gt,vt,Zt,Ue,je,Ze,Ft,wt,Dt):k.isDataTexture?K.texSubImage2D(K.TEXTURE_2D,Ee,gt,vt,Ue,je,Ft,wt,Dt.data):k.isCompressedTexture?K.compressedTexSubImage2D(K.TEXTURE_2D,Ee,gt,vt,Dt.width,Dt.height,Ft,Dt.data):K.texSubImage2D(K.TEXTURE_2D,Ee,gt,vt,Ue,je,Ft,wt,Dt);K.pixelStorei(K.UNPACK_ROW_LENGTH,Gt),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,$t),K.pixelStorei(K.UNPACK_SKIP_PIXELS,qn),K.pixelStorei(K.UNPACK_SKIP_ROWS,ln),K.pixelStorei(K.UNPACK_SKIP_IMAGES,mn),Ee===0&&J.generateMipmaps&&K.generateMipmap(dn),it.unbindTexture()},this.copyTextureToTexture3D=function(k,J,ie=null,$=null,ue=0){return k.isTexture!==!0&&(ad("WebGLRenderer: copyTextureToTexture3D function signature has changed."),ie=arguments[0]||null,$=arguments[1]||null,k=arguments[2],J=arguments[3],ue=arguments[4]||0),ad('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(k,J,ie,$,ue)},this.initRenderTarget=function(k){ot.get(k).__webglFramebuffer===void 0&&Z.setupRenderTarget(k)},this.initTexture=function(k){k.isCubeTexture?Z.setTextureCube(k,0):k.isData3DTexture?Z.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?Z.setTexture2DArray(k,0):Z.setTexture2D(k,0),it.unbindTexture()},this.resetState=function(){O=0,H=0,B=null,it.reset(),Kt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorspace=Dn._getDrawingBufferColorSpace(e),t.unpackColorSpace=Dn._getUnpackColorSpace()}}const iD=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Bv,AddEquation:$l,AddOperation:YM,AdditiveAnimationBlendMode:ix,AdditiveBlending:ol,AgXToneMapping:JM,AlphaFormat:Qy,AlwaysCompare:dw,AlwaysDepth:lp,AlwaysStencilFunc:wy,AmbientLight:eT,AnimationAction:lT,AnimationClip:Tp,AnimationLoader:SR,AnimationMixer:ZR,AnimationObjectGroup:XR,AnimationUtils:vR,ArcCurve:Cw,ArrayCamera:sT,ArrowHelper:p2,AttachedBindMode:Ey,Audio:oT,AudioAnalyser:OR,AudioContext:bx,AudioListener:DR,AudioLoader:IR,AxesHelper:m2,BackSide:Wi,BasicDepthPacking:ac,BasicShadowMap:CM,BatchedMesh:Mw,Bone:ux,BooleanKeyframeTrack:Fu,Box2:t2,Box3:ir,Box3Helper:d2,BoxGeometry:cc,BoxHelper:h2,BufferAttribute:jn,BufferGeometry:yn,BufferGeometryLoader:rT,ByteType:zv,Cache:nl,Camera:Np,CameraHelper:u2,CanvasTexture:Aw,CapsuleGeometry:i0,CatmullRomCurve3:n0,CineonToneMapping:KM,CircleGeometry:r0,ClampToEdgeWrapping:ji,Clock:Rx,Color:yt,ColorKeyframeTrack:wx,ColorManagement:Dn,CompressedArrayTexture:kb,CompressedCubeTexture:Hb,CompressedTexture:$v,CompressedTextureLoader:ER,ConeGeometry:Bp,ConstantAlphaFactor:WM,ConstantColorFactor:VM,Controls:v2,CubeCamera:_w,CubeReflectionMapping:da,CubeRefractionMapping:nc,CubeTexture:Up,CubeTextureLoader:qw,CubeUVReflectionMapping:Ad,CubicBezierCurve:fx,CubicBezierCurve3:bw,CubicInterpolant:jw,CullFaceBack:yy,CullFaceFront:AM,CullFaceFrontBack:iC,CullFaceNone:TM,Curve:Ho,CurvePath:Iw,CustomBlending:bM,CustomToneMapping:QM,CylinderGeometry:uc,Cylindrical:e2,Data3DTexture:Zv,DataArrayTexture:Dp,DataTexture:ko,DataTextureLoader:Tx,DataUtils:Mu,DecrementStencilOp:gC,DecrementWrapStencilOp:_C,DefaultLoadingManager:Zw,DepthFormat:Cu,DepthStencilFormat:rc,DepthTexture:e0,DetachedBindMode:ew,DirectionalLight:$w,DirectionalLightHelper:c2,DiscreteInterpolant:Xw,DodecahedronGeometry:s0,DoubleSide:Hr,DstAlphaFactor:FM,DstColorFactor:zM,DynamicCopyUsage:DC,DynamicDrawUsage:CC,DynamicReadUsage:IC,EdgesGeometry:Pw,EllipseCurve:t0,EqualCompare:lw,EqualDepth:Jg,EqualStencilFunc:EC,EquirectangularReflectionMapping:_d,EquirectangularRefractionMapping:cp,Euler:Vs,EventDispatcher:Gs,ExtrudeGeometry:a0,FileLoader:Hs,Float16BufferAttribute:Sb,Float32BufferAttribute:Ut,FloatType:di,Fog:Kv,FogExp2:qv,FramebufferTexture:zb,FrontSide:ha,Frustum:Op,GLBufferAttribute:$R,GLSL1:UC,GLSL3:Ty,GreaterCompare:cw,GreaterDepth:ev,GreaterEqualCompare:hw,GreaterEqualDepth:$g,GreaterEqualStencilFunc:AC,GreaterStencilFunc:wC,GridHelper:a2,Group:dd,HalfFloatType:nr,HemisphereLight:Kw,HemisphereLightHelper:o2,IcosahedronGeometry:zp,ImageBitmapLoader:RR,ImageLoader:Ap,ImageUtils:mw,IncrementStencilOp:mC,IncrementWrapStencilOp:vC,InstancedBufferAttribute:Nu,InstancedBufferGeometry:Cx,InstancedInterleavedBuffer:Lv,InstancedMesh:Ed,Int16BufferAttribute:yb,Int32BufferAttribute:xb,Int8BufferAttribute:gb,IntType:Ip,InterleavedBuffer:Qv,InterleavedBufferAttribute:zs,Interpolant:Hp,InterpolateDiscrete:dp,InterpolateLinear:bv,InterpolateSmooth:jg,InvertStencilOp:yC,KeepStencilOp:mu,KeyframeTrack:Vo,LOD:Sw,LatheGeometry:Fp,Layers:Ru,LessCompare:aw,LessDepth:Qg,LessEqualCompare:rx,LessEqualDepth:Lu,LessEqualStencilFunc:MC,LessStencilFunc:SC,Light:dc,LightProbe:iT,Line:sc,Line3:uT,LineBasicMaterial:os,LineCurve:px,LineCurve3:Rw,LineDashedMaterial:Vw,LineLoop:ww,LineSegments:pa,LinearFilter:On,LinearInterpolant:Mx,LinearMipMapLinearFilter:My,LinearMipMapNearestFilter:oC,LinearMipmapLinearFilter:ca,LinearMipmapNearestFilter:Jf,LinearSRGBColorSpace:ro,LinearToneMapping:ZM,LinearTransfer:pp,Loader:as,LoaderUtils:Iy,LoadingManager:f0,LoopOnce:tw,LoopPingPong:iw,LoopRepeat:nw,LuminanceAlphaFormat:ex,LuminanceFormat:$y,MOUSE:tC,Material:pr,MaterialLoader:p0,MathUtils:Xv,Matrix2:Lx,Matrix3:pn,Matrix4:qt,MaxEquation:LM,Mesh:fi,MeshBasicMaterial:ll,MeshDepthMaterial:xx,MeshDistanceMaterial:Sx,MeshLambertMaterial:kw,MeshMatcapMaterial:Hw,MeshNormalMaterial:yx,MeshPhongMaterial:Bw,MeshPhysicalMaterial:Fw,MeshStandardMaterial:Ou,MeshToonMaterial:zw,MinEquation:PM,MirroredRepeatWrapping:hp,MixOperation:XM,MultiplyBlending:Sy,MultiplyOperation:Rp,NearestFilter:Ui,NearestMipMapLinearFilter:sC,NearestMipMapNearestFilter:rC,NearestMipmapLinearFilter:ud,NearestMipmapNearestFilter:qy,NeutralToneMapping:$M,NeverCompare:ow,NeverDepth:Kg,NeverStencilFunc:xC,NoBlending:Rr,NoColorSpace:Fo,NoToneMapping:zo,NormalAnimationBlendMode:jv,NormalBlending:Au,NotEqualCompare:uw,NotEqualDepth:tv,NotEqualStencilFunc:TC,NumberKeyframeTrack:Mp,Object3D:Cn,ObjectLoader:CR,ObjectSpaceNormalMap:sw,OctahedronGeometry:kp,OneFactor:NM,OneMinusConstantAlphaFactor:jM,OneMinusConstantColorFactor:GM,OneMinusDstAlphaFactor:BM,OneMinusDstColorFactor:kM,OneMinusSrcAlphaFactor:qg,OneMinusSrcColorFactor:OM,OrthographicCamera:ul,PCFShadowMap:Fv,PCFSoftShadowMap:Qf,PMREMGenerator:Dy,Path:yp,PerspectiveCamera:Di,Plane:el,PlaneGeometry:cl,PlaneHelper:f2,PointLight:Jw,PointLightHelper:r2,Points:Tw,PointsMaterial:hx,PolarGridHelper:l2,PolyhedronGeometry:hc,PositionalAudio:UR,PropertyBinding:Un,PropertyMixer:aT,QuadraticBezierCurve:mx,QuadraticBezierCurve3:gx,Quaternion:ss,QuaternionKeyframeTrack:Vp,QuaternionLinearInterpolant:Yw,RED_GREEN_RGTC2_Format:Av,RED_RGTC1_Format:nx,REVISION:oc,RGBADepthPacking:rw,RGBAFormat:Ni,RGBAIntegerFormat:Wv,RGBA_ASTC_10x10_Format:xv,RGBA_ASTC_10x5_Format:vv,RGBA_ASTC_10x6_Format:_v,RGBA_ASTC_10x8_Format:yv,RGBA_ASTC_12x10_Format:Sv,RGBA_ASTC_12x12_Format:Ev,RGBA_ASTC_4x4_Format:cv,RGBA_ASTC_5x4_Format:uv,RGBA_ASTC_5x5_Format:hv,RGBA_ASTC_6x5_Format:dv,RGBA_ASTC_6x6_Format:fv,RGBA_ASTC_8x5_Format:pv,RGBA_ASTC_8x6_Format:mv,RGBA_ASTC_8x8_Format:gv,RGBA_BPTC_Format:ip,RGBA_ETC2_EAC_Format:lv,RGBA_PVRTC_2BPPV1_Format:sv,RGBA_PVRTC_4BPPV1_Format:rv,RGBA_S3TC_DXT1_Format:ep,RGBA_S3TC_DXT3_Format:tp,RGBA_S3TC_DXT5_Format:np,RGBDepthPacking:hC,RGBFormat:Jy,RGBIntegerFormat:aC,RGB_BPTC_SIGNED_Format:Mv,RGB_BPTC_UNSIGNED_Format:wv,RGB_ETC1_Format:ov,RGB_ETC2_Format:av,RGB_PVRTC_2BPPV1_Format:iv,RGB_PVRTC_4BPPV1_Format:nv,RGB_S3TC_DXT1_Format:$f,RGDepthPacking:dC,RGFormat:tx,RGIntegerFormat:Gv,RawShaderMaterial:Ow,Ray:Cd,Raycaster:m0,RectAreaLight:tT,RedFormat:Pp,RedIntegerFormat:Lp,ReinhardToneMapping:qM,RenderTarget:Yv,RenderTarget3D:qR,RenderTargetArray:KR,RepeatWrapping:up,ReplaceStencilOp:pC,ReverseSubtractEquation:IM,RingGeometry:l0,SIGNED_RED_GREEN_RGTC2_Format:Cv,SIGNED_RED_RGTC1_Format:Tv,SRGBColorSpace:kn,SRGBTransfer:Zn,Scene:Du,ShaderChunk:En,ShaderLib:Oo,ShaderMaterial:li,ShadowMaterial:Uw,Shape:Iu,ShapeGeometry:c0,ShapePath:g2,ShapeUtils:ua,ShortType:kv,Skeleton:Jv,SkeletonHelper:i2,SkinnedMesh:Ew,Source:Eu,Sphere:rr,SphereGeometry:bd,Spherical:cT,SphericalHarmonics3:nT,SplineCurve:vx,SpotLight:Qw,SpotLightHelper:n2,Sprite:xw,SpriteMaterial:cx,SrcAlphaFactor:Zg,SrcAlphaSaturateFactor:HM,SrcColorFactor:UM,StaticCopyUsage:LC,StaticDrawUsage:mp,StaticReadUsage:RC,StereoCamera:PR,StreamCopyUsage:NC,StreamDrawUsage:bC,StreamReadUsage:PC,StringKeyframeTrack:Bu,SubtractEquation:RM,SubtractiveBlending:xy,TOUCH:nC,TangentSpaceNormalMap:lc,TetrahedronGeometry:u0,Texture:Wn,TextureLoader:MR,TextureUtils:E2,TorusGeometry:h0,TorusKnotGeometry:d0,Triangle:Ms,TriangleFanDrawMode:uC,TriangleStripDrawMode:cC,TrianglesDrawMode:lC,TubeGeometry:Md,UVMapping:tc,Uint16BufferAttribute:ox,Uint32BufferAttribute:ax,Uint8BufferAttribute:vb,Uint8ClampedBufferAttribute:_b,Uniform:bn,UniformsGroup:JR,UniformsLib:_t,UniformsUtils:_p,UnsignedByteType:Oi,UnsignedInt248Type:ic,UnsignedInt5999Type:Ky,UnsignedIntType:fa,UnsignedShort4444Type:Hv,UnsignedShort5551Type:Vv,UnsignedShortType:yd,VSMShadowMap:Uo,Vector2:ke,Vector3:X,Vector4:_n,VectorKeyframeTrack:wp,VideoTexture:Bb,WebGL3DRenderTarget:ob,WebGLArrayRenderTarget:sb,WebGLCoordinateSystem:Bo,WebGLCubeRenderTarget:lx,WebGLRenderTarget:Mi,WebGLRenderer:Nx,WebGLUtils:vT,WebGPUCoordinateSystem:gp,WireframeGeometry:_x,WrapAroundEnding:fp,ZeroCurvatureEnding:xu,ZeroFactor:DM,ZeroSlopeEnding:Su,ZeroStencilOp:fC,createCanvasElement:pw},Symbol.toStringTag,{value:"Module"}));var G_={exports:{}},Zl={};/**
3867
3867
  * @license React
3868
3868
  * react-reconciler-constants.production.min.js
3869
3869
  *
@@ -3897,7 +3897,7 @@ Error generating stack: `+L.message+`
3897
3897
  `+(M.join(" > ")+`
3898
3898
 
3899
3899
  No matching component was found for:
3900
- `)+u.join(" > ")}return null},t.getPublicRootInstance=function(u){if(u=u.current,!u.child)return null;switch(u.child.tag){case 5:return ce(u.child.stateNode);default:return u.child.stateNode}},t.injectIntoDevTools=function(u){if(u={bundleType:u.bundleType,version:u.version,rendererPackageName:u.rendererPackageName,rendererConfig:u.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:c.ReactCurrentDispatcher,findHostInstanceByFiber:Lh,findFiberByHostInstance:u.findFiberByHostInstance||_m,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")u=!1;else{var h=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(h.isDisabled||!h.supportsFiber)u=!0;else{try{gc=h.inject(u),Xs=h}catch{}u=!!h.checkDCE}}return u},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(u,h,x,M){if(!ot)throw Error(a(363));u=So(u,h);var R=Mt(u,x,M).disconnect;return{disconnect:function(){R()}}},t.registerMutableSourceForHydration=function(u,h){var x=h._getVersion;x=x(h._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[h,x]:u.mutableSourceEagerHydrationData.push(h,x)},t.runWithPriority=function(u,h){var x=xn;try{return xn=u,h()}finally{xn=x}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(u,h,x,M){var R=h.current,L=Ln(),Q=Ls(R);return x=gm(x),h.context===null?h.context=x:h.pendingContext=x,h=lo(L,Q),h.payload={element:u},M=M===void 0?null:M,M!==null&&(h.callback=M),Xo(R,h),u=cr(R,Q,L),u!==null&&qu(u,R,Q),Q},t}),Y_}var xE;function pD(){return xE||(xE=1,W_.exports=fD()),W_.exports}var mD=pD();const gD=MM(mD);var SE=ST();const Ux={},Gp=i=>void Object.assign(Ux,i);function vD(i,e){function t(p,{args:g=[],attach:v,...y},E){let T=`${p[0].toUpperCase()}${p.slice(1)}`,w;if(p==="primitive"){if(y.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const _=y.object;w=ld(_,{type:p,root:E,attach:v,primitive:!0})}else{const _=Ux[T];if(!_)throw new Error(`R3F: ${T} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(g))throw new Error("R3F: The args prop must be an array!");w=ld(new _(...g),{type:p,root:E,attach:v,memoizedProps:{args:g}})}return w.__r3f.attach===void 0&&(w.isBufferGeometry?w.__r3f.attach="geometry":w.isMaterial&&(w.__r3f.attach="material")),T!=="inject"&&K_(w,y),w}function n(p,g){let v=!1;if(g){var y,E;(y=g.__r3f)!=null&&y.attach?q_(p,g,g.__r3f.attach):g.isObject3D&&p.isObject3D&&(p.add(g),v=!0),v||(E=p.__r3f)==null||E.objects.push(g),g.__r3f||ld(g,{}),g.__r3f.parent=p,Oy(g),cd(g)}}function r(p,g,v){let y=!1;if(g){var E,T;if((E=g.__r3f)!=null&&E.attach)q_(p,g,g.__r3f.attach);else if(g.isObject3D&&p.isObject3D){g.parent=p,g.dispatchEvent({type:"added"}),p.dispatchEvent({type:"childadded",child:g});const w=p.children.filter(C=>C!==g),_=w.indexOf(v);p.children=[...w.slice(0,_),g,...w.slice(_)],y=!0}y||(T=p.__r3f)==null||T.objects.push(g),g.__r3f||ld(g,{}),g.__r3f.parent=p,Oy(g),cd(g)}}function s(p,g,v=!1){p&&[...p].forEach(y=>a(g,y,v))}function a(p,g,v){if(g){var y,E,T;if(g.__r3f&&(g.__r3f.parent=null),(y=p.__r3f)!=null&&y.objects&&(p.__r3f.objects=p.__r3f.objects.filter(I=>I!==g)),(E=g.__r3f)!=null&&E.attach)AE(p,g,g.__r3f.attach);else if(g.isObject3D&&p.isObject3D){var w;p.remove(g),(w=g.__r3f)!=null&&w.root&&wD(Yg(g),g)}const C=(T=g.__r3f)==null?void 0:T.primitive,b=!C&&(v===void 0?g.dispose!==null:v);if(!C){var _;s((_=g.__r3f)==null?void 0:_.objects,g,b),s(g.children,g,b)}if(delete g.__r3f,b&&g.dispose&&g.type!=="Scene"){const I=()=>{try{g.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?SE.unstable_scheduleCallback(SE.unstable_IdlePriority,I):I()}cd(p)}}function c(p,g,v,y){var E;const T=(E=p.__r3f)==null?void 0:E.parent;if(!T)return;const w=t(g,v,p.__r3f.root);if(p.children){for(const _ of p.children)_.__r3f&&n(w,_);p.children=p.children.filter(_=>!_.__r3f)}p.__r3f.objects.forEach(_=>n(w,_)),p.__r3f.objects=[],p.__r3f.autoRemovedBeforeAppend||a(T,p),w.parent&&(w.__r3f.autoRemovedBeforeAppend=!0),n(T,w),w.raycast&&w.__r3f.eventCount&&Yg(w).getState().internal.interaction.push(w),[y,y.alternate].forEach(_=>{_!==null&&(_.stateNode=w,_.ref&&(typeof _.ref=="function"?_.ref(w):_.ref.current=w))})}const d=()=>{};return{reconciler:gD({createInstance:t,removeChild:a,appendChild:n,appendInitialChild:n,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(p,g)=>{if(!g)return;const v=p.getState().scene;v.__r3f&&(v.__r3f.root=p,n(v,g))},removeChildFromContainer:(p,g)=>{g&&a(p.getState().scene,g)},insertInContainerBefore:(p,g,v)=>{if(!g||!v)return;const y=p.getState().scene;y.__r3f&&r(y,g,v)},getRootHostContext:()=>null,getChildHostContext:p=>p,finalizeInitialChildren(p){var g;return!!((g=p==null?void 0:p.__r3f)!=null?g:{}).handlers},prepareUpdate(p,g,v,y){var E;if(((E=p==null?void 0:p.__r3f)!=null?E:{}).primitive&&y.object&&y.object!==p)return[!0];{const{args:w=[],children:_,...C}=y,{args:b=[],children:I,...N}=v;if(!Array.isArray(w))throw new Error("R3F: the args prop must be an array!");if(w.some((H,B)=>H!==b[B]))return[!0];const O=bT(p,C,N,!0);return O.changes.length?[!1,O]:null}},commitUpdate(p,[g,v],y,E,T,w){g?c(p,y,T,w):K_(p,v)},commitMount(p,g,v,y){var E;const T=(E=p.__r3f)!=null?E:{};p.raycast&&T.handlers&&T.eventCount&&Yg(p).getState().internal.interaction.push(p)},getPublicInstance:p=>p,prepareForCommit:()=>null,preparePortalMount:p=>ld(p.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(p){var g;const{attach:v,parent:y}=(g=p.__r3f)!=null?g:{};v&&y&&AE(y,p,v),p.isObject3D&&(p.visible=!1),cd(p)},unhideInstance(p,g){var v;const{attach:y,parent:E}=(v=p.__r3f)!=null?v:{};y&&E&&q_(E,p,y),(p.isObject3D&&g.visible==null||g.visible)&&(p.visible=!0),cd(p)},createTextInstance:d,hideTextInstance:d,unhideTextInstance:d,getCurrentEventPriority:()=>e?e():md.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&ai.fun(performance.now)?performance.now:ai.fun(Date.now)?Date.now:()=>0,scheduleTimeout:ai.fun(setTimeout)?setTimeout:void 0,cancelTimeout:ai.fun(clearTimeout)?clearTimeout:void 0}),applyProps:K_}}var EE,ME;const Z_=i=>"colorSpace"in i||"outputColorSpace"in i,ET=()=>{var i;return(i=Ux.ColorManagement)!=null?i:null},MT=i=>i&&i.isOrthographicCamera,_D=i=>i&&i.hasOwnProperty("current"),Wp=typeof window<"u"&&((EE=window.document)!=null&&EE.createElement||((ME=window.navigator)==null?void 0:ME.product)==="ReactNative")?te.useLayoutEffect:te.useEffect;function wT(i){const e=te.useRef(i);return Wp(()=>void(e.current=i),[i]),e}function yD({set:i}){return Wp(()=>(i(new Promise(()=>null)),()=>i(!1)),[i]),null}class TT extends te.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}TT.getDerivedStateFromError=()=>({error:!0});const AT="__default",wE=new Map,xD=i=>i&&!!i.memoized&&!!i.changes;function CT(i){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(i)?Math.min(Math.max(i[0],t),i[1]):i}const Bf=i=>{var e;return(e=i.__r3f)==null?void 0:e.root.getState()};function Yg(i){let e=i.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const ai={obj:i=>i===Object(i)&&!ai.arr(i)&&typeof i!="function",fun:i=>typeof i=="function",str:i=>typeof i=="string",num:i=>typeof i=="number",boo:i=>typeof i=="boolean",und:i=>i===void 0,arr:i=>Array.isArray(i),equ(i,e,{arrays:t="shallow",objects:n="reference",strict:r=!0}={}){if(typeof i!=typeof e||!!i!=!!e)return!1;if(ai.str(i)||ai.num(i)||ai.boo(i))return i===e;const s=ai.obj(i);if(s&&n==="reference")return i===e;const a=ai.arr(i);if(a&&t==="reference")return i===e;if((a||s)&&i===e)return!0;let c;for(c in i)if(!(c in e))return!1;if(s&&t==="shallow"&&n==="shallow"){for(c in r?e:i)if(!ai.equ(i[c],e[c],{strict:r,objects:"reference"}))return!1}else for(c in r?e:i)if(i[c]!==e[c])return!1;if(ai.und(c)){if(a&&i.length===0&&e.length===0||s&&Object.keys(i).length===0&&Object.keys(e).length===0)return!0;if(i!==e)return!1}return!0}};function SD(i){const e={nodes:{},materials:{}};return i&&i.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e}function ED(i){i.dispose&&i.type!=="Scene"&&i.dispose();for(const e in i)e.dispose==null||e.dispose(),delete i[e]}function ld(i,e){const t=i;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},i}function Uy(i,e){let t=i;if(e.includes("-")){const n=e.split("-"),r=n.pop();return t=n.reduce((s,a)=>s[a],i),{target:t,key:r}}else return{target:t,key:e}}const TE=/-\d+$/;function q_(i,e,t){if(ai.str(t)){if(TE.test(t)){const s=t.replace(TE,""),{target:a,key:c}=Uy(i,s);Array.isArray(a[c])||(a[c]=[])}const{target:n,key:r}=Uy(i,t);e.__r3f.previousAttach=n[r],n[r]=e}else e.__r3f.previousAttach=t(i,e)}function AE(i,e,t){var n,r;if(ai.str(t)){const{target:s,key:a}=Uy(i,t),c=e.__r3f.previousAttach;c===void 0?delete s[a]:s[a]=c}else(n=e.__r3f)==null||n.previousAttach==null||n.previousAttach(i,e);(r=e.__r3f)==null||delete r.previousAttach}function bT(i,{children:e,key:t,ref:n,...r},{children:s,key:a,ref:c,...d}={},f=!1){const p=i.__r3f,g=Object.entries(r),v=[];if(f){const E=Object.keys(d);for(let T=0;T<E.length;T++)r.hasOwnProperty(E[T])||g.unshift([E[T],AT+"remove"])}g.forEach(([E,T])=>{var w;if((w=i.__r3f)!=null&&w.primitive&&E==="object"||ai.equ(T,d[E]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(E))return v.push([E,T,!0,[]]);let _=[];E.includes("-")&&(_=E.split("-")),v.push([E,T,!1,_]);for(const C in r){const b=r[C];C.startsWith(`${E}-`)&&v.push([C,b,!1,C.split("-")])}});const y={...r};return p!=null&&p.memoizedProps&&p!=null&&p.memoizedProps.args&&(y.args=p.memoizedProps.args),p!=null&&p.memoizedProps&&p!=null&&p.memoizedProps.attach&&(y.attach=p.memoizedProps.attach),{memoized:y,changes:v}}function K_(i,e){var t;const n=i.__r3f,r=n==null?void 0:n.root,s=r==null||r.getState==null?void 0:r.getState(),{memoized:a,changes:c}=xD(e)?e:bT(i,e),d=n==null?void 0:n.eventCount;i.__r3f&&(i.__r3f.memoizedProps=a);for(let v=0;v<c.length;v++){let[y,E,T,w]=c[v];if(Z_(i)){const I="srgb",N="srgb-linear";y==="encoding"?(y="colorSpace",E=E===3001?I:N):y==="outputEncoding"&&(y="outputColorSpace",E=E===3001?I:N)}let _=i,C=_[y];if(w.length&&(C=w.reduce((b,I)=>b[I],i),!(C&&C.set))){const[b,...I]=w.reverse();_=I.reverse().reduce((N,O)=>N[O],i),y=b}if(E===AT+"remove")if(_.constructor){let b=wE.get(_.constructor);b||(b=new _.constructor,wE.set(_.constructor,b)),E=b[y]}else E=0;if(T&&n)E?n.handlers[y]=E:delete n.handlers[y],n.eventCount=Object.keys(n.handlers).length;else if(C&&C.set&&(C.copy||C instanceof Ru)){if(Array.isArray(E))C.fromArray?C.fromArray(E):C.set(...E);else if(C.copy&&E&&E.constructor&&C.constructor===E.constructor)C.copy(E);else if(E!==void 0){var f;const b=(f=C)==null?void 0:f.isColor;!b&&C.setScalar?C.setScalar(E):C instanceof Ru&&E instanceof Ru?C.mask=E.mask:C.set(E),!ET()&&s&&!s.linear&&b&&C.convertSRGBToLinear()}}else{var p;if(_[y]=E,(p=_[y])!=null&&p.isTexture&&_[y].format===Ni&&_[y].type===Oi&&s){const b=_[y];Z_(b)&&Z_(s.gl)?b.colorSpace=s.gl.outputColorSpace:b.encoding=s.gl.outputEncoding}}cd(i)}if(n&&n.parent&&i.raycast&&d!==n.eventCount){const v=Yg(i).getState().internal,y=v.interaction.indexOf(i);y>-1&&v.interaction.splice(y,1),n.eventCount&&v.interaction.push(i)}return!(c.length===1&&c[0][0]==="onUpdate")&&c.length&&(t=i.__r3f)!=null&&t.parent&&Oy(i),i}function cd(i){var e,t;const n=(e=i.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function Oy(i){i.onUpdate==null||i.onUpdate(i)}function RT(i,e){i.manual||(MT(i)?(i.left=e.width/-2,i.right=e.width/2,i.top=e.height/2,i.bottom=e.height/-2):i.aspect=e.width/e.height,i.updateProjectionMatrix(),i.updateMatrixWorld())}function Pg(i){return(i.eventObject||i.object).uuid+"/"+i.index+i.instanceId}function MD(){var i;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return md.DefaultEventPriority;switch((i=e.event)==null?void 0:i.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return md.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return md.ContinuousEventPriority;default:return md.DefaultEventPriority}}function IT(i,e,t,n){const r=t.get(e);r&&(t.delete(e),t.size===0&&(i.delete(n),r.target.releasePointerCapture(n)))}function wD(i,e){const{internal:t}=i.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,r)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((n,r)=>{IT(t.capturedMap,e,n,r)})}function TD(i){function e(d){const{internal:f}=i.getState(),p=d.offsetX-f.initialClick[0],g=d.offsetY-f.initialClick[1];return Math.round(Math.sqrt(p*p+g*g))}function t(d){return d.filter(f=>["Move","Over","Enter","Out","Leave"].some(p=>{var g;return(g=f.__r3f)==null?void 0:g.handlers["onPointer"+p]}))}function n(d,f){const p=i.getState(),g=new Set,v=[],y=f?f(p.internal.interaction):p.internal.interaction;for(let _=0;_<y.length;_++){const C=Bf(y[_]);C&&(C.raycaster.camera=void 0)}p.previousRoot||p.events.compute==null||p.events.compute(d,p);function E(_){const C=Bf(_);if(!C||!C.events.enabled||C.raycaster.camera===null)return[];if(C.raycaster.camera===void 0){var b;C.events.compute==null||C.events.compute(d,C,(b=C.previousRoot)==null?void 0:b.getState()),C.raycaster.camera===void 0&&(C.raycaster.camera=null)}return C.raycaster.camera?C.raycaster.intersectObject(_,!0):[]}let T=y.flatMap(E).sort((_,C)=>{const b=Bf(_.object),I=Bf(C.object);return!b||!I?_.distance-C.distance:I.events.priority-b.events.priority||_.distance-C.distance}).filter(_=>{const C=Pg(_);return g.has(C)?!1:(g.add(C),!0)});p.events.filter&&(T=p.events.filter(T,p));for(const _ of T){let C=_.object;for(;C;){var w;(w=C.__r3f)!=null&&w.eventCount&&v.push({..._,eventObject:C}),C=C.parent}}if("pointerId"in d&&p.internal.capturedMap.has(d.pointerId))for(let _ of p.internal.capturedMap.get(d.pointerId).values())g.has(Pg(_.intersection))||v.push(_.intersection);return v}function r(d,f,p,g){const v=i.getState();if(d.length){const y={stopped:!1};for(const E of d){const T=Bf(E.object)||v,{raycaster:w,pointer:_,camera:C,internal:b}=T,I=new X(_.x,_.y,0).unproject(C),N=U=>{var W,ne;return(W=(ne=b.capturedMap.get(U))==null?void 0:ne.has(E.eventObject))!=null?W:!1},O=U=>{const W={intersection:E,target:f.target};b.capturedMap.has(U)?b.capturedMap.get(U).set(E.eventObject,W):b.capturedMap.set(U,new Map([[E.eventObject,W]])),f.target.setPointerCapture(U)},H=U=>{const W=b.capturedMap.get(U);W&&IT(b.capturedMap,E.eventObject,W,U)};let B={};for(let U in f){let W=f[U];typeof W!="function"&&(B[U]=W)}let D={...E,...B,pointer:_,intersections:d,stopped:y.stopped,delta:p,unprojectedPoint:I,ray:w.ray,camera:C,stopPropagation(){const U="pointerId"in f&&b.capturedMap.get(f.pointerId);if((!U||U.has(E.eventObject))&&(D.stopped=y.stopped=!0,b.hovered.size&&Array.from(b.hovered.values()).find(W=>W.eventObject===E.eventObject))){const W=d.slice(0,d.indexOf(E));s([...W,E])}},target:{hasPointerCapture:N,setPointerCapture:O,releasePointerCapture:H},currentTarget:{hasPointerCapture:N,setPointerCapture:O,releasePointerCapture:H},nativeEvent:f};if(g(D),y.stopped===!0)break}}return d}function s(d){const{internal:f}=i.getState();for(const p of f.hovered.values())if(!d.length||!d.find(g=>g.object===p.object&&g.index===p.index&&g.instanceId===p.instanceId)){const v=p.eventObject.__r3f,y=v==null?void 0:v.handlers;if(f.hovered.delete(Pg(p)),v!=null&&v.eventCount){const E={...p,intersections:d};y.onPointerOut==null||y.onPointerOut(E),y.onPointerLeave==null||y.onPointerLeave(E)}}}function a(d,f){for(let p=0;p<f.length;p++){const g=f[p].__r3f;g==null||g.handlers.onPointerMissed==null||g.handlers.onPointerMissed(d)}}function c(d){switch(d){case"onPointerLeave":case"onPointerCancel":return()=>s([]);case"onLostPointerCapture":return f=>{const{internal:p}=i.getState();"pointerId"in f&&p.capturedMap.has(f.pointerId)&&requestAnimationFrame(()=>{p.capturedMap.has(f.pointerId)&&(p.capturedMap.delete(f.pointerId),s([]))})}}return function(p){const{onPointerMissed:g,internal:v}=i.getState();v.lastEvent.current=p;const y=d==="onPointerMove",E=d==="onClick"||d==="onContextMenu"||d==="onDoubleClick",w=n(p,y?t:void 0),_=E?e(p):0;d==="onPointerDown"&&(v.initialClick=[p.offsetX,p.offsetY],v.initialHits=w.map(b=>b.eventObject)),E&&!w.length&&_<=2&&(a(p,v.interaction),g&&g(p)),y&&s(w);function C(b){const I=b.eventObject,N=I.__r3f,O=N==null?void 0:N.handlers;if(N!=null&&N.eventCount)if(y){if(O.onPointerOver||O.onPointerEnter||O.onPointerOut||O.onPointerLeave){const H=Pg(b),B=v.hovered.get(H);B?B.stopped&&b.stopPropagation():(v.hovered.set(H,b),O.onPointerOver==null||O.onPointerOver(b),O.onPointerEnter==null||O.onPointerEnter(b))}O.onPointerMove==null||O.onPointerMove(b)}else{const H=O[d];H?(!E||v.initialHits.includes(I))&&(a(p,v.interaction.filter(B=>!v.initialHits.includes(B))),H(b)):E&&v.initialHits.includes(I)&&a(p,v.interaction.filter(B=>!v.initialHits.includes(B)))}}r(w,p,_,C)}}return{handlePointer:c}}const AD=["set","get","setSize","setFrameloop","setDpr","events","invalidate","advance","size","viewport"],PT=i=>!!(i!=null&&i.render),Ox=te.createContext(null),CD=(i,e)=>{const t=_T((c,d)=>{const f=new X,p=new X,g=new X;function v(_=d().camera,C=p,b=d().size){const{width:I,height:N,top:O,left:H}=b,B=I/N;C.isVector3?g.copy(C):g.set(...C);const D=_.getWorldPosition(f).distanceTo(g);if(MT(_))return{width:I/_.zoom,height:N/_.zoom,top:O,left:H,factor:1,distance:D,aspect:B};{const U=_.fov*Math.PI/180,W=2*Math.tan(U/2)*D,ne=W*(I/N);return{width:ne,height:W,top:O,left:H,factor:I/ne,distance:D,aspect:B}}}let y;const E=_=>c(C=>({performance:{...C.performance,current:_}})),T=new ke;return{set:c,get:d,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(_=1)=>i(d(),_),advance:(_,C)=>e(_,C,d()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Rx,pointer:T,mouse:T,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const _=d();y&&clearTimeout(y),_.performance.current!==_.performance.min&&E(_.performance.min),y=setTimeout(()=>E(d().performance.max),_.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:v},setEvents:_=>c(C=>({...C,events:{...C.events,..._}})),setSize:(_,C,b,I,N)=>{const O=d().camera,H={width:_,height:C,top:I||0,left:N||0,updateStyle:b};c(B=>({size:H,viewport:{...B.viewport,...v(O,p,H)}}))},setDpr:_=>c(C=>{const b=CT(_);return{viewport:{...C.viewport,dpr:b,initialDpr:C.viewport.initialDpr||b}}}),setFrameloop:(_="always")=>{const C=d().clock;C.stop(),C.elapsedTime=0,_!=="never"&&(C.start(),C.elapsedTime=0),c(()=>({frameloop:_}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:te.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(_,C,b)=>{const I=d().internal;return I.priority=I.priority+(C>0?1:0),I.subscribers.push({ref:_,priority:C,store:b}),I.subscribers=I.subscribers.sort((N,O)=>N.priority-O.priority),()=>{const N=d().internal;N!=null&&N.subscribers&&(N.priority=N.priority-(C>0?1:0),N.subscribers=N.subscribers.filter(O=>O.ref!==_))}}}}}),n=t.getState();let r=n.size,s=n.viewport.dpr,a=n.camera;return t.subscribe(()=>{const{camera:c,size:d,viewport:f,gl:p,set:g}=t.getState();if(d.width!==r.width||d.height!==r.height||f.dpr!==s){var v;r=d,s=f.dpr,RT(c,d),p.setPixelRatio(f.dpr);const y=(v=d.updateStyle)!=null?v:typeof HTMLCanvasElement<"u"&&p.domElement instanceof HTMLCanvasElement;p.setSize(d.width,d.height,y)}c!==a&&(a=c,g(y=>({viewport:{...y.viewport,...y.viewport.getCurrentViewport(c)}})))}),t.subscribe(c=>i(c)),t};let Lg,bD=new Set,RD=new Set,ID=new Set;function Q_(i,e){if(i.size)for(const{callback:t}of i.values())t(e)}function zf(i,e){switch(i){case"before":return Q_(bD,e);case"after":return Q_(RD,e);case"tail":return Q_(ID,e)}}let J_,$_;function ey(i,e,t){let n=e.clock.getDelta();for(e.frameloop==="never"&&typeof i=="number"&&(n=i-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=i),J_=e.internal.subscribers,Lg=0;Lg<J_.length;Lg++)$_=J_[Lg],$_.ref.current($_.store.getState(),n,t);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}function PD(i){let e=!1,t=!1,n,r,s;function a(f){r=requestAnimationFrame(a),e=!0,n=0,zf("before",f),t=!0;for(const g of i.values()){var p;s=g.store.getState(),s.internal.active&&(s.frameloop==="always"||s.internal.frames>0)&&!((p=s.gl.xr)!=null&&p.isPresenting)&&(n+=ey(f,s))}if(t=!1,zf("after",f),n===0)return zf("tail",f),e=!1,cancelAnimationFrame(r)}function c(f,p=1){var g;if(!f)return i.forEach(v=>c(v.store.getState(),p));(g=f.gl.xr)!=null&&g.isPresenting||!f.internal.active||f.frameloop==="never"||(p>1?f.internal.frames=Math.min(60,f.internal.frames+p):t?f.internal.frames=2:f.internal.frames=1,e||(e=!0,requestAnimationFrame(a)))}function d(f,p=!0,g,v){if(p&&zf("before",f),g)ey(f,g,v);else for(const y of i.values())ey(f,y.store.getState());p&&zf("after",f)}return{loop:a,invalidate:c,advance:d}}function Fx(){const i=te.useContext(Ox);if(!i)throw new Error("R3F: Hooks can only be used within the Canvas component!");return i}function br(i=t=>t,e){return Fx()(i,e)}function so(i,e=0){const t=Fx(),n=t.getState().internal.subscribe,r=wT(i);return Wp(()=>n(r,e,t),[e,n,t]),null}const CE=new WeakMap;function LT(i,e){return function(t,...n){let r=CE.get(t);return r||(r=new t,CE.set(t,r)),i&&i(r),Promise.all(n.map(s=>new Promise((a,c)=>r.load(s,d=>{d.scene&&Object.assign(d,SD(d.scene)),a(d)},e,d=>c(new Error(`Could not load ${s}: ${d==null?void 0:d.message}`))))))}}function wd(i,e,t,n){const r=Array.isArray(e)?e:[e],s=cD(LT(t,n),[i,...r],{equal:ai.equ});return Array.isArray(e)?s:s[0]}wd.preload=function(i,e,t){const n=Array.isArray(e)?e:[e];return uD(LT(t),[i,...n])};wd.clear=function(i,e){const t=Array.isArray(e)?e:[e];return hD([i,...t])};const Td=new Map,{invalidate:bE,advance:RE}=PD(Td),{reconciler:Cp,applyProps:Jl}=vD(Td,MD),td={objects:"shallow",strict:!1},LD=(i,e)=>{const t=typeof i=="function"?i(e):i;return PT(t)?t:new Nx({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...i})};function DD(i,e){const t=typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement;if(e){const{width:n,height:r,top:s,left:a,updateStyle:c=t}=e;return{width:n,height:r,top:s,left:a,updateStyle:c}}else if(typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement&&i.parentElement){const{width:n,height:r,top:s,left:a}=i.parentElement.getBoundingClientRect();return{width:n,height:r,top:s,left:a,updateStyle:t}}else if(typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas)return{width:i.width,height:i.height,top:0,left:0,updateStyle:t};return{width:0,height:0,top:0,left:0}}function ND(i){const e=Td.get(i),t=e==null?void 0:e.fiber,n=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,s=n||CD(bE,RE),a=t||Cp.createContainer(s,md.ConcurrentRoot,null,!1,null,"",r,null);e||Td.set(i,{fiber:a,store:s});let c,d=!1,f;return{configure(p={}){let{gl:g,size:v,scene:y,events:E,onCreated:T,shadows:w=!1,linear:_=!1,flat:C=!1,legacy:b=!1,orthographic:I=!1,frameloop:N="always",dpr:O=[1,2],performance:H,raycaster:B,camera:D,onPointerMissed:U}=p,W=s.getState(),ne=W.gl;W.gl||W.set({gl:ne=LD(g,i)});let re=W.raycaster;re||W.set({raycaster:re=new m0});const{params:he,...fe}=B||{};if(ai.equ(fe,re,td)||Jl(re,{...fe}),ai.equ(he,re.params,td)||Jl(re,{params:{...re.params,...he}}),!W.camera||W.camera===f&&!ai.equ(f,D,td)){f=D;const se=D instanceof Np,Y=se?D:I?new ul(0,0,0,0,.1,1e3):new Di(75,0,.1,1e3);se||(Y.position.z=5,D&&(Jl(Y,D),("aspect"in D||"left"in D||"right"in D||"bottom"in D||"top"in D)&&(Y.manual=!0,Y.updateProjectionMatrix())),!W.camera&&!(D!=null&&D.rotation)&&Y.lookAt(0,0,0)),W.set({camera:Y}),re.camera=Y}if(!W.scene){let se;y!=null&&y.isScene?se=y:(se=new Du,y&&Jl(se,y)),W.set({scene:ld(se)})}if(!W.xr){var ce;const se=(ze,ve)=>{const Pe=s.getState();Pe.frameloop!=="never"&&RE(ze,!0,Pe,ve)},Y=()=>{const ze=s.getState();ze.gl.xr.enabled=ze.gl.xr.isPresenting,ze.gl.xr.setAnimationLoop(ze.gl.xr.isPresenting?se:null),ze.gl.xr.isPresenting||bE(ze)},le={connect(){const ze=s.getState().gl;ze.xr.addEventListener("sessionstart",Y),ze.xr.addEventListener("sessionend",Y)},disconnect(){const ze=s.getState().gl;ze.xr.removeEventListener("sessionstart",Y),ze.xr.removeEventListener("sessionend",Y)}};typeof((ce=ne.xr)==null?void 0:ce.addEventListener)=="function"&&le.connect(),W.set({xr:le})}if(ne.shadowMap){const se=ne.shadowMap.enabled,Y=ne.shadowMap.type;if(ne.shadowMap.enabled=!!w,ai.boo(w))ne.shadowMap.type=Qf;else if(ai.str(w)){var xe;const le={basic:CM,percentage:Fv,soft:Qf,variance:Uo};ne.shadowMap.type=(xe=le[w])!=null?xe:Qf}else ai.obj(w)&&Object.assign(ne.shadowMap,w);(se!==ne.shadowMap.enabled||Y!==ne.shadowMap.type)&&(ne.shadowMap.needsUpdate=!0)}const q=ET();q&&("enabled"in q?q.enabled=!b:"legacyMode"in q&&(q.legacyMode=b)),d||Jl(ne,{outputEncoding:_?3e3:3001,toneMapping:C?zo:Bv}),W.legacy!==b&&W.set(()=>({legacy:b})),W.linear!==_&&W.set(()=>({linear:_})),W.flat!==C&&W.set(()=>({flat:C})),g&&!ai.fun(g)&&!PT(g)&&!ai.equ(g,ne,td)&&Jl(ne,g),E&&!W.events.handlers&&W.set({events:E(s)});const de=DD(i,v);return ai.equ(de,W.size,td)||W.setSize(de.width,de.height,de.updateStyle,de.top,de.left),O&&W.viewport.dpr!==CT(O)&&W.setDpr(O),W.frameloop!==N&&W.setFrameloop(N),W.onPointerMissed||W.set({onPointerMissed:U}),H&&!ai.equ(H,W.performance,td)&&W.set(se=>({performance:{...se.performance,...H}})),c=T,d=!0,this},render(p){return d||this.configure(),Cp.updateContainer(z.jsx(UD,{store:s,children:p,onCreated:c,rootElement:i}),a,null,()=>{}),s},unmount(){DT(i)}}}function UD({store:i,children:e,onCreated:t,rootElement:n}){return Wp(()=>{const r=i.getState();r.set(s=>({internal:{...s.internal,active:!0}})),t&&t(r),i.getState().events.connected||r.events.connect==null||r.events.connect(n)},[]),z.jsx(Ox.Provider,{value:i,children:e})}function DT(i,e){const t=Td.get(i),n=t==null?void 0:t.fiber;if(n){const r=t==null?void 0:t.store.getState();r&&(r.internal.active=!1),Cp.updateContainer(null,n,null,()=>{r&&setTimeout(()=>{try{var s,a,c,d;r.events.disconnect==null||r.events.disconnect(),(s=r.gl)==null||(a=s.renderLists)==null||a.dispose==null||a.dispose(),(c=r.gl)==null||c.forceContextLoss==null||c.forceContextLoss(),(d=r.gl)!=null&&d.xr&&r.xr.disconnect(),ED(r),Td.delete(i)}catch{}},500)})}}function OD(i,e,t){return z.jsx(FD,{children:i,container:e,state:t},e.uuid)}function FD({state:i={},children:e,container:t}){const{events:n,size:r,...s}=i,a=Fx(),[c]=te.useState(()=>new m0),[d]=te.useState(()=>new ke),f=te.useCallback((g,v)=>{const y={...g};Object.keys(g).forEach(T=>{(AD.includes(T)||g[T]!==v[T]&&v[T])&&delete y[T]});let E;if(v&&r){const T=v.camera;E=g.viewport.getCurrentViewport(T,new X,r),T!==g.camera&&RT(T,r)}return{...y,scene:t,raycaster:c,pointer:d,mouse:d,previousRoot:a,events:{...g.events,...v==null?void 0:v.events,...n},size:{...g.size,...r},viewport:{...g.viewport,...E},...s}},[i]),[p]=te.useState(()=>{const g=a.getState();return _T((y,E)=>({...g,scene:t,raycaster:c,pointer:d,mouse:d,previousRoot:a,events:{...g.events,...n},size:{...g.size,...r},...s,set:y,get:E,setEvents:T=>y(w=>({...w,events:{...w.events,...T}}))}))});return te.useEffect(()=>{const g=a.subscribe(v=>p.setState(y=>f(v,y)));return()=>{g()}},[f]),te.useEffect(()=>{p.setState(g=>f(a.getState(),g))},[f]),te.useEffect(()=>()=>{p.destroy()},[]),z.jsx(z.Fragment,{children:Cp.createPortal(z.jsx(Ox.Provider,{value:p,children:e}),p,null)})}Cp.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:te.version});const ty={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function BD(i){const{handlePointer:e}=TD(i);return{priority:1,enabled:!0,compute(t,n,r){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(ty).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:r}=i.getState();(t=r.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var n;const{set:r,events:s}=i.getState();s.disconnect==null||s.disconnect(),r(a=>({events:{...a.events,connected:t}})),Object.entries((n=s.handlers)!=null?n:[]).forEach(([a,c])=>{const[d,f]=ty[a];t.addEventListener(d,c,{passive:f})})},disconnect:()=>{const{set:t,events:n}=i.getState();if(n.connected){var r;Object.entries((r=n.handlers)!=null?r:[]).forEach(([s,a])=>{if(n&&n.connected instanceof HTMLElement){const[c]=ty[s];n.connected.removeEventListener(c,a)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}function IE(i,e){let t;return(...n)=>{window.clearTimeout(t),t=window.setTimeout(()=>i(...n),e)}}function zD({debounce:i,scroll:e,polyfill:t,offsetSize:n}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!r)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,a]=te.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=te.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),d=i?typeof i=="number"?i:i.scroll:null,f=i?typeof i=="number"?i:i.resize:null,p=te.useRef(!1);te.useEffect(()=>(p.current=!0,()=>void(p.current=!1)));const[g,v,y]=te.useMemo(()=>{const _=()=>{if(!c.current.element)return;const{left:C,top:b,width:I,height:N,bottom:O,right:H,x:B,y:D}=c.current.element.getBoundingClientRect(),U={left:C,top:b,width:I,height:N,bottom:O,right:H,x:B,y:D};c.current.element instanceof HTMLElement&&n&&(U.height=c.current.element.offsetHeight,U.width=c.current.element.offsetWidth),Object.freeze(U),p.current&&!GD(c.current.lastBounds,U)&&a(c.current.lastBounds=U)};return[_,f?IE(_,f):_,d?IE(_,d):_]},[a,n,d,f]);function E(){c.current.scrollContainers&&(c.current.scrollContainers.forEach(_=>_.removeEventListener("scroll",y,!0)),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null),c.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",c.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",c.current.orientationHandler))}function T(){c.current.element&&(c.current.resizeObserver=new r(y),c.current.resizeObserver.observe(c.current.element),e&&c.current.scrollContainers&&c.current.scrollContainers.forEach(_=>_.addEventListener("scroll",y,{capture:!0,passive:!0})),c.current.orientationHandler=()=>{y()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",c.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",c.current.orientationHandler))}const w=_=>{!_||_===c.current.element||(E(),c.current.element=_,c.current.scrollContainers=NT(_),T())};return HD(y,!!e),kD(v),te.useEffect(()=>{E(),T()},[e,y,v]),te.useEffect(()=>E,[]),[w,s,g]}function kD(i){te.useEffect(()=>{const e=i;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[i])}function HD(i,e){te.useEffect(()=>{if(e){const t=i;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[i,e])}function NT(i){const e=[];if(!i||i===document.body)return e;const{overflow:t,overflowX:n,overflowY:r}=window.getComputedStyle(i);return[t,n,r].some(s=>s==="auto"||s==="scroll")&&e.push(i),[...e,...NT(i.parentElement)]}const VD=["x","y","top","bottom","left","right","width","height"],GD=(i,e)=>VD.every(t=>i[t]===e[t]);var WD=Object.defineProperty,jD=Object.defineProperties,XD=Object.getOwnPropertyDescriptors,PE=Object.getOwnPropertySymbols,YD=Object.prototype.hasOwnProperty,ZD=Object.prototype.propertyIsEnumerable,LE=(i,e,t)=>e in i?WD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,DE=(i,e)=>{for(var t in e||(e={}))YD.call(e,t)&&LE(i,t,e[t]);if(PE)for(var t of PE(e))ZD.call(e,t)&&LE(i,t,e[t]);return i},qD=(i,e)=>jD(i,XD(e)),NE,UE;typeof window<"u"&&((NE=window.document)!=null&&NE.createElement||((UE=window.navigator)==null?void 0:UE.product)==="ReactNative")?te.useLayoutEffect:te.useEffect;function UT(i,e,t){if(!i)return;if(t(i)===!0)return i;let n=i.child;for(;n;){const r=UT(n,e,t);if(r)return r;n=n.sibling}}function OT(i){try{return Object.defineProperties(i,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return i}}const OE=console.error;console.error=function(){const i=[...arguments].join("");if(i!=null&&i.startsWith("Warning:")&&i.includes("useContext")){console.error=OE;return}return OE.apply(this,arguments)};const Bx=OT(te.createContext(null));class FT extends te.Component{render(){return te.createElement(Bx.Provider,{value:this._reactInternals},this.props.children)}}function KD(){const i=te.useContext(Bx);if(i===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=te.useId();return te.useMemo(()=>{for(const n of[i,i==null?void 0:i.alternate]){if(!n)continue;const r=UT(n,!1,s=>{let a=s.memoizedState;for(;a;){if(a.memoizedState===e)return!0;a=a.next}});if(r)return r}},[i,e])}function QD(){const i=KD(),[e]=te.useState(()=>new Map);e.clear();let t=i;for(;t;){if(t.type&&typeof t.type=="object"){const r=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;r&&r!==Bx&&!e.has(r)&&e.set(r,te.useContext(OT(r)))}t=t.return}return e}function JD(){const i=QD();return te.useMemo(()=>Array.from(i.keys()).reduce((e,t)=>n=>te.createElement(e,null,te.createElement(t.Provider,qD(DE({},n),{value:i.get(t)}))),e=>te.createElement(FT,DE({},e))),[i])}const $D=te.forwardRef(function({children:e,fallback:t,resize:n,style:r,gl:s,events:a=BD,eventSource:c,eventPrefix:d,shadows:f,linear:p,flat:g,legacy:v,orthographic:y,frameloop:E,dpr:T,performance:w,raycaster:_,camera:C,scene:b,onPointerMissed:I,onCreated:N,...O},H){te.useMemo(()=>Gp(iD),[]);const B=JD(),[D,U]=zD({scroll:!0,debounce:{scroll:50,resize:0},...n}),W=te.useRef(null),ne=te.useRef(null);te.useImperativeHandle(H,()=>W.current);const re=wT(I),[he,fe]=te.useState(!1),[ce,xe]=te.useState(!1);if(he)throw he;if(ce)throw ce;const q=te.useRef(null);Wp(()=>{const se=W.current;U.width>0&&U.height>0&&se&&(q.current||(q.current=ND(se)),q.current.configure({gl:s,events:a,shadows:f,linear:p,flat:g,legacy:v,orthographic:y,frameloop:E,dpr:T,performance:w,raycaster:_,camera:C,scene:b,size:U,onPointerMissed:(...Y)=>re.current==null?void 0:re.current(...Y),onCreated:Y=>{Y.events.connect==null||Y.events.connect(c?_D(c)?c.current:c:ne.current),d&&Y.setEvents({compute:(le,ze)=>{const ve=le[d+"X"],Pe=le[d+"Y"];ze.pointer.set(ve/ze.size.width*2-1,-(Pe/ze.size.height)*2+1),ze.raycaster.setFromCamera(ze.pointer,ze.camera)}}),N==null||N(Y)}}),q.current.render(z.jsx(B,{children:z.jsx(TT,{set:xe,children:z.jsx(te.Suspense,{fallback:z.jsx(yD,{set:fe}),children:e??null})})})))}),te.useEffect(()=>{const se=W.current;if(se)return()=>DT(se)},[]);const de=c?"none":"auto";return z.jsx("div",{ref:ne,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:de,...r},...O,children:z.jsx("div",{ref:D,style:{width:"100%",height:"100%"},children:z.jsx("canvas",{ref:W,style:{display:"block"},children:t})})})}),eN=te.forwardRef(function(e,t){return z.jsx(FT,{children:z.jsx($D,{...e,ref:t})})}),tN="modulepreload",nN=function(i){return"/"+i},FE={},iN=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let a=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=a(t.map(f=>{if(f=nN(f),f in FE)return;FE[f]=!0;const p=f.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":tN,p||(v.as="script"),v.crossOrigin="",v.href=f,d&&v.setAttribute("nonce",d),document.head.appendChild(v),p)return new Promise((y,E)=>{v.addEventListener("load",y),v.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return r.then(a=>{for(const c of a||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})},BE=i=>{let e;const t=new Set,n=(f,p)=>{const g=typeof f=="function"?f(e):f;if(!Object.is(g,e)){const v=e;e=p??(typeof g!="object"||g===null)?g:Object.assign({},e,g),t.forEach(y=>y(e,v))}},r=()=>e,c={setState:n,getState:r,getInitialState:()=>d,subscribe:f=>(t.add(f),()=>t.delete(f))},d=e=i(n,r,c);return c},rN=(i=>i?BE(i):BE),sN=i=>i;function oN(i,e=sN){const t=yu.useSyncExternalStore(i.subscribe,yu.useCallback(()=>e(i.getState()),[i,e]),yu.useCallback(()=>e(i.getInitialState()),[i,e]));return yu.useDebugValue(t),t}const zE=i=>{const e=rN(i),t=n=>oN(e,n);return Object.assign(t,e),t},v0=(i=>i?zE(i):zE);function ny(i){var p,g;const e=i.nodes.filter(v=>v.kind==="module"),t=new Map,n=new Map;for(const v of i.nodes){if(v.kind==="file"&&v.parentId){const y=t.get(v.parentId)??[];y.push(v),t.set(v.parentId,y)}if(v.kind==="function"&&v.parentId){const y=n.get(v.parentId)??[];y.push(v),n.set(v.parentId,y)}}const r=new Set(e.map(v=>v.id)),s=i.edges.filter(v=>r.has(v.sourceId)&&r.has(v.targetId)),a=i.edges.filter(v=>v.kind==="calls");let c=0,d=0,f=80;if(e.length>0){let v=1/0,y=-1/0,E=1/0,T=-1/0;for(const C of e){const b=(((p=C.dimensions)==null?void 0:p.width)??10)/2,I=(((g=C.dimensions)==null?void 0:g.depth)??10)/2;v=Math.min(v,C.position.x-b),y=Math.max(y,C.position.x+b),E=Math.min(E,C.position.z-I),T=Math.max(T,C.position.z+I)}c=(v+y)/2,d=(E+T)/2;const w=y-v,_=T-E;f=Math.max(w,_)*.75+20}return{modules:e,filesByModule:t,moduleEdges:s,cityCenter:{x:c,z:d},cityExtent:f,functionsByFile:n,callEdges:a}}const ni=v0(i=>({graph:null,isLoading:!1,error:null,isLive:!1,liveStatus:null,modules:[],filesByModule:new Map,moduleEdges:[],cityCenter:{x:0,z:0},cityExtent:80,functionsByFile:new Map,callEdges:[],loadGraph:async()=>{i({isLoading:!0,error:null});try{let e=await fetch("/api/graph");if(e.ok||(e=await fetch("/fixture.json")),!e.ok)throw new Error(`Failed to load graph: ${e.status}`);const t=await e.json(),n=ny(t);i({graph:t,isLoading:!1,...n})}catch(e){i({isLoading:!1,error:e instanceof Error?e.message:"Unknown error"})}},setGraph:e=>{const t=ny(e);i({graph:e,isLoading:!1,error:null,...t})},connectLive:()=>{iN(async()=>{const{connectLiveSocket:e}=await import("./websocket-CTmhT_5q.js");return{connectLiveSocket:e}},[]).then(({connectLiveSocket:e})=>{e(t=>{const n=ny(t);i({graph:t,isLive:!0,liveStatus:null,isLoading:!1,error:null,...n})},t=>i({liveStatus:t||null})),i({isLive:!0})}).catch(()=>{})}})),kE=.5,HE=1.5,VE=1.5,GE=1,aN=.15,lN=20,cN=.01,BT=.02,uN=.05,hN=.1,dN=.2,fN=.3,zT=80,nd=25,Dg=.7,pN="#22C55E",mN="#3B82F6",gN="#F59E0B",vN="#F97316",_N="#EF4444",yN=3,xN=.2,SN=2,EN=2e3,MN="#0a0a1a",wN="#0a0a1a",TN=120,AN=400,iy=12,WE=.4,jE=15,hn=v0(i=>({zoomLevel:0,selectedModuleId:null,selectedFileId:null,selectedFunctionId:null,interiorFileId:null,hoveredNodeId:null,cameraTarget:null,isSearchOpen:!1,highlightedNodeIds:new Set,highlightedEdgeKeys:new Set,selectModule:e=>{i({selectedModuleId:e,selectedFileId:null,selectedFunctionId:null})},selectFile:e=>{i({selectedFileId:e,selectedFunctionId:null})},selectFunction:e=>{i({selectedFunctionId:e})},enterBuilding:e=>{const{x:t,z:n}=e.position;i({zoomLevel:3,interiorFileId:e.id,selectedFileId:e.id,selectedModuleId:e.parentId,selectedFunctionId:null,cameraTarget:{position:[t,jE,n+12],lookAt:[t,jE*.4,n],_ts:Date.now()}})},exitBuilding:()=>{const e=hn.getState(),{graph:t}=ni.getState(),n=e.selectedModuleId;let r=null;if(n&&t){const s=t.nodes.find(a=>a.id===n);if(s){const{x:a,z:c}=s.position;r={position:[a+nd*Dg,nd,c+nd*Dg],lookAt:[a,0,c],_ts:Date.now()}}}i({zoomLevel:1,interiorFileId:null,selectedFunctionId:null,cameraTarget:r??e.cameraTarget})},clearSelection:()=>{i({selectedModuleId:null,selectedFileId:null,selectedFunctionId:null,interiorFileId:null})},setHovered:e=>{i({hoveredNodeId:e})},flyToModule:e=>{const{x:t,z:n}=e.position;i({zoomLevel:1,selectedModuleId:e.id,selectedFileId:null,selectedFunctionId:null,interiorFileId:null,cameraTarget:{position:[t+nd*Dg,nd,n+nd*Dg],lookAt:[t,0,n],_ts:Date.now()}})},flyToFile:e=>{const{x:t,z:n}=e.position;i({zoomLevel:1,selectedModuleId:e.parentId,selectedFileId:e.id,selectedFunctionId:null,interiorFileId:null,cameraTarget:{position:[t+iy*WE,iy,n+iy*WE],lookAt:[t,0,n],_ts:Date.now()}})},flyToSatellite:()=>{const{cityCenter:e,cityExtent:t}=ni.getState(),n=Math.max(zT,t);i({zoomLevel:0,selectedModuleId:null,selectedFileId:null,selectedFunctionId:null,interiorFileId:null,cameraTarget:{position:[e.x,n,e.z+.01],lookAt:[e.x,0,e.z],_ts:Date.now()}})},toggleSearch:()=>{i(e=>({isSearchOpen:!e.isSearchOpen}))},setHighlights:(e,t)=>{i({highlightedNodeIds:new Set(e),highlightedEdgeKeys:new Set(t)})},clearHighlights:()=>{i({highlightedNodeIds:new Set,highlightedEdgeKeys:new Set})}}));function CN(i){const e=[];let t=new Set;for(const n of i){t=new Set(t);for(const r of n.nodesAdded)t.add(r);for(const r of n.nodesRemoved)t.delete(r);e.push(t)}return e}const fr=v0(i=>({isTimelineActive:!1,currentSnapshotIndex:0,totalSnapshots:0,isPlaying:!1,playbackSpeed:2,visibleNodeIds:new Set,snapshots:[],_cumulativeSets:[],activateTimeline:e=>{if(e.length===0)return;const t=CN(e),n=e.length-1;i({isTimelineActive:!0,snapshots:e,totalSnapshots:e.length,currentSnapshotIndex:n,visibleNodeIds:t[n]??new Set,_cumulativeSets:t,isPlaying:!1})},deactivateTimeline:()=>{i({isTimelineActive:!1,isPlaying:!1,currentSnapshotIndex:0,totalSnapshots:0,visibleNodeIds:new Set,snapshots:[],_cumulativeSets:[]})},setSnapshot:e=>{i(t=>{const n=Math.max(0,Math.min(e,t.totalSnapshots-1));return{currentSnapshotIndex:n,visibleNodeIds:t._cumulativeSets[n]??new Set}})},play:()=>{i({isPlaying:!0})},pause:()=>{i({isPlaying:!1})},setSpeed:e=>{i({playbackSpeed:e})}}));function bN(i){const e=Math.max(i.loc,1),t=Math.max(VE,Math.sqrt(e)*kE),n=Math.max(VE,Math.sqrt(e)*kE);let r;return i.complexity>0?r=Math.max(GE,Math.log2(i.complexity+1)*HE):r=Math.max(GE,Math.sqrt(e)*aN*HE),r=Math.min(r,lN),{width:t,height:r,depth:n}}function RN(i){const e=[],t=[],n=i.nodes.filter(p=>p.kind==="module"),r=i.nodes.filter(p=>p.kind==="file");for(const p of n)e.push({id:p.id,name:p.name,x:p.position.x,z:p.position.z,width:p.dimensions.width,depth:p.dimensions.depth,totalLoc:p.loc});for(const p of r){const g=p.dimensions.width>.01?p.dimensions:bN(p);t.push({nodeId:p.id,name:p.name,x:p.position.x,y:p.position.y||g.height/2,z:p.position.z,width:g.width,height:g.height,depth:g.depth,loc:p.loc,healthScore:p.healthScore,churnScore:p.churnScore,busFactor:p.busFactor,moduleId:p.parentId??""})}let s=1/0,a=-1/0,c=1/0,d=-1/0;for(const p of e)s=Math.min(s,p.x-p.width/2),a=Math.max(a,p.x+p.width/2),c=Math.min(c,p.z-p.depth/2),d=Math.max(d,p.z+p.depth/2);const f={x:(s+a)/2||0,z:(c+d)/2||0};return{modules:e,buildings:t,center:f,bounds:{minX:s,maxX:a,minZ:c,maxZ:d}}}function IN(i){return i<=2?uN:i<=5?hN:i<=10?dN:fN}function XE(i,e,t){const n=i.width/2,r=i.depth/2,s=i.x,a=i.z,c=e-s,d=t-a;if(Math.abs(c)<.001&&Math.abs(d)<.001)return[s+n,a];const f=n/Math.abs(c||.001),p=r/Math.abs(d||.001),g=Math.min(f,p);return[s+c*g,a+d*g]}function PN(i,e){const t=new Map(i.map(r=>[r.id,r])),n=[];for(const r of e){const s=t.get(r.sourceId),a=t.get(r.targetId);if(!s||!a)continue;const[c,d]=XE(s,a.x,a.z),[f,p]=XE(a,s.x,s.z),g=(c+f)/2,v=(d+p)/2,y=f-c,E=p-d,T=Math.sqrt(y*y+E*E),w=T*.15,_=-E/(T||1)*w,C=y/(T||1)*w;n.push({sourceModuleId:r.sourceId,targetModuleId:r.targetId,points:[[c,0,d],[g+_,0,v+C],[f,0,p]],thickness:IN(r.weight),weight:r.weight})}return n}function al(){return al=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},al.apply(null,arguments)}const jp=new X,zx=new X,LN=new X,YE=new ke;function DN(i,e,t){const n=jp.setFromMatrixPosition(i.matrixWorld);n.project(e);const r=t.width/2,s=t.height/2;return[n.x*r+r,-(n.y*s)+s]}function NN(i,e){const t=jp.setFromMatrixPosition(i.matrixWorld),n=zx.setFromMatrixPosition(e.matrixWorld),r=t.sub(n),s=e.getWorldDirection(LN);return r.angleTo(s)>Math.PI/2}function UN(i,e,t,n){const r=jp.setFromMatrixPosition(i.matrixWorld),s=r.clone();s.project(e),YE.set(s.x,s.y),t.setFromCamera(YE,e);const a=t.intersectObjects(n,!0);if(a.length){const c=a[0].distance;return r.distanceTo(t.ray.origin)<c}return!0}function ON(i,e){if(e instanceof ul)return e.zoom;if(e instanceof Di){const t=jp.setFromMatrixPosition(i.matrixWorld),n=zx.setFromMatrixPosition(e.matrixWorld),r=e.fov*Math.PI/180,s=t.distanceTo(n);return 1/(2*Math.tan(r/2)*s)}else return 1}function FN(i,e,t){if(e instanceof Di||e instanceof ul){const n=jp.setFromMatrixPosition(i.matrixWorld),r=zx.setFromMatrixPosition(e.matrixWorld),s=n.distanceTo(r),a=(t[1]-t[0])/(e.far-e.near),c=t[1]-a*e.far;return Math.round(a*s+c)}}const Fy=i=>Math.abs(i)<1e-10?0:i;function kT(i,e,t=""){let n="matrix3d(";for(let r=0;r!==16;r++)n+=Fy(e[r]*i.elements[r])+(r!==15?",":")");return t+n}const BN=(i=>e=>kT(e,i))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),zN=(i=>(e,t)=>kT(e,i(t),"translate(-50%,-50%)"))(i=>[1/i,1/i,1/i,1,-1/i,-1/i,-1/i,-1,1/i,1/i,1/i,1,1,1,1,1]);function kN(i){return i&&typeof i=="object"&&"current"in i}const il=te.forwardRef(({children:i,eps:e=.001,style:t,className:n,prepend:r,center:s,fullscreen:a,portal:c,distanceFactor:d,sprite:f=!1,transform:p=!1,occlude:g,onOcclude:v,castShadow:y,receiveShadow:E,material:T,geometry:w,zIndexRange:_=[16777271,0],calculatePosition:C=DN,as:b="div",wrapperClass:I,pointerEvents:N="auto",...O},H)=>{const{gl:B,camera:D,scene:U,size:W,raycaster:ne,events:re,viewport:he}=br(),[fe]=te.useState(()=>document.createElement(b)),ce=te.useRef(),xe=te.useRef(null),q=te.useRef(0),de=te.useRef([0,0]),se=te.useRef(null),Y=te.useRef(null),le=(c==null?void 0:c.current)||re.connected||B.domElement.parentNode,ze=te.useRef(null),ve=te.useRef(!1),Pe=te.useMemo(()=>g&&g!=="blending"||Array.isArray(g)&&g.length&&kN(g[0]),[g]);te.useLayoutEffect(()=>{const ht=B.domElement;g&&g==="blending"?(ht.style.zIndex=`${Math.floor(_[0]/2)}`,ht.style.position="absolute",ht.style.pointerEvents="none"):(ht.style.zIndex=null,ht.style.position=null,ht.style.pointerEvents=null)},[g]),te.useLayoutEffect(()=>{if(xe.current){const ht=ce.current=wM.createRoot(fe);if(U.updateMatrixWorld(),p)fe.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const pt=C(xe.current,D,W);fe.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${pt[0]}px,${pt[1]}px,0);transform-origin:0 0;`}return le&&(r?le.prepend(fe):le.appendChild(fe)),()=>{le&&le.removeChild(fe),ht.unmount()}}},[le,p]),te.useLayoutEffect(()=>{I&&(fe.className=I)},[I]);const Le=te.useMemo(()=>p?{position:"absolute",top:0,left:0,width:W.width,height:W.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:s?"translate3d(-50%,-50%,0)":"none",...a&&{top:-W.height/2,left:-W.width/2,width:W.width,height:W.height},...t},[t,s,a,W,p]),Be=te.useMemo(()=>({position:"absolute",pointerEvents:N}),[N]);te.useLayoutEffect(()=>{if(ve.current=!1,p){var ht;(ht=ce.current)==null||ht.render(te.createElement("div",{ref:se,style:Le},te.createElement("div",{ref:Y,style:Be},te.createElement("div",{ref:H,className:n,style:t,children:i}))))}else{var pt;(pt=ce.current)==null||pt.render(te.createElement("div",{ref:H,style:Le,className:n,children:i}))}});const Ke=te.useRef(!0);so(ht=>{if(xe.current){D.updateMatrixWorld(),xe.current.updateWorldMatrix(!0,!1);const pt=p?de.current:C(xe.current,D,W);if(p||Math.abs(q.current-D.zoom)>e||Math.abs(de.current[0]-pt[0])>e||Math.abs(de.current[1]-pt[1])>e){const Ve=NN(xe.current,D);let Ge=!1;Pe&&(Array.isArray(g)?Ge=g.map(dt=>dt.current):g!=="blending"&&(Ge=[U]));const K=Ke.current;if(Ge){const dt=UN(xe.current,D,ne,Ge);Ke.current=dt&&!Ve}else Ke.current=!Ve;K!==Ke.current&&(v?v(!Ke.current):fe.style.display=Ke.current?"block":"none");const At=Math.floor(_[0]/2),Je=g?Pe?[_[0],At]:[At-1,0]:_;if(fe.style.zIndex=`${FN(xe.current,D,Je)}`,p){const[dt,it]=[W.width/2,W.height/2],zt=D.projectionMatrix.elements[5]*it,{isOrthographicCamera:ot,top:Z,left:G,bottom:Se,right:Fe}=D,Xe=BN(D.matrixWorldInverse),He=ot?`scale(${zt})translate(${Fy(-(Fe+G)/2)}px,${Fy((Z+Se)/2)}px)`:`translateZ(${zt}px)`;let Mt=xe.current.matrixWorld;f&&(Mt=D.matrixWorldInverse.clone().transpose().copyPosition(Mt).scale(xe.current.scale),Mt.elements[3]=Mt.elements[7]=Mt.elements[11]=0,Mt.elements[15]=1),fe.style.width=W.width+"px",fe.style.height=W.height+"px",fe.style.perspective=ot?"":`${zt}px`,se.current&&Y.current&&(se.current.style.transform=`${He}${Xe}translate(${dt}px,${it}px)`,Y.current.style.transform=zN(Mt,1/((d||10)/400)))}else{const dt=d===void 0?1:ON(xe.current,D)*d;fe.style.transform=`translate3d(${pt[0]}px,${pt[1]}px,0) scale(${dt})`}de.current=pt,q.current=D.zoom}}if(!Pe&&ze.current&&!ve.current)if(p){if(se.current){const pt=se.current.children[0];if(pt!=null&&pt.clientWidth&&pt!=null&&pt.clientHeight){const{isOrthographicCamera:Ve}=D;if(Ve||w)O.scale&&(Array.isArray(O.scale)?O.scale instanceof X?ze.current.scale.copy(O.scale.clone().divideScalar(1)):ze.current.scale.set(1/O.scale[0],1/O.scale[1],1/O.scale[2]):ze.current.scale.setScalar(1/O.scale));else{const Ge=(d||10)/400,K=pt.clientWidth*Ge,At=pt.clientHeight*Ge;ze.current.scale.set(K,At,1)}ve.current=!0}}}else{const pt=fe.children[0];if(pt!=null&&pt.clientWidth&&pt!=null&&pt.clientHeight){const Ve=1/he.factor,Ge=pt.clientWidth*Ve,K=pt.clientHeight*Ve;ze.current.scale.set(Ge,K,1),ve.current=!0}ze.current.lookAt(ht.camera.position)}});const ft=te.useMemo(()=>({vertexShader:p?void 0:`
3900
+ `)+u.join(" > ")}return null},t.getPublicRootInstance=function(u){if(u=u.current,!u.child)return null;switch(u.child.tag){case 5:return ce(u.child.stateNode);default:return u.child.stateNode}},t.injectIntoDevTools=function(u){if(u={bundleType:u.bundleType,version:u.version,rendererPackageName:u.rendererPackageName,rendererConfig:u.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:c.ReactCurrentDispatcher,findHostInstanceByFiber:Lh,findFiberByHostInstance:u.findFiberByHostInstance||_m,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")u=!1;else{var h=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(h.isDisabled||!h.supportsFiber)u=!0;else{try{gc=h.inject(u),Xs=h}catch{}u=!!h.checkDCE}}return u},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(u,h,x,M){if(!ot)throw Error(a(363));u=So(u,h);var R=Mt(u,x,M).disconnect;return{disconnect:function(){R()}}},t.registerMutableSourceForHydration=function(u,h){var x=h._getVersion;x=x(h._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[h,x]:u.mutableSourceEagerHydrationData.push(h,x)},t.runWithPriority=function(u,h){var x=xn;try{return xn=u,h()}finally{xn=x}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(u,h,x,M){var R=h.current,L=Ln(),Q=Ls(R);return x=gm(x),h.context===null?h.context=x:h.pendingContext=x,h=lo(L,Q),h.payload={element:u},M=M===void 0?null:M,M!==null&&(h.callback=M),Xo(R,h),u=cr(R,Q,L),u!==null&&qu(u,R,Q),Q},t}),Y_}var xE;function pD(){return xE||(xE=1,W_.exports=fD()),W_.exports}var mD=pD();const gD=MM(mD);var SE=ST();const Ux={},Gp=i=>void Object.assign(Ux,i);function vD(i,e){function t(p,{args:g=[],attach:v,...y},E){let T=`${p[0].toUpperCase()}${p.slice(1)}`,w;if(p==="primitive"){if(y.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const _=y.object;w=ld(_,{type:p,root:E,attach:v,primitive:!0})}else{const _=Ux[T];if(!_)throw new Error(`R3F: ${T} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(g))throw new Error("R3F: The args prop must be an array!");w=ld(new _(...g),{type:p,root:E,attach:v,memoizedProps:{args:g}})}return w.__r3f.attach===void 0&&(w.isBufferGeometry?w.__r3f.attach="geometry":w.isMaterial&&(w.__r3f.attach="material")),T!=="inject"&&K_(w,y),w}function n(p,g){let v=!1;if(g){var y,E;(y=g.__r3f)!=null&&y.attach?q_(p,g,g.__r3f.attach):g.isObject3D&&p.isObject3D&&(p.add(g),v=!0),v||(E=p.__r3f)==null||E.objects.push(g),g.__r3f||ld(g,{}),g.__r3f.parent=p,Oy(g),cd(g)}}function r(p,g,v){let y=!1;if(g){var E,T;if((E=g.__r3f)!=null&&E.attach)q_(p,g,g.__r3f.attach);else if(g.isObject3D&&p.isObject3D){g.parent=p,g.dispatchEvent({type:"added"}),p.dispatchEvent({type:"childadded",child:g});const w=p.children.filter(C=>C!==g),_=w.indexOf(v);p.children=[...w.slice(0,_),g,...w.slice(_)],y=!0}y||(T=p.__r3f)==null||T.objects.push(g),g.__r3f||ld(g,{}),g.__r3f.parent=p,Oy(g),cd(g)}}function s(p,g,v=!1){p&&[...p].forEach(y=>a(g,y,v))}function a(p,g,v){if(g){var y,E,T;if(g.__r3f&&(g.__r3f.parent=null),(y=p.__r3f)!=null&&y.objects&&(p.__r3f.objects=p.__r3f.objects.filter(I=>I!==g)),(E=g.__r3f)!=null&&E.attach)AE(p,g,g.__r3f.attach);else if(g.isObject3D&&p.isObject3D){var w;p.remove(g),(w=g.__r3f)!=null&&w.root&&wD(Yg(g),g)}const C=(T=g.__r3f)==null?void 0:T.primitive,b=!C&&(v===void 0?g.dispose!==null:v);if(!C){var _;s((_=g.__r3f)==null?void 0:_.objects,g,b),s(g.children,g,b)}if(delete g.__r3f,b&&g.dispose&&g.type!=="Scene"){const I=()=>{try{g.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?SE.unstable_scheduleCallback(SE.unstable_IdlePriority,I):I()}cd(p)}}function c(p,g,v,y){var E;const T=(E=p.__r3f)==null?void 0:E.parent;if(!T)return;const w=t(g,v,p.__r3f.root);if(p.children){for(const _ of p.children)_.__r3f&&n(w,_);p.children=p.children.filter(_=>!_.__r3f)}p.__r3f.objects.forEach(_=>n(w,_)),p.__r3f.objects=[],p.__r3f.autoRemovedBeforeAppend||a(T,p),w.parent&&(w.__r3f.autoRemovedBeforeAppend=!0),n(T,w),w.raycast&&w.__r3f.eventCount&&Yg(w).getState().internal.interaction.push(w),[y,y.alternate].forEach(_=>{_!==null&&(_.stateNode=w,_.ref&&(typeof _.ref=="function"?_.ref(w):_.ref.current=w))})}const d=()=>{};return{reconciler:gD({createInstance:t,removeChild:a,appendChild:n,appendInitialChild:n,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(p,g)=>{if(!g)return;const v=p.getState().scene;v.__r3f&&(v.__r3f.root=p,n(v,g))},removeChildFromContainer:(p,g)=>{g&&a(p.getState().scene,g)},insertInContainerBefore:(p,g,v)=>{if(!g||!v)return;const y=p.getState().scene;y.__r3f&&r(y,g,v)},getRootHostContext:()=>null,getChildHostContext:p=>p,finalizeInitialChildren(p){var g;return!!((g=p==null?void 0:p.__r3f)!=null?g:{}).handlers},prepareUpdate(p,g,v,y){var E;if(((E=p==null?void 0:p.__r3f)!=null?E:{}).primitive&&y.object&&y.object!==p)return[!0];{const{args:w=[],children:_,...C}=y,{args:b=[],children:I,...N}=v;if(!Array.isArray(w))throw new Error("R3F: the args prop must be an array!");if(w.some((H,B)=>H!==b[B]))return[!0];const O=bT(p,C,N,!0);return O.changes.length?[!1,O]:null}},commitUpdate(p,[g,v],y,E,T,w){g?c(p,y,T,w):K_(p,v)},commitMount(p,g,v,y){var E;const T=(E=p.__r3f)!=null?E:{};p.raycast&&T.handlers&&T.eventCount&&Yg(p).getState().internal.interaction.push(p)},getPublicInstance:p=>p,prepareForCommit:()=>null,preparePortalMount:p=>ld(p.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(p){var g;const{attach:v,parent:y}=(g=p.__r3f)!=null?g:{};v&&y&&AE(y,p,v),p.isObject3D&&(p.visible=!1),cd(p)},unhideInstance(p,g){var v;const{attach:y,parent:E}=(v=p.__r3f)!=null?v:{};y&&E&&q_(E,p,y),(p.isObject3D&&g.visible==null||g.visible)&&(p.visible=!0),cd(p)},createTextInstance:d,hideTextInstance:d,unhideTextInstance:d,getCurrentEventPriority:()=>e?e():md.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&ai.fun(performance.now)?performance.now:ai.fun(Date.now)?Date.now:()=>0,scheduleTimeout:ai.fun(setTimeout)?setTimeout:void 0,cancelTimeout:ai.fun(clearTimeout)?clearTimeout:void 0}),applyProps:K_}}var EE,ME;const Z_=i=>"colorSpace"in i||"outputColorSpace"in i,ET=()=>{var i;return(i=Ux.ColorManagement)!=null?i:null},MT=i=>i&&i.isOrthographicCamera,_D=i=>i&&i.hasOwnProperty("current"),Wp=typeof window<"u"&&((EE=window.document)!=null&&EE.createElement||((ME=window.navigator)==null?void 0:ME.product)==="ReactNative")?te.useLayoutEffect:te.useEffect;function wT(i){const e=te.useRef(i);return Wp(()=>void(e.current=i),[i]),e}function yD({set:i}){return Wp(()=>(i(new Promise(()=>null)),()=>i(!1)),[i]),null}class TT extends te.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}TT.getDerivedStateFromError=()=>({error:!0});const AT="__default",wE=new Map,xD=i=>i&&!!i.memoized&&!!i.changes;function CT(i){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(i)?Math.min(Math.max(i[0],t),i[1]):i}const Bf=i=>{var e;return(e=i.__r3f)==null?void 0:e.root.getState()};function Yg(i){let e=i.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const ai={obj:i=>i===Object(i)&&!ai.arr(i)&&typeof i!="function",fun:i=>typeof i=="function",str:i=>typeof i=="string",num:i=>typeof i=="number",boo:i=>typeof i=="boolean",und:i=>i===void 0,arr:i=>Array.isArray(i),equ(i,e,{arrays:t="shallow",objects:n="reference",strict:r=!0}={}){if(typeof i!=typeof e||!!i!=!!e)return!1;if(ai.str(i)||ai.num(i)||ai.boo(i))return i===e;const s=ai.obj(i);if(s&&n==="reference")return i===e;const a=ai.arr(i);if(a&&t==="reference")return i===e;if((a||s)&&i===e)return!0;let c;for(c in i)if(!(c in e))return!1;if(s&&t==="shallow"&&n==="shallow"){for(c in r?e:i)if(!ai.equ(i[c],e[c],{strict:r,objects:"reference"}))return!1}else for(c in r?e:i)if(i[c]!==e[c])return!1;if(ai.und(c)){if(a&&i.length===0&&e.length===0||s&&Object.keys(i).length===0&&Object.keys(e).length===0)return!0;if(i!==e)return!1}return!0}};function SD(i){const e={nodes:{},materials:{}};return i&&i.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e}function ED(i){i.dispose&&i.type!=="Scene"&&i.dispose();for(const e in i)e.dispose==null||e.dispose(),delete i[e]}function ld(i,e){const t=i;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},i}function Uy(i,e){let t=i;if(e.includes("-")){const n=e.split("-"),r=n.pop();return t=n.reduce((s,a)=>s[a],i),{target:t,key:r}}else return{target:t,key:e}}const TE=/-\d+$/;function q_(i,e,t){if(ai.str(t)){if(TE.test(t)){const s=t.replace(TE,""),{target:a,key:c}=Uy(i,s);Array.isArray(a[c])||(a[c]=[])}const{target:n,key:r}=Uy(i,t);e.__r3f.previousAttach=n[r],n[r]=e}else e.__r3f.previousAttach=t(i,e)}function AE(i,e,t){var n,r;if(ai.str(t)){const{target:s,key:a}=Uy(i,t),c=e.__r3f.previousAttach;c===void 0?delete s[a]:s[a]=c}else(n=e.__r3f)==null||n.previousAttach==null||n.previousAttach(i,e);(r=e.__r3f)==null||delete r.previousAttach}function bT(i,{children:e,key:t,ref:n,...r},{children:s,key:a,ref:c,...d}={},f=!1){const p=i.__r3f,g=Object.entries(r),v=[];if(f){const E=Object.keys(d);for(let T=0;T<E.length;T++)r.hasOwnProperty(E[T])||g.unshift([E[T],AT+"remove"])}g.forEach(([E,T])=>{var w;if((w=i.__r3f)!=null&&w.primitive&&E==="object"||ai.equ(T,d[E]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(E))return v.push([E,T,!0,[]]);let _=[];E.includes("-")&&(_=E.split("-")),v.push([E,T,!1,_]);for(const C in r){const b=r[C];C.startsWith(`${E}-`)&&v.push([C,b,!1,C.split("-")])}});const y={...r};return p!=null&&p.memoizedProps&&p!=null&&p.memoizedProps.args&&(y.args=p.memoizedProps.args),p!=null&&p.memoizedProps&&p!=null&&p.memoizedProps.attach&&(y.attach=p.memoizedProps.attach),{memoized:y,changes:v}}function K_(i,e){var t;const n=i.__r3f,r=n==null?void 0:n.root,s=r==null||r.getState==null?void 0:r.getState(),{memoized:a,changes:c}=xD(e)?e:bT(i,e),d=n==null?void 0:n.eventCount;i.__r3f&&(i.__r3f.memoizedProps=a);for(let v=0;v<c.length;v++){let[y,E,T,w]=c[v];if(Z_(i)){const I="srgb",N="srgb-linear";y==="encoding"?(y="colorSpace",E=E===3001?I:N):y==="outputEncoding"&&(y="outputColorSpace",E=E===3001?I:N)}let _=i,C=_[y];if(w.length&&(C=w.reduce((b,I)=>b[I],i),!(C&&C.set))){const[b,...I]=w.reverse();_=I.reverse().reduce((N,O)=>N[O],i),y=b}if(E===AT+"remove")if(_.constructor){let b=wE.get(_.constructor);b||(b=new _.constructor,wE.set(_.constructor,b)),E=b[y]}else E=0;if(T&&n)E?n.handlers[y]=E:delete n.handlers[y],n.eventCount=Object.keys(n.handlers).length;else if(C&&C.set&&(C.copy||C instanceof Ru)){if(Array.isArray(E))C.fromArray?C.fromArray(E):C.set(...E);else if(C.copy&&E&&E.constructor&&C.constructor===E.constructor)C.copy(E);else if(E!==void 0){var f;const b=(f=C)==null?void 0:f.isColor;!b&&C.setScalar?C.setScalar(E):C instanceof Ru&&E instanceof Ru?C.mask=E.mask:C.set(E),!ET()&&s&&!s.linear&&b&&C.convertSRGBToLinear()}}else{var p;if(_[y]=E,(p=_[y])!=null&&p.isTexture&&_[y].format===Ni&&_[y].type===Oi&&s){const b=_[y];Z_(b)&&Z_(s.gl)?b.colorSpace=s.gl.outputColorSpace:b.encoding=s.gl.outputEncoding}}cd(i)}if(n&&n.parent&&i.raycast&&d!==n.eventCount){const v=Yg(i).getState().internal,y=v.interaction.indexOf(i);y>-1&&v.interaction.splice(y,1),n.eventCount&&v.interaction.push(i)}return!(c.length===1&&c[0][0]==="onUpdate")&&c.length&&(t=i.__r3f)!=null&&t.parent&&Oy(i),i}function cd(i){var e,t;const n=(e=i.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function Oy(i){i.onUpdate==null||i.onUpdate(i)}function RT(i,e){i.manual||(MT(i)?(i.left=e.width/-2,i.right=e.width/2,i.top=e.height/2,i.bottom=e.height/-2):i.aspect=e.width/e.height,i.updateProjectionMatrix(),i.updateMatrixWorld())}function Pg(i){return(i.eventObject||i.object).uuid+"/"+i.index+i.instanceId}function MD(){var i;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return md.DefaultEventPriority;switch((i=e.event)==null?void 0:i.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return md.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return md.ContinuousEventPriority;default:return md.DefaultEventPriority}}function IT(i,e,t,n){const r=t.get(e);r&&(t.delete(e),t.size===0&&(i.delete(n),r.target.releasePointerCapture(n)))}function wD(i,e){const{internal:t}=i.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,r)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((n,r)=>{IT(t.capturedMap,e,n,r)})}function TD(i){function e(d){const{internal:f}=i.getState(),p=d.offsetX-f.initialClick[0],g=d.offsetY-f.initialClick[1];return Math.round(Math.sqrt(p*p+g*g))}function t(d){return d.filter(f=>["Move","Over","Enter","Out","Leave"].some(p=>{var g;return(g=f.__r3f)==null?void 0:g.handlers["onPointer"+p]}))}function n(d,f){const p=i.getState(),g=new Set,v=[],y=f?f(p.internal.interaction):p.internal.interaction;for(let _=0;_<y.length;_++){const C=Bf(y[_]);C&&(C.raycaster.camera=void 0)}p.previousRoot||p.events.compute==null||p.events.compute(d,p);function E(_){const C=Bf(_);if(!C||!C.events.enabled||C.raycaster.camera===null)return[];if(C.raycaster.camera===void 0){var b;C.events.compute==null||C.events.compute(d,C,(b=C.previousRoot)==null?void 0:b.getState()),C.raycaster.camera===void 0&&(C.raycaster.camera=null)}return C.raycaster.camera?C.raycaster.intersectObject(_,!0):[]}let T=y.flatMap(E).sort((_,C)=>{const b=Bf(_.object),I=Bf(C.object);return!b||!I?_.distance-C.distance:I.events.priority-b.events.priority||_.distance-C.distance}).filter(_=>{const C=Pg(_);return g.has(C)?!1:(g.add(C),!0)});p.events.filter&&(T=p.events.filter(T,p));for(const _ of T){let C=_.object;for(;C;){var w;(w=C.__r3f)!=null&&w.eventCount&&v.push({..._,eventObject:C}),C=C.parent}}if("pointerId"in d&&p.internal.capturedMap.has(d.pointerId))for(let _ of p.internal.capturedMap.get(d.pointerId).values())g.has(Pg(_.intersection))||v.push(_.intersection);return v}function r(d,f,p,g){const v=i.getState();if(d.length){const y={stopped:!1};for(const E of d){const T=Bf(E.object)||v,{raycaster:w,pointer:_,camera:C,internal:b}=T,I=new X(_.x,_.y,0).unproject(C),N=U=>{var W,ne;return(W=(ne=b.capturedMap.get(U))==null?void 0:ne.has(E.eventObject))!=null?W:!1},O=U=>{const W={intersection:E,target:f.target};b.capturedMap.has(U)?b.capturedMap.get(U).set(E.eventObject,W):b.capturedMap.set(U,new Map([[E.eventObject,W]])),f.target.setPointerCapture(U)},H=U=>{const W=b.capturedMap.get(U);W&&IT(b.capturedMap,E.eventObject,W,U)};let B={};for(let U in f){let W=f[U];typeof W!="function"&&(B[U]=W)}let D={...E,...B,pointer:_,intersections:d,stopped:y.stopped,delta:p,unprojectedPoint:I,ray:w.ray,camera:C,stopPropagation(){const U="pointerId"in f&&b.capturedMap.get(f.pointerId);if((!U||U.has(E.eventObject))&&(D.stopped=y.stopped=!0,b.hovered.size&&Array.from(b.hovered.values()).find(W=>W.eventObject===E.eventObject))){const W=d.slice(0,d.indexOf(E));s([...W,E])}},target:{hasPointerCapture:N,setPointerCapture:O,releasePointerCapture:H},currentTarget:{hasPointerCapture:N,setPointerCapture:O,releasePointerCapture:H},nativeEvent:f};if(g(D),y.stopped===!0)break}}return d}function s(d){const{internal:f}=i.getState();for(const p of f.hovered.values())if(!d.length||!d.find(g=>g.object===p.object&&g.index===p.index&&g.instanceId===p.instanceId)){const v=p.eventObject.__r3f,y=v==null?void 0:v.handlers;if(f.hovered.delete(Pg(p)),v!=null&&v.eventCount){const E={...p,intersections:d};y.onPointerOut==null||y.onPointerOut(E),y.onPointerLeave==null||y.onPointerLeave(E)}}}function a(d,f){for(let p=0;p<f.length;p++){const g=f[p].__r3f;g==null||g.handlers.onPointerMissed==null||g.handlers.onPointerMissed(d)}}function c(d){switch(d){case"onPointerLeave":case"onPointerCancel":return()=>s([]);case"onLostPointerCapture":return f=>{const{internal:p}=i.getState();"pointerId"in f&&p.capturedMap.has(f.pointerId)&&requestAnimationFrame(()=>{p.capturedMap.has(f.pointerId)&&(p.capturedMap.delete(f.pointerId),s([]))})}}return function(p){const{onPointerMissed:g,internal:v}=i.getState();v.lastEvent.current=p;const y=d==="onPointerMove",E=d==="onClick"||d==="onContextMenu"||d==="onDoubleClick",w=n(p,y?t:void 0),_=E?e(p):0;d==="onPointerDown"&&(v.initialClick=[p.offsetX,p.offsetY],v.initialHits=w.map(b=>b.eventObject)),E&&!w.length&&_<=2&&(a(p,v.interaction),g&&g(p)),y&&s(w);function C(b){const I=b.eventObject,N=I.__r3f,O=N==null?void 0:N.handlers;if(N!=null&&N.eventCount)if(y){if(O.onPointerOver||O.onPointerEnter||O.onPointerOut||O.onPointerLeave){const H=Pg(b),B=v.hovered.get(H);B?B.stopped&&b.stopPropagation():(v.hovered.set(H,b),O.onPointerOver==null||O.onPointerOver(b),O.onPointerEnter==null||O.onPointerEnter(b))}O.onPointerMove==null||O.onPointerMove(b)}else{const H=O[d];H?(!E||v.initialHits.includes(I))&&(a(p,v.interaction.filter(B=>!v.initialHits.includes(B))),H(b)):E&&v.initialHits.includes(I)&&a(p,v.interaction.filter(B=>!v.initialHits.includes(B)))}}r(w,p,_,C)}}return{handlePointer:c}}const AD=["set","get","setSize","setFrameloop","setDpr","events","invalidate","advance","size","viewport"],PT=i=>!!(i!=null&&i.render),Ox=te.createContext(null),CD=(i,e)=>{const t=_T((c,d)=>{const f=new X,p=new X,g=new X;function v(_=d().camera,C=p,b=d().size){const{width:I,height:N,top:O,left:H}=b,B=I/N;C.isVector3?g.copy(C):g.set(...C);const D=_.getWorldPosition(f).distanceTo(g);if(MT(_))return{width:I/_.zoom,height:N/_.zoom,top:O,left:H,factor:1,distance:D,aspect:B};{const U=_.fov*Math.PI/180,W=2*Math.tan(U/2)*D,ne=W*(I/N);return{width:ne,height:W,top:O,left:H,factor:I/ne,distance:D,aspect:B}}}let y;const E=_=>c(C=>({performance:{...C.performance,current:_}})),T=new ke;return{set:c,get:d,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(_=1)=>i(d(),_),advance:(_,C)=>e(_,C,d()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Rx,pointer:T,mouse:T,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const _=d();y&&clearTimeout(y),_.performance.current!==_.performance.min&&E(_.performance.min),y=setTimeout(()=>E(d().performance.max),_.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:v},setEvents:_=>c(C=>({...C,events:{...C.events,..._}})),setSize:(_,C,b,I,N)=>{const O=d().camera,H={width:_,height:C,top:I||0,left:N||0,updateStyle:b};c(B=>({size:H,viewport:{...B.viewport,...v(O,p,H)}}))},setDpr:_=>c(C=>{const b=CT(_);return{viewport:{...C.viewport,dpr:b,initialDpr:C.viewport.initialDpr||b}}}),setFrameloop:(_="always")=>{const C=d().clock;C.stop(),C.elapsedTime=0,_!=="never"&&(C.start(),C.elapsedTime=0),c(()=>({frameloop:_}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:te.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(_,C,b)=>{const I=d().internal;return I.priority=I.priority+(C>0?1:0),I.subscribers.push({ref:_,priority:C,store:b}),I.subscribers=I.subscribers.sort((N,O)=>N.priority-O.priority),()=>{const N=d().internal;N!=null&&N.subscribers&&(N.priority=N.priority-(C>0?1:0),N.subscribers=N.subscribers.filter(O=>O.ref!==_))}}}}}),n=t.getState();let r=n.size,s=n.viewport.dpr,a=n.camera;return t.subscribe(()=>{const{camera:c,size:d,viewport:f,gl:p,set:g}=t.getState();if(d.width!==r.width||d.height!==r.height||f.dpr!==s){var v;r=d,s=f.dpr,RT(c,d),p.setPixelRatio(f.dpr);const y=(v=d.updateStyle)!=null?v:typeof HTMLCanvasElement<"u"&&p.domElement instanceof HTMLCanvasElement;p.setSize(d.width,d.height,y)}c!==a&&(a=c,g(y=>({viewport:{...y.viewport,...y.viewport.getCurrentViewport(c)}})))}),t.subscribe(c=>i(c)),t};let Lg,bD=new Set,RD=new Set,ID=new Set;function Q_(i,e){if(i.size)for(const{callback:t}of i.values())t(e)}function zf(i,e){switch(i){case"before":return Q_(bD,e);case"after":return Q_(RD,e);case"tail":return Q_(ID,e)}}let J_,$_;function ey(i,e,t){let n=e.clock.getDelta();for(e.frameloop==="never"&&typeof i=="number"&&(n=i-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=i),J_=e.internal.subscribers,Lg=0;Lg<J_.length;Lg++)$_=J_[Lg],$_.ref.current($_.store.getState(),n,t);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}function PD(i){let e=!1,t=!1,n,r,s;function a(f){r=requestAnimationFrame(a),e=!0,n=0,zf("before",f),t=!0;for(const g of i.values()){var p;s=g.store.getState(),s.internal.active&&(s.frameloop==="always"||s.internal.frames>0)&&!((p=s.gl.xr)!=null&&p.isPresenting)&&(n+=ey(f,s))}if(t=!1,zf("after",f),n===0)return zf("tail",f),e=!1,cancelAnimationFrame(r)}function c(f,p=1){var g;if(!f)return i.forEach(v=>c(v.store.getState(),p));(g=f.gl.xr)!=null&&g.isPresenting||!f.internal.active||f.frameloop==="never"||(p>1?f.internal.frames=Math.min(60,f.internal.frames+p):t?f.internal.frames=2:f.internal.frames=1,e||(e=!0,requestAnimationFrame(a)))}function d(f,p=!0,g,v){if(p&&zf("before",f),g)ey(f,g,v);else for(const y of i.values())ey(f,y.store.getState());p&&zf("after",f)}return{loop:a,invalidate:c,advance:d}}function Fx(){const i=te.useContext(Ox);if(!i)throw new Error("R3F: Hooks can only be used within the Canvas component!");return i}function br(i=t=>t,e){return Fx()(i,e)}function so(i,e=0){const t=Fx(),n=t.getState().internal.subscribe,r=wT(i);return Wp(()=>n(r,e,t),[e,n,t]),null}const CE=new WeakMap;function LT(i,e){return function(t,...n){let r=CE.get(t);return r||(r=new t,CE.set(t,r)),i&&i(r),Promise.all(n.map(s=>new Promise((a,c)=>r.load(s,d=>{d.scene&&Object.assign(d,SD(d.scene)),a(d)},e,d=>c(new Error(`Could not load ${s}: ${d==null?void 0:d.message}`))))))}}function wd(i,e,t,n){const r=Array.isArray(e)?e:[e],s=cD(LT(t,n),[i,...r],{equal:ai.equ});return Array.isArray(e)?s:s[0]}wd.preload=function(i,e,t){const n=Array.isArray(e)?e:[e];return uD(LT(t),[i,...n])};wd.clear=function(i,e){const t=Array.isArray(e)?e:[e];return hD([i,...t])};const Td=new Map,{invalidate:bE,advance:RE}=PD(Td),{reconciler:Cp,applyProps:Jl}=vD(Td,MD),td={objects:"shallow",strict:!1},LD=(i,e)=>{const t=typeof i=="function"?i(e):i;return PT(t)?t:new Nx({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...i})};function DD(i,e){const t=typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement;if(e){const{width:n,height:r,top:s,left:a,updateStyle:c=t}=e;return{width:n,height:r,top:s,left:a,updateStyle:c}}else if(typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement&&i.parentElement){const{width:n,height:r,top:s,left:a}=i.parentElement.getBoundingClientRect();return{width:n,height:r,top:s,left:a,updateStyle:t}}else if(typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas)return{width:i.width,height:i.height,top:0,left:0,updateStyle:t};return{width:0,height:0,top:0,left:0}}function ND(i){const e=Td.get(i),t=e==null?void 0:e.fiber,n=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,s=n||CD(bE,RE),a=t||Cp.createContainer(s,md.ConcurrentRoot,null,!1,null,"",r,null);e||Td.set(i,{fiber:a,store:s});let c,d=!1,f;return{configure(p={}){let{gl:g,size:v,scene:y,events:E,onCreated:T,shadows:w=!1,linear:_=!1,flat:C=!1,legacy:b=!1,orthographic:I=!1,frameloop:N="always",dpr:O=[1,2],performance:H,raycaster:B,camera:D,onPointerMissed:U}=p,W=s.getState(),ne=W.gl;W.gl||W.set({gl:ne=LD(g,i)});let re=W.raycaster;re||W.set({raycaster:re=new m0});const{params:he,...fe}=B||{};if(ai.equ(fe,re,td)||Jl(re,{...fe}),ai.equ(he,re.params,td)||Jl(re,{params:{...re.params,...he}}),!W.camera||W.camera===f&&!ai.equ(f,D,td)){f=D;const se=D instanceof Np,Y=se?D:I?new ul(0,0,0,0,.1,1e3):new Di(75,0,.1,1e3);se||(Y.position.z=5,D&&(Jl(Y,D),("aspect"in D||"left"in D||"right"in D||"bottom"in D||"top"in D)&&(Y.manual=!0,Y.updateProjectionMatrix())),!W.camera&&!(D!=null&&D.rotation)&&Y.lookAt(0,0,0)),W.set({camera:Y}),re.camera=Y}if(!W.scene){let se;y!=null&&y.isScene?se=y:(se=new Du,y&&Jl(se,y)),W.set({scene:ld(se)})}if(!W.xr){var ce;const se=(ze,ve)=>{const Pe=s.getState();Pe.frameloop!=="never"&&RE(ze,!0,Pe,ve)},Y=()=>{const ze=s.getState();ze.gl.xr.enabled=ze.gl.xr.isPresenting,ze.gl.xr.setAnimationLoop(ze.gl.xr.isPresenting?se:null),ze.gl.xr.isPresenting||bE(ze)},le={connect(){const ze=s.getState().gl;ze.xr.addEventListener("sessionstart",Y),ze.xr.addEventListener("sessionend",Y)},disconnect(){const ze=s.getState().gl;ze.xr.removeEventListener("sessionstart",Y),ze.xr.removeEventListener("sessionend",Y)}};typeof((ce=ne.xr)==null?void 0:ce.addEventListener)=="function"&&le.connect(),W.set({xr:le})}if(ne.shadowMap){const se=ne.shadowMap.enabled,Y=ne.shadowMap.type;if(ne.shadowMap.enabled=!!w,ai.boo(w))ne.shadowMap.type=Qf;else if(ai.str(w)){var xe;const le={basic:CM,percentage:Fv,soft:Qf,variance:Uo};ne.shadowMap.type=(xe=le[w])!=null?xe:Qf}else ai.obj(w)&&Object.assign(ne.shadowMap,w);(se!==ne.shadowMap.enabled||Y!==ne.shadowMap.type)&&(ne.shadowMap.needsUpdate=!0)}const q=ET();q&&("enabled"in q?q.enabled=!b:"legacyMode"in q&&(q.legacyMode=b)),d||Jl(ne,{outputEncoding:_?3e3:3001,toneMapping:C?zo:Bv}),W.legacy!==b&&W.set(()=>({legacy:b})),W.linear!==_&&W.set(()=>({linear:_})),W.flat!==C&&W.set(()=>({flat:C})),g&&!ai.fun(g)&&!PT(g)&&!ai.equ(g,ne,td)&&Jl(ne,g),E&&!W.events.handlers&&W.set({events:E(s)});const de=DD(i,v);return ai.equ(de,W.size,td)||W.setSize(de.width,de.height,de.updateStyle,de.top,de.left),O&&W.viewport.dpr!==CT(O)&&W.setDpr(O),W.frameloop!==N&&W.setFrameloop(N),W.onPointerMissed||W.set({onPointerMissed:U}),H&&!ai.equ(H,W.performance,td)&&W.set(se=>({performance:{...se.performance,...H}})),c=T,d=!0,this},render(p){return d||this.configure(),Cp.updateContainer(z.jsx(UD,{store:s,children:p,onCreated:c,rootElement:i}),a,null,()=>{}),s},unmount(){DT(i)}}}function UD({store:i,children:e,onCreated:t,rootElement:n}){return Wp(()=>{const r=i.getState();r.set(s=>({internal:{...s.internal,active:!0}})),t&&t(r),i.getState().events.connected||r.events.connect==null||r.events.connect(n)},[]),z.jsx(Ox.Provider,{value:i,children:e})}function DT(i,e){const t=Td.get(i),n=t==null?void 0:t.fiber;if(n){const r=t==null?void 0:t.store.getState();r&&(r.internal.active=!1),Cp.updateContainer(null,n,null,()=>{r&&setTimeout(()=>{try{var s,a,c,d;r.events.disconnect==null||r.events.disconnect(),(s=r.gl)==null||(a=s.renderLists)==null||a.dispose==null||a.dispose(),(c=r.gl)==null||c.forceContextLoss==null||c.forceContextLoss(),(d=r.gl)!=null&&d.xr&&r.xr.disconnect(),ED(r),Td.delete(i)}catch{}},500)})}}function OD(i,e,t){return z.jsx(FD,{children:i,container:e,state:t},e.uuid)}function FD({state:i={},children:e,container:t}){const{events:n,size:r,...s}=i,a=Fx(),[c]=te.useState(()=>new m0),[d]=te.useState(()=>new ke),f=te.useCallback((g,v)=>{const y={...g};Object.keys(g).forEach(T=>{(AD.includes(T)||g[T]!==v[T]&&v[T])&&delete y[T]});let E;if(v&&r){const T=v.camera;E=g.viewport.getCurrentViewport(T,new X,r),T!==g.camera&&RT(T,r)}return{...y,scene:t,raycaster:c,pointer:d,mouse:d,previousRoot:a,events:{...g.events,...v==null?void 0:v.events,...n},size:{...g.size,...r},viewport:{...g.viewport,...E},...s}},[i]),[p]=te.useState(()=>{const g=a.getState();return _T((y,E)=>({...g,scene:t,raycaster:c,pointer:d,mouse:d,previousRoot:a,events:{...g.events,...n},size:{...g.size,...r},...s,set:y,get:E,setEvents:T=>y(w=>({...w,events:{...w.events,...T}}))}))});return te.useEffect(()=>{const g=a.subscribe(v=>p.setState(y=>f(v,y)));return()=>{g()}},[f]),te.useEffect(()=>{p.setState(g=>f(a.getState(),g))},[f]),te.useEffect(()=>()=>{p.destroy()},[]),z.jsx(z.Fragment,{children:Cp.createPortal(z.jsx(Ox.Provider,{value:p,children:e}),p,null)})}Cp.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:te.version});const ty={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function BD(i){const{handlePointer:e}=TD(i);return{priority:1,enabled:!0,compute(t,n,r){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(ty).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:r}=i.getState();(t=r.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var n;const{set:r,events:s}=i.getState();s.disconnect==null||s.disconnect(),r(a=>({events:{...a.events,connected:t}})),Object.entries((n=s.handlers)!=null?n:[]).forEach(([a,c])=>{const[d,f]=ty[a];t.addEventListener(d,c,{passive:f})})},disconnect:()=>{const{set:t,events:n}=i.getState();if(n.connected){var r;Object.entries((r=n.handlers)!=null?r:[]).forEach(([s,a])=>{if(n&&n.connected instanceof HTMLElement){const[c]=ty[s];n.connected.removeEventListener(c,a)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}function IE(i,e){let t;return(...n)=>{window.clearTimeout(t),t=window.setTimeout(()=>i(...n),e)}}function zD({debounce:i,scroll:e,polyfill:t,offsetSize:n}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!r)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,a]=te.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=te.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),d=i?typeof i=="number"?i:i.scroll:null,f=i?typeof i=="number"?i:i.resize:null,p=te.useRef(!1);te.useEffect(()=>(p.current=!0,()=>void(p.current=!1)));const[g,v,y]=te.useMemo(()=>{const _=()=>{if(!c.current.element)return;const{left:C,top:b,width:I,height:N,bottom:O,right:H,x:B,y:D}=c.current.element.getBoundingClientRect(),U={left:C,top:b,width:I,height:N,bottom:O,right:H,x:B,y:D};c.current.element instanceof HTMLElement&&n&&(U.height=c.current.element.offsetHeight,U.width=c.current.element.offsetWidth),Object.freeze(U),p.current&&!GD(c.current.lastBounds,U)&&a(c.current.lastBounds=U)};return[_,f?IE(_,f):_,d?IE(_,d):_]},[a,n,d,f]);function E(){c.current.scrollContainers&&(c.current.scrollContainers.forEach(_=>_.removeEventListener("scroll",y,!0)),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null),c.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",c.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",c.current.orientationHandler))}function T(){c.current.element&&(c.current.resizeObserver=new r(y),c.current.resizeObserver.observe(c.current.element),e&&c.current.scrollContainers&&c.current.scrollContainers.forEach(_=>_.addEventListener("scroll",y,{capture:!0,passive:!0})),c.current.orientationHandler=()=>{y()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",c.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",c.current.orientationHandler))}const w=_=>{!_||_===c.current.element||(E(),c.current.element=_,c.current.scrollContainers=NT(_),T())};return HD(y,!!e),kD(v),te.useEffect(()=>{E(),T()},[e,y,v]),te.useEffect(()=>E,[]),[w,s,g]}function kD(i){te.useEffect(()=>{const e=i;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[i])}function HD(i,e){te.useEffect(()=>{if(e){const t=i;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[i,e])}function NT(i){const e=[];if(!i||i===document.body)return e;const{overflow:t,overflowX:n,overflowY:r}=window.getComputedStyle(i);return[t,n,r].some(s=>s==="auto"||s==="scroll")&&e.push(i),[...e,...NT(i.parentElement)]}const VD=["x","y","top","bottom","left","right","width","height"],GD=(i,e)=>VD.every(t=>i[t]===e[t]);var WD=Object.defineProperty,jD=Object.defineProperties,XD=Object.getOwnPropertyDescriptors,PE=Object.getOwnPropertySymbols,YD=Object.prototype.hasOwnProperty,ZD=Object.prototype.propertyIsEnumerable,LE=(i,e,t)=>e in i?WD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,DE=(i,e)=>{for(var t in e||(e={}))YD.call(e,t)&&LE(i,t,e[t]);if(PE)for(var t of PE(e))ZD.call(e,t)&&LE(i,t,e[t]);return i},qD=(i,e)=>jD(i,XD(e)),NE,UE;typeof window<"u"&&((NE=window.document)!=null&&NE.createElement||((UE=window.navigator)==null?void 0:UE.product)==="ReactNative")?te.useLayoutEffect:te.useEffect;function UT(i,e,t){if(!i)return;if(t(i)===!0)return i;let n=i.child;for(;n;){const r=UT(n,e,t);if(r)return r;n=n.sibling}}function OT(i){try{return Object.defineProperties(i,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return i}}const OE=console.error;console.error=function(){const i=[...arguments].join("");if(i!=null&&i.startsWith("Warning:")&&i.includes("useContext")){console.error=OE;return}return OE.apply(this,arguments)};const Bx=OT(te.createContext(null));class FT extends te.Component{render(){return te.createElement(Bx.Provider,{value:this._reactInternals},this.props.children)}}function KD(){const i=te.useContext(Bx);if(i===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=te.useId();return te.useMemo(()=>{for(const n of[i,i==null?void 0:i.alternate]){if(!n)continue;const r=UT(n,!1,s=>{let a=s.memoizedState;for(;a;){if(a.memoizedState===e)return!0;a=a.next}});if(r)return r}},[i,e])}function QD(){const i=KD(),[e]=te.useState(()=>new Map);e.clear();let t=i;for(;t;){if(t.type&&typeof t.type=="object"){const r=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;r&&r!==Bx&&!e.has(r)&&e.set(r,te.useContext(OT(r)))}t=t.return}return e}function JD(){const i=QD();return te.useMemo(()=>Array.from(i.keys()).reduce((e,t)=>n=>te.createElement(e,null,te.createElement(t.Provider,qD(DE({},n),{value:i.get(t)}))),e=>te.createElement(FT,DE({},e))),[i])}const $D=te.forwardRef(function({children:e,fallback:t,resize:n,style:r,gl:s,events:a=BD,eventSource:c,eventPrefix:d,shadows:f,linear:p,flat:g,legacy:v,orthographic:y,frameloop:E,dpr:T,performance:w,raycaster:_,camera:C,scene:b,onPointerMissed:I,onCreated:N,...O},H){te.useMemo(()=>Gp(iD),[]);const B=JD(),[D,U]=zD({scroll:!0,debounce:{scroll:50,resize:0},...n}),W=te.useRef(null),ne=te.useRef(null);te.useImperativeHandle(H,()=>W.current);const re=wT(I),[he,fe]=te.useState(!1),[ce,xe]=te.useState(!1);if(he)throw he;if(ce)throw ce;const q=te.useRef(null);Wp(()=>{const se=W.current;U.width>0&&U.height>0&&se&&(q.current||(q.current=ND(se)),q.current.configure({gl:s,events:a,shadows:f,linear:p,flat:g,legacy:v,orthographic:y,frameloop:E,dpr:T,performance:w,raycaster:_,camera:C,scene:b,size:U,onPointerMissed:(...Y)=>re.current==null?void 0:re.current(...Y),onCreated:Y=>{Y.events.connect==null||Y.events.connect(c?_D(c)?c.current:c:ne.current),d&&Y.setEvents({compute:(le,ze)=>{const ve=le[d+"X"],Pe=le[d+"Y"];ze.pointer.set(ve/ze.size.width*2-1,-(Pe/ze.size.height)*2+1),ze.raycaster.setFromCamera(ze.pointer,ze.camera)}}),N==null||N(Y)}}),q.current.render(z.jsx(B,{children:z.jsx(TT,{set:xe,children:z.jsx(te.Suspense,{fallback:z.jsx(yD,{set:fe}),children:e??null})})})))}),te.useEffect(()=>{const se=W.current;if(se)return()=>DT(se)},[]);const de=c?"none":"auto";return z.jsx("div",{ref:ne,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:de,...r},...O,children:z.jsx("div",{ref:D,style:{width:"100%",height:"100%"},children:z.jsx("canvas",{ref:W,style:{display:"block"},children:t})})})}),eN=te.forwardRef(function(e,t){return z.jsx(FT,{children:z.jsx($D,{...e,ref:t})})}),tN="modulepreload",nN=function(i){return"/"+i},FE={},iN=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let a=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=a(t.map(f=>{if(f=nN(f),f in FE)return;FE[f]=!0;const p=f.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":tN,p||(v.as="script"),v.crossOrigin="",v.href=f,d&&v.setAttribute("nonce",d),document.head.appendChild(v),p)return new Promise((y,E)=>{v.addEventListener("load",y),v.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return r.then(a=>{for(const c of a||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})},BE=i=>{let e;const t=new Set,n=(f,p)=>{const g=typeof f=="function"?f(e):f;if(!Object.is(g,e)){const v=e;e=p??(typeof g!="object"||g===null)?g:Object.assign({},e,g),t.forEach(y=>y(e,v))}},r=()=>e,c={setState:n,getState:r,getInitialState:()=>d,subscribe:f=>(t.add(f),()=>t.delete(f))},d=e=i(n,r,c);return c},rN=(i=>i?BE(i):BE),sN=i=>i;function oN(i,e=sN){const t=yu.useSyncExternalStore(i.subscribe,yu.useCallback(()=>e(i.getState()),[i,e]),yu.useCallback(()=>e(i.getInitialState()),[i,e]));return yu.useDebugValue(t),t}const zE=i=>{const e=rN(i),t=n=>oN(e,n);return Object.assign(t,e),t},v0=(i=>i?zE(i):zE);function ny(i){var p,g;const e=i.nodes.filter(v=>v.kind==="module"),t=new Map,n=new Map;for(const v of i.nodes){if(v.kind==="file"&&v.parentId){const y=t.get(v.parentId)??[];y.push(v),t.set(v.parentId,y)}if(v.kind==="function"&&v.parentId){const y=n.get(v.parentId)??[];y.push(v),n.set(v.parentId,y)}}const r=new Set(e.map(v=>v.id)),s=i.edges.filter(v=>r.has(v.sourceId)&&r.has(v.targetId)),a=i.edges.filter(v=>v.kind==="calls");let c=0,d=0,f=80;if(e.length>0){let v=1/0,y=-1/0,E=1/0,T=-1/0;for(const C of e){const b=(((p=C.dimensions)==null?void 0:p.width)??10)/2,I=(((g=C.dimensions)==null?void 0:g.depth)??10)/2;v=Math.min(v,C.position.x-b),y=Math.max(y,C.position.x+b),E=Math.min(E,C.position.z-I),T=Math.max(T,C.position.z+I)}c=(v+y)/2,d=(E+T)/2;const w=y-v,_=T-E;f=Math.max(w,_)*.75+20}return{modules:e,filesByModule:t,moduleEdges:s,cityCenter:{x:c,z:d},cityExtent:f,functionsByFile:n,callEdges:a}}const ni=v0(i=>({graph:null,isLoading:!1,error:null,isLive:!1,liveStatus:null,modules:[],filesByModule:new Map,moduleEdges:[],cityCenter:{x:0,z:0},cityExtent:80,functionsByFile:new Map,callEdges:[],loadGraph:async()=>{i({isLoading:!0,error:null});try{let e=await fetch("/api/graph");if(e.ok||(e=await fetch("/fixture.json")),!e.ok)throw new Error(`Failed to load graph: ${e.status}`);const t=await e.json(),n=ny(t);i({graph:t,isLoading:!1,...n})}catch(e){i({isLoading:!1,error:e instanceof Error?e.message:"Unknown error"})}},setGraph:e=>{const t=ny(e);i({graph:e,isLoading:!1,error:null,...t})},connectLive:()=>{iN(async()=>{const{connectLiveSocket:e}=await import("./websocket-CTmhT_5q.js");return{connectLiveSocket:e}},[]).then(({connectLiveSocket:e})=>{e(t=>{const n=ny(t);i({graph:t,isLive:!0,liveStatus:null,isLoading:!1,error:null,...n})},t=>i({liveStatus:t||null})),i({isLive:!0})}).catch(()=>{})}})),kE=.7,HE=2.5,VE=1,GE=1.2,aN=.25,lN=35,cN=.01,BT=.02,uN=.05,hN=.1,dN=.2,fN=.3,zT=80,nd=25,Dg=.7,pN="#22C55E",mN="#3B82F6",gN="#F59E0B",vN="#F97316",_N="#EF4444",yN=3,xN=.4,SN=2,EN=2e3,MN="#0a0a1a",wN="#0a0a1a",TN=150,AN=500,iy=12,WE=.4,jE=15,hn=v0(i=>({zoomLevel:0,selectedModuleId:null,selectedFileId:null,selectedFunctionId:null,interiorFileId:null,hoveredNodeId:null,cameraTarget:null,isSearchOpen:!1,highlightedNodeIds:new Set,highlightedEdgeKeys:new Set,selectModule:e=>{i({selectedModuleId:e,selectedFileId:null,selectedFunctionId:null})},selectFile:e=>{i({selectedFileId:e,selectedFunctionId:null})},selectFunction:e=>{i({selectedFunctionId:e})},enterBuilding:e=>{const{x:t,z:n}=e.position;i({zoomLevel:3,interiorFileId:e.id,selectedFileId:e.id,selectedModuleId:e.parentId,selectedFunctionId:null,cameraTarget:{position:[t,jE,n+12],lookAt:[t,jE*.4,n],_ts:Date.now()}})},exitBuilding:()=>{const e=hn.getState(),{graph:t}=ni.getState(),n=e.selectedModuleId;let r=null;if(n&&t){const s=t.nodes.find(a=>a.id===n);if(s){const{x:a,z:c}=s.position;r={position:[a+nd*Dg,nd,c+nd*Dg],lookAt:[a,0,c],_ts:Date.now()}}}i({zoomLevel:1,interiorFileId:null,selectedFunctionId:null,cameraTarget:r??e.cameraTarget})},clearSelection:()=>{i({selectedModuleId:null,selectedFileId:null,selectedFunctionId:null,interiorFileId:null})},setHovered:e=>{i({hoveredNodeId:e})},flyToModule:e=>{const{x:t,z:n}=e.position;i({zoomLevel:1,selectedModuleId:e.id,selectedFileId:null,selectedFunctionId:null,interiorFileId:null,cameraTarget:{position:[t+nd*Dg,nd,n+nd*Dg],lookAt:[t,0,n],_ts:Date.now()}})},flyToFile:e=>{const{x:t,z:n}=e.position;i({zoomLevel:1,selectedModuleId:e.parentId,selectedFileId:e.id,selectedFunctionId:null,interiorFileId:null,cameraTarget:{position:[t+iy*WE,iy,n+iy*WE],lookAt:[t,0,n],_ts:Date.now()}})},flyToSatellite:()=>{const{cityCenter:e,cityExtent:t}=ni.getState(),n=Math.max(zT,t);i({zoomLevel:0,selectedModuleId:null,selectedFileId:null,selectedFunctionId:null,interiorFileId:null,cameraTarget:{position:[e.x,n,e.z+.01],lookAt:[e.x,0,e.z],_ts:Date.now()}})},toggleSearch:()=>{i(e=>({isSearchOpen:!e.isSearchOpen}))},setHighlights:(e,t)=>{i({highlightedNodeIds:new Set(e),highlightedEdgeKeys:new Set(t)})},clearHighlights:()=>{i({highlightedNodeIds:new Set,highlightedEdgeKeys:new Set})}}));function CN(i){const e=[];let t=new Set;for(const n of i){t=new Set(t);for(const r of n.nodesAdded)t.add(r);for(const r of n.nodesRemoved)t.delete(r);e.push(t)}return e}const fr=v0(i=>({isTimelineActive:!1,currentSnapshotIndex:0,totalSnapshots:0,isPlaying:!1,playbackSpeed:2,visibleNodeIds:new Set,snapshots:[],_cumulativeSets:[],activateTimeline:e=>{if(e.length===0)return;const t=CN(e),n=e.length-1;i({isTimelineActive:!0,snapshots:e,totalSnapshots:e.length,currentSnapshotIndex:n,visibleNodeIds:t[n]??new Set,_cumulativeSets:t,isPlaying:!1})},deactivateTimeline:()=>{i({isTimelineActive:!1,isPlaying:!1,currentSnapshotIndex:0,totalSnapshots:0,visibleNodeIds:new Set,snapshots:[],_cumulativeSets:[]})},setSnapshot:e=>{i(t=>{const n=Math.max(0,Math.min(e,t.totalSnapshots-1));return{currentSnapshotIndex:n,visibleNodeIds:t._cumulativeSets[n]??new Set}})},play:()=>{i({isPlaying:!0})},pause:()=>{i({isPlaying:!1})},setSpeed:e=>{i({playbackSpeed:e})}}));function bN(i){const e=Math.max(i.loc,1),t=Math.max(VE,Math.sqrt(e)*kE),n=Math.max(VE,Math.sqrt(e)*kE);let r;return i.complexity>0?r=Math.max(GE,Math.log2(i.complexity+1)*HE):r=Math.max(GE,Math.sqrt(e)*aN*HE),r=Math.min(r,lN),{width:t,height:r,depth:n}}function RN(i){const e=[],t=[],n=i.nodes.filter(p=>p.kind==="module"),r=i.nodes.filter(p=>p.kind==="file");for(const p of n)e.push({id:p.id,name:p.name,x:p.position.x,z:p.position.z,width:p.dimensions.width,depth:p.dimensions.depth,totalLoc:p.loc});for(const p of r){const g=p.dimensions.width>.01?p.dimensions:bN(p);t.push({nodeId:p.id,name:p.name,x:p.position.x,y:p.position.y||g.height/2,z:p.position.z,width:g.width,height:g.height,depth:g.depth,loc:p.loc,healthScore:p.healthScore,churnScore:p.churnScore,busFactor:p.busFactor,moduleId:p.parentId??""})}let s=1/0,a=-1/0,c=1/0,d=-1/0;for(const p of e)s=Math.min(s,p.x-p.width/2),a=Math.max(a,p.x+p.width/2),c=Math.min(c,p.z-p.depth/2),d=Math.max(d,p.z+p.depth/2);const f={x:(s+a)/2||0,z:(c+d)/2||0};return{modules:e,buildings:t,center:f,bounds:{minX:s,maxX:a,minZ:c,maxZ:d}}}function IN(i){return i<=2?uN:i<=5?hN:i<=10?dN:fN}function XE(i,e,t){const n=i.width/2,r=i.depth/2,s=i.x,a=i.z,c=e-s,d=t-a;if(Math.abs(c)<.001&&Math.abs(d)<.001)return[s+n,a];const f=n/Math.abs(c||.001),p=r/Math.abs(d||.001),g=Math.min(f,p);return[s+c*g,a+d*g]}function PN(i,e){const t=new Map(i.map(r=>[r.id,r])),n=[];for(const r of e){const s=t.get(r.sourceId),a=t.get(r.targetId);if(!s||!a)continue;const[c,d]=XE(s,a.x,a.z),[f,p]=XE(a,s.x,s.z),g=(c+f)/2,v=(d+p)/2,y=f-c,E=p-d,T=Math.sqrt(y*y+E*E),w=T*.15,_=-E/(T||1)*w,C=y/(T||1)*w;n.push({sourceModuleId:r.sourceId,targetModuleId:r.targetId,points:[[c,0,d],[g+_,0,v+C],[f,0,p]],thickness:IN(r.weight),weight:r.weight})}return n}function al(){return al=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},al.apply(null,arguments)}const jp=new X,zx=new X,LN=new X,YE=new ke;function DN(i,e,t){const n=jp.setFromMatrixPosition(i.matrixWorld);n.project(e);const r=t.width/2,s=t.height/2;return[n.x*r+r,-(n.y*s)+s]}function NN(i,e){const t=jp.setFromMatrixPosition(i.matrixWorld),n=zx.setFromMatrixPosition(e.matrixWorld),r=t.sub(n),s=e.getWorldDirection(LN);return r.angleTo(s)>Math.PI/2}function UN(i,e,t,n){const r=jp.setFromMatrixPosition(i.matrixWorld),s=r.clone();s.project(e),YE.set(s.x,s.y),t.setFromCamera(YE,e);const a=t.intersectObjects(n,!0);if(a.length){const c=a[0].distance;return r.distanceTo(t.ray.origin)<c}return!0}function ON(i,e){if(e instanceof ul)return e.zoom;if(e instanceof Di){const t=jp.setFromMatrixPosition(i.matrixWorld),n=zx.setFromMatrixPosition(e.matrixWorld),r=e.fov*Math.PI/180,s=t.distanceTo(n);return 1/(2*Math.tan(r/2)*s)}else return 1}function FN(i,e,t){if(e instanceof Di||e instanceof ul){const n=jp.setFromMatrixPosition(i.matrixWorld),r=zx.setFromMatrixPosition(e.matrixWorld),s=n.distanceTo(r),a=(t[1]-t[0])/(e.far-e.near),c=t[1]-a*e.far;return Math.round(a*s+c)}}const Fy=i=>Math.abs(i)<1e-10?0:i;function kT(i,e,t=""){let n="matrix3d(";for(let r=0;r!==16;r++)n+=Fy(e[r]*i.elements[r])+(r!==15?",":")");return t+n}const BN=(i=>e=>kT(e,i))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),zN=(i=>(e,t)=>kT(e,i(t),"translate(-50%,-50%)"))(i=>[1/i,1/i,1/i,1,-1/i,-1/i,-1/i,-1,1/i,1/i,1/i,1,1,1,1,1]);function kN(i){return i&&typeof i=="object"&&"current"in i}const il=te.forwardRef(({children:i,eps:e=.001,style:t,className:n,prepend:r,center:s,fullscreen:a,portal:c,distanceFactor:d,sprite:f=!1,transform:p=!1,occlude:g,onOcclude:v,castShadow:y,receiveShadow:E,material:T,geometry:w,zIndexRange:_=[16777271,0],calculatePosition:C=DN,as:b="div",wrapperClass:I,pointerEvents:N="auto",...O},H)=>{const{gl:B,camera:D,scene:U,size:W,raycaster:ne,events:re,viewport:he}=br(),[fe]=te.useState(()=>document.createElement(b)),ce=te.useRef(),xe=te.useRef(null),q=te.useRef(0),de=te.useRef([0,0]),se=te.useRef(null),Y=te.useRef(null),le=(c==null?void 0:c.current)||re.connected||B.domElement.parentNode,ze=te.useRef(null),ve=te.useRef(!1),Pe=te.useMemo(()=>g&&g!=="blending"||Array.isArray(g)&&g.length&&kN(g[0]),[g]);te.useLayoutEffect(()=>{const ht=B.domElement;g&&g==="blending"?(ht.style.zIndex=`${Math.floor(_[0]/2)}`,ht.style.position="absolute",ht.style.pointerEvents="none"):(ht.style.zIndex=null,ht.style.position=null,ht.style.pointerEvents=null)},[g]),te.useLayoutEffect(()=>{if(xe.current){const ht=ce.current=wM.createRoot(fe);if(U.updateMatrixWorld(),p)fe.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const pt=C(xe.current,D,W);fe.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${pt[0]}px,${pt[1]}px,0);transform-origin:0 0;`}return le&&(r?le.prepend(fe):le.appendChild(fe)),()=>{le&&le.removeChild(fe),ht.unmount()}}},[le,p]),te.useLayoutEffect(()=>{I&&(fe.className=I)},[I]);const Le=te.useMemo(()=>p?{position:"absolute",top:0,left:0,width:W.width,height:W.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:s?"translate3d(-50%,-50%,0)":"none",...a&&{top:-W.height/2,left:-W.width/2,width:W.width,height:W.height},...t},[t,s,a,W,p]),Be=te.useMemo(()=>({position:"absolute",pointerEvents:N}),[N]);te.useLayoutEffect(()=>{if(ve.current=!1,p){var ht;(ht=ce.current)==null||ht.render(te.createElement("div",{ref:se,style:Le},te.createElement("div",{ref:Y,style:Be},te.createElement("div",{ref:H,className:n,style:t,children:i}))))}else{var pt;(pt=ce.current)==null||pt.render(te.createElement("div",{ref:H,style:Le,className:n,children:i}))}});const Ke=te.useRef(!0);so(ht=>{if(xe.current){D.updateMatrixWorld(),xe.current.updateWorldMatrix(!0,!1);const pt=p?de.current:C(xe.current,D,W);if(p||Math.abs(q.current-D.zoom)>e||Math.abs(de.current[0]-pt[0])>e||Math.abs(de.current[1]-pt[1])>e){const Ve=NN(xe.current,D);let Ge=!1;Pe&&(Array.isArray(g)?Ge=g.map(dt=>dt.current):g!=="blending"&&(Ge=[U]));const K=Ke.current;if(Ge){const dt=UN(xe.current,D,ne,Ge);Ke.current=dt&&!Ve}else Ke.current=!Ve;K!==Ke.current&&(v?v(!Ke.current):fe.style.display=Ke.current?"block":"none");const At=Math.floor(_[0]/2),Je=g?Pe?[_[0],At]:[At-1,0]:_;if(fe.style.zIndex=`${FN(xe.current,D,Je)}`,p){const[dt,it]=[W.width/2,W.height/2],zt=D.projectionMatrix.elements[5]*it,{isOrthographicCamera:ot,top:Z,left:G,bottom:Se,right:Fe}=D,Xe=BN(D.matrixWorldInverse),He=ot?`scale(${zt})translate(${Fy(-(Fe+G)/2)}px,${Fy((Z+Se)/2)}px)`:`translateZ(${zt}px)`;let Mt=xe.current.matrixWorld;f&&(Mt=D.matrixWorldInverse.clone().transpose().copyPosition(Mt).scale(xe.current.scale),Mt.elements[3]=Mt.elements[7]=Mt.elements[11]=0,Mt.elements[15]=1),fe.style.width=W.width+"px",fe.style.height=W.height+"px",fe.style.perspective=ot?"":`${zt}px`,se.current&&Y.current&&(se.current.style.transform=`${He}${Xe}translate(${dt}px,${it}px)`,Y.current.style.transform=zN(Mt,1/((d||10)/400)))}else{const dt=d===void 0?1:ON(xe.current,D)*d;fe.style.transform=`translate3d(${pt[0]}px,${pt[1]}px,0) scale(${dt})`}de.current=pt,q.current=D.zoom}}if(!Pe&&ze.current&&!ve.current)if(p){if(se.current){const pt=se.current.children[0];if(pt!=null&&pt.clientWidth&&pt!=null&&pt.clientHeight){const{isOrthographicCamera:Ve}=D;if(Ve||w)O.scale&&(Array.isArray(O.scale)?O.scale instanceof X?ze.current.scale.copy(O.scale.clone().divideScalar(1)):ze.current.scale.set(1/O.scale[0],1/O.scale[1],1/O.scale[2]):ze.current.scale.setScalar(1/O.scale));else{const Ge=(d||10)/400,K=pt.clientWidth*Ge,At=pt.clientHeight*Ge;ze.current.scale.set(K,At,1)}ve.current=!0}}}else{const pt=fe.children[0];if(pt!=null&&pt.clientWidth&&pt!=null&&pt.clientHeight){const Ve=1/he.factor,Ge=pt.clientWidth*Ve,K=pt.clientHeight*Ve;ze.current.scale.set(Ge,K,1),ve.current=!0}ze.current.lookAt(ht.camera.position)}});const ft=te.useMemo(()=>({vertexShader:p?void 0:`
3901
3901
  /*
3902
3902
  This shader is from the THREE's SpriteMaterial.
3903
3903
  We need to turn the backing plane into a Sprite
@@ -4525,7 +4525,7 @@ void main() {
4525
4525
  vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));
4526
4526
  gl_FragColor = vec4( clampedHdrColor , 1.0 );
4527
4527
  }
4528
- `;class AU extends li{constructor({gamma:t,offsetHdr:n,offsetSdr:r,gainMapMin:s,gainMapMax:a,maxDisplayBoost:c,hdrCapacityMin:d,hdrCapacityMax:f,sdr:p,gainMap:g}){super({name:"GainMapDecoderMaterial",vertexShader:wU,fragmentShader:TU,uniforms:{sdr:{value:p},gainMap:{value:g},gamma:{value:new X(1/t[0],1/t[1],1/t[2])},offsetHdr:{value:new X().fromArray(n)},offsetSdr:{value:new X().fromArray(r)},gainMapMin:{value:new X().fromArray(s)},gainMapMax:{value:new X().fromArray(a)},weightFactor:{value:(Math.log2(c)-d)/(f-d)}},blending:Rr,depthTest:!1,depthWrite:!1});Ci(this,"_maxDisplayBoost");Ci(this,"_hdrCapacityMin");Ci(this,"_hdrCapacityMax");this._maxDisplayBoost=c,this._hdrCapacityMin=d,this._hdrCapacityMax=f,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(t){this.uniforms.sdr.value=t}get gainMap(){return this.uniforms.gainMap.value}set gainMap(t){this.uniforms.gainMap.value=t}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(t){this.uniforms.offsetHdr.value.fromArray(t)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(t){this.uniforms.offsetSdr.value.fromArray(t)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(t){this.uniforms.gainMapMin.value.fromArray(t)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(t){this.uniforms.gainMapMax.value.fromArray(t)}get gamma(){const t=this.uniforms.gamma.value;return[1/t.x,1/t.y,1/t.z]}set gamma(t){const n=this.uniforms.gamma.value;n.x=1/t[0],n.y=1/t[1],n.z=1/t[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(t){this._hdrCapacityMin=t,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(t){this._hdrCapacityMax=t,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(t){this._maxDisplayBoost=Math.max(1,Math.min(65504,t)),this.calculateWeight()}calculateWeight(){const t=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,t))}}class eA extends MU{constructor(e,t){super({renderer:e,createMaterial:n=>new AU(n),createQuadRenderer:n=>new Vx(n)},t)}async render(e,t,n,r){const{sdrImage:s,gainMapImage:a,needsFlip:c}=await this.processImages(n,r,"flipY"),{gainMap:d,sdr:f}=this.createTextures(s,a,c);this.updateQuadRenderer(e,s,d,f,t),e.render()}}class CU extends eA{load([e,t,n],r,s,a){const c=this.prepareQuadRenderer();let d,f,p;const g=async()=>{if(d&&f&&p){try{await this.render(c,p,d,f)}catch(D){this.manager.itemError(e),this.manager.itemError(t),this.manager.itemError(n),typeof a=="function"&&a(D),c.disposeOnDemandRenderer();return}typeof r=="function"&&r(c),this.manager.itemEnd(e),this.manager.itemEnd(t),this.manager.itemEnd(n),c.disposeOnDemandRenderer()}};let v=!0,y=0,E=0,T=!0,w=0,_=0,C=!0,b=0,I=0;const N=()=>{if(typeof s=="function"){const D=y+w+b,U=E+_+I,W=v&&T&&C;s(new ProgressEvent("progress",{lengthComputable:W,loaded:U,total:D}))}};this.manager.itemStart(e),this.manager.itemStart(t),this.manager.itemStart(n);const O=new Hs(this._internalLoadingManager);O.setResponseType("arraybuffer"),O.setRequestHeader(this.requestHeader),O.setPath(this.path),O.setWithCredentials(this.withCredentials),O.load(e,async D=>{if(typeof D=="string")throw new Error("Invalid sdr buffer");d=D,await g()},D=>{v=D.lengthComputable,E=D.loaded,y=D.total,N()},D=>{this.manager.itemError(e),typeof a=="function"&&a(D)});const H=new Hs(this._internalLoadingManager);H.setResponseType("arraybuffer"),H.setRequestHeader(this.requestHeader),H.setPath(this.path),H.setWithCredentials(this.withCredentials),H.load(t,async D=>{if(typeof D=="string")throw new Error("Invalid gainmap buffer");f=D,await g()},D=>{T=D.lengthComputable,_=D.loaded,w=D.total,N()},D=>{this.manager.itemError(t),typeof a=="function"&&a(D)});const B=new Hs(this._internalLoadingManager);return B.setRequestHeader(this.requestHeader),B.setPath(this.path),B.setWithCredentials(this.withCredentials),B.load(n,async D=>{if(typeof D!="string")throw new Error("Invalid metadata string");p=JSON.parse(D),await g()},D=>{C=D.lengthComputable,I=D.loaded,b=D.total,N()},D=>{this.manager.itemError(n),typeof a=="function"&&a(D)}),c}}class bU extends eA{load(e,t,n,r){const s=this.prepareQuadRenderer(),a=new Hs(this._internalLoadingManager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),this.manager.itemStart(e),a.load(e,async c=>{if(typeof c=="string")throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const d=new Uint8Array(c);let f,p,g;try{const v=await EU(d);f=v.sdr,p=v.gainMap,g=v.metadata}catch(v){if(v instanceof $T||v instanceof JT)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),g={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},f=d;else throw v}try{await this.render(s,g,f.buffer,p==null?void 0:p.buffer)}catch(v){this.manager.itemError(e),typeof r=="function"&&r(v),s.disposeOnDemandRenderer();return}typeof t=="function"&&t(s),this.manager.itemEnd(e),s.disposeOnDemandRenderer()},n,c=>{this.manager.itemError(e),typeof r=="function"&&r(c)}),s}}const bp={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},tA="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",vd=i=>Array.isArray(i),Gx=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"];function y0({files:i=Gx,path:e="",preset:t=void 0,encoding:n=void 0,extensions:r}={}){let s=null,a=!1;t&&(Wx(t),i=bp[t],e=tA),a=vd(i);const{extension:c,isCubemap:d}=jx(i);if(s=Xx(c),!s)throw new Error("useEnvironment: Unrecognized file extension: "+i);const f=br(y=>y.gl);te.useLayoutEffect(()=>{if(c!=="webp"&&c!=="jpg"&&c!=="jpeg")return;function y(){wd.clear(s,a?[i]:i)}f.domElement.addEventListener("webglcontextlost",y,{once:!0})},[i,f.domElement]);const p=wd(s,a?[i]:i,y=>{(c==="webp"||c==="jpg"||c==="jpeg")&&y.setRenderer(f),y.setPath==null||y.setPath(e),r&&r(y)});let g=a?p[0]:p;if(c==="jpg"||c==="jpeg"||c==="webp"){var v;g=(v=g.renderTarget)==null?void 0:v.texture}return g.mapping=d?da:_d,"colorSpace"in g?g.colorSpace=n??d?"srgb":"srgb-linear":g.encoding=n??d?_U:vU,g}const RU={files:Gx,path:"",preset:void 0,extensions:void 0};y0.preload=i=>{const e={...RU,...i};let{files:t,path:n=""}=e;const{preset:r,extensions:s}=e;r&&(Wx(r),t=bp[r],n=tA);const{extension:a}=jx(t);if(a==="webp"||a==="jpg"||a==="jpeg")throw new Error("useEnvironment: Preloading gainmaps is not supported");const c=Xx(a);if(!c)throw new Error("useEnvironment: Unrecognized file extension: "+t);wd.preload(c,vd(t)?[t]:t,d=>{d.setPath==null||d.setPath(n),s&&s(d)})};const IU={files:Gx,preset:void 0};y0.clear=i=>{const e={...IU,...i};let{files:t}=e;const{preset:n}=e;n&&(Wx(n),t=bp[n]);const{extension:r}=jx(t),s=Xx(r);if(!s)throw new Error("useEnvironment: Unrecognized file extension: "+t);wd.clear(s,vd(t)?[t]:t)};function Wx(i){if(!(i in bp))throw new Error("Preset must be one of: "+Object.keys(bp).join(", "))}function jx(i){var e;const t=vd(i)&&i.length===6,n=vd(i)&&i.length===3&&i.some(a=>a.endsWith("json")),r=vd(i)?i[0]:i;return{extension:t?"cube":n?"webp":r.startsWith("data:application/exr")?"exr":r.startsWith("data:application/hdr")?"hdr":r.startsWith("data:image/jpeg")?"jpg":(e=r.split(".").pop())==null||(e=e.split("?"))==null||(e=e.shift())==null?void 0:e.toLowerCase(),isCubemap:t,isGainmap:n}}function Xx(i){return i==="cube"?qw:i==="hdr"?iU:i==="exr"?rU:i==="jpg"||i==="jpeg"?bU:i==="webp"?CU:null}const PU=i=>i.current&&i.current.isScene,LU=i=>PU(i)?i.current:i;function Yx(i,e,t,n,r={}){var s,a,c,d;r={backgroundBlurriness:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...r};const f=LU(e||t),p=f.background,g=f.environment,v={backgroundBlurriness:f.backgroundBlurriness,backgroundIntensity:f.backgroundIntensity,backgroundRotation:(s=(a=f.backgroundRotation)==null||a.clone==null?void 0:a.clone())!==null&&s!==void 0?s:[0,0,0],environmentIntensity:f.environmentIntensity,environmentRotation:(c=(d=f.environmentRotation)==null||d.clone==null?void 0:d.clone())!==null&&c!==void 0?c:[0,0,0]};return i!=="only"&&(f.environment=n),i&&(f.background=n),Jl(f,r),()=>{i!=="only"&&(f.environment=g),i&&(f.background=p),Jl(f,v)}}function Zx({scene:i,background:e=!1,map:t,...n}){const r=br(s=>s.scene);return te.useLayoutEffect(()=>{if(t)return Yx(e,i,r,t,n)}),null}function nA({background:i=!1,scene:e,blur:t,backgroundBlurriness:n,backgroundIntensity:r,backgroundRotation:s,environmentIntensity:a,environmentRotation:c,...d}){const f=y0(d),p=br(g=>g.scene);return te.useLayoutEffect(()=>Yx(i,e,p,f,{backgroundBlurriness:t??n,backgroundIntensity:r,backgroundRotation:s,environmentIntensity:a,environmentRotation:c})),te.useEffect(()=>()=>{f.dispose()},[f]),null}function DU({children:i,near:e=.1,far:t=1e3,resolution:n=256,frames:r=1,map:s,background:a=!1,blur:c,backgroundBlurriness:d,backgroundIntensity:f,backgroundRotation:p,environmentIntensity:g,environmentRotation:v,scene:y,files:E,path:T,preset:w=void 0,extensions:_}){const C=br(B=>B.gl),b=br(B=>B.scene),I=te.useRef(null),[N]=te.useState(()=>new Du),O=te.useMemo(()=>{const B=new lx(n);return B.texture.type=nr,B},[n]);te.useEffect(()=>()=>{O.dispose()},[O]),te.useLayoutEffect(()=>{if(r===1){const B=C.autoClear;C.autoClear=!0,I.current.update(C,N),C.autoClear=B}return Yx(a,y,b,O.texture,{backgroundBlurriness:c??d,backgroundIntensity:f,backgroundRotation:p,environmentIntensity:g,environmentRotation:v})},[i,N,O.texture,y,b,a,r,C]);let H=1;return so(()=>{if(r===1/0||H<r){const B=C.autoClear;C.autoClear=!0,I.current.update(C,N),C.autoClear=B,H++}}),te.createElement(te.Fragment,null,OD(te.createElement(te.Fragment,null,i,te.createElement("cubeCamera",{ref:I,args:[e,t,O]}),E||w?te.createElement(nA,{background:!0,files:E,preset:w,path:T,extensions:_}):s?te.createElement(Zx,{background:!0,map:s,extensions:_}):null),N))}function NU(i){var e,t,n,r;const s=y0(i),a=i.map||s;te.useMemo(()=>Gp({GroundProjectedEnvImpl:nU}),[]),te.useEffect(()=>()=>{s.dispose()},[s]);const c=te.useMemo(()=>[a],[a]),d=(e=i.ground)==null?void 0:e.height,f=(t=i.ground)==null?void 0:t.radius,p=(n=(r=i.ground)==null?void 0:r.scale)!==null&&n!==void 0?n:1e3;return te.createElement(te.Fragment,null,te.createElement(Zx,al({},i,{map:a})),te.createElement("groundProjectedEnvImpl",{args:c,scale:p,height:d,radius:f}))}function UU(i){return i.ground?te.createElement(NU,i):i.map?te.createElement(Zx,i):i.children?te.createElement(DU,i):te.createElement(nA,i)}function OU(){return z.jsxs(z.Fragment,{children:[z.jsx("color",{attach:"background",args:[MN]}),z.jsx("fog",{attach:"fog",args:[wN,TN,AN]}),z.jsx(UU,{preset:"night",environmentIntensity:.3})]})}function FU(){const i=te.useMemo(()=>{const t=document.createElement("canvas");t.width=256,t.height=256;const n=t.getContext("2d"),r=n.createRadialGradient(256/2,256/2,0,256/2,256/2,256/2);r.addColorStop(0,"rgba(70, 80, 160, 0.18)"),r.addColorStop(.4,"rgba(50, 60, 140, 0.08)"),r.addColorStop(.7,"rgba(30, 30, 80, 0.03)"),r.addColorStop(1,"rgba(0, 0, 0, 0)"),n.fillStyle=r,n.fillRect(0,0,256,256);const s=new Aw(t);return s.needsUpdate=!0,s},[]);return z.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.005,0],children:[z.jsx("planeGeometry",{args:[200,200]}),z.jsx("meshBasicMaterial",{map:i,transparent:!0,blending:ol,depthWrite:!1})]})}function BU(){return z.jsxs(z.Fragment,{children:[z.jsx(gU,{args:[500,500],cellSize:2,cellThickness:.3,cellColor:"#1a1a2e",sectionSize:10,sectionThickness:.5,sectionColor:"#252540",fadeDistance:200,fadeStrength:1.5,infiniteGrid:!0,position:[0,-.01,0]}),z.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.02,0],receiveShadow:!0,children:[z.jsx("planeGeometry",{args:[500,500]}),z.jsx("meshStandardMaterial",{color:"#0d0d1a",roughness:1,metalness:0})]}),z.jsx(FU,{})]})}const cM=["#4A9BD9","#D97B4A","#5BAD7A","#9B6DBF","#D9A84A","#4AD9C4","#D94A6B","#7A8BA3","#B5D94A","#D94AD9","#4A7AD9","#D9D14A"];function iA(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t)&4294967295;return Math.abs(e)}function rA(i){const e=iA(i)%cM.length;return cM[e]}function x0(i){return i>=90?pN:i>=70?mN:i>=50?gN:i>=30?vN:_N}function zU(i,e,t){const n=t!==void 0&&t!==50?x0(t):rA(i),r=(iA(`${i}:${e}`)%30-15)/100;return kU(n,r)}function kU(i,e){const t=parseInt(i.slice(1,3),16),n=parseInt(i.slice(3,5),16),r=parseInt(i.slice(5,7),16),s=a=>Math.min(255,Math.max(0,Math.round(a*(1+e))));return`#${s(t).toString(16).padStart(2,"0")}${s(n).toString(16).padStart(2,"0")}${s(r).toString(16).padStart(2,"0")}`}function HU({layout:i,isSelected:e}){const[t,n]=te.useState(!1),r=te.useRef(null),s=hn(g=>g.zoomLevel),a=hn(g=>g.flyToModule),c=ni(g=>g.modules),d=rA(i.id),f=e?.35:t?.28:.2;so(()=>{if(r.current){const g=r.current.material;g.opacity!==void 0&&(g.opacity+=(f-g.opacity)*.1)}});const p=g=>{g.stopPropagation();const v=c.find(y=>y.id===i.id);v&&a(v)};return z.jsxs("group",{position:[i.x,cN,i.z],children:[z.jsxs("mesh",{ref:r,rotation:[-Math.PI/2,0,0],onClick:p,onPointerOver:()=>n(!0),onPointerOut:()=>n(!1),children:[z.jsx("planeGeometry",{args:[i.width,i.depth]}),z.jsx("meshStandardMaterial",{color:d,transparent:!0,opacity:f,emissive:d,emissiveIntensity:t?.3:.1})]}),z.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.005,0],children:[z.jsx("planeGeometry",{args:[i.width+1.5,i.depth+1.5]}),z.jsx("meshStandardMaterial",{color:d,transparent:!0,opacity:e?.15:t?.1:.06,emissive:d,emissiveIntensity:.4})]}),z.jsxs("lineSegments",{rotation:[-Math.PI/2,0,0],children:[z.jsx("edgesGeometry",{args:[new cl(i.width,i.depth)]}),z.jsx("lineBasicMaterial",{color:d,transparent:!0,opacity:e?.8:t?.7:.55})]}),s===0&&z.jsx(il,{position:[0,2,0],center:!0,distanceFactor:80,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#fff",background:"rgba(10, 10, 26, 0.85)",padding:"6px 16px",borderRadius:"6px",fontSize:"16px",fontFamily:"system-ui, sans-serif",fontWeight:600,whiteSpace:"nowrap",border:`2px solid ${d}88`,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:i.name})})]})}const VU=`
4528
+ `;class AU extends li{constructor({gamma:t,offsetHdr:n,offsetSdr:r,gainMapMin:s,gainMapMax:a,maxDisplayBoost:c,hdrCapacityMin:d,hdrCapacityMax:f,sdr:p,gainMap:g}){super({name:"GainMapDecoderMaterial",vertexShader:wU,fragmentShader:TU,uniforms:{sdr:{value:p},gainMap:{value:g},gamma:{value:new X(1/t[0],1/t[1],1/t[2])},offsetHdr:{value:new X().fromArray(n)},offsetSdr:{value:new X().fromArray(r)},gainMapMin:{value:new X().fromArray(s)},gainMapMax:{value:new X().fromArray(a)},weightFactor:{value:(Math.log2(c)-d)/(f-d)}},blending:Rr,depthTest:!1,depthWrite:!1});Ci(this,"_maxDisplayBoost");Ci(this,"_hdrCapacityMin");Ci(this,"_hdrCapacityMax");this._maxDisplayBoost=c,this._hdrCapacityMin=d,this._hdrCapacityMax=f,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(t){this.uniforms.sdr.value=t}get gainMap(){return this.uniforms.gainMap.value}set gainMap(t){this.uniforms.gainMap.value=t}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(t){this.uniforms.offsetHdr.value.fromArray(t)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(t){this.uniforms.offsetSdr.value.fromArray(t)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(t){this.uniforms.gainMapMin.value.fromArray(t)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(t){this.uniforms.gainMapMax.value.fromArray(t)}get gamma(){const t=this.uniforms.gamma.value;return[1/t.x,1/t.y,1/t.z]}set gamma(t){const n=this.uniforms.gamma.value;n.x=1/t[0],n.y=1/t[1],n.z=1/t[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(t){this._hdrCapacityMin=t,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(t){this._hdrCapacityMax=t,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(t){this._maxDisplayBoost=Math.max(1,Math.min(65504,t)),this.calculateWeight()}calculateWeight(){const t=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,t))}}class eA extends MU{constructor(e,t){super({renderer:e,createMaterial:n=>new AU(n),createQuadRenderer:n=>new Vx(n)},t)}async render(e,t,n,r){const{sdrImage:s,gainMapImage:a,needsFlip:c}=await this.processImages(n,r,"flipY"),{gainMap:d,sdr:f}=this.createTextures(s,a,c);this.updateQuadRenderer(e,s,d,f,t),e.render()}}class CU extends eA{load([e,t,n],r,s,a){const c=this.prepareQuadRenderer();let d,f,p;const g=async()=>{if(d&&f&&p){try{await this.render(c,p,d,f)}catch(D){this.manager.itemError(e),this.manager.itemError(t),this.manager.itemError(n),typeof a=="function"&&a(D),c.disposeOnDemandRenderer();return}typeof r=="function"&&r(c),this.manager.itemEnd(e),this.manager.itemEnd(t),this.manager.itemEnd(n),c.disposeOnDemandRenderer()}};let v=!0,y=0,E=0,T=!0,w=0,_=0,C=!0,b=0,I=0;const N=()=>{if(typeof s=="function"){const D=y+w+b,U=E+_+I,W=v&&T&&C;s(new ProgressEvent("progress",{lengthComputable:W,loaded:U,total:D}))}};this.manager.itemStart(e),this.manager.itemStart(t),this.manager.itemStart(n);const O=new Hs(this._internalLoadingManager);O.setResponseType("arraybuffer"),O.setRequestHeader(this.requestHeader),O.setPath(this.path),O.setWithCredentials(this.withCredentials),O.load(e,async D=>{if(typeof D=="string")throw new Error("Invalid sdr buffer");d=D,await g()},D=>{v=D.lengthComputable,E=D.loaded,y=D.total,N()},D=>{this.manager.itemError(e),typeof a=="function"&&a(D)});const H=new Hs(this._internalLoadingManager);H.setResponseType("arraybuffer"),H.setRequestHeader(this.requestHeader),H.setPath(this.path),H.setWithCredentials(this.withCredentials),H.load(t,async D=>{if(typeof D=="string")throw new Error("Invalid gainmap buffer");f=D,await g()},D=>{T=D.lengthComputable,_=D.loaded,w=D.total,N()},D=>{this.manager.itemError(t),typeof a=="function"&&a(D)});const B=new Hs(this._internalLoadingManager);return B.setRequestHeader(this.requestHeader),B.setPath(this.path),B.setWithCredentials(this.withCredentials),B.load(n,async D=>{if(typeof D!="string")throw new Error("Invalid metadata string");p=JSON.parse(D),await g()},D=>{C=D.lengthComputable,I=D.loaded,b=D.total,N()},D=>{this.manager.itemError(n),typeof a=="function"&&a(D)}),c}}class bU extends eA{load(e,t,n,r){const s=this.prepareQuadRenderer(),a=new Hs(this._internalLoadingManager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),this.manager.itemStart(e),a.load(e,async c=>{if(typeof c=="string")throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const d=new Uint8Array(c);let f,p,g;try{const v=await EU(d);f=v.sdr,p=v.gainMap,g=v.metadata}catch(v){if(v instanceof $T||v instanceof JT)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),g={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},f=d;else throw v}try{await this.render(s,g,f.buffer,p==null?void 0:p.buffer)}catch(v){this.manager.itemError(e),typeof r=="function"&&r(v),s.disposeOnDemandRenderer();return}typeof t=="function"&&t(s),this.manager.itemEnd(e),s.disposeOnDemandRenderer()},n,c=>{this.manager.itemError(e),typeof r=="function"&&r(c)}),s}}const bp={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},tA="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",vd=i=>Array.isArray(i),Gx=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"];function y0({files:i=Gx,path:e="",preset:t=void 0,encoding:n=void 0,extensions:r}={}){let s=null,a=!1;t&&(Wx(t),i=bp[t],e=tA),a=vd(i);const{extension:c,isCubemap:d}=jx(i);if(s=Xx(c),!s)throw new Error("useEnvironment: Unrecognized file extension: "+i);const f=br(y=>y.gl);te.useLayoutEffect(()=>{if(c!=="webp"&&c!=="jpg"&&c!=="jpeg")return;function y(){wd.clear(s,a?[i]:i)}f.domElement.addEventListener("webglcontextlost",y,{once:!0})},[i,f.domElement]);const p=wd(s,a?[i]:i,y=>{(c==="webp"||c==="jpg"||c==="jpeg")&&y.setRenderer(f),y.setPath==null||y.setPath(e),r&&r(y)});let g=a?p[0]:p;if(c==="jpg"||c==="jpeg"||c==="webp"){var v;g=(v=g.renderTarget)==null?void 0:v.texture}return g.mapping=d?da:_d,"colorSpace"in g?g.colorSpace=n??d?"srgb":"srgb-linear":g.encoding=n??d?_U:vU,g}const RU={files:Gx,path:"",preset:void 0,extensions:void 0};y0.preload=i=>{const e={...RU,...i};let{files:t,path:n=""}=e;const{preset:r,extensions:s}=e;r&&(Wx(r),t=bp[r],n=tA);const{extension:a}=jx(t);if(a==="webp"||a==="jpg"||a==="jpeg")throw new Error("useEnvironment: Preloading gainmaps is not supported");const c=Xx(a);if(!c)throw new Error("useEnvironment: Unrecognized file extension: "+t);wd.preload(c,vd(t)?[t]:t,d=>{d.setPath==null||d.setPath(n),s&&s(d)})};const IU={files:Gx,preset:void 0};y0.clear=i=>{const e={...IU,...i};let{files:t}=e;const{preset:n}=e;n&&(Wx(n),t=bp[n]);const{extension:r}=jx(t),s=Xx(r);if(!s)throw new Error("useEnvironment: Unrecognized file extension: "+t);wd.clear(s,vd(t)?[t]:t)};function Wx(i){if(!(i in bp))throw new Error("Preset must be one of: "+Object.keys(bp).join(", "))}function jx(i){var e;const t=vd(i)&&i.length===6,n=vd(i)&&i.length===3&&i.some(a=>a.endsWith("json")),r=vd(i)?i[0]:i;return{extension:t?"cube":n?"webp":r.startsWith("data:application/exr")?"exr":r.startsWith("data:application/hdr")?"hdr":r.startsWith("data:image/jpeg")?"jpg":(e=r.split(".").pop())==null||(e=e.split("?"))==null||(e=e.shift())==null?void 0:e.toLowerCase(),isCubemap:t,isGainmap:n}}function Xx(i){return i==="cube"?qw:i==="hdr"?iU:i==="exr"?rU:i==="jpg"||i==="jpeg"?bU:i==="webp"?CU:null}const PU=i=>i.current&&i.current.isScene,LU=i=>PU(i)?i.current:i;function Yx(i,e,t,n,r={}){var s,a,c,d;r={backgroundBlurriness:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...r};const f=LU(e||t),p=f.background,g=f.environment,v={backgroundBlurriness:f.backgroundBlurriness,backgroundIntensity:f.backgroundIntensity,backgroundRotation:(s=(a=f.backgroundRotation)==null||a.clone==null?void 0:a.clone())!==null&&s!==void 0?s:[0,0,0],environmentIntensity:f.environmentIntensity,environmentRotation:(c=(d=f.environmentRotation)==null||d.clone==null?void 0:d.clone())!==null&&c!==void 0?c:[0,0,0]};return i!=="only"&&(f.environment=n),i&&(f.background=n),Jl(f,r),()=>{i!=="only"&&(f.environment=g),i&&(f.background=p),Jl(f,v)}}function Zx({scene:i,background:e=!1,map:t,...n}){const r=br(s=>s.scene);return te.useLayoutEffect(()=>{if(t)return Yx(e,i,r,t,n)}),null}function nA({background:i=!1,scene:e,blur:t,backgroundBlurriness:n,backgroundIntensity:r,backgroundRotation:s,environmentIntensity:a,environmentRotation:c,...d}){const f=y0(d),p=br(g=>g.scene);return te.useLayoutEffect(()=>Yx(i,e,p,f,{backgroundBlurriness:t??n,backgroundIntensity:r,backgroundRotation:s,environmentIntensity:a,environmentRotation:c})),te.useEffect(()=>()=>{f.dispose()},[f]),null}function DU({children:i,near:e=.1,far:t=1e3,resolution:n=256,frames:r=1,map:s,background:a=!1,blur:c,backgroundBlurriness:d,backgroundIntensity:f,backgroundRotation:p,environmentIntensity:g,environmentRotation:v,scene:y,files:E,path:T,preset:w=void 0,extensions:_}){const C=br(B=>B.gl),b=br(B=>B.scene),I=te.useRef(null),[N]=te.useState(()=>new Du),O=te.useMemo(()=>{const B=new lx(n);return B.texture.type=nr,B},[n]);te.useEffect(()=>()=>{O.dispose()},[O]),te.useLayoutEffect(()=>{if(r===1){const B=C.autoClear;C.autoClear=!0,I.current.update(C,N),C.autoClear=B}return Yx(a,y,b,O.texture,{backgroundBlurriness:c??d,backgroundIntensity:f,backgroundRotation:p,environmentIntensity:g,environmentRotation:v})},[i,N,O.texture,y,b,a,r,C]);let H=1;return so(()=>{if(r===1/0||H<r){const B=C.autoClear;C.autoClear=!0,I.current.update(C,N),C.autoClear=B,H++}}),te.createElement(te.Fragment,null,OD(te.createElement(te.Fragment,null,i,te.createElement("cubeCamera",{ref:I,args:[e,t,O]}),E||w?te.createElement(nA,{background:!0,files:E,preset:w,path:T,extensions:_}):s?te.createElement(Zx,{background:!0,map:s,extensions:_}):null),N))}function NU(i){var e,t,n,r;const s=y0(i),a=i.map||s;te.useMemo(()=>Gp({GroundProjectedEnvImpl:nU}),[]),te.useEffect(()=>()=>{s.dispose()},[s]);const c=te.useMemo(()=>[a],[a]),d=(e=i.ground)==null?void 0:e.height,f=(t=i.ground)==null?void 0:t.radius,p=(n=(r=i.ground)==null?void 0:r.scale)!==null&&n!==void 0?n:1e3;return te.createElement(te.Fragment,null,te.createElement(Zx,al({},i,{map:a})),te.createElement("groundProjectedEnvImpl",{args:c,scale:p,height:d,radius:f}))}function UU(i){return i.ground?te.createElement(NU,i):i.map?te.createElement(Zx,i):i.children?te.createElement(DU,i):te.createElement(nA,i)}function OU(){return z.jsxs(z.Fragment,{children:[z.jsx("color",{attach:"background",args:[MN]}),z.jsx("fog",{attach:"fog",args:[wN,TN,AN]}),z.jsx(UU,{preset:"night",environmentIntensity:.5})]})}function FU(){const i=te.useMemo(()=>{const t=document.createElement("canvas");t.width=256,t.height=256;const n=t.getContext("2d"),r=n.createRadialGradient(256/2,256/2,0,256/2,256/2,256/2);r.addColorStop(0,"rgba(80, 120, 200, 0.35)"),r.addColorStop(.4,"rgba(60, 100, 180, 0.18)"),r.addColorStop(.7,"rgba(40, 60, 120, 0.08)"),r.addColorStop(1,"rgba(0, 0, 0, 0)"),n.fillStyle=r,n.fillRect(0,0,256,256);const s=new Aw(t);return s.needsUpdate=!0,s},[]);return z.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.005,0],children:[z.jsx("planeGeometry",{args:[300,300]}),z.jsx("meshBasicMaterial",{map:i,transparent:!0,blending:ol,depthWrite:!1})]})}function BU(){return z.jsxs(z.Fragment,{children:[z.jsx(gU,{args:[500,500],cellSize:2,cellThickness:.6,cellColor:"#1a2a40",sectionSize:10,sectionThickness:1,sectionColor:"#2a4060",fadeDistance:300,fadeStrength:1,infiniteGrid:!0,position:[0,-.01,0]}),z.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.02,0],receiveShadow:!0,children:[z.jsx("planeGeometry",{args:[500,500]}),z.jsx("meshStandardMaterial",{color:"#0d0d1a",roughness:1,metalness:0})]}),z.jsx(FU,{})]})}const cM=["#5CB8FF","#FF8C5A","#6BE88E","#B589F5","#FFB84D","#5AEBD7","#FF5A8A","#8BA3C0","#C8FF5A","#E85AE8","#5A8AFF","#FFE85A"];function iA(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t)&4294967295;return Math.abs(e)}function rA(i){const e=iA(i)%cM.length;return cM[e]}function x0(i){return i>=90?pN:i>=70?mN:i>=50?gN:i>=30?vN:_N}function zU(i,e,t){const n=t!==void 0&&t!==50?x0(t):rA(i),r=(iA(`${i}:${e}`)%30-15)/100;return kU(n,r)}function kU(i,e){const t=parseInt(i.slice(1,3),16),n=parseInt(i.slice(3,5),16),r=parseInt(i.slice(5,7),16),s=a=>Math.min(255,Math.max(0,Math.round(a*(1+e))));return`#${s(t).toString(16).padStart(2,"0")}${s(n).toString(16).padStart(2,"0")}${s(r).toString(16).padStart(2,"0")}`}function HU({layout:i,isSelected:e}){const[t,n]=te.useState(!1),r=te.useRef(null),s=hn(g=>g.zoomLevel),a=hn(g=>g.flyToModule),c=ni(g=>g.modules),d=rA(i.id),f=e?.5:t?.4:.3;so(()=>{if(r.current){const g=r.current.material;g.opacity!==void 0&&(g.opacity+=(f-g.opacity)*.1)}});const p=g=>{g.stopPropagation();const v=c.find(y=>y.id===i.id);v&&a(v)};return z.jsxs("group",{position:[i.x,cN,i.z],children:[z.jsxs("mesh",{ref:r,rotation:[-Math.PI/2,0,0],onClick:p,onPointerOver:()=>n(!0),onPointerOut:()=>n(!1),children:[z.jsx("planeGeometry",{args:[i.width,i.depth]}),z.jsx("meshStandardMaterial",{color:d,transparent:!0,opacity:f,emissive:d,emissiveIntensity:t?.5:.25})]}),z.jsxs("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-.005,0],children:[z.jsx("planeGeometry",{args:[i.width+3,i.depth+3]}),z.jsx("meshStandardMaterial",{color:d,transparent:!0,opacity:e?.3:t?.2:.12,emissive:d,emissiveIntensity:.7})]}),z.jsxs("lineSegments",{rotation:[-Math.PI/2,0,0],children:[z.jsx("edgesGeometry",{args:[new cl(i.width,i.depth)]}),z.jsx("lineBasicMaterial",{color:d,transparent:!0,opacity:e?1:t?.9:.7})]}),s===0&&z.jsx(il,{position:[0,2,0],center:!0,distanceFactor:80,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#fff",background:"rgba(10, 10, 26, 0.85)",padding:"6px 16px",borderRadius:"6px",fontSize:"16px",fontFamily:"system-ui, sans-serif",fontWeight:600,whiteSpace:"nowrap",border:`2px solid ${d}88`,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:i.name})})]})}const VU=`
4529
4529
  attribute vec3 instanceColorAttr;
4530
4530
  varying vec2 vUv;
4531
4531
  varying vec3 vNormal;
@@ -4553,7 +4553,7 @@ void main() {
4553
4553
 
4554
4554
  void main() {
4555
4555
  vec3 tintColor = vColor;
4556
- vec3 baseColor = tintColor * 0.15; // dark tinted base
4556
+ vec3 baseColor = tintColor * 0.45; // brightened base
4557
4557
 
4558
4558
  // Only draw windows on side faces (not top or bottom)
4559
4559
  float isSide = 1.0 - abs(vNormal.y);
@@ -4573,7 +4573,7 @@ void main() {
4573
4573
 
4574
4574
  // Subtle time-based flicker on some windows
4575
4575
  float flickerSpeed = 1.0 + rand * 3.0;
4576
- float flicker = 0.85 + 0.15 * sin(uTime * flickerSpeed + rand * 6.28);
4576
+ float flicker = 0.7 + 0.3 * sin(uTime * flickerSpeed + rand * 6.28);
4577
4577
 
4578
4578
  // Window glow: warm white/yellow mixed with health tint
4579
4579
  vec3 warmLight = vec3(1.0, 0.92, 0.7);
@@ -4581,7 +4581,7 @@ void main() {
4581
4581
 
4582
4582
  // Rooftop: lighter tint
4583
4583
  float isTop = max(0.0, vNormal.y);
4584
- vec3 rooftopColor = tintColor * 0.35 + vec3(0.05);
4584
+ vec3 rooftopColor = tintColor * 0.65 + vec3(0.05);
4585
4585
 
4586
4586
  // Surface color
4587
4587
  vec3 surfaceColor = mix(baseColor, rooftopColor, isTop);
@@ -4591,7 +4591,7 @@ void main() {
4591
4591
 
4592
4592
  // Subtle edge glow
4593
4593
  float edgeFresnel = pow(1.0 - abs(dot(normalize(vNormal), vec3(0.0, 0.3, 0.95))), 3.0);
4594
- finalColor += tintColor * edgeFresnel * 0.15;
4594
+ finalColor += tintColor * edgeFresnel * 0.35;
4595
4595
 
4596
4596
  gl_FragColor = vec4(finalColor, 1.0);
4597
4597
  }
@@ -4608,9 +4608,9 @@ void main() {
4608
4608
  varying vec3 vColor;
4609
4609
 
4610
4610
  void main() {
4611
- gl_FragColor = vec4(vColor * 0.4, 1.0);
4611
+ gl_FragColor = vec4(vColor * 0.8, 1.0);
4612
4612
  }
4613
- `;function XU({buildings:i,moduleId:e,visible:t=!0}){const n=te.useRef(null),r=te.useMemo(()=>new Cn,[]),s=hn(y=>y.selectFile),a=hn(y=>y.setHovered),c=hn(y=>y.zoomLevel),d=te.useMemo(()=>new li({vertexShader:VU,fragmentShader:GU,uniforms:{uTime:{value:0}}}),[]),f=te.useMemo(()=>new li({vertexShader:WU,fragmentShader:jU}),[]);te.useEffect(()=>{if(!n.current||i.length===0)return;const y=n.current,E=y.geometry;for(let C=0;C<i.length;C++){const b=i[C];r.position.set(b.x,b.y,b.z),r.scale.set(b.width,b.height,b.depth),r.updateMatrix(),y.setMatrixAt(C,r.matrix)}y.instanceMatrix.needsUpdate=!0;const T=new Float32Array(i.length*3),w=new yt;for(let C=0;C<i.length;C++){const b=i[C];w.set(zU(e,b.loc,b.healthScore)),T[C*3]=w.r,T[C*3+1]=w.g,T[C*3+2]=w.b}const _=new Nu(T,3);E.setAttribute("instanceColorAttr",_),y.computeBoundingBox(),y.computeBoundingSphere()},[i,e,r]),te.useEffect(()=>{n.current&&(n.current.material=c===0?f:d)},[c,f,d]),so(({clock:y})=>{c!==0&&(d.uniforms.uTime.value=y.getElapsedTime())});const p=te.useCallback(y=>{y.stopPropagation(),y.instanceId!==void 0&&y.instanceId<i.length&&s(i[y.instanceId].nodeId)},[i,s]),g=te.useCallback(y=>{y.stopPropagation(),y.instanceId!==void 0&&y.instanceId<i.length&&(a(i[y.instanceId].nodeId),document.body.style.cursor="pointer")},[i,a]),v=te.useCallback(()=>{a(null),document.body.style.cursor="auto"},[a]);return i.length===0?null:z.jsx("instancedMesh",{ref:n,args:[void 0,void 0,i.length],castShadow:!0,receiveShadow:!0,visible:t,onClick:p,onPointerOver:g,onPointerOut:v,material:c===0?f:d,children:z.jsx("boxGeometry",{args:[1,1,1]})})}function YU({path:i}){const e=te.useRef(null),t=te.useRef(null),n=hn(p=>p.highlightedEdgeKeys),r=te.useMemo(()=>{const p=`${i.sourceModuleId}:${i.targetModuleId}`,g=`${i.targetModuleId}:${i.sourceModuleId}`;return n.has(p)||n.has(g)},[n,i.sourceModuleId,i.targetModuleId]),s=te.useMemo(()=>{const p=i.points.map(g=>new X(g[0],BT,g[2]));return new n0(p)},[i.points]),a=te.useMemo(()=>new Md(s,32,i.thickness,8,!1),[s,i.thickness]),c=te.useMemo(()=>new Md(s,32,i.thickness*3,8,!1),[s,i.thickness]),d=te.useMemo(()=>i.weight>=10?"#3B82F6":i.weight>=5?"#60A5FA":"#64748B",[i.weight]);so(({clock:p})=>{if(t.current){const g=t.current.material;r?g.opacity=.2+Math.sin(p.getElapsedTime()*2.5)*.08:g.opacity=.06+Math.sin(p.getElapsedTime()*1.5+i.weight)*.03}});const f=r?1:.6;return z.jsxs("group",{children:[z.jsx("mesh",{ref:t,geometry:c,children:z.jsx("meshBasicMaterial",{color:r?"#818CF8":d,transparent:!0,opacity:r?.2:.08,depthWrite:!1,blending:ol})}),z.jsx("mesh",{ref:e,geometry:a,children:z.jsx("meshBasicMaterial",{color:r?"#818CF8":d,transparent:!0,opacity:f})})]})}function ZU({paths:i}){return z.jsx("group",{children:i.map((e,t)=>z.jsx(YU,{path:e},`${e.sourceModuleId}-${e.targetModuleId}-${t}`))})}const qU=te.memo(ZU);function KU({buildings:i}){const e=hn(r=>r.zoomLevel),t=hn(r=>r.selectedModuleId);if(e!==1||!t)return null;const n=i.filter(r=>r.moduleId===t).slice(0,50);return z.jsx("group",{children:n.map(r=>z.jsx(il,{position:[r.x,r.y+r.height/2+.3,r.z],center:!0,distanceFactor:15,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#e2e8f0",background:"rgba(10, 10, 26, 0.7)",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontFamily:"system-ui, sans-serif",whiteSpace:"nowrap",maxWidth:"150px",overflow:"hidden",textOverflow:"ellipsis"},children:r.name})},r.nodeId))})}function QU(i){return i.split(/[\s.]+/).slice(0,2).map(e=>{var t;return((t=e[0])==null?void 0:t.toUpperCase())??""}).join("")}function JU(i){let e=0;for(let n=0;n<i.length;n++)e=(e<<5)-e+i.charCodeAt(n)&4294967295;return`hsl(${Math.abs(e)%360}, 50%, 45%)`}function $U({buildings:i}){const e=hn(s=>s.zoomLevel),t=hn(s=>s.selectedModuleId),n=ni(s=>s.graph);if(e!==1||!t||!n)return null;const r=i.filter(s=>s.moduleId===t).slice(0,30);return z.jsx("group",{children:r.map(s=>{const a=n.nodes.find(p=>p.id===s.nodeId);if(!(a!=null&&a.primaryOwner))return null;const c=a.primaryOwner,d=QU(c),f=JU(c);return z.jsx(il,{position:[s.x,s.y+s.height/2+.8,s.z],center:!0,distanceFactor:12,style:{pointerEvents:"none"},children:z.jsx("div",{title:c,style:{width:"24px",height:"24px",borderRadius:"50%",backgroundColor:f,color:"#fff",fontSize:"10px",fontWeight:600,fontFamily:"system-ui, sans-serif",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(10, 10, 26, 0.8)",boxShadow:"0 2px 4px rgba(0,0,0,0.5)"},children:d})},`avatar-${s.nodeId}`)})})}function eO(i){return i>=10?new yt("#5B9CF6").multiplyScalar(1.5):i>=5?new yt("#80B5FA").multiplyScalar(1.5):new yt("#84A8CB").multiplyScalar(1.5)}function tO({roads:i}){const{particleRoads:e,totalParticles:t}=te.useMemo(()=>{const d=[];let f=0;for(const p of i){const g=Math.min(8,SN+Math.floor(p.weight));if(f+g>EN)break;const v=[...p.points].reverse().map(T=>new X(T[0],BT+.15,T[2])),y=new n0(v),E=y.getLength();d.push({curve:y,curveLength:E,color:eO(p.weight),count:g}),f+=g}return{particleRoads:d,totalParticles:f}},[i]),n=te.useRef(new Float32Array(0)),{positions:r,colors:s}=te.useMemo(()=>{const d=new Float32Array(t*3),f=new Float32Array(t*3),p=new Float32Array(t);let g=0;for(const v of e)for(let y=0;y<v.count;y++){p[g]=y/v.count;const E=v.curve.getPointAt(p[g]);d[g*3]=E.x,d[g*3+1]=E.y,d[g*3+2]=E.z,f[g*3]=v.color.r,f[g*3+1]=v.color.g,f[g*3+2]=v.color.b,g++}return n.current=p,{positions:d,colors:f}},[e,t]),a=te.useRef(r);a.current=r;const c=te.useRef(null);return so((d,f)=>{if(!c.current||t===0)return;const g=c.current.geometry.getAttribute("position"),v=n.current;let y=0;for(const E of e){const T=yN*f/Math.max(E.curveLength,.1);for(let w=0;w<E.count;w++){let _=v[y]+T;_>1&&(_-=1),v[y]=_;const C=E.curve.getPointAt(_);g.array[y*3]=C.x,g.array[y*3+1]=C.y,g.array[y*3+2]=C.z,y++}}g.needsUpdate=!0}),t===0?null:z.jsxs("points",{ref:c,children:[z.jsxs("bufferGeometry",{children:[z.jsx("bufferAttribute",{attach:"attributes-position",array:r,count:t,itemSize:3}),z.jsx("bufferAttribute",{attach:"attributes-color",array:s,count:t,itemSize:3})]}),z.jsx("pointsMaterial",{size:xN,sizeAttenuation:!0,transparent:!0,opacity:.8,blending:ol,depthWrite:!1,vertexColors:!0})]})}function sA(i){let e=i;return()=>(e=(e*16807+0)%2147483647,(e-1)/2147483646)}function nO(i,e){const t=[],r=i.map(a=>({minX:a.x-a.width/2,maxX:a.x+a.width/2,minZ:a.z-a.depth/2,maxZ:a.z+a.depth/2}));function s(a,c){for(const d of r)if(a>=d.minX-.5&&a<=d.maxX+.5&&c>=d.minZ-.5&&c<=d.maxZ+.5)return!0;return!1}for(let a=0;a<i.length;a++)for(let c=a+1;c<i.length&&!(t.length>=150);c++){const d=i[a],f=i[c],p=(d.x+f.x)/2,g=(d.z+f.z)/2,v=Math.sqrt((d.x-f.x)**2+(d.z-f.z)**2);if(v>60||v<5)continue;const y=2+Math.floor(e()*3);for(let E=0;E<y&&!(t.length>=150);E++){const T=Math.min(v*.3,6),w=p+(e()-.5)*T,_=g+(e()-.5)*T;s(w,_)||t.push({x:w,z:_,scale:.4+e()*.6})}}return t}function iO(i,e){const t=[];for(const r of i){if(t.length>=80)break;if(r.points.length<2)continue;const s=r.points.length>=3?r.points[1]:r.points[0],a=r.points[0],c=r.points[r.points.length-1],d=c[0]-a[0],f=c[2]-a[2],p=Math.sqrt(d*d+f*f);if(p<2)continue;const g=-f/p*1.2,v=d/p*1.2,y=e()>.5?1:-1;t.push({x:s[0]+g*y,z:s[2]+v*y})}return t}function rO({trees:i}){const{trunkMesh:e,canopyMesh:t}=te.useMemo(()=>{const n=new uc(.04,.06,.5,4),r=new Ou({color:"#3d2817",roughness:.9}),s=new Ed(n,r,i.length),a=new Bp(.3,.7,5),c=new Ou({color:"#1a6b3a",roughness:.8,emissive:"#0a2a15",emissiveIntensity:.2}),d=new Ed(a,c,i.length),f=new Cn;for(let p=0;p<i.length;p++){const g=i[p];f.position.set(g.x,.25*g.scale,g.z),f.scale.set(g.scale,g.scale,g.scale),f.updateMatrix(),s.setMatrixAt(p,f.matrix),f.position.set(g.x,.85*g.scale,g.z),f.scale.set(g.scale,g.scale,g.scale),f.updateMatrix(),d.setMatrixAt(p,f.matrix)}return s.instanceMatrix.needsUpdate=!0,d.instanceMatrix.needsUpdate=!0,{trunkMesh:s,canopyMesh:d}},[i]);return i.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx("primitive",{object:e}),z.jsx("primitive",{object:t})]})}function sO({lamps:i}){const e=te.useMemo(()=>{const n=new uc(.03,.03,1.8,4),r=new Ou({color:"#4a4a5a",roughness:.6,metalness:.4}),s=new Ed(n,r,i.length),a=new Cn;for(let c=0;c<i.length;c++){const d=i[c];a.position.set(d.x,.9,d.z),a.scale.set(1,1,1),a.updateMatrix(),s.setMatrixAt(c,a.matrix)}return s.instanceMatrix.needsUpdate=!0,s},[i]),t=te.useMemo(()=>{const n=new bd(.1,6,6),r=new Ou({color:"#FFD070",emissive:"#FFD070",emissiveIntensity:2,toneMapped:!1}),s=new Ed(n,r,i.length),a=new Cn;for(let c=0;c<i.length;c++){const d=i[c];a.position.set(d.x,1.85,d.z),a.scale.set(1,1,1),a.updateMatrix(),s.setMatrixAt(c,a.matrix)}return s.instanceMatrix.needsUpdate=!0,s},[i]);return i.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx("primitive",{object:e}),z.jsx("primitive",{object:t})]})}function oO({center:i}){const{positions:r,baseY:s}=te.useMemo(()=>{const c=sA(777),d=new Float32Array(600),f=new Float32Array(200);for(let p=0;p<200;p++)d[p*3]=i.x+(c()-.5)*80*2,d[p*3+1]=2+c()*20,d[p*3+2]=i.z+(c()-.5)*80*2,f[p]=d[p*3+1];return{positions:d,baseY:f}},[i]),a=te.useRef(null);return so(({clock:c})=>{if(!a.current)return;const d=a.current.geometry.getAttribute("position"),f=c.elapsedTime;for(let p=0;p<200;p++){const g=s[p]+(f*.3+p*.37)%15,v=Math.sin(f*.2+p*1.13)*.3,y=Math.cos(f*.15+p*.91)*.3;d.array[p*3]=r[p*3]+v,d.array[p*3+1]=g>25?g-23:g,d.array[p*3+2]=r[p*3+2]+y}d.needsUpdate=!0}),z.jsxs("points",{ref:a,children:[z.jsx("bufferGeometry",{children:z.jsx("bufferAttribute",{attach:"attributes-position",array:r,count:200,itemSize:3})}),z.jsx("pointsMaterial",{size:.08,sizeAttenuation:!0,transparent:!0,opacity:.25,color:"#8090c0",blending:ol,depthWrite:!1})]})}function aO({modules:i,roads:e,center:t}){const n=te.useMemo(()=>sA(42),[]),r=te.useMemo(()=>nO(i,n),[i,n]),s=te.useMemo(()=>iO(e,n),[e,n]);return z.jsxs(z.Fragment,{children:[z.jsx(rO,{trees:r}),z.jsx(sO,{lamps:s}),z.jsx(oO,{center:t})]})}function lO(i,e,t){if(i.length===0)return{floors:[],connections:[]};const n=[...i].sort((p,g)=>(p.position.y||0)-(g.position.y||0)||p.name.localeCompare(g.name)),r=.4,s=[];let a=0;for(const p of n){const g=Math.max(.5,Math.sqrt(Math.max(p.complexity,1))*.3),v=p.tags.includes("exported");s.push({functionId:p.id,name:p.name,y:a+g/2,height:g,width:t,complexity:p.complexity,isExported:v}),a+=g+r}const c=new Set(n.map(p=>p.id)),d=[],f=new Map(s.map(p=>[p.functionId,p]));for(const p of e)if(c.has(p.sourceId)&&c.has(p.targetId)){const g=f.get(p.sourceId),v=f.get(p.targetId);g&&v&&d.push({fromId:p.sourceId,toId:p.targetId,fromY:g.y,toY:v.y})}return{floors:s,connections:d}}function cO(i){return i<=5?"#22C55E":i<=10?"#3B82F6":i<=20?"#F59E0B":i<=40?"#F97316":"#EF4444"}function uO({floor:i,buildingWidth:e,isSelected:t,onSelect:n,onHover:r}){const s=cO(i.complexity),a=t?.4:.1;return z.jsxs("group",{position:[0,i.y,0],children:[z.jsxs("mesh",{onClick:c=>{c.stopPropagation(),n(i.functionId)},onPointerOver:c=>{c.stopPropagation(),r(i.functionId),document.body.style.cursor="pointer"},onPointerOut:()=>{r(null),document.body.style.cursor="auto"},children:[z.jsx("boxGeometry",{args:[e,i.height,e*.6]}),z.jsx("meshStandardMaterial",{color:s,transparent:!0,opacity:t?.9:.7,emissive:s,emissiveIntensity:a})]}),i.isExported&&z.jsxs("mesh",{position:[e/2+.15,0,0],children:[z.jsx("sphereGeometry",{args:[.1,8,8]}),z.jsx("meshStandardMaterial",{color:"#22C55E",emissive:"#22C55E",emissiveIntensity:.5})]}),z.jsx(il,{position:[-e/2-.3,0,0],center:!0,style:{pointerEvents:"none"},children:z.jsxs("div",{style:{color:"#e2e8f0",background:"rgba(10, 10, 26, 0.8)",padding:"2px 8px",borderRadius:"3px",fontSize:"11px",fontFamily:"monospace",whiteSpace:"nowrap",borderLeft:`3px solid ${s}`},children:[i.name,i.complexity>0&&z.jsxs("span",{style:{opacity:.5,marginLeft:"6px",fontSize:"9px"},children:["cx:",i.complexity]})]})})]})}function hO(){const i=hn(_=>_.interiorFileId),e=hn(_=>_.selectedFunctionId),t=hn(_=>_.selectFunction),n=hn(_=>_.exitBuilding),r=hn(_=>_.setHovered),s=ni(_=>_.graph),a=ni(_=>_.functionsByFile),c=ni(_=>_.callEdges),d=te.useMemo(()=>!s||!i?null:s.nodes.find(_=>_.id===i)??null,[s,i]),f=te.useMemo(()=>i?a.get(i)??[]:[],[a,i]),p=te.useMemo(()=>{const _=(d==null?void 0:d.dimensions.width)??4;return lO(f,c,Math.max(_,3))},[f,c,d]),g=te.useMemo(()=>{if(!s)return[];const _=new Set(f.map(b=>b.id)),C=new Map(p.floors.map(b=>[b.functionId,b]));return c.filter(b=>_.has(b.sourceId)&&!_.has(b.targetId)).map(b=>{const I=C.get(b.sourceId),N=s.nodes.find(O=>O.id===b.targetId);return!I||!N?null:{fromY:I.y,targetName:N.name,targetId:b.targetId}}).filter(b=>b!==null).slice(0,20)},[c,f,s,p.floors]),v=te.useCallback(_=>{t(_)},[t]),y=te.useCallback(_=>{r(_)},[r]);if(!d||!i)return null;const E=Math.max(d.dimensions.width??4,3),{x:T,z:w}=d.position;return z.jsxs("group",{position:[T,0,w],children:[z.jsxs("lineSegments",{position:[0,p.floors.length>0?p.floors[p.floors.length-1].y/2:2,0],children:[z.jsx("edgesGeometry",{args:[new cc(E+.6,(p.floors.length>0?p.floors[p.floors.length-1].y+1:4)+.5,E*.6+.6)]}),z.jsx("lineBasicMaterial",{color:"#4a4a6e",transparent:!0,opacity:.4})]}),p.floors.map(_=>z.jsx(uO,{floor:_,buildingWidth:E,isSelected:_.functionId===e,onSelect:v,onHover:y},_.functionId)),p.connections.map((_,C)=>{const b=E/2+.5;return z.jsx($E,{points:[[b,_.fromY,0],[b+.8,(_.fromY+_.toY)/2,0],[b,_.toY,0]],color:"#6366f1",lineWidth:1.5,transparent:!0,opacity:.6},`conn-${C}`)}),g.map((_,C)=>z.jsxs("group",{children:[z.jsx($E,{points:[[E/2+.3,_.fromY,0],[E/2+2.5,_.fromY,0]],color:"#F59E0B",lineWidth:1,transparent:!0,opacity:.5}),z.jsx(il,{position:[E/2+3,_.fromY,0],center:!0,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#F59E0B",fontSize:"9px",fontFamily:"monospace",whiteSpace:"nowrap",opacity:.7},children:_.targetName})})]},`out-${C}`)),z.jsx(il,{position:[0,p.floors.length>0?p.floors[p.floors.length-1].y+1.5:3,0],center:!0,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#e2e8f0",background:"rgba(10, 10, 26, 0.85)",padding:"4px 12px",borderRadius:"6px",fontSize:"13px",fontFamily:"system-ui, sans-serif",fontWeight:600,whiteSpace:"nowrap",border:`1px solid ${x0(d.healthScore)}44`},children:d.name})}),z.jsx(il,{position:[0,-1.5,0],center:!0,children:z.jsx("button",{onClick:n,style:{color:"#e2e8f0",background:"rgba(30, 30, 50, 0.9)",padding:"6px 16px",borderRadius:"6px",fontSize:"12px",fontFamily:"system-ui, sans-serif",border:"1px solid #4a4a6e",cursor:"pointer"},onMouseEnter:_=>{_.target.style.background="rgba(50, 50, 80, 0.9)"},onMouseLeave:_=>{_.target.style.background="rgba(30, 30, 50, 0.9)"},children:"Exit Building"})}),p.floors.length===0&&z.jsx(il,{position:[0,2,0],center:!0,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#94a3b8",fontSize:"12px",fontFamily:"system-ui, sans-serif",textAlign:"center"},children:"No function details available for this file"})})]})}const Gg=10,dO=30,fO=50,pO=40;function mO({buildings:i}){const e=hn(s=>s.zoomLevel),{flameBuildings:t,warningBuildings:n,shimmerBuildings:r}=te.useMemo(()=>{const s=[],a=[],c=[];for(const d of i)d.churnScore>.7&&d.healthScore<40&&s.length<dO&&s.push(d),d.busFactor===1&&d.busFactor>0&&a.length<fO&&a.push(d),d.healthScore>=90&&c.length<pO&&c.push(d);return{flameBuildings:s,warningBuildings:a,shimmerBuildings:c}},[i]);return z.jsxs(z.Fragment,{children:[t.length>0&&z.jsx(gO,{buildings:t}),e>=1&&e<=2&&n.length>0&&z.jsx(vO,{buildings:n}),r.length>0&&z.jsx(_O,{buildings:r})]})}function gO({buildings:i}){const e=te.useRef(null),t=i.length*Gg,{positions:n,velocities:r,basePositions:s}=te.useMemo(()=>{const c=new Float32Array(t*3),d=new Float32Array(t),f=new Float32Array(t*3);for(let p=0;p<i.length;p++){const g=i[p];for(let v=0;v<Gg;v++){const y=(p*Gg+v)*3,E=(Math.random()-.5)*g.width*.6,T=(Math.random()-.5)*g.depth*.6,w=g.y+g.height/2;f[y]=g.x+E,f[y+1]=w,f[y+2]=g.z+T,c[y]=f[y],c[y+1]=w+Math.random()*2,c[y+2]=f[y+2],d[p*Gg+v]=.8+Math.random()*1.2}}return{positions:c,velocities:d,basePositions:f}},[i,t]),a=te.useMemo(()=>{const c=new Float32Array(t*3);for(let d=0;d<t;d++){const f=Math.random();c[d*3]=1,c[d*3+1]=.2+f*.5,c[d*3+2]=0}return c},[t]);return so((c,d)=>{if(!e.current)return;const p=e.current.geometry.getAttribute("position");if(!p)return;const g=p.array;for(let v=0;v<t;v++){const y=v*3,E=s[y+1];g[y+1]+=r[v]*d,g[y]+=(Math.random()-.5)*d*.3,g[y+2]+=(Math.random()-.5)*d*.3,g[y+1]>E+3&&(g[y]=s[y]+(Math.random()-.5)*.3,g[y+1]=E,g[y+2]=s[y+2]+(Math.random()-.5)*.3)}p.needsUpdate=!0}),t===0?null:z.jsxs("points",{ref:e,children:[z.jsxs("bufferGeometry",{children:[z.jsx("bufferAttribute",{attach:"attributes-position",args:[n,3]}),z.jsx("bufferAttribute",{attach:"attributes-color",args:[a,3]})]}),z.jsx("pointsMaterial",{size:.3,vertexColors:!0,transparent:!0,opacity:.8,blending:ol,depthWrite:!1,sizeAttenuation:!0})]})}function vO({buildings:i}){return z.jsx(z.Fragment,{children:i.map(e=>z.jsx(il,{position:[e.x,e.y+e.height/2+1.5,e.z],center:!0,style:{pointerEvents:"none"},zIndexRange:[10,0],children:z.jsx("div",{className:"text-amber-400 text-xs font-bold select-none opacity-80",title:"Bus Factor: 1 — single contributor",children:"⚠"})},`warn-${e.nodeId}`))})}function _O({buildings:i}){const e=te.useRef(null),t=te.useMemo(()=>new Cn,[]);return te.useMemo(()=>{if(e.current){for(let n=0;n<i.length;n++){const r=i[n];t.position.set(r.x,r.y+r.height/2+.5,r.z),t.scale.setScalar(.25),t.updateMatrix(),e.current.setMatrixAt(n,t.matrix)}e.current.instanceMatrix.needsUpdate=!0}},[i,t]),so(({clock:n})=>{if(!e.current)return;const r=n.getElapsedTime(),s=.2+Math.sin(r*2)*.08;for(let a=0;a<i.length;a++){const c=i[a];t.position.set(c.x,c.y+c.height/2+.5+Math.sin(r*1.5+a)*.15,c.z),t.scale.setScalar(s),t.updateMatrix(),e.current.setMatrixAt(a,t.matrix)}e.current.instanceMatrix.needsUpdate=!0}),i.length===0?null:z.jsxs("instancedMesh",{ref:e,args:[void 0,void 0,i.length],children:[z.jsx("sphereGeometry",{args:[1,8,8]}),z.jsx("meshBasicMaterial",{color:"#fbbf24",transparent:!0,opacity:.6,blending:ol,depthWrite:!1})]})}function yO({center:i}){const e=te.useRef(null),t=hn(s=>s.cameraTarget),n=hn(s=>s.flyToSatellite),r=ni(s=>s.cityExtent);return te.useEffect(()=>{if(!e.current)return;const s=Math.max(zT,r);e.current.setLookAt(i.x,s,i.z+.01,i.x,0,i.z,!1)},[i,r]),te.useEffect(()=>{if(!e.current||!t)return;const{position:s,lookAt:a}=t;e.current.setLookAt(s[0],s[1],s[2],a[0],a[1],a[2],!0)},[t]),te.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),z.jsx(pU,{ref:e,makeDefault:!0,smoothTime:.4,draggingSmoothTime:.15,dollySpeed:1,truckSpeed:2,minDistance:5,maxDistance:300,minPolarAngle:.1,maxPolarAngle:Math.PI/2.2,mouseButtons:{left:2,middle:16,right:1,wheel:16},touches:{one:128,two:4096,three:64}})}/**
4613
+ `;function XU({buildings:i,moduleId:e,visible:t=!0}){const n=te.useRef(null),r=te.useMemo(()=>new Cn,[]),s=hn(y=>y.selectFile),a=hn(y=>y.setHovered),c=hn(y=>y.zoomLevel),d=te.useMemo(()=>new li({vertexShader:VU,fragmentShader:GU,uniforms:{uTime:{value:0}}}),[]),f=te.useMemo(()=>new li({vertexShader:WU,fragmentShader:jU}),[]);te.useEffect(()=>{if(!n.current||i.length===0)return;const y=n.current,E=y.geometry;for(let C=0;C<i.length;C++){const b=i[C];r.position.set(b.x,b.y,b.z),r.scale.set(b.width,b.height,b.depth),r.updateMatrix(),y.setMatrixAt(C,r.matrix)}y.instanceMatrix.needsUpdate=!0;const T=new Float32Array(i.length*3),w=new yt;for(let C=0;C<i.length;C++){const b=i[C];w.set(zU(e,b.loc,b.healthScore)),T[C*3]=w.r,T[C*3+1]=w.g,T[C*3+2]=w.b}const _=new Nu(T,3);E.setAttribute("instanceColorAttr",_),y.computeBoundingBox(),y.computeBoundingSphere()},[i,e,r]),te.useEffect(()=>{n.current&&(n.current.material=c===0?f:d)},[c,f,d]),so(({clock:y})=>{c!==0&&(d.uniforms.uTime.value=y.getElapsedTime())});const p=te.useCallback(y=>{y.stopPropagation(),y.instanceId!==void 0&&y.instanceId<i.length&&s(i[y.instanceId].nodeId)},[i,s]),g=te.useCallback(y=>{y.stopPropagation(),y.instanceId!==void 0&&y.instanceId<i.length&&(a(i[y.instanceId].nodeId),document.body.style.cursor="pointer")},[i,a]),v=te.useCallback(()=>{a(null),document.body.style.cursor="auto"},[a]);return i.length===0?null:z.jsx("instancedMesh",{ref:n,args:[void 0,void 0,i.length],castShadow:!0,receiveShadow:!0,visible:t,onClick:p,onPointerOver:g,onPointerOut:v,material:c===0?f:d,children:z.jsx("boxGeometry",{args:[1,1,1]})})}function YU({path:i}){const e=te.useRef(null),t=te.useRef(null),n=hn(p=>p.highlightedEdgeKeys),r=te.useMemo(()=>{const p=`${i.sourceModuleId}:${i.targetModuleId}`,g=`${i.targetModuleId}:${i.sourceModuleId}`;return n.has(p)||n.has(g)},[n,i.sourceModuleId,i.targetModuleId]),s=te.useMemo(()=>{const p=i.points.map(g=>new X(g[0],BT,g[2]));return new n0(p)},[i.points]),a=te.useMemo(()=>new Md(s,32,i.thickness,8,!1),[s,i.thickness]),c=te.useMemo(()=>new Md(s,32,i.thickness*5,8,!1),[s,i.thickness]),d=te.useMemo(()=>i.weight>=10?"#60A5FA":i.weight>=5?"#38BDF8":"#7C9CC0",[i.weight]);so(({clock:p})=>{if(t.current){const g=t.current.material;r?g.opacity=.5+Math.sin(p.getElapsedTime()*2.5)*.15:g.opacity=.2+Math.sin(p.getElapsedTime()*1.5+i.weight)*.08}});const f=r?1:.85;return z.jsxs("group",{children:[z.jsx("mesh",{ref:t,geometry:c,children:z.jsx("meshBasicMaterial",{color:r?"#818CF8":d,transparent:!0,opacity:r?.5:.2,depthWrite:!1,blending:ol})}),z.jsx("mesh",{ref:e,geometry:a,children:z.jsx("meshBasicMaterial",{color:r?"#818CF8":d,transparent:!0,opacity:f})})]})}function ZU({paths:i}){return z.jsx("group",{children:i.map((e,t)=>z.jsx(YU,{path:e},`${e.sourceModuleId}-${e.targetModuleId}-${t}`))})}const qU=te.memo(ZU);function KU({buildings:i}){const e=hn(r=>r.zoomLevel),t=hn(r=>r.selectedModuleId);if(e!==1||!t)return null;const n=i.filter(r=>r.moduleId===t).slice(0,50);return z.jsx("group",{children:n.map(r=>z.jsx(il,{position:[r.x,r.y+r.height/2+.3,r.z],center:!0,distanceFactor:15,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#e2e8f0",background:"rgba(10, 10, 26, 0.7)",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontFamily:"system-ui, sans-serif",whiteSpace:"nowrap",maxWidth:"150px",overflow:"hidden",textOverflow:"ellipsis"},children:r.name})},r.nodeId))})}function QU(i){return i.split(/[\s.]+/).slice(0,2).map(e=>{var t;return((t=e[0])==null?void 0:t.toUpperCase())??""}).join("")}function JU(i){let e=0;for(let n=0;n<i.length;n++)e=(e<<5)-e+i.charCodeAt(n)&4294967295;return`hsl(${Math.abs(e)%360}, 50%, 45%)`}function $U({buildings:i}){const e=hn(s=>s.zoomLevel),t=hn(s=>s.selectedModuleId),n=ni(s=>s.graph);if(e!==1||!t||!n)return null;const r=i.filter(s=>s.moduleId===t).slice(0,30);return z.jsx("group",{children:r.map(s=>{const a=n.nodes.find(p=>p.id===s.nodeId);if(!(a!=null&&a.primaryOwner))return null;const c=a.primaryOwner,d=QU(c),f=JU(c);return z.jsx(il,{position:[s.x,s.y+s.height/2+.8,s.z],center:!0,distanceFactor:12,style:{pointerEvents:"none"},children:z.jsx("div",{title:c,style:{width:"24px",height:"24px",borderRadius:"50%",backgroundColor:f,color:"#fff",fontSize:"10px",fontWeight:600,fontFamily:"system-ui, sans-serif",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(10, 10, 26, 0.8)",boxShadow:"0 2px 4px rgba(0,0,0,0.5)"},children:d})},`avatar-${s.nodeId}`)})})}function eO(i){return i>=10?new yt("#5B9CF6").multiplyScalar(1.5):i>=5?new yt("#80B5FA").multiplyScalar(1.5):new yt("#84A8CB").multiplyScalar(1.5)}function tO({roads:i}){const{particleRoads:e,totalParticles:t}=te.useMemo(()=>{const d=[];let f=0;for(const p of i){const g=Math.min(8,SN+Math.floor(p.weight));if(f+g>EN)break;const v=[...p.points].reverse().map(T=>new X(T[0],BT+.15,T[2])),y=new n0(v),E=y.getLength();d.push({curve:y,curveLength:E,color:eO(p.weight),count:g}),f+=g}return{particleRoads:d,totalParticles:f}},[i]),n=te.useRef(new Float32Array(0)),{positions:r,colors:s}=te.useMemo(()=>{const d=new Float32Array(t*3),f=new Float32Array(t*3),p=new Float32Array(t);let g=0;for(const v of e)for(let y=0;y<v.count;y++){p[g]=y/v.count;const E=v.curve.getPointAt(p[g]);d[g*3]=E.x,d[g*3+1]=E.y,d[g*3+2]=E.z,f[g*3]=v.color.r,f[g*3+1]=v.color.g,f[g*3+2]=v.color.b,g++}return n.current=p,{positions:d,colors:f}},[e,t]),a=te.useRef(r);a.current=r;const c=te.useRef(null);return so((d,f)=>{if(!c.current||t===0)return;const g=c.current.geometry.getAttribute("position"),v=n.current;let y=0;for(const E of e){const T=yN*f/Math.max(E.curveLength,.1);for(let w=0;w<E.count;w++){let _=v[y]+T;_>1&&(_-=1),v[y]=_;const C=E.curve.getPointAt(_);g.array[y*3]=C.x,g.array[y*3+1]=C.y,g.array[y*3+2]=C.z,y++}}g.needsUpdate=!0}),t===0?null:z.jsxs("points",{ref:c,children:[z.jsxs("bufferGeometry",{children:[z.jsx("bufferAttribute",{attach:"attributes-position",array:r,count:t,itemSize:3}),z.jsx("bufferAttribute",{attach:"attributes-color",array:s,count:t,itemSize:3})]}),z.jsx("pointsMaterial",{size:xN,sizeAttenuation:!0,transparent:!0,opacity:.8,blending:ol,depthWrite:!1,vertexColors:!0})]})}function sA(i){let e=i;return()=>(e=(e*16807+0)%2147483647,(e-1)/2147483646)}function nO(i,e){const t=[],r=i.map(a=>({minX:a.x-a.width/2,maxX:a.x+a.width/2,minZ:a.z-a.depth/2,maxZ:a.z+a.depth/2}));function s(a,c){for(const d of r)if(a>=d.minX-.5&&a<=d.maxX+.5&&c>=d.minZ-.5&&c<=d.maxZ+.5)return!0;return!1}for(let a=0;a<i.length;a++)for(let c=a+1;c<i.length&&!(t.length>=150);c++){const d=i[a],f=i[c],p=(d.x+f.x)/2,g=(d.z+f.z)/2,v=Math.sqrt((d.x-f.x)**2+(d.z-f.z)**2);if(v>60||v<5)continue;const y=2+Math.floor(e()*3);for(let E=0;E<y&&!(t.length>=150);E++){const T=Math.min(v*.3,6),w=p+(e()-.5)*T,_=g+(e()-.5)*T;s(w,_)||t.push({x:w,z:_,scale:.4+e()*.6})}}return t}function iO(i,e){const t=[];for(const r of i){if(t.length>=80)break;if(r.points.length<2)continue;const s=r.points.length>=3?r.points[1]:r.points[0],a=r.points[0],c=r.points[r.points.length-1],d=c[0]-a[0],f=c[2]-a[2],p=Math.sqrt(d*d+f*f);if(p<2)continue;const g=-f/p*1.2,v=d/p*1.2,y=e()>.5?1:-1;t.push({x:s[0]+g*y,z:s[2]+v*y})}return t}function rO({trees:i}){const{trunkMesh:e,canopyMesh:t}=te.useMemo(()=>{const n=new uc(.04,.06,.5,4),r=new Ou({color:"#3d2817",roughness:.9}),s=new Ed(n,r,i.length),a=new Bp(.3,.7,5),c=new Ou({color:"#1a6b3a",roughness:.8,emissive:"#0a2a15",emissiveIntensity:.2}),d=new Ed(a,c,i.length),f=new Cn;for(let p=0;p<i.length;p++){const g=i[p];f.position.set(g.x,.25*g.scale,g.z),f.scale.set(g.scale,g.scale,g.scale),f.updateMatrix(),s.setMatrixAt(p,f.matrix),f.position.set(g.x,.85*g.scale,g.z),f.scale.set(g.scale,g.scale,g.scale),f.updateMatrix(),d.setMatrixAt(p,f.matrix)}return s.instanceMatrix.needsUpdate=!0,d.instanceMatrix.needsUpdate=!0,{trunkMesh:s,canopyMesh:d}},[i]);return i.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx("primitive",{object:e}),z.jsx("primitive",{object:t})]})}function sO({lamps:i}){const e=te.useMemo(()=>{const n=new uc(.03,.03,1.8,4),r=new Ou({color:"#4a4a5a",roughness:.6,metalness:.4}),s=new Ed(n,r,i.length),a=new Cn;for(let c=0;c<i.length;c++){const d=i[c];a.position.set(d.x,.9,d.z),a.scale.set(1,1,1),a.updateMatrix(),s.setMatrixAt(c,a.matrix)}return s.instanceMatrix.needsUpdate=!0,s},[i]),t=te.useMemo(()=>{const n=new bd(.1,6,6),r=new Ou({color:"#FFD070",emissive:"#FFD070",emissiveIntensity:2,toneMapped:!1}),s=new Ed(n,r,i.length),a=new Cn;for(let c=0;c<i.length;c++){const d=i[c];a.position.set(d.x,1.85,d.z),a.scale.set(1,1,1),a.updateMatrix(),s.setMatrixAt(c,a.matrix)}return s.instanceMatrix.needsUpdate=!0,s},[i]);return i.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx("primitive",{object:e}),z.jsx("primitive",{object:t})]})}function oO({center:i}){const{positions:r,baseY:s}=te.useMemo(()=>{const c=sA(777),d=new Float32Array(600),f=new Float32Array(200);for(let p=0;p<200;p++)d[p*3]=i.x+(c()-.5)*80*2,d[p*3+1]=2+c()*20,d[p*3+2]=i.z+(c()-.5)*80*2,f[p]=d[p*3+1];return{positions:d,baseY:f}},[i]),a=te.useRef(null);return so(({clock:c})=>{if(!a.current)return;const d=a.current.geometry.getAttribute("position"),f=c.elapsedTime;for(let p=0;p<200;p++){const g=s[p]+(f*.3+p*.37)%15,v=Math.sin(f*.2+p*1.13)*.3,y=Math.cos(f*.15+p*.91)*.3;d.array[p*3]=r[p*3]+v,d.array[p*3+1]=g>25?g-23:g,d.array[p*3+2]=r[p*3+2]+y}d.needsUpdate=!0}),z.jsxs("points",{ref:a,children:[z.jsx("bufferGeometry",{children:z.jsx("bufferAttribute",{attach:"attributes-position",array:r,count:200,itemSize:3})}),z.jsx("pointsMaterial",{size:.08,sizeAttenuation:!0,transparent:!0,opacity:.25,color:"#8090c0",blending:ol,depthWrite:!1})]})}function aO({modules:i,roads:e,center:t}){const n=te.useMemo(()=>sA(42),[]),r=te.useMemo(()=>nO(i,n),[i,n]),s=te.useMemo(()=>iO(e,n),[e,n]);return z.jsxs(z.Fragment,{children:[z.jsx(rO,{trees:r}),z.jsx(sO,{lamps:s}),z.jsx(oO,{center:t})]})}function lO(i,e,t){if(i.length===0)return{floors:[],connections:[]};const n=[...i].sort((p,g)=>(p.position.y||0)-(g.position.y||0)||p.name.localeCompare(g.name)),r=.4,s=[];let a=0;for(const p of n){const g=Math.max(.5,Math.sqrt(Math.max(p.complexity,1))*.3),v=p.tags.includes("exported");s.push({functionId:p.id,name:p.name,y:a+g/2,height:g,width:t,complexity:p.complexity,isExported:v}),a+=g+r}const c=new Set(n.map(p=>p.id)),d=[],f=new Map(s.map(p=>[p.functionId,p]));for(const p of e)if(c.has(p.sourceId)&&c.has(p.targetId)){const g=f.get(p.sourceId),v=f.get(p.targetId);g&&v&&d.push({fromId:p.sourceId,toId:p.targetId,fromY:g.y,toY:v.y})}return{floors:s,connections:d}}function cO(i){return i<=5?"#22C55E":i<=10?"#3B82F6":i<=20?"#F59E0B":i<=40?"#F97316":"#EF4444"}function uO({floor:i,buildingWidth:e,isSelected:t,onSelect:n,onHover:r}){const s=cO(i.complexity),a=t?.4:.1;return z.jsxs("group",{position:[0,i.y,0],children:[z.jsxs("mesh",{onClick:c=>{c.stopPropagation(),n(i.functionId)},onPointerOver:c=>{c.stopPropagation(),r(i.functionId),document.body.style.cursor="pointer"},onPointerOut:()=>{r(null),document.body.style.cursor="auto"},children:[z.jsx("boxGeometry",{args:[e,i.height,e*.6]}),z.jsx("meshStandardMaterial",{color:s,transparent:!0,opacity:t?.9:.7,emissive:s,emissiveIntensity:a})]}),i.isExported&&z.jsxs("mesh",{position:[e/2+.15,0,0],children:[z.jsx("sphereGeometry",{args:[.1,8,8]}),z.jsx("meshStandardMaterial",{color:"#22C55E",emissive:"#22C55E",emissiveIntensity:.5})]}),z.jsx(il,{position:[-e/2-.3,0,0],center:!0,style:{pointerEvents:"none"},children:z.jsxs("div",{style:{color:"#e2e8f0",background:"rgba(10, 10, 26, 0.8)",padding:"2px 8px",borderRadius:"3px",fontSize:"11px",fontFamily:"monospace",whiteSpace:"nowrap",borderLeft:`3px solid ${s}`},children:[i.name,i.complexity>0&&z.jsxs("span",{style:{opacity:.5,marginLeft:"6px",fontSize:"9px"},children:["cx:",i.complexity]})]})})]})}function hO(){const i=hn(_=>_.interiorFileId),e=hn(_=>_.selectedFunctionId),t=hn(_=>_.selectFunction),n=hn(_=>_.exitBuilding),r=hn(_=>_.setHovered),s=ni(_=>_.graph),a=ni(_=>_.functionsByFile),c=ni(_=>_.callEdges),d=te.useMemo(()=>!s||!i?null:s.nodes.find(_=>_.id===i)??null,[s,i]),f=te.useMemo(()=>i?a.get(i)??[]:[],[a,i]),p=te.useMemo(()=>{const _=(d==null?void 0:d.dimensions.width)??4;return lO(f,c,Math.max(_,3))},[f,c,d]),g=te.useMemo(()=>{if(!s)return[];const _=new Set(f.map(b=>b.id)),C=new Map(p.floors.map(b=>[b.functionId,b]));return c.filter(b=>_.has(b.sourceId)&&!_.has(b.targetId)).map(b=>{const I=C.get(b.sourceId),N=s.nodes.find(O=>O.id===b.targetId);return!I||!N?null:{fromY:I.y,targetName:N.name,targetId:b.targetId}}).filter(b=>b!==null).slice(0,20)},[c,f,s,p.floors]),v=te.useCallback(_=>{t(_)},[t]),y=te.useCallback(_=>{r(_)},[r]);if(!d||!i)return null;const E=Math.max(d.dimensions.width??4,3),{x:T,z:w}=d.position;return z.jsxs("group",{position:[T,0,w],children:[z.jsxs("lineSegments",{position:[0,p.floors.length>0?p.floors[p.floors.length-1].y/2:2,0],children:[z.jsx("edgesGeometry",{args:[new cc(E+.6,(p.floors.length>0?p.floors[p.floors.length-1].y+1:4)+.5,E*.6+.6)]}),z.jsx("lineBasicMaterial",{color:"#4a4a6e",transparent:!0,opacity:.4})]}),p.floors.map(_=>z.jsx(uO,{floor:_,buildingWidth:E,isSelected:_.functionId===e,onSelect:v,onHover:y},_.functionId)),p.connections.map((_,C)=>{const b=E/2+.5;return z.jsx($E,{points:[[b,_.fromY,0],[b+.8,(_.fromY+_.toY)/2,0],[b,_.toY,0]],color:"#6366f1",lineWidth:1.5,transparent:!0,opacity:.6},`conn-${C}`)}),g.map((_,C)=>z.jsxs("group",{children:[z.jsx($E,{points:[[E/2+.3,_.fromY,0],[E/2+2.5,_.fromY,0]],color:"#F59E0B",lineWidth:1,transparent:!0,opacity:.5}),z.jsx(il,{position:[E/2+3,_.fromY,0],center:!0,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#F59E0B",fontSize:"9px",fontFamily:"monospace",whiteSpace:"nowrap",opacity:.7},children:_.targetName})})]},`out-${C}`)),z.jsx(il,{position:[0,p.floors.length>0?p.floors[p.floors.length-1].y+1.5:3,0],center:!0,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#e2e8f0",background:"rgba(10, 10, 26, 0.85)",padding:"4px 12px",borderRadius:"6px",fontSize:"13px",fontFamily:"system-ui, sans-serif",fontWeight:600,whiteSpace:"nowrap",border:`1px solid ${x0(d.healthScore)}44`},children:d.name})}),z.jsx(il,{position:[0,-1.5,0],center:!0,children:z.jsx("button",{onClick:n,style:{color:"#e2e8f0",background:"rgba(30, 30, 50, 0.9)",padding:"6px 16px",borderRadius:"6px",fontSize:"12px",fontFamily:"system-ui, sans-serif",border:"1px solid #4a4a6e",cursor:"pointer"},onMouseEnter:_=>{_.target.style.background="rgba(50, 50, 80, 0.9)"},onMouseLeave:_=>{_.target.style.background="rgba(30, 30, 50, 0.9)"},children:"Exit Building"})}),p.floors.length===0&&z.jsx(il,{position:[0,2,0],center:!0,style:{pointerEvents:"none"},children:z.jsx("div",{style:{color:"#94a3b8",fontSize:"12px",fontFamily:"system-ui, sans-serif",textAlign:"center"},children:"No function details available for this file"})})]})}const Gg=10,dO=30,fO=50,pO=40;function mO({buildings:i}){const e=hn(s=>s.zoomLevel),{flameBuildings:t,warningBuildings:n,shimmerBuildings:r}=te.useMemo(()=>{const s=[],a=[],c=[];for(const d of i)d.churnScore>.7&&d.healthScore<40&&s.length<dO&&s.push(d),d.busFactor===1&&d.busFactor>0&&a.length<fO&&a.push(d),d.healthScore>=90&&c.length<pO&&c.push(d);return{flameBuildings:s,warningBuildings:a,shimmerBuildings:c}},[i]);return z.jsxs(z.Fragment,{children:[t.length>0&&z.jsx(gO,{buildings:t}),e>=1&&e<=2&&n.length>0&&z.jsx(vO,{buildings:n}),r.length>0&&z.jsx(_O,{buildings:r})]})}function gO({buildings:i}){const e=te.useRef(null),t=i.length*Gg,{positions:n,velocities:r,basePositions:s}=te.useMemo(()=>{const c=new Float32Array(t*3),d=new Float32Array(t),f=new Float32Array(t*3);for(let p=0;p<i.length;p++){const g=i[p];for(let v=0;v<Gg;v++){const y=(p*Gg+v)*3,E=(Math.random()-.5)*g.width*.6,T=(Math.random()-.5)*g.depth*.6,w=g.y+g.height/2;f[y]=g.x+E,f[y+1]=w,f[y+2]=g.z+T,c[y]=f[y],c[y+1]=w+Math.random()*2,c[y+2]=f[y+2],d[p*Gg+v]=.8+Math.random()*1.2}}return{positions:c,velocities:d,basePositions:f}},[i,t]),a=te.useMemo(()=>{const c=new Float32Array(t*3);for(let d=0;d<t;d++){const f=Math.random();c[d*3]=1,c[d*3+1]=.2+f*.5,c[d*3+2]=0}return c},[t]);return so((c,d)=>{if(!e.current)return;const p=e.current.geometry.getAttribute("position");if(!p)return;const g=p.array;for(let v=0;v<t;v++){const y=v*3,E=s[y+1];g[y+1]+=r[v]*d,g[y]+=(Math.random()-.5)*d*.3,g[y+2]+=(Math.random()-.5)*d*.3,g[y+1]>E+3&&(g[y]=s[y]+(Math.random()-.5)*.3,g[y+1]=E,g[y+2]=s[y+2]+(Math.random()-.5)*.3)}p.needsUpdate=!0}),t===0?null:z.jsxs("points",{ref:e,children:[z.jsxs("bufferGeometry",{children:[z.jsx("bufferAttribute",{attach:"attributes-position",args:[n,3]}),z.jsx("bufferAttribute",{attach:"attributes-color",args:[a,3]})]}),z.jsx("pointsMaterial",{size:.3,vertexColors:!0,transparent:!0,opacity:.8,blending:ol,depthWrite:!1,sizeAttenuation:!0})]})}function vO({buildings:i}){return z.jsx(z.Fragment,{children:i.map(e=>z.jsx(il,{position:[e.x,e.y+e.height/2+1.5,e.z],center:!0,style:{pointerEvents:"none"},zIndexRange:[10,0],children:z.jsx("div",{className:"text-amber-400 text-xs font-bold select-none opacity-80",title:"Bus Factor: 1 — single contributor",children:"⚠"})},`warn-${e.nodeId}`))})}function _O({buildings:i}){const e=te.useRef(null),t=te.useMemo(()=>new Cn,[]);return te.useMemo(()=>{if(e.current){for(let n=0;n<i.length;n++){const r=i[n];t.position.set(r.x,r.y+r.height/2+.5,r.z),t.scale.setScalar(.25),t.updateMatrix(),e.current.setMatrixAt(n,t.matrix)}e.current.instanceMatrix.needsUpdate=!0}},[i,t]),so(({clock:n})=>{if(!e.current)return;const r=n.getElapsedTime(),s=.2+Math.sin(r*2)*.08;for(let a=0;a<i.length;a++){const c=i[a];t.position.set(c.x,c.y+c.height/2+.5+Math.sin(r*1.5+a)*.15,c.z),t.scale.setScalar(s),t.updateMatrix(),e.current.setMatrixAt(a,t.matrix)}e.current.instanceMatrix.needsUpdate=!0}),i.length===0?null:z.jsxs("instancedMesh",{ref:e,args:[void 0,void 0,i.length],children:[z.jsx("sphereGeometry",{args:[1,8,8]}),z.jsx("meshBasicMaterial",{color:"#fbbf24",transparent:!0,opacity:.6,blending:ol,depthWrite:!1})]})}function yO({center:i}){const e=te.useRef(null),t=hn(s=>s.cameraTarget),n=hn(s=>s.flyToSatellite),r=ni(s=>s.cityExtent);return te.useEffect(()=>{if(!e.current)return;const s=Math.max(zT,r);e.current.setLookAt(i.x,s,i.z+.01,i.x,0,i.z,!1)},[i,r]),te.useEffect(()=>{if(!e.current||!t)return;const{position:s,lookAt:a}=t;e.current.setLookAt(s[0],s[1],s[2],a[0],a[1],a[2],!0)},[t]),te.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),z.jsx(pU,{ref:e,makeDefault:!0,smoothTime:.4,draggingSmoothTime:.15,dollySpeed:1,truckSpeed:2,minDistance:5,maxDistance:300,minPolarAngle:.1,maxPolarAngle:Math.PI/2.2,mouseButtons:{left:2,middle:16,right:1,wheel:16},touches:{one:128,two:4096,three:64}})}/**
4614
4614
  * postprocessing v6.39.0 build Fri Mar 20 2026
4615
4615
  * https://github.com/pmndrs/postprocessing
4616
4616
  * Copyright 2015-2026 Raoul van Rüschen
@@ -4793,6 +4793,6 @@ return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
4793
4793
  `+n),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,i.colorSpace===kn&&(n+=`color0 = sRGBToLinear(color0);
4794
4794
  `),i.uvTransformation?(r=`vec2 transformedUv = vUv;
4795
4795
  `+r,i.defines.set("UV","transformedUv")):i.defines.set("UV","vUv"),i.shaderParts.set(zn.FRAGMENT_HEAD,t),i.shaderParts.set(zn.FRAGMENT_MAIN_IMAGE,n),i.shaderParts.set(zn.FRAGMENT_MAIN_UV,r);for(const[a,c]of i.shaderParts)c!==null&&i.shaderParts.set(a,c.trim().replace(/^#/,`
4796
- #`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(i)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(i,e=ac){this.fullscreenMaterial.depthBuffer=i,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(i,e)}render(i,e,t,n,r){for(const s of this.effects)s.update(i,e,n);if(!this.skipRendering||this.renderToScreen){const s=this.fullscreenMaterial;s.inputBuffer=e.texture,s.time+=n*this.timeScale,i.setRenderTarget(this.renderToScreen?null:t),i.render(this.scene,this.camera)}}setSize(i,e){this.fullscreenMaterial.setSize(i,e);for(const t of this.effects)t.setSize(i,e)}initialize(i,e,t){this.renderer=i;for(const n of this.effects)n.initialize(i,e,t);this.updateMaterial(),t!==void 0&&t!==Oi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const i of this.effects)i.removeEventListener("change",this.listener),i.dispose()}handleEvent(i){switch(i.type){case"change":this.recompile();break}}},FF=class extends ws{constructor(i,e,{renderTarget:t,resolutionScale:n=1,width:r=Vr.AUTO_SIZE,height:s=Vr.AUTO_SIZE,resolutionX:a=r,resolutionY:c=s}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new cA(i,e,new yx);const d=this.renderPass;d.ignoreBackground=!0,d.skipShadowMapUpdate=!0;const f=d.getClearPass();f.overrideClearColor=new yt(7829503),f.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new Mi(1,1,{minFilter:Ui,magFilter:Ui}),this.renderTarget.texture.name="NormalPass.Target");const p=this.resolution=new Vr(this,a,c,n);p.addEventListener("change",g=>this.setSize(p.baseWidth,p.baseHeight))}set mainScene(i){this.renderPass.mainScene=i}set mainCamera(i){this.renderPass.mainCamera=i}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}render(i,e,t,n,r){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(i,s,s)}setSize(i,e){const t=this.resolution;t.setBaseSize(i,e),this.renderTarget.setSize(t.width,t.height)}};const BF=te.createContext(null),fM=i=>(i.getAttributes()&sl.CONVOLUTION)===sl.CONVOLUTION,zF=yu.memo(te.forwardRef(({children:i,camera:e,scene:t,resolutionScale:n,enabled:r=!0,renderPriority:s=1,autoClear:a=!0,depthBuffer:c,enableNormalPass:d,stencilBuffer:f,multisampling:p=8,frameBufferType:g=nr},v)=>{const{gl:y,scene:E,camera:T,size:w}=br(),_=t||E,C=e||T,[b,I,N]=te.useMemo(()=>{const B=HN(),D=new CO(y,{depthBuffer:c,stencilBuffer:f,multisampling:p>0&&B?p:0,frameBufferType:g});D.addPass(new cA(_,C));let U=null,W=null;return d&&(W=new FF(_,C),W.enabled=!1,D.addPass(W),n!==void 0&&B&&(U=new RF({normalBuffer:W.texture,resolutionScale:n}),U.enabled=!1,D.addPass(U))),[D,W,U]},[C,y,c,f,p,g,_,d,n]);te.useEffect(()=>b==null?void 0:b.setSize(w.width,w.height),[b,w]),so((B,D)=>{if(r){const U=y.autoClear;y.autoClear=a,f&&!a&&y.clearStencil(),b.render(D),y.autoClear=U}},r?s:0);const O=te.useRef(null);te.useLayoutEffect(()=>{var B;const D=[],U=(B=O.current)==null?void 0:B.__r3f;if(U&&b){const W=U.objects;for(let ne=0;ne<W.length;ne++){const re=W[ne];if(re instanceof Dv){const he=[re];if(!fM(re)){let ce=null;for(;(ce=W[ne+1])instanceof Dv&&!fM(ce);)he.push(ce),ne++}const fe=new OF(C,...he);D.push(fe)}else re instanceof ws&&D.push(re)}for(const ne of D)b==null||b.addPass(ne);I&&(I.enabled=!0),N&&(N.enabled=!0)}return()=>{for(const W of D)b==null||b.removePass(W);I&&(I.enabled=!1),N&&(N.enabled=!1)}},[b,i,C,I,N]),te.useEffect(()=>{const B=y.toneMapping;return y.toneMapping=zo,()=>{y.toneMapping=B}},[y]);const H=te.useMemo(()=>({composer:b,normalPass:I,downSamplingPass:N,resolutionScale:n,camera:C,scene:_}),[b,I,N,n,C,_]);return te.useImperativeHandle(v,()=>b,[b]),z.jsx(BF.Provider,{value:H,children:z.jsx("group",{ref:O,children:i})})}));let kF=0;const pM=new WeakMap,uA=(i,e)=>yu.forwardRef(function({blendFunction:n=e==null?void 0:e.blendFunction,opacity:r=e==null?void 0:e.opacity,...s},a){let c=pM.get(i);if(!c){const p=`@react-three/postprocessing/${i.name}-${kF++}`;Gp({[p]:i}),pM.set(i,c=p)}const d=br(p=>p.camera),f=yu.useMemo(()=>{var p,g;return[...(p=e==null?void 0:e.args)!=null?p:[],...(g=s.args)!=null?g:[{...e,...s}]]},[JSON.stringify(s)]);return z.jsx(c,{camera:d,"blendMode-blendFunction":n,"blendMode-opacity-value":r,...s,ref:a,args:f})}),HF=uA(TF,{blendFunction:An.ADD}),VF=uA(PF);function GF(){return z.jsxs(zF,{children:[z.jsx(HF,{intensity:.4,luminanceThreshold:.3,luminanceSmoothing:.9,mipmapBlur:!0}),z.jsx(VF,{offset:.3,darkness:.6,blendFunction:An.NORMAL})]})}function WF(){const i=ni(v=>v.graph),e=ni(v=>v.moduleEdges),t=hn(v=>v.selectedModuleId),n=hn(v=>v.zoomLevel),r=hn(v=>v.interiorFileId),s=fr(v=>v.isTimelineActive),a=fr(v=>v.visibleNodeIds),c=te.useMemo(()=>i?RN(i):null,[i]),d=te.useMemo(()=>c?PN(c.modules,e):[],[c,e]),f=te.useMemo(()=>{if(!c)return new Map;const v=new Map;for(const y of c.buildings){if(s&&!a.has(y.nodeId))continue;const E=v.get(y.moduleId)??[];E.push(y),v.set(y.moduleId,E)}return v},[c,s,a]),p=te.useMemo(()=>c?s?c.buildings.filter(v=>a.has(v.nodeId)):c.buildings:[],[c,s,a]);if(!c)return null;const g=n===3&&r!==null;return z.jsxs(z.Fragment,{children:[z.jsx(OU,{}),z.jsx(BU,{}),z.jsx("ambientLight",{intensity:.15,color:"#8090b0"}),z.jsx("directionalLight",{position:[60,100,40],intensity:.4,color:"#c0d0ff",castShadow:!0,"shadow-mapSize":[2048,2048],"shadow-camera-far":250,"shadow-camera-left":-120,"shadow-camera-right":120,"shadow-camera-top":120,"shadow-camera-bottom":-120}),z.jsx("directionalLight",{position:[-40,50,-30],intensity:.15,color:"#ff9060"}),z.jsx("pointLight",{position:[0,40,0],intensity:.5,color:"#4a7bd9",distance:200,decay:1}),z.jsx("pointLight",{position:[80,15,80],intensity:.3,color:"#6366f1",distance:100,decay:2}),z.jsx("pointLight",{position:[-80,15,-80],intensity:.3,color:"#0ea5e9",distance:100,decay:2}),g?z.jsx(hO,{}):z.jsxs(z.Fragment,{children:[c.modules.map(v=>z.jsx(HU,{layout:v,isSelected:v.id===t},v.id)),c.modules.map(v=>{const y=f.get(v.id)??[];return z.jsx(XU,{buildings:y,moduleId:v.id},v.id)}),z.jsx(qU,{paths:d}),z.jsx(tO,{roads:d}),z.jsx(KU,{buildings:p}),z.jsx($U,{buildings:p}),z.jsx(mO,{buildings:p}),z.jsx(aO,{modules:c.modules,roads:d,center:c.center})]}),z.jsx(yO,{center:c.center}),z.jsx(GF,{})]})}function mM(){return z.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-[#0a0a1a] text-[#e2e8f0]",children:[z.jsx("div",{className:"text-3xl font-light mb-4 tracking-wider",children:"Cartographer"}),z.jsx("div",{className:"text-sm opacity-60 animate-pulse",children:"Loading city..."})]})}function jF({message:i}){return z.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-[#0a0a1a] text-[#e2e8f0]",children:[z.jsx("div",{className:"text-3xl font-light mb-4 tracking-wider text-red-400",children:"Error"}),z.jsx("div",{className:"text-sm opacity-80 max-w-md text-center",children:i}),z.jsx("button",{className:"mt-6 px-4 py-2 text-sm bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:()=>window.location.reload(),children:"Retry"})]})}const is=v0((i,e)=>({activeExpedition:null,currentStepIndex:0,isPlaying:!1,isPaused:!1,isListOpen:!1,startExpedition:t=>{i({activeExpedition:t,currentStepIndex:0,isPlaying:!0,isPaused:!1,isListOpen:!1})},nextStep:()=>{const{activeExpedition:t,currentStepIndex:n}=e();if(!t)return;const r=t.steps.length-1;n<r?i({currentStepIndex:n+1}):i({isPlaying:!1,isPaused:!1})},prevStep:()=>{const{currentStepIndex:t}=e();t>0&&i({currentStepIndex:t-1})},pause:()=>{i({isPaused:!0})},resume:()=>{i({isPaused:!1,isPlaying:!0})},stopExpedition:()=>{i({activeExpedition:null,currentStepIndex:0,isPlaying:!1,isPaused:!1})},toggleList:()=>{i(t=>({isListOpen:!t.isListOpen}))}}));function XF(){const i=ni(_=>_.graph),e=ni(_=>_.isLive),t=ni(_=>_.liveStatus),n=hn(_=>_.zoomLevel),r=hn(_=>_.selectedModuleId),s=hn(_=>_.selectedFileId),a=hn(_=>_.flyToSatellite),c=hn(_=>_.enterBuilding),d=hn(_=>_.exitBuilding),f=ni(_=>_.modules),p=is(_=>_.toggleList),g=is(_=>_.isListOpen),v=fr(_=>_.isTimelineActive),y=fr(_=>_.activateTimeline),E=fr(_=>_.deactivateTimeline);if(!i)return null;const T=f.find(_=>_.id===r),w=i.evolution.length>0;return z.jsx("div",{className:"absolute top-4 left-4 pointer-events-none",children:z.jsxs("div",{className:"bg-[#0a0a1a]/75 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e]",children:[z.jsx("div",{className:"text-sm font-medium mb-1",children:i.meta.repo}),z.jsxs("div",{className:"text-xs opacity-60",children:[i.meta.totalFiles," files · ",i.meta.totalModules," modules · ",i.meta.languages.join(", ")]}),e&&z.jsxs("div",{className:"flex items-center gap-1.5 mt-2",children:[z.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),z.jsx("span",{className:"text-xs opacity-60",children:"LIVE"}),t&&z.jsx("span",{className:"text-xs opacity-40 ml-1",children:t})]}),n===1&&T&&z.jsxs("div",{className:"mt-2 pt-2 border-t border-[#2a2a3e]",children:[z.jsxs("div",{className:"text-xs opacity-80",children:["Module: ",z.jsx("span",{className:"font-medium",children:T.name})]}),z.jsx("button",{className:"pointer-events-auto mt-1 text-xs px-2 py-1 bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:a,children:"Back to Overview"}),s&&z.jsx("button",{className:"pointer-events-auto mt-1 text-xs px-2 py-1 bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:()=>{const _=i==null?void 0:i.nodes.find(C=>C.id===s);_&&c(_)},children:"Enter Building"})]}),n===3&&z.jsxs("div",{className:"mt-2 pt-2 border-t border-[#2a2a3e]",children:[z.jsx("div",{className:"text-xs opacity-80",children:"Interior View"}),z.jsx("button",{className:"pointer-events-auto mt-1 text-xs px-2 py-1 bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:d,children:"Exit Building"})]}),z.jsxs("div",{className:"mt-2 pt-2 border-t border-[#2a2a3e] flex gap-2",children:[z.jsx("button",{className:`pointer-events-auto text-xs px-2 py-1 rounded transition-colors ${g?"bg-[#6366f1]/20 text-[#818CF8]":"bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0]"}`,onClick:p,children:"Expeditions"}),w&&z.jsx("button",{className:`pointer-events-auto text-xs px-2 py-1 rounded transition-colors ${v?"bg-[#6366f1]/20 text-[#818CF8]":"bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0]"}`,onClick:()=>{v?E():y(i.evolution)},children:"Timeline"})]})]})})}const gM={api:"#3B82F6",middleware:"#8B5CF6",business_logic:"#22C55E",data_access:"#F59E0B",utility:"#94A3B8",configuration:"#6B7280",presentation:"#EC4899",infrastructure:"#F97316",testing:"#14B8A6"};function YF({score:i}){return i===50?z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("span",{className:"text-2xl font-bold opacity-40",children:"--"}),z.jsx("span",{className:"text-xs opacity-40",children:"Not computed"})]}):z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("span",{className:"text-2xl font-bold",style:{color:x0(i)},children:Math.round(i)}),z.jsx("span",{className:"text-xs opacity-60",children:"/ 100"})]})}function ZF({file:i}){var t,n,r,s;if(i.healthScore===50&&i.complexity===0)return null;const e=[{label:"Complexity",score:Math.max(0,100-Math.min(i.complexity*3,100)),detail:`${i.complexity} cyclomatic`},{label:"Churn stability",score:i.churnScore>0?Math.round((1-i.churnScore)*100):75,detail:i.churnScore>0?`${Math.round(i.churnScore*100)}% churn`:"No data"},{label:"Type safety",score:(t=i.path)!=null&&t.endsWith(".ts")||(n=i.path)!=null&&n.endsWith(".tsx")?100:30,detail:(r=i.path)!=null&&r.endsWith(".ts")||(s=i.path)!=null&&s.endsWith(".tsx")?"TypeScript":"JavaScript"},{label:"Bus factor",score:i.busFactor===0?50:i.busFactor===1?25:Math.min(100,i.busFactor*30),detail:i.busFactor>0?`${i.busFactor} contributor(s)`:"No data"},{label:"Size",score:i.loc<100?100:i.loc<300?70:i.loc<500?40:20,detail:`${i.loc} lines`}];return z.jsx("div",{className:"space-y-1.5",children:e.map(a=>z.jsxs("div",{children:[z.jsxs("div",{className:"flex justify-between text-[10px] mb-0.5",children:[z.jsx("span",{className:"opacity-60",children:a.label}),z.jsx("span",{className:"opacity-40",children:a.detail})]}),z.jsx("div",{className:"h-1 bg-[#1a1a2e] rounded-full overflow-hidden",children:z.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a.score}%`,backgroundColor:a.score>=70?"#22C55E":a.score>=40?"#F59E0B":"#EF4444"}})})]},a.label))})}function qF({score:i}){const e=Math.min(100,Math.round(i*100)),t=e>70?"#EF4444":e>40?"#F59E0B":"#22C55E";return z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("div",{className:"flex-1 h-1.5 bg-[#2a2a3e] rounded-full overflow-hidden",children:z.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${e}%`,backgroundColor:t}})}),z.jsxs("span",{className:"text-xs w-8 text-right",children:[e,"%"]})]})}function KF({file:i}){return i.totalCommits>0||i.lastModified!==null||i.churnScore>0||i.busFactor>0||i.primaryOwner!==null?z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Git"}),z.jsxs("div",{className:"space-y-1.5 text-xs",children:[i.totalCommits>0&&z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Commits"}),z.jsx("span",{children:i.totalCommits})]}),i.lastModified&&z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Last modified"}),z.jsx("span",{children:new Date(i.lastModified).toLocaleDateString()})]}),i.churnScore>0&&z.jsxs("div",{children:[z.jsx("div",{className:"flex justify-between mb-0.5",children:z.jsx("span",{className:"opacity-60",children:"Churn"})}),z.jsx(qF,{score:i.churnScore})]}),i.busFactor>0&&z.jsxs("div",{className:"flex justify-between items-center",children:[z.jsx("span",{className:"opacity-60",children:"Bus factor"}),z.jsxs("span",{className:"flex items-center gap-1",children:[i.busFactor,i.busFactor===1&&z.jsx("span",{className:"text-[#EF4444] text-[10px]",title:"Single point of failure",children:"!!"})]})]}),i.primaryOwner&&z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Primary owner"}),z.jsx("span",{className:"truncate ml-2 max-w-[140px]",children:i.primaryOwner})]})]})]}):z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Git"}),z.jsx("div",{className:"text-xs opacity-40 italic",children:"Git data not available"})]})}function QF(){const i=hn(c=>c.selectedFunctionId),e=hn(c=>c.clearSelection),t=ni(c=>c.graph),n=ni(c=>c.callEdges),r=te.useMemo(()=>!t||!i?null:t.nodes.find(c=>c.id===i)??null,[t,i]),{callers:s,callees:a}=te.useMemo(()=>{if(!t||!i)return{callers:[],callees:[]};const c=[],d=[];for(const f of n){if(f.sourceId===i){const p=t.nodes.find(g=>g.id===f.targetId);p&&d.push(p)}if(f.targetId===i){const p=t.nodes.find(g=>g.id===f.sourceId);p&&c.push(p)}}return{callers:c,callees:d}},[t,i,n]);return r?z.jsx("div",{className:"absolute right-4 top-4 w-80 max-h-[calc(100vh-2rem)] overflow-y-auto",children:z.jsxs("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e] space-y-4",children:[z.jsxs("div",{children:[z.jsxs("div",{className:"flex items-start justify-between gap-2",children:[z.jsx("div",{className:"text-sm font-medium font-mono break-words",children:r.name}),z.jsx("button",{className:"text-xs opacity-60 hover:opacity-100 transition-opacity shrink-0 mt-0.5",onClick:()=>e(),children:"x"})]}),z.jsxs("div",{className:"text-[10px] opacity-40 mt-0.5",children:[r.kind==="function"?"Function":r.kind,r.tags.includes("exported")&&z.jsx("span",{className:"ml-1 text-[#22C55E]",children:"(exported)"})]})]}),r.summary&&z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Summary"}),z.jsx("p",{className:"text-sm leading-relaxed",children:r.summary}),r.explanation&&z.jsx("p",{className:"text-xs opacity-70 mt-1 leading-relaxed",children:r.explanation})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Metrics"}),z.jsxs("div",{className:"space-y-1 text-xs",children:[z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Complexity"}),z.jsx("span",{children:r.complexity})]}),z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Lines of code"}),z.jsx("span",{children:r.loc})]})]})]}),s.length>0&&z.jsxs("div",{children:[z.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:["Called by (",s.length,")"]}),z.jsxs("div",{className:"space-y-1",children:[s.slice(0,10).map(c=>z.jsx("div",{className:"text-xs font-mono opacity-70 truncate",children:c.name},c.id)),s.length>10&&z.jsxs("div",{className:"text-[10px] opacity-40",children:["+",s.length-10," more"]})]})]}),a.length>0&&z.jsxs("div",{children:[z.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:["Calls (",a.length,")"]}),z.jsxs("div",{className:"space-y-1",children:[a.slice(0,10).map(c=>z.jsx("div",{className:"text-xs font-mono opacity-70 truncate",children:c.name},c.id)),a.length>10&&z.jsxs("div",{className:"text-[10px] opacity-40",children:["+",a.length-10," more"]})]})]}),r.tags.length>0&&z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Tags"}),z.jsx("div",{className:"flex flex-wrap gap-1",children:r.tags.map(c=>z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[#2a2a3e] opacity-70",children:c},c))})]})]})}):null}function JF(){const i=hn(p=>p.zoomLevel),e=hn(p=>p.selectedFileId),t=hn(p=>p.selectedFunctionId),n=hn(p=>p.clearSelection),r=ni(p=>p.graph),s=ni(p=>p.modules),[a,c]=te.useState(!1);if(i===3&&t)return z.jsx(QF,{});if(!e||!r)return null;const d=r.nodes.find(p=>p.id===e);if(!d)return null;const f=s.find(p=>p.id===d.parentId);return z.jsx("div",{className:"absolute right-4 top-4 w-80 max-h-[calc(100vh-2rem)] overflow-y-auto",children:z.jsxs("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e] space-y-4",children:[z.jsxs("div",{children:[z.jsxs("div",{className:"flex items-start justify-between gap-2",children:[z.jsx("div",{className:"text-sm font-medium break-words",children:d.name}),z.jsx("button",{className:"text-xs opacity-60 hover:opacity-100 transition-opacity shrink-0 mt-0.5",onClick:()=>n(),children:"x"})]}),d.path&&z.jsx("div",{className:"text-xs opacity-50 mt-1 break-all",children:d.path}),f&&z.jsxs("div",{className:"text-xs opacity-40 mt-0.5",children:["Module: ",f.name]})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"AI Summary"}),d.summary?z.jsxs("div",{children:[z.jsx("p",{className:"text-sm leading-relaxed",children:d.summary}),d.explanation&&z.jsxs("div",{className:"mt-1",children:[z.jsx("button",{className:"text-[10px] opacity-50 hover:opacity-80 transition-opacity",onClick:()=>c(!a),children:a?"Collapse":"Show more"}),a&&z.jsx("p",{className:"text-xs opacity-70 mt-1 leading-relaxed",children:d.explanation})]})]}):z.jsx("p",{className:"text-xs opacity-40 italic",children:"No AI summary available"})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Health"}),z.jsx(YF,{score:d.healthScore}),z.jsx(ZF,{file:d})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Metrics"}),z.jsxs("div",{className:"space-y-1 text-xs",children:[z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Lines of code"}),z.jsx("span",{children:d.loc})]}),z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Complexity"}),z.jsx("span",{children:d.complexity})]})]})]}),z.jsx(KF,{file:d}),(d.layer||d.tags.length>0)&&z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Classification"}),z.jsxs("div",{className:"flex flex-wrap gap-1",children:[d.layer&&z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:(gM[d.layer]??"#6B7280")+"30",color:gM[d.layer]??"#6B7280"},children:d.layer.replace(/_/g," ")}),d.tags.map(p=>z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[#2a2a3e] opacity-70",children:p},p))]})]})]})})}function fc(i){return Array.isArray?Array.isArray(i):dA(i)==="[object Array]"}function $F(i){if(typeof i=="string")return i;let e=i+"";return e=="0"&&1/i==-1/0?"-0":e}function vM(i){return i==null?"":$F(i)}function Bs(i){return typeof i=="string"}function Vy(i){return typeof i=="number"}function eB(i){return i===!0||i===!1||tB(i)&&dA(i)=="[object Boolean]"}function hA(i){return typeof i=="object"}function tB(i){return hA(i)&&i!==null}function Fs(i){return i!=null}function Wg(i){return!i.trim().length}function dA(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}const nB="Incorrect 'index' type",iB=i=>`Invalid value for key ${i}`,rB=i=>`Pattern length exceeds max of ${i}.`,sB=i=>`Missing ${i} property in key`,oB=i=>`Property 'weight' in key '${i}' must be a positive integer`,_M=Object.prototype.hasOwnProperty;class aB{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(n=>{let r=fA(n);this._keys.push(r),this._keyMap[r.id]=r,t+=r.weight}),this._keys.forEach(n=>{n.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function fA(i){let e=null,t=null,n=null,r=1,s=null;if(Bs(i)||fc(i))n=i,e=yM(i),t=Gy(i);else{if(!_M.call(i,"name"))throw new Error(sB("name"));const a=i.name;if(n=a,_M.call(i,"weight")&&(r=i.weight,r<=0))throw new Error(oB(a));e=yM(a),t=Gy(a),s=i.getFn}return{path:e,id:t,weight:r,src:n,getFn:s}}function yM(i){return fc(i)?i:i.split(".")}function Gy(i){return fc(i)?i.join("."):i}function lB(i,e){let t=[],n=!1;const r=(s,a,c,d)=>{if(Fs(s))if(!a[c])t.push(d!==void 0?{v:s,i:d}:s);else{let f=a[c];const p=s[f];if(!Fs(p))return;if(c===a.length-1&&(Bs(p)||Vy(p)||eB(p)))t.push(d!==void 0?{v:vM(p),i:d}:vM(p));else if(fc(p)){n=!0;for(let g=0,v=p.length;g<v;g+=1)r(p[g],a,c+1,g)}else a.length&&r(p,a,c+1,d)}};return r(i,Bs(e)?e.split("."):e,0),n?t:t[0]}const cB={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},uB={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(i,e)=>i.score===e.score?i.idx<e.idx?-1:1:i.score<e.score?-1:1},hB={location:0,threshold:.6,distance:100},dB={useExtendedSearch:!1,getFn:lB,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var nn={...uB,...cB,...hB,...dB};const fB=/[^ ]+/g;function pB(i=1,e=3){const t=new Map,n=Math.pow(10,e);return{get(r){const s=r.match(fB).length;if(t.has(s))return t.get(s);const a=1/Math.pow(s,.5*i),c=parseFloat(Math.round(a*n)/n);return t.set(s,c),c},clear(){t.clear()}}}class Kx{constructor({getFn:e=nn.getFn,fieldNormWeight:t=nn.fieldNormWeight}={}){this.norm=pB(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,n)=>{this._keysMap[t.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Bs(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){const t=this.size();Bs(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}removeAll(e){for(let t=e.length-1;t>=0;t-=1)this.records.splice(e[t],1);for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i=t}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!Fs(e)||Wg(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((r,s)=>{let a=r.getFn?r.getFn(e):this.getFn(e,r.path);if(Fs(a)){if(fc(a)){let c=[];for(let d=0,f=a.length;d<f;d+=1){const p=a[d];if(Fs(p)){if(Bs(p)){if(!Wg(p)){let g={v:p,i:d,n:this.norm.get(p)};c.push(g)}}else if(Bs(p.v)&&!Wg(p.v)){let g={v:p.v,i:p.i,n:this.norm.get(p.v)};c.push(g)}}}n.$[s]=c}else if(Bs(a)&&!Wg(a)){let c={v:a,n:this.norm.get(a)};n.$[s]=c}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function pA(i,e,{getFn:t=nn.getFn,fieldNormWeight:n=nn.fieldNormWeight}={}){const r=new Kx({getFn:t,fieldNormWeight:n});return r.setKeys(i.map(fA)),r.setSources(e),r.create(),r}function mB(i,{getFn:e=nn.getFn,fieldNormWeight:t=nn.fieldNormWeight}={}){const{keys:n,records:r}=i,s=new Kx({getFn:e,fieldNormWeight:t});return s.setKeys(n),s.setIndexRecords(r),s}function gB(i=[],e=nn.minMatchCharLength){let t=[],n=-1,r=-1,s=0;for(let a=i.length;s<a;s+=1){let c=i[s];c&&n===-1?n=s:!c&&n!==-1&&(r=s-1,r-n+1>=e&&t.push([n,r]),n=-1)}return i[s-1]&&s-n>=e&&t.push([n,s-1]),t}const _u=32;function vB(i,e,t,{location:n=nn.location,distance:r=nn.distance,threshold:s=nn.threshold,findAllMatches:a=nn.findAllMatches,minMatchCharLength:c=nn.minMatchCharLength,includeMatches:d=nn.includeMatches,ignoreLocation:f=nn.ignoreLocation}={}){if(e.length>_u)throw new Error(rB(_u));const p=e.length,g=i.length,v=Math.max(0,Math.min(n,g));let y=s,E=v;const T=(B,D)=>{const U=B/p;if(f)return U;const W=Math.abs(v-D);return r?U+W/r:W?1:U},w=c>1||d,_=w?Array(g):[];let C;for(;(C=i.indexOf(e,E))>-1;){let B=T(0,C);if(y=Math.min(B,y),E=C+p,w){let D=0;for(;D<p;)_[C+D]=1,D+=1}}E=-1;let b=[],I=1,N=p+g;const O=1<<p-1;for(let B=0;B<p;B+=1){let D=0,U=N;for(;D<U;)T(B,v+U)<=y?D=U:N=U,U=Math.floor((N-D)/2+D);N=U;let W=Math.max(1,v-U+1),ne=a?g:Math.min(v+U,g)+p,re=Array(ne+2);re[ne+1]=(1<<B)-1;for(let fe=ne;fe>=W;fe-=1){let ce=fe-1,xe=t[i[ce]];if(w&&(_[ce]=+!!xe),re[fe]=(re[fe+1]<<1|1)&xe,B&&(re[fe]|=(b[fe+1]|b[fe])<<1|1|b[fe+1]),re[fe]&O&&(I=T(B,ce),I<=y)){if(y=I,E=ce,E<=v)break;W=Math.max(1,2*v-E)}}if(T(B+1,v)>y)break;b=re}const H={isMatch:E>=0,score:Math.max(.001,I)};if(w){const B=gB(_,c);B.length?d&&(H.indices=B):H.isMatch=!1}return H}function _B(i){let e={};for(let t=0,n=i.length;t<n;t+=1){const r=i.charAt(t);e[r]=(e[r]||0)|1<<n-t-1}return e}const Nv=String.prototype.normalize?(i=>i.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(i=>i);function yB(i){if(i.length<=1)return i;i.sort((t,n)=>t[0]-n[0]||t[1]-n[1]);const e=[i[0]];for(let t=1,n=i.length;t<n;t+=1){const r=e[e.length-1],s=i[t];s[0]<=r[1]+1?r[1]=Math.max(r[1],s[1]):e.push(s)}return e}class mA{constructor(e,{location:t=nn.location,threshold:n=nn.threshold,distance:r=nn.distance,includeMatches:s=nn.includeMatches,findAllMatches:a=nn.findAllMatches,minMatchCharLength:c=nn.minMatchCharLength,isCaseSensitive:d=nn.isCaseSensitive,ignoreDiacritics:f=nn.ignoreDiacritics,ignoreLocation:p=nn.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:s,findAllMatches:a,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:f,ignoreLocation:p},e=d?e:e.toLowerCase(),e=f?Nv(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const g=(y,E)=>{this.chunks.push({pattern:y,alphabet:_B(y),startIndex:E})},v=this.pattern.length;if(v>_u){let y=0;const E=v%_u,T=v-E;for(;y<T;)g(this.pattern.substr(y,_u),y),y+=_u;if(E){const w=v-_u;g(this.pattern.substr(w),w)}}else g(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Nv(e):e,this.pattern===e){let T={isMatch:!0,score:0};return r&&(T.indices=[[0,e.length-1]]),T}const{location:s,distance:a,threshold:c,findAllMatches:d,minMatchCharLength:f,ignoreLocation:p}=this.options;let g=[],v=0,y=!1;this.chunks.forEach(({pattern:T,alphabet:w,startIndex:_})=>{const{isMatch:C,score:b,indices:I}=vB(e,T,w,{location:s+_,distance:a,threshold:c,findAllMatches:d,minMatchCharLength:f,includeMatches:r,ignoreLocation:p});C&&(y=!0),v+=b,C&&I&&g.push(...I)});let E={isMatch:y,score:y?v/this.chunks.length:1};return y&&r&&(E.indices=yB(g)),E}}class pc{constructor(e){this.pattern=e}static isMultiMatch(e){return xM(e,this.multiRegex)}static isSingleMatch(e){return xM(e,this.singleRegex)}search(){}}function xM(i,e){const t=i.match(e);return t?t[1]:null}class xB extends pc{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class SB extends pc{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class EB extends pc{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class MB extends pc{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class wB extends pc{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class TB extends pc{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class gA extends pc{constructor(e,{location:t=nn.location,threshold:n=nn.threshold,distance:r=nn.distance,includeMatches:s=nn.includeMatches,findAllMatches:a=nn.findAllMatches,minMatchCharLength:c=nn.minMatchCharLength,isCaseSensitive:d=nn.isCaseSensitive,ignoreDiacritics:f=nn.ignoreDiacritics,ignoreLocation:p=nn.ignoreLocation}={}){super(e),this._bitapSearch=new mA(e,{location:t,threshold:n,distance:r,includeMatches:s,findAllMatches:a,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:f,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class vA extends pc{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n;const r=[],s=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+s,r.push([n,t-1]);const a=!!r.length;return{isMatch:a,score:a?0:1,indices:r}}}const Wy=[xB,vA,EB,MB,TB,wB,SB,gA],SM=Wy.length,AB=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,CB="|";function bB(i,e={}){return i.split(CB).map(t=>{let n=t.trim().split(AB).filter(s=>s&&!!s.trim()),r=[];for(let s=0,a=n.length;s<a;s+=1){const c=n[s];let d=!1,f=-1;for(;!d&&++f<SM;){const p=Wy[f];let g=p.isMultiMatch(c);g&&(r.push(new p(g,e)),d=!0)}if(!d)for(f=-1;++f<SM;){const p=Wy[f];let g=p.isSingleMatch(c);if(g){r.push(new p(g,e));break}}}return r})}const RB=new Set([gA.type,vA.type]);class IB{constructor(e,{isCaseSensitive:t=nn.isCaseSensitive,ignoreDiacritics:n=nn.ignoreDiacritics,includeMatches:r=nn.includeMatches,minMatchCharLength:s=nn.minMatchCharLength,ignoreLocation:a=nn.ignoreLocation,findAllMatches:c=nn.findAllMatches,location:d=nn.location,threshold:f=nn.threshold,distance:p=nn.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:s,findAllMatches:c,ignoreLocation:a,location:d,threshold:f,distance:p},e=t?e:e.toLowerCase(),e=n?Nv(e):e,this.pattern=e,this.query=bB(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:s}=this.options;e=r?e:e.toLowerCase(),e=s?Nv(e):e;let a=0,c=[],d=0;for(let f=0,p=t.length;f<p;f+=1){const g=t[f];c.length=0,a=0;for(let v=0,y=g.length;v<y;v+=1){const E=g[v],{isMatch:T,indices:w,score:_}=E.search(e);if(T){if(a+=1,d+=_,n){const C=E.constructor.type;RB.has(C)?c.push(...w):c.push(w)}}else{d=0,a=0,c.length=0;break}}if(a){let v={isMatch:!0,score:d/a};return n&&(v.indices=c),v}}return{isMatch:!1,score:1}}}const jy=[];function _A(...i){jy.push(...i)}function yA(i,e){for(let t=0,n=jy.length;t<n;t+=1){let r=jy[t];if(r.condition(i,e))return new r(i,e)}return new mA(i,e)}const Uv={AND:"$and",OR:"$or"},Xy={PATH:"$path",PATTERN:"$val"},Yy=i=>!!(i[Uv.AND]||i[Uv.OR]),PB=i=>!!i[Xy.PATH],LB=i=>!fc(i)&&hA(i)&&!Yy(i),EM=i=>({[Uv.AND]:Object.keys(i).map(e=>({[e]:i[e]}))});function xA(i,e,{auto:t=!0}={}){const n=r=>{let s=Object.keys(r);const a=PB(r);if(!a&&s.length>1&&!Yy(r))return n(EM(r));if(LB(r)){const d=a?r[Xy.PATH]:s[0],f=a?r[Xy.PATTERN]:r[d];if(!Bs(f))throw new Error(iB(d));const p={keyId:Gy(d),pattern:f};return t&&(p.searcher=yA(f,e)),p}let c={children:[],operator:s[0]};return s.forEach(d=>{const f=r[d];fc(f)&&f.forEach(p=>{c.children.push(n(p))})}),c};return Yy(i)||(i=EM(i)),n(i)}function Zy(i,{ignoreFieldNorm:e=nn.ignoreFieldNorm}){let t=1;i.matches.forEach(({key:n,norm:r,score:s})=>{const a=n?n.weight:null;t*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(e?1:r))}),i.score=t}function DB(i,{ignoreFieldNorm:e=nn.ignoreFieldNorm}){i.forEach(t=>{Zy(t,{ignoreFieldNorm:e})})}class NB{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){const t=this.heap;for(;e>0;){const n=e-1>>1;if(t[e].score<=t[n].score)break;const r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){const t=this.heap,n=t.length;let r=e;do{e=r;const s=2*e+1,a=2*e+2;if(s<n&&t[s].score>t[r].score&&(r=s),a<n&&t[a].score>t[r].score&&(r=a),r!==e){const c=t[e];t[e]=t[r],t[r]=c}}while(r!==e)}}function UB(i,e){const t=i.matches;e.matches=[],Fs(t)&&t.forEach(n=>{if(!Fs(n.indices)||!n.indices.length)return;const{indices:r,value:s}=n;let a={indices:r,value:s};n.key&&(a.key=n.key.src),n.idx>-1&&(a.refIndex=n.idx),e.matches.push(a)})}function OB(i,e){e.score=i.score}function FB(i,e,{includeMatches:t=nn.includeMatches,includeScore:n=nn.includeScore}={}){const r=[];return t&&r.push(UB),n&&r.push(OB),i.map(s=>{const{idx:a}=s,c={item:e[a],refIndex:a};return r.length&&r.forEach(d=>{d(s,c)}),c})}class zu{constructor(e,t={},n){this.options={...nn,...t},this.options.useExtendedSearch,this._keyStore=new aB(this.options.keys),this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=yA(e,this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Kx))throw new Error(nB);this._myIndex=t||pA(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Fs(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[],n=[];for(let r=0,s=this._docs.length;r<s;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){for(let r=n.length-1;r>=0;r-=1)this._docs.splice(n[r],1);this._myIndex.removeAll(n)}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:s,sortFn:a,ignoreFieldNorm:c}=this.options,d=Vy(t)&&t>0&&Bs(e);let f;if(d){const p=new NB(t);Bs(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),f=p.extractSorted(a)}else f=Bs(e)?Bs(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),DB(f,{ignoreFieldNorm:c}),s&&f.sort(a),Vy(t)&&t>-1&&(f=f.slice(0,t));return FB(f,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){const r=this._getSearcher(e),{records:s}=this._myIndex,a=t?null:[];return s.forEach(({v:c,i:d,n:f})=>{if(!Fs(c))return;const{isMatch:p,score:g,indices:v}=r.searchIn(c);if(p){const y={item:c,idx:d,matches:[{score:g,value:c,norm:f,indices:v}]};t?(Zy(y,{ignoreFieldNorm:n}),t.shouldInsert(y.score)&&t.insert(y)):a.push(y)}}),a}_searchLogical(e){const t=xA(e,this.options),n=(c,d,f)=>{if(!c.children){const{keyId:g,searcher:v}=c,y=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(d,g),searcher:v});return y&&y.length?[{idx:f,item:d,matches:y}]:[]}const p=[];for(let g=0,v=c.children.length;g<v;g+=1){const y=c.children[g],E=n(y,d,f);if(E.length)p.push(...E);else if(c.operator===Uv.AND)return[]}return p},r=this._myIndex.records,s=new Map,a=[];return r.forEach(({$:c,i:d})=>{if(Fs(c)){let f=n(t,c,d);f.length&&(s.has(d)||(s.set(d,{idx:d,item:c,matches:[]}),a.push(s.get(d))),f.forEach(({matches:p})=>{s.get(d).matches.push(...p)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){const r=this._getSearcher(e),{keys:s,records:a}=this._myIndex,c=t?null:[];return a.forEach(({$:d,i:f})=>{if(!Fs(d))return;let p=[];if(s.forEach((g,v)=>{p.push(...this._findMatches({key:g,value:d[v],searcher:r}))}),p.length){const g={idx:f,item:d,matches:p};t?(Zy(g,{ignoreFieldNorm:n}),t.shouldInsert(g.score)&&t.insert(g)):c.push(g)}}),c}_findMatches({key:e,value:t,searcher:n}){if(!Fs(t))return[];let r=[];if(fc(t))t.forEach(({v:s,i:a,n:c})=>{if(!Fs(s))return;const{isMatch:d,score:f,indices:p}=n.searchIn(s);d&&r.push({score:f,key:e,value:s,idx:a,norm:c,indices:p})});else{const{v:s,n:a}=t,{isMatch:c,score:d,indices:f}=n.searchIn(s);c&&r.push({score:d,key:e,value:s,norm:a,indices:f})}return r}}zu.version="7.2.0";zu.createIndex=pA;zu.parseIndex=mB;zu.config=nn;zu.parseQuery=xA;_A(IB);zu.use=function(...i){i.forEach(e=>_A(e))};function BB({kind:i}){switch(i){case"module":return z.jsx("span",{className:"text-xs opacity-70",children:"[M]"});case"file":return z.jsx("span",{className:"text-xs opacity-70",children:"[F]"});case"function":return z.jsx("span",{className:"text-xs opacity-70",children:"[fn]"});case"class":return z.jsx("span",{className:"text-xs opacity-70",children:"[C]"});default:return z.jsx("span",{className:"text-xs opacity-70",children:"[?]"})}}function zB(i,e){return i?i.length<=e?i:"..."+i.slice(i.length-e+3):""}function kB(){const i=hn(_=>_.isSearchOpen),e=hn(_=>_.toggleSearch),t=hn(_=>_.flyToModule),n=hn(_=>_.flyToFile),r=hn(_=>_.selectFile),s=ni(_=>_.graph),a=ni(_=>_.modules),[c,d]=te.useState(""),[f,p]=te.useState(0),g=te.useRef(null),v=te.useMemo(()=>{const _=new Map;for(const C of a)_.set(C.id,C.name);return _},[a]),y=te.useMemo(()=>{if(!s)return null;const _=s.nodes.filter(C=>C.kind==="module"||C.kind==="file");return new zu(_,{keys:[{name:"name",weight:2},{name:"path",weight:1},{name:"summary",weight:.5}],threshold:.4,includeScore:!0})},[s]),E=te.useMemo(()=>!y||!c.trim()?[]:y.search(c,{limit:15}).map(_=>_.item),[y,c]);te.useEffect(()=>{p(0)},[E]),te.useEffect(()=>{i&&(d(""),p(0),requestAnimationFrame(()=>{var _;(_=g.current)==null||_.focus()}))},[i]),te.useEffect(()=>{function _(C){(C.metaKey||C.ctrlKey)&&C.key==="k"&&(C.preventDefault(),e())}return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e]);const T=te.useCallback(_=>{_.kind==="module"?t(_):(n(_),r(_.id)),e()},[t,n,r,e]),w=te.useCallback(_=>{_.key==="ArrowDown"?(_.preventDefault(),p(C=>Math.min(C+1,E.length-1))):_.key==="ArrowUp"?(_.preventDefault(),p(C=>Math.max(C-1,0))):_.key==="Enter"?(_.preventDefault(),E[f]&&T(E[f])):_.key==="Escape"&&(_.preventDefault(),e())},[E,f,T,e]);return i?z.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:_=>{_.target===_.currentTarget&&e()},children:[z.jsx("div",{className:"absolute inset-0 bg-[#0a0a1a]/90 backdrop-blur-md"}),z.jsx("div",{className:"relative w-full max-w-lg mx-4",children:z.jsxs("div",{className:"bg-[#1a1a2e] rounded-lg border border-[#3a3a4e] overflow-hidden shadow-2xl",children:[z.jsxs("div",{className:"flex items-center px-4 py-3 gap-3",children:[z.jsx("span",{className:"text-[#94a3b8] text-sm shrink-0",children:"/"}),z.jsx("input",{ref:g,type:"text",value:c,onChange:_=>d(_.target.value),onKeyDown:w,placeholder:"Search files, modules...",className:"flex-1 bg-transparent text-[#e2e8f0] text-sm outline-none placeholder:text-[#4a4a6e]"}),z.jsx("kbd",{className:"text-[10px] text-[#94a3b8] border border-[#3a3a4e] rounded px-1.5 py-0.5 shrink-0",children:"ESC"})]}),E.length>0&&z.jsx("div",{className:"border-t border-[#2a2a3e] max-h-80 overflow-y-auto",children:E.map((_,C)=>z.jsxs("button",{className:`w-full text-left px-4 py-2.5 flex items-center gap-3 transition-colors ${C===f?"bg-[#2a2a3e]":"hover:bg-[#1f1f35]"}`,onClick:()=>T(_),onMouseEnter:()=>p(C),children:[z.jsx(BB,{kind:_.kind}),z.jsxs("div",{className:"flex-1 min-w-0",children:[z.jsx("div",{className:"text-sm text-[#e2e8f0] truncate",children:_.name}),z.jsx("div",{className:"text-[10px] text-[#94a3b8] truncate",children:_.path?zB(_.path,50):v.get(_.id)??""})]}),_.healthScore!==50&&z.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:x0(_.healthScore)},title:`Health: ${Math.round(_.healthScore)}`}),_.kind==="file"&&_.parentId&&z.jsx("span",{className:"text-[10px] text-[#94a3b8] opacity-60 shrink-0",children:v.get(_.parentId)??""})]},_.id))}),c.trim()&&E.length===0&&z.jsx("div",{className:"border-t border-[#2a2a3e] px-4 py-6 text-center text-xs text-[#94a3b8] opacity-60",children:"No results found"})]})})]}):null}function HB({onClose:i}){const[e,t]=te.useState(""),[n,r]=te.useState(!1),[s,a]=te.useState(null),c=te.useRef(null),d=is(p=>p.startExpedition);te.useEffect(()=>{requestAnimationFrame(()=>{var p;(p=c.current)==null||p.focus()})},[]),te.useEffect(()=>{function p(g){g.key==="Escape"&&i()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[i]);const f=te.useCallback(async()=>{const p=e.trim();if(!(!p||n)){r(!0),a(null);try{const g=await fetch("/api/expedition/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:p})});if(!g.ok){const y=await g.text();throw new Error(y||`Request failed with status ${g.status}`)}const v=await g.json();d(v),i()}catch(g){a(g instanceof Error?g.message:"Failed to generate expedition")}finally{r(!1)}}},[e,n,d,i]);return z.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:p=>{p.target===p.currentTarget&&!n&&i()},children:[z.jsx("div",{className:"absolute inset-0 bg-[#0a0a1a]/80 backdrop-blur-md"}),z.jsx("div",{className:"relative w-full max-w-lg mx-4",children:z.jsxs("div",{className:"bg-[#0a0a1a]/95 backdrop-blur-sm rounded-lg border border-[#2a2a3e] shadow-2xl overflow-hidden",children:[z.jsxs("div",{className:"px-5 pt-4 pb-2",children:[z.jsx("div",{className:"text-sm font-semibold text-[#e2e8f0]",children:"Custom Expedition"}),z.jsx("div",{className:"text-xs opacity-40 mt-0.5",children:"Ask a question and get a guided tour of the relevant code"})]}),z.jsx("div",{className:"px-5 py-3",children:z.jsx("div",{className:"flex items-center gap-3 bg-[#1a1a2e] rounded-lg border border-[#3a3a4e] px-4 py-3",children:z.jsx("input",{ref:c,type:"text",value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),f())},placeholder:"Ask about your codebase...",className:"flex-1 bg-transparent text-[#e2e8f0] text-sm outline-none placeholder:text-[#4a4a6e]",disabled:n})})}),s&&z.jsx("div",{className:"px-5 pb-2",children:z.jsx("div",{className:"text-xs text-[#EF4444] bg-[#EF4444]/10 rounded px-3 py-2",children:s})}),z.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2 border-t border-[#2a2a3e]",children:[z.jsx("button",{className:"px-4 py-2 text-xs text-[#e2e8f0] rounded hover:bg-[#2a2a3e] transition-colors",onClick:i,disabled:n,children:"Cancel"}),z.jsx("button",{className:"px-4 py-2 text-xs text-[#e2e8f0] rounded bg-[#14B8A6] hover:bg-[#0d9488] transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",onClick:f,disabled:!e.trim()||n,children:n?z.jsxs("span",{className:"flex items-center gap-2 justify-center",children:[z.jsx("span",{className:"inline-block w-3 h-3 border border-[#e2e8f0]/50 border-t-[#e2e8f0] rounded-full animate-spin"}),"Generating..."]}):"Generate Tour"})]})]})})]})}const VB={grand_tour:"#3B82F6",request_flow:"#8B5CF6",danger_zones:"#EF4444",knowledge_silos:"#F59E0B",custom:"#14B8A6"},GB={grand_tour:"Grand Tour",request_flow:"Request Flow",danger_zones:"Danger Zones",knowledge_silos:"Knowledge Silos",custom:"Custom"};function WB({expedition:i,onStart:e}){const t=VB[i.kind]??"#94A3B8",n=GB[i.kind]??i.kind;return z.jsxs("button",{className:"w-full text-left p-3 rounded-lg bg-[#1a1a2e]/60 hover:bg-[#1a1a2e] transition-colors border border-[#2a2a3e] hover:border-[#3a3a4e]",onClick:()=>e(i),children:[z.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t+"30",color:t},children:n}),z.jsxs("span",{className:"text-[10px] opacity-40 ml-auto",children:["~",i.estimatedMinutes," min"]})]}),z.jsx("div",{className:"text-sm font-medium text-[#e2e8f0] mb-0.5",children:i.title}),z.jsx("div",{className:"text-xs opacity-50 leading-relaxed line-clamp-2",children:i.description}),z.jsxs("div",{className:"text-[10px] opacity-30 mt-1",children:[i.steps.length," steps"]})]})}function jB(){const i=is(c=>c.isListOpen),e=is(c=>c.toggleList),t=is(c=>c.startExpedition),n=ni(c=>c.graph),[r,s]=te.useState(!1);if(!i||!n)return null;const a=n.expeditions??[];return z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"absolute left-4 top-24 w-80 max-h-[calc(100vh-8rem)] overflow-y-auto z-40",children:z.jsxs("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e]",children:[z.jsxs("div",{className:"flex items-center justify-between mb-3",children:[z.jsx("div",{className:"text-sm font-semibold",children:"Expeditions"}),z.jsx("button",{className:"text-xs opacity-60 hover:opacity-100 transition-opacity",onClick:e,children:"x"})]}),a.length>0?z.jsx("div",{className:"space-y-2",children:a.map(c=>z.jsx(WB,{expedition:c,onStart:t},c.id))}):z.jsx("div",{className:"text-xs opacity-40 italic py-4 text-center",children:"No expeditions available for this codebase"}),z.jsxs("button",{className:"w-full mt-3 p-3 rounded-lg border border-dashed border-[#3a3a4e] hover:border-[#14B8A6] hover:bg-[#14B8A6]/10 transition-colors text-center",onClick:()=>s(!0),children:[z.jsx("div",{className:"text-xs font-medium text-[#14B8A6]",children:"+ Custom Expedition"}),z.jsx("div",{className:"text-[10px] opacity-40 mt-0.5",children:"Ask a question about your codebase"})]})]})}),r&&z.jsx(HB,{onClose:()=>s(!1)})]})}function XB({text:i,stepIndex:e}){const[t,n]=te.useState(""),[r,s]=te.useState(!1),a=te.useRef(null);return te.useEffect(()=>{n(""),s(!1);let c=0;return a.current&&clearInterval(a.current),a.current=setInterval(()=>{c++,c>=i.length?(n(i),s(!0),a.current&&(clearInterval(a.current),a.current=null)):n(i.slice(0,c))},18),()=>{a.current&&(clearInterval(a.current),a.current=null)}},[i,e]),i?z.jsx("div",{className:`absolute bottom-24 left-1/2 -translate-x-1/2 w-full max-w-2xl px-4 z-30 transition-opacity duration-500 ${r?"opacity-70":"opacity-100"}`,children:z.jsx("div",{className:"bg-[#0a0a1a]/80 backdrop-blur-sm rounded-lg px-6 py-4 text-[#e2e8f0] border border-[#2a2a3e]",children:z.jsxs("p",{className:"text-sm leading-relaxed",children:[t,!r&&z.jsx("span",{className:"inline-block w-0.5 h-4 bg-[#e2e8f0] ml-0.5 animate-pulse"})]})})}):null}function YB(){const i=is(N=>N.activeExpedition),e=is(N=>N.currentStepIndex),t=is(N=>N.isPlaying),n=is(N=>N.isPaused),r=is(N=>N.nextStep),s=is(N=>N.prevStep),a=is(N=>N.pause),c=is(N=>N.resume),d=is(N=>N.stopExpedition),f=hn(N=>N.flyToModule),p=hn(N=>N.flyToFile),g=hn(N=>N.enterBuilding),v=hn(N=>N.setHighlights),y=hn(N=>N.clearHighlights),E=ni(N=>N.graph),T=te.useRef(null),w=te.useCallback(N=>{if(!i||!E)return;const O=i.steps[N];if(!O)return;const H=E.nodes.find(B=>B.id===O.nodeId);H&&(v(O.highlightNodes,O.highlightEdges),O.action==="enter_building"&&H.kind==="file"?g(H):O.zoomLevel===0?H.kind==="module"&&f(H):O.zoomLevel===3&&H.kind==="file"?g(H):H.kind==="module"?f(H):p(H))},[i,E,f,p,g,v]);if(te.useEffect(()=>{i&&w(e)},[i,e,w]),te.useEffect(()=>{if(T.current&&(clearTimeout(T.current),T.current=null),!i||!t||n)return;const N=i.steps[e];if(!N)return;const O=N.duration*1e3;if(!(O<=0))return T.current=setTimeout(()=>{r()},O),()=>{T.current&&(clearTimeout(T.current),T.current=null)}},[i,e,t,n,r]),te.useEffect(()=>{i||y()},[i,y]),!i)return null;const _=i.steps[e],C=i.steps.length,b=C>0?(e+1)/C*100:0,I=e>=C-1;return z.jsxs(z.Fragment,{children:[_&&z.jsx(XB,{text:_.narration,stepIndex:e}),z.jsxs("div",{className:"absolute bottom-0 left-0 right-0 z-40",children:[z.jsx("div",{className:"h-0.5 bg-[#1a1a2e]",children:z.jsx("div",{className:"h-full bg-[#6366f1] transition-all duration-300",style:{width:`${b}%`}})}),z.jsx("div",{className:"bg-[#0a0a1a]/90 backdrop-blur-sm border-t border-[#2a2a3e] px-6 py-3",children:z.jsxs("div",{className:"flex items-center gap-4 max-w-4xl mx-auto",children:[z.jsxs("div",{className:"flex-1 min-w-0",children:[z.jsx("div",{className:"text-xs font-medium text-[#e2e8f0] truncate",children:i.title}),z.jsxs("div",{className:"text-[10px] text-[#94a3b8] opacity-60",children:["Step ",e+1," / ",C]})]}),z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("button",{className:"px-2 py-1.5 text-xs text-[#e2e8f0] rounded hover:bg-[#2a2a3e] transition-colors disabled:opacity-30 disabled:cursor-not-allowed",onClick:s,disabled:e===0,title:"Previous step",children:"|<"}),z.jsx("button",{className:"px-3 py-1.5 text-xs text-[#e2e8f0] rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] transition-colors font-medium min-w-[60px]",onClick:()=>{n||!t?c():a()},children:n||!t?"Play":"Pause"}),z.jsx("button",{className:"px-2 py-1.5 text-xs text-[#e2e8f0] rounded hover:bg-[#2a2a3e] transition-colors disabled:opacity-30 disabled:cursor-not-allowed",onClick:r,disabled:I,title:"Next step",children:">|"}),z.jsx("button",{className:"px-2 py-1.5 text-xs text-[#EF4444] rounded hover:bg-[#EF4444]/10 transition-colors ml-2",onClick:d,title:"Stop expedition",children:"X"})]})]})})]})]})}const ZB=[{label:"0.5x",value:4},{label:"1x",value:2},{label:"2x",value:1},{label:"4x",value:.5}];function qB(){const i=fr(_=>_.isTimelineActive),e=fr(_=>_.currentSnapshotIndex),t=fr(_=>_.totalSnapshots),n=fr(_=>_.isPlaying),r=fr(_=>_.playbackSpeed),s=fr(_=>_.visibleNodeIds),a=fr(_=>_.snapshots),c=fr(_=>_.setSnapshot),d=fr(_=>_.play),f=fr(_=>_.pause),p=fr(_=>_.setSpeed),g=fr(_=>_.deactivateTimeline),v=te.useRef(null);te.useEffect(()=>(v.current&&(clearInterval(v.current),v.current=null),n&&t>0&&(v.current=setInterval(()=>{const _=fr.getState();_.currentSnapshotIndex>=_.totalSnapshots-1?f():c(_.currentSnapshotIndex+1)},r*1e3)),()=>{v.current&&clearInterval(v.current)}),[n,r,t,c,f]);const y=te.useCallback(_=>{const C=parseInt(_.target.value,10);c(C),n&&f()},[c,n,f]),E=te.useCallback(()=>{c(0),d()},[c,d]);if(!i||t===0)return null;const T=a[e],w=T!=null&&T.timestamp?new Date(T.timestamp).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return z.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 pointer-events-auto",children:z.jsx("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-md border-t border-[#2a2a3e] px-6 py-3",children:z.jsxs("div",{className:"max-w-4xl mx-auto",children:[z.jsxs("div",{className:"flex items-center justify-between mb-2",children:[z.jsxs("div",{className:"text-xs text-[#e2e8f0]",children:[z.jsx("span",{className:"opacity-60",children:"Snapshot"})," ",z.jsx("span",{className:"font-medium",children:e+1}),z.jsxs("span",{className:"opacity-40",children:[" / ",t]}),w&&z.jsx("span",{className:"ml-3 opacity-50",children:w}),(T==null?void 0:T.author)&&z.jsxs("span",{className:"ml-2 opacity-40",children:["by ",T.author]})]}),z.jsxs("div",{className:"flex items-center gap-3",children:[z.jsxs("span",{className:"text-xs opacity-40 text-[#e2e8f0]",children:[s.size," nodes"]}),z.jsx("button",{className:"text-xs px-2 py-0.5 rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0] transition-colors",onClick:g,children:"Close"})]})]}),z.jsxs("div",{className:"flex items-center gap-3",children:[z.jsx("div",{className:"flex items-center gap-1",children:n?z.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0] transition-colors",onClick:f,title:"Pause",children:z.jsx(QB,{})}):z.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0] transition-colors",onClick:()=>{e>=t-1?E():d()},title:"Play",children:z.jsx(KB,{})})}),z.jsx("input",{type:"range",min:0,max:t-1,value:e,onChange:y,className:`flex-1 h-1.5 accent-[#6366f1] bg-[#2a2a3e] rounded-full appearance-none cursor-pointer
4796
+ #`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(i)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(i,e=ac){this.fullscreenMaterial.depthBuffer=i,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(i,e)}render(i,e,t,n,r){for(const s of this.effects)s.update(i,e,n);if(!this.skipRendering||this.renderToScreen){const s=this.fullscreenMaterial;s.inputBuffer=e.texture,s.time+=n*this.timeScale,i.setRenderTarget(this.renderToScreen?null:t),i.render(this.scene,this.camera)}}setSize(i,e){this.fullscreenMaterial.setSize(i,e);for(const t of this.effects)t.setSize(i,e)}initialize(i,e,t){this.renderer=i;for(const n of this.effects)n.initialize(i,e,t);this.updateMaterial(),t!==void 0&&t!==Oi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const i of this.effects)i.removeEventListener("change",this.listener),i.dispose()}handleEvent(i){switch(i.type){case"change":this.recompile();break}}},FF=class extends ws{constructor(i,e,{renderTarget:t,resolutionScale:n=1,width:r=Vr.AUTO_SIZE,height:s=Vr.AUTO_SIZE,resolutionX:a=r,resolutionY:c=s}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new cA(i,e,new yx);const d=this.renderPass;d.ignoreBackground=!0,d.skipShadowMapUpdate=!0;const f=d.getClearPass();f.overrideClearColor=new yt(7829503),f.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new Mi(1,1,{minFilter:Ui,magFilter:Ui}),this.renderTarget.texture.name="NormalPass.Target");const p=this.resolution=new Vr(this,a,c,n);p.addEventListener("change",g=>this.setSize(p.baseWidth,p.baseHeight))}set mainScene(i){this.renderPass.mainScene=i}set mainCamera(i){this.renderPass.mainCamera=i}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(i){this.resolution.scale=i}render(i,e,t,n,r){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(i,s,s)}setSize(i,e){const t=this.resolution;t.setBaseSize(i,e),this.renderTarget.setSize(t.width,t.height)}};const BF=te.createContext(null),fM=i=>(i.getAttributes()&sl.CONVOLUTION)===sl.CONVOLUTION,zF=yu.memo(te.forwardRef(({children:i,camera:e,scene:t,resolutionScale:n,enabled:r=!0,renderPriority:s=1,autoClear:a=!0,depthBuffer:c,enableNormalPass:d,stencilBuffer:f,multisampling:p=8,frameBufferType:g=nr},v)=>{const{gl:y,scene:E,camera:T,size:w}=br(),_=t||E,C=e||T,[b,I,N]=te.useMemo(()=>{const B=HN(),D=new CO(y,{depthBuffer:c,stencilBuffer:f,multisampling:p>0&&B?p:0,frameBufferType:g});D.addPass(new cA(_,C));let U=null,W=null;return d&&(W=new FF(_,C),W.enabled=!1,D.addPass(W),n!==void 0&&B&&(U=new RF({normalBuffer:W.texture,resolutionScale:n}),U.enabled=!1,D.addPass(U))),[D,W,U]},[C,y,c,f,p,g,_,d,n]);te.useEffect(()=>b==null?void 0:b.setSize(w.width,w.height),[b,w]),so((B,D)=>{if(r){const U=y.autoClear;y.autoClear=a,f&&!a&&y.clearStencil(),b.render(D),y.autoClear=U}},r?s:0);const O=te.useRef(null);te.useLayoutEffect(()=>{var B;const D=[],U=(B=O.current)==null?void 0:B.__r3f;if(U&&b){const W=U.objects;for(let ne=0;ne<W.length;ne++){const re=W[ne];if(re instanceof Dv){const he=[re];if(!fM(re)){let ce=null;for(;(ce=W[ne+1])instanceof Dv&&!fM(ce);)he.push(ce),ne++}const fe=new OF(C,...he);D.push(fe)}else re instanceof ws&&D.push(re)}for(const ne of D)b==null||b.addPass(ne);I&&(I.enabled=!0),N&&(N.enabled=!0)}return()=>{for(const W of D)b==null||b.removePass(W);I&&(I.enabled=!1),N&&(N.enabled=!1)}},[b,i,C,I,N]),te.useEffect(()=>{const B=y.toneMapping;return y.toneMapping=zo,()=>{y.toneMapping=B}},[y]);const H=te.useMemo(()=>({composer:b,normalPass:I,downSamplingPass:N,resolutionScale:n,camera:C,scene:_}),[b,I,N,n,C,_]);return te.useImperativeHandle(v,()=>b,[b]),z.jsx(BF.Provider,{value:H,children:z.jsx("group",{ref:O,children:i})})}));let kF=0;const pM=new WeakMap,uA=(i,e)=>yu.forwardRef(function({blendFunction:n=e==null?void 0:e.blendFunction,opacity:r=e==null?void 0:e.opacity,...s},a){let c=pM.get(i);if(!c){const p=`@react-three/postprocessing/${i.name}-${kF++}`;Gp({[p]:i}),pM.set(i,c=p)}const d=br(p=>p.camera),f=yu.useMemo(()=>{var p,g;return[...(p=e==null?void 0:e.args)!=null?p:[],...(g=s.args)!=null?g:[{...e,...s}]]},[JSON.stringify(s)]);return z.jsx(c,{camera:d,"blendMode-blendFunction":n,"blendMode-opacity-value":r,...s,ref:a,args:f})}),HF=uA(TF,{blendFunction:An.ADD}),VF=uA(PF);function GF(){return z.jsxs(zF,{children:[z.jsx(HF,{intensity:.8,luminanceThreshold:.15,luminanceSmoothing:.75,mipmapBlur:!0}),z.jsx(VF,{offset:.4,darkness:.85,blendFunction:An.NORMAL})]})}function WF(){const i=ni(v=>v.graph),e=ni(v=>v.moduleEdges),t=hn(v=>v.selectedModuleId),n=hn(v=>v.zoomLevel),r=hn(v=>v.interiorFileId),s=fr(v=>v.isTimelineActive),a=fr(v=>v.visibleNodeIds),c=te.useMemo(()=>i?RN(i):null,[i]),d=te.useMemo(()=>c?PN(c.modules,e):[],[c,e]),f=te.useMemo(()=>{if(!c)return new Map;const v=new Map;for(const y of c.buildings){if(s&&!a.has(y.nodeId))continue;const E=v.get(y.moduleId)??[];E.push(y),v.set(y.moduleId,E)}return v},[c,s,a]),p=te.useMemo(()=>c?s?c.buildings.filter(v=>a.has(v.nodeId)):c.buildings:[],[c,s,a]);if(!c)return null;const g=n===3&&r!==null;return z.jsxs(z.Fragment,{children:[z.jsx(OU,{}),z.jsx(BU,{}),z.jsx("ambientLight",{intensity:.3,color:"#a0b0d0"}),z.jsx("directionalLight",{position:[60,100,40],intensity:.6,color:"#c0d0ff",castShadow:!0,"shadow-mapSize":[2048,2048],"shadow-camera-far":250,"shadow-camera-left":-120,"shadow-camera-right":120,"shadow-camera-top":120,"shadow-camera-bottom":-120}),z.jsx("directionalLight",{position:[-40,50,-30],intensity:.35,color:"#ff9060"}),z.jsx("pointLight",{position:[0,40,0],intensity:.8,color:"#4a7bd9",distance:300,decay:1}),z.jsx("pointLight",{position:[80,15,80],intensity:.5,color:"#6366f1",distance:100,decay:2}),z.jsx("pointLight",{position:[-80,15,-80],intensity:.5,color:"#0ea5e9",distance:100,decay:2}),g?z.jsx(hO,{}):z.jsxs(z.Fragment,{children:[c.modules.map(v=>z.jsx(HU,{layout:v,isSelected:v.id===t},v.id)),c.modules.map(v=>{const y=f.get(v.id)??[];return z.jsx(XU,{buildings:y,moduleId:v.id},v.id)}),z.jsx(qU,{paths:d}),z.jsx(tO,{roads:d}),z.jsx(KU,{buildings:p}),z.jsx($U,{buildings:p}),z.jsx(mO,{buildings:p}),z.jsx(aO,{modules:c.modules,roads:d,center:c.center})]}),z.jsx(yO,{center:c.center}),z.jsx(GF,{})]})}function mM(){return z.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-[#0a0a1a] text-[#e2e8f0]",children:[z.jsx("div",{className:"text-3xl font-light mb-4 tracking-wider",children:"Cartographer"}),z.jsx("div",{className:"text-sm opacity-60 animate-pulse",children:"Loading city..."})]})}function jF({message:i}){return z.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-[#0a0a1a] text-[#e2e8f0]",children:[z.jsx("div",{className:"text-3xl font-light mb-4 tracking-wider text-red-400",children:"Error"}),z.jsx("div",{className:"text-sm opacity-80 max-w-md text-center",children:i}),z.jsx("button",{className:"mt-6 px-4 py-2 text-sm bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:()=>window.location.reload(),children:"Retry"})]})}const is=v0((i,e)=>({activeExpedition:null,currentStepIndex:0,isPlaying:!1,isPaused:!1,isListOpen:!1,startExpedition:t=>{i({activeExpedition:t,currentStepIndex:0,isPlaying:!0,isPaused:!1,isListOpen:!1})},nextStep:()=>{const{activeExpedition:t,currentStepIndex:n}=e();if(!t)return;const r=t.steps.length-1;n<r?i({currentStepIndex:n+1}):i({isPlaying:!1,isPaused:!1})},prevStep:()=>{const{currentStepIndex:t}=e();t>0&&i({currentStepIndex:t-1})},pause:()=>{i({isPaused:!0})},resume:()=>{i({isPaused:!1,isPlaying:!0})},stopExpedition:()=>{i({activeExpedition:null,currentStepIndex:0,isPlaying:!1,isPaused:!1})},toggleList:()=>{i(t=>({isListOpen:!t.isListOpen}))}}));function XF(){const i=ni(_=>_.graph),e=ni(_=>_.isLive),t=ni(_=>_.liveStatus),n=hn(_=>_.zoomLevel),r=hn(_=>_.selectedModuleId),s=hn(_=>_.selectedFileId),a=hn(_=>_.flyToSatellite),c=hn(_=>_.enterBuilding),d=hn(_=>_.exitBuilding),f=ni(_=>_.modules),p=is(_=>_.toggleList),g=is(_=>_.isListOpen),v=fr(_=>_.isTimelineActive),y=fr(_=>_.activateTimeline),E=fr(_=>_.deactivateTimeline);if(!i)return null;const T=f.find(_=>_.id===r),w=i.evolution.length>0;return z.jsx("div",{className:"absolute top-4 left-4 pointer-events-none",children:z.jsxs("div",{className:"bg-[#0a0a1a]/75 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e]",children:[z.jsx("div",{className:"text-sm font-medium mb-1",children:i.meta.repo}),z.jsxs("div",{className:"text-xs opacity-60",children:[i.meta.totalFiles," files · ",i.meta.totalModules," modules · ",i.meta.languages.join(", ")]}),e&&z.jsxs("div",{className:"flex items-center gap-1.5 mt-2",children:[z.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),z.jsx("span",{className:"text-xs opacity-60",children:"LIVE"}),t&&z.jsx("span",{className:"text-xs opacity-40 ml-1",children:t})]}),n===1&&T&&z.jsxs("div",{className:"mt-2 pt-2 border-t border-[#2a2a3e]",children:[z.jsxs("div",{className:"text-xs opacity-80",children:["Module: ",z.jsx("span",{className:"font-medium",children:T.name})]}),z.jsx("button",{className:"pointer-events-auto mt-1 text-xs px-2 py-1 bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:a,children:"Back to Overview"}),s&&z.jsx("button",{className:"pointer-events-auto mt-1 text-xs px-2 py-1 bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:()=>{const _=i==null?void 0:i.nodes.find(C=>C.id===s);_&&c(_)},children:"Enter Building"})]}),n===3&&z.jsxs("div",{className:"mt-2 pt-2 border-t border-[#2a2a3e]",children:[z.jsx("div",{className:"text-xs opacity-80",children:"Interior View"}),z.jsx("button",{className:"pointer-events-auto mt-1 text-xs px-2 py-1 bg-[#1a1a2e] rounded hover:bg-[#2a2a3e] transition-colors",onClick:d,children:"Exit Building"})]}),z.jsxs("div",{className:"mt-2 pt-2 border-t border-[#2a2a3e] flex gap-2",children:[z.jsx("button",{className:`pointer-events-auto text-xs px-2 py-1 rounded transition-colors ${g?"bg-[#6366f1]/20 text-[#818CF8]":"bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0]"}`,onClick:p,children:"Expeditions"}),w&&z.jsx("button",{className:`pointer-events-auto text-xs px-2 py-1 rounded transition-colors ${v?"bg-[#6366f1]/20 text-[#818CF8]":"bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0]"}`,onClick:()=>{v?E():y(i.evolution)},children:"Timeline"})]})]})})}const gM={api:"#3B82F6",middleware:"#8B5CF6",business_logic:"#22C55E",data_access:"#F59E0B",utility:"#94A3B8",configuration:"#6B7280",presentation:"#EC4899",infrastructure:"#F97316",testing:"#14B8A6"};function YF({score:i}){return i===50?z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("span",{className:"text-2xl font-bold opacity-40",children:"--"}),z.jsx("span",{className:"text-xs opacity-40",children:"Not computed"})]}):z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("span",{className:"text-2xl font-bold",style:{color:x0(i)},children:Math.round(i)}),z.jsx("span",{className:"text-xs opacity-60",children:"/ 100"})]})}function ZF({file:i}){var t,n,r,s;if(i.healthScore===50&&i.complexity===0)return null;const e=[{label:"Complexity",score:Math.max(0,100-Math.min(i.complexity*3,100)),detail:`${i.complexity} cyclomatic`},{label:"Churn stability",score:i.churnScore>0?Math.round((1-i.churnScore)*100):75,detail:i.churnScore>0?`${Math.round(i.churnScore*100)}% churn`:"No data"},{label:"Type safety",score:(t=i.path)!=null&&t.endsWith(".ts")||(n=i.path)!=null&&n.endsWith(".tsx")?100:30,detail:(r=i.path)!=null&&r.endsWith(".ts")||(s=i.path)!=null&&s.endsWith(".tsx")?"TypeScript":"JavaScript"},{label:"Bus factor",score:i.busFactor===0?50:i.busFactor===1?25:Math.min(100,i.busFactor*30),detail:i.busFactor>0?`${i.busFactor} contributor(s)`:"No data"},{label:"Size",score:i.loc<100?100:i.loc<300?70:i.loc<500?40:20,detail:`${i.loc} lines`}];return z.jsx("div",{className:"space-y-1.5",children:e.map(a=>z.jsxs("div",{children:[z.jsxs("div",{className:"flex justify-between text-[10px] mb-0.5",children:[z.jsx("span",{className:"opacity-60",children:a.label}),z.jsx("span",{className:"opacity-40",children:a.detail})]}),z.jsx("div",{className:"h-1 bg-[#1a1a2e] rounded-full overflow-hidden",children:z.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a.score}%`,backgroundColor:a.score>=70?"#22C55E":a.score>=40?"#F59E0B":"#EF4444"}})})]},a.label))})}function qF({score:i}){const e=Math.min(100,Math.round(i*100)),t=e>70?"#EF4444":e>40?"#F59E0B":"#22C55E";return z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("div",{className:"flex-1 h-1.5 bg-[#2a2a3e] rounded-full overflow-hidden",children:z.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${e}%`,backgroundColor:t}})}),z.jsxs("span",{className:"text-xs w-8 text-right",children:[e,"%"]})]})}function KF({file:i}){return i.totalCommits>0||i.lastModified!==null||i.churnScore>0||i.busFactor>0||i.primaryOwner!==null?z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Git"}),z.jsxs("div",{className:"space-y-1.5 text-xs",children:[i.totalCommits>0&&z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Commits"}),z.jsx("span",{children:i.totalCommits})]}),i.lastModified&&z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Last modified"}),z.jsx("span",{children:new Date(i.lastModified).toLocaleDateString()})]}),i.churnScore>0&&z.jsxs("div",{children:[z.jsx("div",{className:"flex justify-between mb-0.5",children:z.jsx("span",{className:"opacity-60",children:"Churn"})}),z.jsx(qF,{score:i.churnScore})]}),i.busFactor>0&&z.jsxs("div",{className:"flex justify-between items-center",children:[z.jsx("span",{className:"opacity-60",children:"Bus factor"}),z.jsxs("span",{className:"flex items-center gap-1",children:[i.busFactor,i.busFactor===1&&z.jsx("span",{className:"text-[#EF4444] text-[10px]",title:"Single point of failure",children:"!!"})]})]}),i.primaryOwner&&z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Primary owner"}),z.jsx("span",{className:"truncate ml-2 max-w-[140px]",children:i.primaryOwner})]})]})]}):z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Git"}),z.jsx("div",{className:"text-xs opacity-40 italic",children:"Git data not available"})]})}function QF(){const i=hn(c=>c.selectedFunctionId),e=hn(c=>c.clearSelection),t=ni(c=>c.graph),n=ni(c=>c.callEdges),r=te.useMemo(()=>!t||!i?null:t.nodes.find(c=>c.id===i)??null,[t,i]),{callers:s,callees:a}=te.useMemo(()=>{if(!t||!i)return{callers:[],callees:[]};const c=[],d=[];for(const f of n){if(f.sourceId===i){const p=t.nodes.find(g=>g.id===f.targetId);p&&d.push(p)}if(f.targetId===i){const p=t.nodes.find(g=>g.id===f.sourceId);p&&c.push(p)}}return{callers:c,callees:d}},[t,i,n]);return r?z.jsx("div",{className:"absolute right-4 top-4 w-80 max-h-[calc(100vh-2rem)] overflow-y-auto",children:z.jsxs("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e] space-y-4",children:[z.jsxs("div",{children:[z.jsxs("div",{className:"flex items-start justify-between gap-2",children:[z.jsx("div",{className:"text-sm font-medium font-mono break-words",children:r.name}),z.jsx("button",{className:"text-xs opacity-60 hover:opacity-100 transition-opacity shrink-0 mt-0.5",onClick:()=>e(),children:"x"})]}),z.jsxs("div",{className:"text-[10px] opacity-40 mt-0.5",children:[r.kind==="function"?"Function":r.kind,r.tags.includes("exported")&&z.jsx("span",{className:"ml-1 text-[#22C55E]",children:"(exported)"})]})]}),r.summary&&z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Summary"}),z.jsx("p",{className:"text-sm leading-relaxed",children:r.summary}),r.explanation&&z.jsx("p",{className:"text-xs opacity-70 mt-1 leading-relaxed",children:r.explanation})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Metrics"}),z.jsxs("div",{className:"space-y-1 text-xs",children:[z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Complexity"}),z.jsx("span",{children:r.complexity})]}),z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Lines of code"}),z.jsx("span",{children:r.loc})]})]})]}),s.length>0&&z.jsxs("div",{children:[z.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:["Called by (",s.length,")"]}),z.jsxs("div",{className:"space-y-1",children:[s.slice(0,10).map(c=>z.jsx("div",{className:"text-xs font-mono opacity-70 truncate",children:c.name},c.id)),s.length>10&&z.jsxs("div",{className:"text-[10px] opacity-40",children:["+",s.length-10," more"]})]})]}),a.length>0&&z.jsxs("div",{children:[z.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:["Calls (",a.length,")"]}),z.jsxs("div",{className:"space-y-1",children:[a.slice(0,10).map(c=>z.jsx("div",{className:"text-xs font-mono opacity-70 truncate",children:c.name},c.id)),a.length>10&&z.jsxs("div",{className:"text-[10px] opacity-40",children:["+",a.length-10," more"]})]})]}),r.tags.length>0&&z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Tags"}),z.jsx("div",{className:"flex flex-wrap gap-1",children:r.tags.map(c=>z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[#2a2a3e] opacity-70",children:c},c))})]})]})}):null}function JF(){const i=hn(p=>p.zoomLevel),e=hn(p=>p.selectedFileId),t=hn(p=>p.selectedFunctionId),n=hn(p=>p.clearSelection),r=ni(p=>p.graph),s=ni(p=>p.modules),[a,c]=te.useState(!1);if(i===3&&t)return z.jsx(QF,{});if(!e||!r)return null;const d=r.nodes.find(p=>p.id===e);if(!d)return null;const f=s.find(p=>p.id===d.parentId);return z.jsx("div",{className:"absolute right-4 top-4 w-80 max-h-[calc(100vh-2rem)] overflow-y-auto",children:z.jsxs("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e] space-y-4",children:[z.jsxs("div",{children:[z.jsxs("div",{className:"flex items-start justify-between gap-2",children:[z.jsx("div",{className:"text-sm font-medium break-words",children:d.name}),z.jsx("button",{className:"text-xs opacity-60 hover:opacity-100 transition-opacity shrink-0 mt-0.5",onClick:()=>n(),children:"x"})]}),d.path&&z.jsx("div",{className:"text-xs opacity-50 mt-1 break-all",children:d.path}),f&&z.jsxs("div",{className:"text-xs opacity-40 mt-0.5",children:["Module: ",f.name]})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"AI Summary"}),d.summary?z.jsxs("div",{children:[z.jsx("p",{className:"text-sm leading-relaxed",children:d.summary}),d.explanation&&z.jsxs("div",{className:"mt-1",children:[z.jsx("button",{className:"text-[10px] opacity-50 hover:opacity-80 transition-opacity",onClick:()=>c(!a),children:a?"Collapse":"Show more"}),a&&z.jsx("p",{className:"text-xs opacity-70 mt-1 leading-relaxed",children:d.explanation})]})]}):z.jsx("p",{className:"text-xs opacity-40 italic",children:"No AI summary available"})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Health"}),z.jsx(YF,{score:d.healthScore}),z.jsx(ZF,{file:d})]}),z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Metrics"}),z.jsxs("div",{className:"space-y-1 text-xs",children:[z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Lines of code"}),z.jsx("span",{children:d.loc})]}),z.jsxs("div",{className:"flex justify-between",children:[z.jsx("span",{className:"opacity-60",children:"Complexity"}),z.jsx("span",{children:d.complexity})]})]})]}),z.jsx(KF,{file:d}),(d.layer||d.tags.length>0)&&z.jsxs("div",{children:[z.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider opacity-40 mb-1",children:"Classification"}),z.jsxs("div",{className:"flex flex-wrap gap-1",children:[d.layer&&z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:(gM[d.layer]??"#6B7280")+"30",color:gM[d.layer]??"#6B7280"},children:d.layer.replace(/_/g," ")}),d.tags.map(p=>z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[#2a2a3e] opacity-70",children:p},p))]})]})]})})}function fc(i){return Array.isArray?Array.isArray(i):dA(i)==="[object Array]"}function $F(i){if(typeof i=="string")return i;let e=i+"";return e=="0"&&1/i==-1/0?"-0":e}function vM(i){return i==null?"":$F(i)}function Bs(i){return typeof i=="string"}function Vy(i){return typeof i=="number"}function eB(i){return i===!0||i===!1||tB(i)&&dA(i)=="[object Boolean]"}function hA(i){return typeof i=="object"}function tB(i){return hA(i)&&i!==null}function Fs(i){return i!=null}function Wg(i){return!i.trim().length}function dA(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}const nB="Incorrect 'index' type",iB=i=>`Invalid value for key ${i}`,rB=i=>`Pattern length exceeds max of ${i}.`,sB=i=>`Missing ${i} property in key`,oB=i=>`Property 'weight' in key '${i}' must be a positive integer`,_M=Object.prototype.hasOwnProperty;class aB{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(n=>{let r=fA(n);this._keys.push(r),this._keyMap[r.id]=r,t+=r.weight}),this._keys.forEach(n=>{n.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function fA(i){let e=null,t=null,n=null,r=1,s=null;if(Bs(i)||fc(i))n=i,e=yM(i),t=Gy(i);else{if(!_M.call(i,"name"))throw new Error(sB("name"));const a=i.name;if(n=a,_M.call(i,"weight")&&(r=i.weight,r<=0))throw new Error(oB(a));e=yM(a),t=Gy(a),s=i.getFn}return{path:e,id:t,weight:r,src:n,getFn:s}}function yM(i){return fc(i)?i:i.split(".")}function Gy(i){return fc(i)?i.join("."):i}function lB(i,e){let t=[],n=!1;const r=(s,a,c,d)=>{if(Fs(s))if(!a[c])t.push(d!==void 0?{v:s,i:d}:s);else{let f=a[c];const p=s[f];if(!Fs(p))return;if(c===a.length-1&&(Bs(p)||Vy(p)||eB(p)))t.push(d!==void 0?{v:vM(p),i:d}:vM(p));else if(fc(p)){n=!0;for(let g=0,v=p.length;g<v;g+=1)r(p[g],a,c+1,g)}else a.length&&r(p,a,c+1,d)}};return r(i,Bs(e)?e.split("."):e,0),n?t:t[0]}const cB={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},uB={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(i,e)=>i.score===e.score?i.idx<e.idx?-1:1:i.score<e.score?-1:1},hB={location:0,threshold:.6,distance:100},dB={useExtendedSearch:!1,getFn:lB,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var nn={...uB,...cB,...hB,...dB};const fB=/[^ ]+/g;function pB(i=1,e=3){const t=new Map,n=Math.pow(10,e);return{get(r){const s=r.match(fB).length;if(t.has(s))return t.get(s);const a=1/Math.pow(s,.5*i),c=parseFloat(Math.round(a*n)/n);return t.set(s,c),c},clear(){t.clear()}}}class Kx{constructor({getFn:e=nn.getFn,fieldNormWeight:t=nn.fieldNormWeight}={}){this.norm=pB(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,n)=>{this._keysMap[t.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Bs(this.docs[0])?this.docs.forEach((e,t)=>{this._addString(e,t)}):this.docs.forEach((e,t)=>{this._addObject(e,t)}),this.norm.clear())}add(e){const t=this.size();Bs(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}removeAll(e){for(let t=e.length-1;t>=0;t-=1)this.records.splice(e[t],1);for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i=t}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!Fs(e)||Wg(e))return;let n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}_addObject(e,t){let n={i:t,$:{}};this.keys.forEach((r,s)=>{let a=r.getFn?r.getFn(e):this.getFn(e,r.path);if(Fs(a)){if(fc(a)){let c=[];for(let d=0,f=a.length;d<f;d+=1){const p=a[d];if(Fs(p)){if(Bs(p)){if(!Wg(p)){let g={v:p,i:d,n:this.norm.get(p)};c.push(g)}}else if(Bs(p.v)&&!Wg(p.v)){let g={v:p.v,i:p.i,n:this.norm.get(p.v)};c.push(g)}}}n.$[s]=c}else if(Bs(a)&&!Wg(a)){let c={v:a,n:this.norm.get(a)};n.$[s]=c}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function pA(i,e,{getFn:t=nn.getFn,fieldNormWeight:n=nn.fieldNormWeight}={}){const r=new Kx({getFn:t,fieldNormWeight:n});return r.setKeys(i.map(fA)),r.setSources(e),r.create(),r}function mB(i,{getFn:e=nn.getFn,fieldNormWeight:t=nn.fieldNormWeight}={}){const{keys:n,records:r}=i,s=new Kx({getFn:e,fieldNormWeight:t});return s.setKeys(n),s.setIndexRecords(r),s}function gB(i=[],e=nn.minMatchCharLength){let t=[],n=-1,r=-1,s=0;for(let a=i.length;s<a;s+=1){let c=i[s];c&&n===-1?n=s:!c&&n!==-1&&(r=s-1,r-n+1>=e&&t.push([n,r]),n=-1)}return i[s-1]&&s-n>=e&&t.push([n,s-1]),t}const _u=32;function vB(i,e,t,{location:n=nn.location,distance:r=nn.distance,threshold:s=nn.threshold,findAllMatches:a=nn.findAllMatches,minMatchCharLength:c=nn.minMatchCharLength,includeMatches:d=nn.includeMatches,ignoreLocation:f=nn.ignoreLocation}={}){if(e.length>_u)throw new Error(rB(_u));const p=e.length,g=i.length,v=Math.max(0,Math.min(n,g));let y=s,E=v;const T=(B,D)=>{const U=B/p;if(f)return U;const W=Math.abs(v-D);return r?U+W/r:W?1:U},w=c>1||d,_=w?Array(g):[];let C;for(;(C=i.indexOf(e,E))>-1;){let B=T(0,C);if(y=Math.min(B,y),E=C+p,w){let D=0;for(;D<p;)_[C+D]=1,D+=1}}E=-1;let b=[],I=1,N=p+g;const O=1<<p-1;for(let B=0;B<p;B+=1){let D=0,U=N;for(;D<U;)T(B,v+U)<=y?D=U:N=U,U=Math.floor((N-D)/2+D);N=U;let W=Math.max(1,v-U+1),ne=a?g:Math.min(v+U,g)+p,re=Array(ne+2);re[ne+1]=(1<<B)-1;for(let fe=ne;fe>=W;fe-=1){let ce=fe-1,xe=t[i[ce]];if(w&&(_[ce]=+!!xe),re[fe]=(re[fe+1]<<1|1)&xe,B&&(re[fe]|=(b[fe+1]|b[fe])<<1|1|b[fe+1]),re[fe]&O&&(I=T(B,ce),I<=y)){if(y=I,E=ce,E<=v)break;W=Math.max(1,2*v-E)}}if(T(B+1,v)>y)break;b=re}const H={isMatch:E>=0,score:Math.max(.001,I)};if(w){const B=gB(_,c);B.length?d&&(H.indices=B):H.isMatch=!1}return H}function _B(i){let e={};for(let t=0,n=i.length;t<n;t+=1){const r=i.charAt(t);e[r]=(e[r]||0)|1<<n-t-1}return e}const Nv=String.prototype.normalize?(i=>i.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(i=>i);function yB(i){if(i.length<=1)return i;i.sort((t,n)=>t[0]-n[0]||t[1]-n[1]);const e=[i[0]];for(let t=1,n=i.length;t<n;t+=1){const r=e[e.length-1],s=i[t];s[0]<=r[1]+1?r[1]=Math.max(r[1],s[1]):e.push(s)}return e}class mA{constructor(e,{location:t=nn.location,threshold:n=nn.threshold,distance:r=nn.distance,includeMatches:s=nn.includeMatches,findAllMatches:a=nn.findAllMatches,minMatchCharLength:c=nn.minMatchCharLength,isCaseSensitive:d=nn.isCaseSensitive,ignoreDiacritics:f=nn.ignoreDiacritics,ignoreLocation:p=nn.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:s,findAllMatches:a,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:f,ignoreLocation:p},e=d?e:e.toLowerCase(),e=f?Nv(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const g=(y,E)=>{this.chunks.push({pattern:y,alphabet:_B(y),startIndex:E})},v=this.pattern.length;if(v>_u){let y=0;const E=v%_u,T=v-E;for(;y<T;)g(this.pattern.substr(y,_u),y),y+=_u;if(E){const w=v-_u;g(this.pattern.substr(w),w)}}else g(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Nv(e):e,this.pattern===e){let T={isMatch:!0,score:0};return r&&(T.indices=[[0,e.length-1]]),T}const{location:s,distance:a,threshold:c,findAllMatches:d,minMatchCharLength:f,ignoreLocation:p}=this.options;let g=[],v=0,y=!1;this.chunks.forEach(({pattern:T,alphabet:w,startIndex:_})=>{const{isMatch:C,score:b,indices:I}=vB(e,T,w,{location:s+_,distance:a,threshold:c,findAllMatches:d,minMatchCharLength:f,includeMatches:r,ignoreLocation:p});C&&(y=!0),v+=b,C&&I&&g.push(...I)});let E={isMatch:y,score:y?v/this.chunks.length:1};return y&&r&&(E.indices=yB(g)),E}}class pc{constructor(e){this.pattern=e}static isMultiMatch(e){return xM(e,this.multiRegex)}static isSingleMatch(e){return xM(e,this.singleRegex)}search(){}}function xM(i,e){const t=i.match(e);return t?t[1]:null}class xB extends pc{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class SB extends pc{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class EB extends pc{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}class MB extends pc{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class wB extends pc{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class TB extends pc{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}class gA extends pc{constructor(e,{location:t=nn.location,threshold:n=nn.threshold,distance:r=nn.distance,includeMatches:s=nn.includeMatches,findAllMatches:a=nn.findAllMatches,minMatchCharLength:c=nn.minMatchCharLength,isCaseSensitive:d=nn.isCaseSensitive,ignoreDiacritics:f=nn.ignoreDiacritics,ignoreLocation:p=nn.ignoreLocation}={}){super(e),this._bitapSearch=new mA(e,{location:t,threshold:n,distance:r,includeMatches:s,findAllMatches:a,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:f,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class vA extends pc{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t=0,n;const r=[],s=this.pattern.length;for(;(n=e.indexOf(this.pattern,t))>-1;)t=n+s,r.push([n,t-1]);const a=!!r.length;return{isMatch:a,score:a?0:1,indices:r}}}const Wy=[xB,vA,EB,MB,TB,wB,SB,gA],SM=Wy.length,AB=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,CB="|";function bB(i,e={}){return i.split(CB).map(t=>{let n=t.trim().split(AB).filter(s=>s&&!!s.trim()),r=[];for(let s=0,a=n.length;s<a;s+=1){const c=n[s];let d=!1,f=-1;for(;!d&&++f<SM;){const p=Wy[f];let g=p.isMultiMatch(c);g&&(r.push(new p(g,e)),d=!0)}if(!d)for(f=-1;++f<SM;){const p=Wy[f];let g=p.isSingleMatch(c);if(g){r.push(new p(g,e));break}}}return r})}const RB=new Set([gA.type,vA.type]);class IB{constructor(e,{isCaseSensitive:t=nn.isCaseSensitive,ignoreDiacritics:n=nn.ignoreDiacritics,includeMatches:r=nn.includeMatches,minMatchCharLength:s=nn.minMatchCharLength,ignoreLocation:a=nn.ignoreLocation,findAllMatches:c=nn.findAllMatches,location:d=nn.location,threshold:f=nn.threshold,distance:p=nn.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:s,findAllMatches:c,ignoreLocation:a,location:d,threshold:f,distance:p},e=t?e:e.toLowerCase(),e=n?Nv(e):e,this.pattern=e,this.query=bB(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:s}=this.options;e=r?e:e.toLowerCase(),e=s?Nv(e):e;let a=0,c=[],d=0;for(let f=0,p=t.length;f<p;f+=1){const g=t[f];c.length=0,a=0;for(let v=0,y=g.length;v<y;v+=1){const E=g[v],{isMatch:T,indices:w,score:_}=E.search(e);if(T){if(a+=1,d+=_,n){const C=E.constructor.type;RB.has(C)?c.push(...w):c.push(w)}}else{d=0,a=0,c.length=0;break}}if(a){let v={isMatch:!0,score:d/a};return n&&(v.indices=c),v}}return{isMatch:!1,score:1}}}const jy=[];function _A(...i){jy.push(...i)}function yA(i,e){for(let t=0,n=jy.length;t<n;t+=1){let r=jy[t];if(r.condition(i,e))return new r(i,e)}return new mA(i,e)}const Uv={AND:"$and",OR:"$or"},Xy={PATH:"$path",PATTERN:"$val"},Yy=i=>!!(i[Uv.AND]||i[Uv.OR]),PB=i=>!!i[Xy.PATH],LB=i=>!fc(i)&&hA(i)&&!Yy(i),EM=i=>({[Uv.AND]:Object.keys(i).map(e=>({[e]:i[e]}))});function xA(i,e,{auto:t=!0}={}){const n=r=>{let s=Object.keys(r);const a=PB(r);if(!a&&s.length>1&&!Yy(r))return n(EM(r));if(LB(r)){const d=a?r[Xy.PATH]:s[0],f=a?r[Xy.PATTERN]:r[d];if(!Bs(f))throw new Error(iB(d));const p={keyId:Gy(d),pattern:f};return t&&(p.searcher=yA(f,e)),p}let c={children:[],operator:s[0]};return s.forEach(d=>{const f=r[d];fc(f)&&f.forEach(p=>{c.children.push(n(p))})}),c};return Yy(i)||(i=EM(i)),n(i)}function Zy(i,{ignoreFieldNorm:e=nn.ignoreFieldNorm}){let t=1;i.matches.forEach(({key:n,norm:r,score:s})=>{const a=n?n.weight:null;t*=Math.pow(s===0&&a?Number.EPSILON:s,(a||1)*(e?1:r))}),i.score=t}function DB(i,{ignoreFieldNorm:e=nn.ignoreFieldNorm}){i.forEach(t=>{Zy(t,{ignoreFieldNorm:e})})}class NB{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){const t=this.heap;for(;e>0;){const n=e-1>>1;if(t[e].score<=t[n].score)break;const r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){const t=this.heap,n=t.length;let r=e;do{e=r;const s=2*e+1,a=2*e+2;if(s<n&&t[s].score>t[r].score&&(r=s),a<n&&t[a].score>t[r].score&&(r=a),r!==e){const c=t[e];t[e]=t[r],t[r]=c}}while(r!==e)}}function UB(i,e){const t=i.matches;e.matches=[],Fs(t)&&t.forEach(n=>{if(!Fs(n.indices)||!n.indices.length)return;const{indices:r,value:s}=n;let a={indices:r,value:s};n.key&&(a.key=n.key.src),n.idx>-1&&(a.refIndex=n.idx),e.matches.push(a)})}function OB(i,e){e.score=i.score}function FB(i,e,{includeMatches:t=nn.includeMatches,includeScore:n=nn.includeScore}={}){const r=[];return t&&r.push(UB),n&&r.push(OB),i.map(s=>{const{idx:a}=s,c={item:e[a],refIndex:a};return r.length&&r.forEach(d=>{d(s,c)}),c})}class zu{constructor(e,t={},n){this.options={...nn,...t},this.options.useExtendedSearch,this._keyStore=new aB(this.options.keys),this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=yA(e,this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Kx))throw new Error(nB);this._myIndex=t||pA(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Fs(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[],n=[];for(let r=0,s=this._docs.length;r<s;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){for(let r=n.length-1;r>=0;r-=1)this._docs.splice(n[r],1);this._myIndex.removeAll(n)}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:s,sortFn:a,ignoreFieldNorm:c}=this.options,d=Vy(t)&&t>0&&Bs(e);let f;if(d){const p=new NB(t);Bs(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),f=p.extractSorted(a)}else f=Bs(e)?Bs(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),DB(f,{ignoreFieldNorm:c}),s&&f.sort(a),Vy(t)&&t>-1&&(f=f.slice(0,t));return FB(f,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){const r=this._getSearcher(e),{records:s}=this._myIndex,a=t?null:[];return s.forEach(({v:c,i:d,n:f})=>{if(!Fs(c))return;const{isMatch:p,score:g,indices:v}=r.searchIn(c);if(p){const y={item:c,idx:d,matches:[{score:g,value:c,norm:f,indices:v}]};t?(Zy(y,{ignoreFieldNorm:n}),t.shouldInsert(y.score)&&t.insert(y)):a.push(y)}}),a}_searchLogical(e){const t=xA(e,this.options),n=(c,d,f)=>{if(!c.children){const{keyId:g,searcher:v}=c,y=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(d,g),searcher:v});return y&&y.length?[{idx:f,item:d,matches:y}]:[]}const p=[];for(let g=0,v=c.children.length;g<v;g+=1){const y=c.children[g],E=n(y,d,f);if(E.length)p.push(...E);else if(c.operator===Uv.AND)return[]}return p},r=this._myIndex.records,s=new Map,a=[];return r.forEach(({$:c,i:d})=>{if(Fs(c)){let f=n(t,c,d);f.length&&(s.has(d)||(s.set(d,{idx:d,item:c,matches:[]}),a.push(s.get(d))),f.forEach(({matches:p})=>{s.get(d).matches.push(...p)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){const r=this._getSearcher(e),{keys:s,records:a}=this._myIndex,c=t?null:[];return a.forEach(({$:d,i:f})=>{if(!Fs(d))return;let p=[];if(s.forEach((g,v)=>{p.push(...this._findMatches({key:g,value:d[v],searcher:r}))}),p.length){const g={idx:f,item:d,matches:p};t?(Zy(g,{ignoreFieldNorm:n}),t.shouldInsert(g.score)&&t.insert(g)):c.push(g)}}),c}_findMatches({key:e,value:t,searcher:n}){if(!Fs(t))return[];let r=[];if(fc(t))t.forEach(({v:s,i:a,n:c})=>{if(!Fs(s))return;const{isMatch:d,score:f,indices:p}=n.searchIn(s);d&&r.push({score:f,key:e,value:s,idx:a,norm:c,indices:p})});else{const{v:s,n:a}=t,{isMatch:c,score:d,indices:f}=n.searchIn(s);c&&r.push({score:d,key:e,value:s,norm:a,indices:f})}return r}}zu.version="7.2.0";zu.createIndex=pA;zu.parseIndex=mB;zu.config=nn;zu.parseQuery=xA;_A(IB);zu.use=function(...i){i.forEach(e=>_A(e))};function BB({kind:i}){switch(i){case"module":return z.jsx("span",{className:"text-xs opacity-70",children:"[M]"});case"file":return z.jsx("span",{className:"text-xs opacity-70",children:"[F]"});case"function":return z.jsx("span",{className:"text-xs opacity-70",children:"[fn]"});case"class":return z.jsx("span",{className:"text-xs opacity-70",children:"[C]"});default:return z.jsx("span",{className:"text-xs opacity-70",children:"[?]"})}}function zB(i,e){return i?i.length<=e?i:"..."+i.slice(i.length-e+3):""}function kB(){const i=hn(_=>_.isSearchOpen),e=hn(_=>_.toggleSearch),t=hn(_=>_.flyToModule),n=hn(_=>_.flyToFile),r=hn(_=>_.selectFile),s=ni(_=>_.graph),a=ni(_=>_.modules),[c,d]=te.useState(""),[f,p]=te.useState(0),g=te.useRef(null),v=te.useMemo(()=>{const _=new Map;for(const C of a)_.set(C.id,C.name);return _},[a]),y=te.useMemo(()=>{if(!s)return null;const _=s.nodes.filter(C=>C.kind==="module"||C.kind==="file");return new zu(_,{keys:[{name:"name",weight:2},{name:"path",weight:1},{name:"summary",weight:.5}],threshold:.4,includeScore:!0})},[s]),E=te.useMemo(()=>!y||!c.trim()?[]:y.search(c,{limit:15}).map(_=>_.item),[y,c]);te.useEffect(()=>{p(0)},[E]),te.useEffect(()=>{i&&(d(""),p(0),requestAnimationFrame(()=>{var _;(_=g.current)==null||_.focus()}))},[i]),te.useEffect(()=>{function _(C){(C.metaKey||C.ctrlKey)&&C.key==="k"&&(C.preventDefault(),e())}return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e]);const T=te.useCallback(_=>{_.kind==="module"?t(_):(n(_),r(_.id)),e()},[t,n,r,e]),w=te.useCallback(_=>{_.key==="ArrowDown"?(_.preventDefault(),p(C=>Math.min(C+1,E.length-1))):_.key==="ArrowUp"?(_.preventDefault(),p(C=>Math.max(C-1,0))):_.key==="Enter"?(_.preventDefault(),E[f]&&T(E[f])):_.key==="Escape"&&(_.preventDefault(),e())},[E,f,T,e]);return i?z.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:_=>{_.target===_.currentTarget&&e()},children:[z.jsx("div",{className:"absolute inset-0 bg-[#0a0a1a]/90 backdrop-blur-md"}),z.jsx("div",{className:"relative w-full max-w-lg mx-4",children:z.jsxs("div",{className:"bg-[#1a1a2e] rounded-lg border border-[#3a3a4e] overflow-hidden shadow-2xl",children:[z.jsxs("div",{className:"flex items-center px-4 py-3 gap-3",children:[z.jsx("span",{className:"text-[#94a3b8] text-sm shrink-0",children:"/"}),z.jsx("input",{ref:g,type:"text",value:c,onChange:_=>d(_.target.value),onKeyDown:w,placeholder:"Search files, modules...",className:"flex-1 bg-transparent text-[#e2e8f0] text-sm outline-none placeholder:text-[#4a4a6e]"}),z.jsx("kbd",{className:"text-[10px] text-[#94a3b8] border border-[#3a3a4e] rounded px-1.5 py-0.5 shrink-0",children:"ESC"})]}),E.length>0&&z.jsx("div",{className:"border-t border-[#2a2a3e] max-h-80 overflow-y-auto",children:E.map((_,C)=>z.jsxs("button",{className:`w-full text-left px-4 py-2.5 flex items-center gap-3 transition-colors ${C===f?"bg-[#2a2a3e]":"hover:bg-[#1f1f35]"}`,onClick:()=>T(_),onMouseEnter:()=>p(C),children:[z.jsx(BB,{kind:_.kind}),z.jsxs("div",{className:"flex-1 min-w-0",children:[z.jsx("div",{className:"text-sm text-[#e2e8f0] truncate",children:_.name}),z.jsx("div",{className:"text-[10px] text-[#94a3b8] truncate",children:_.path?zB(_.path,50):v.get(_.id)??""})]}),_.healthScore!==50&&z.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:x0(_.healthScore)},title:`Health: ${Math.round(_.healthScore)}`}),_.kind==="file"&&_.parentId&&z.jsx("span",{className:"text-[10px] text-[#94a3b8] opacity-60 shrink-0",children:v.get(_.parentId)??""})]},_.id))}),c.trim()&&E.length===0&&z.jsx("div",{className:"border-t border-[#2a2a3e] px-4 py-6 text-center text-xs text-[#94a3b8] opacity-60",children:"No results found"})]})})]}):null}function HB({onClose:i}){const[e,t]=te.useState(""),[n,r]=te.useState(!1),[s,a]=te.useState(null),c=te.useRef(null),d=is(p=>p.startExpedition);te.useEffect(()=>{requestAnimationFrame(()=>{var p;(p=c.current)==null||p.focus()})},[]),te.useEffect(()=>{function p(g){g.key==="Escape"&&i()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[i]);const f=te.useCallback(async()=>{const p=e.trim();if(!(!p||n)){r(!0),a(null);try{const g=await fetch("/api/expedition/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:p})});if(!g.ok){const y=await g.text();throw new Error(y||`Request failed with status ${g.status}`)}const v=await g.json();d(v),i()}catch(g){a(g instanceof Error?g.message:"Failed to generate expedition")}finally{r(!1)}}},[e,n,d,i]);return z.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:p=>{p.target===p.currentTarget&&!n&&i()},children:[z.jsx("div",{className:"absolute inset-0 bg-[#0a0a1a]/80 backdrop-blur-md"}),z.jsx("div",{className:"relative w-full max-w-lg mx-4",children:z.jsxs("div",{className:"bg-[#0a0a1a]/95 backdrop-blur-sm rounded-lg border border-[#2a2a3e] shadow-2xl overflow-hidden",children:[z.jsxs("div",{className:"px-5 pt-4 pb-2",children:[z.jsx("div",{className:"text-sm font-semibold text-[#e2e8f0]",children:"Custom Expedition"}),z.jsx("div",{className:"text-xs opacity-40 mt-0.5",children:"Ask a question and get a guided tour of the relevant code"})]}),z.jsx("div",{className:"px-5 py-3",children:z.jsx("div",{className:"flex items-center gap-3 bg-[#1a1a2e] rounded-lg border border-[#3a3a4e] px-4 py-3",children:z.jsx("input",{ref:c,type:"text",value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),f())},placeholder:"Ask about your codebase...",className:"flex-1 bg-transparent text-[#e2e8f0] text-sm outline-none placeholder:text-[#4a4a6e]",disabled:n})})}),s&&z.jsx("div",{className:"px-5 pb-2",children:z.jsx("div",{className:"text-xs text-[#EF4444] bg-[#EF4444]/10 rounded px-3 py-2",children:s})}),z.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2 border-t border-[#2a2a3e]",children:[z.jsx("button",{className:"px-4 py-2 text-xs text-[#e2e8f0] rounded hover:bg-[#2a2a3e] transition-colors",onClick:i,disabled:n,children:"Cancel"}),z.jsx("button",{className:"px-4 py-2 text-xs text-[#e2e8f0] rounded bg-[#14B8A6] hover:bg-[#0d9488] transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",onClick:f,disabled:!e.trim()||n,children:n?z.jsxs("span",{className:"flex items-center gap-2 justify-center",children:[z.jsx("span",{className:"inline-block w-3 h-3 border border-[#e2e8f0]/50 border-t-[#e2e8f0] rounded-full animate-spin"}),"Generating..."]}):"Generate Tour"})]})]})})]})}const VB={grand_tour:"#3B82F6",request_flow:"#8B5CF6",danger_zones:"#EF4444",knowledge_silos:"#F59E0B",custom:"#14B8A6"},GB={grand_tour:"Grand Tour",request_flow:"Request Flow",danger_zones:"Danger Zones",knowledge_silos:"Knowledge Silos",custom:"Custom"};function WB({expedition:i,onStart:e}){const t=VB[i.kind]??"#94A3B8",n=GB[i.kind]??i.kind;return z.jsxs("button",{className:"w-full text-left p-3 rounded-lg bg-[#1a1a2e]/60 hover:bg-[#1a1a2e] transition-colors border border-[#2a2a3e] hover:border-[#3a3a4e]",onClick:()=>e(i),children:[z.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[z.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t+"30",color:t},children:n}),z.jsxs("span",{className:"text-[10px] opacity-40 ml-auto",children:["~",i.estimatedMinutes," min"]})]}),z.jsx("div",{className:"text-sm font-medium text-[#e2e8f0] mb-0.5",children:i.title}),z.jsx("div",{className:"text-xs opacity-50 leading-relaxed line-clamp-2",children:i.description}),z.jsxs("div",{className:"text-[10px] opacity-30 mt-1",children:[i.steps.length," steps"]})]})}function jB(){const i=is(c=>c.isListOpen),e=is(c=>c.toggleList),t=is(c=>c.startExpedition),n=ni(c=>c.graph),[r,s]=te.useState(!1);if(!i||!n)return null;const a=n.expeditions??[];return z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"absolute left-4 top-24 w-80 max-h-[calc(100vh-8rem)] overflow-y-auto z-40",children:z.jsxs("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-sm rounded-lg px-4 py-3 text-[#e2e8f0] border border-[#2a2a3e]",children:[z.jsxs("div",{className:"flex items-center justify-between mb-3",children:[z.jsx("div",{className:"text-sm font-semibold",children:"Expeditions"}),z.jsx("button",{className:"text-xs opacity-60 hover:opacity-100 transition-opacity",onClick:e,children:"x"})]}),a.length>0?z.jsx("div",{className:"space-y-2",children:a.map(c=>z.jsx(WB,{expedition:c,onStart:t},c.id))}):z.jsx("div",{className:"text-xs opacity-40 italic py-4 text-center",children:"No expeditions available for this codebase"}),z.jsxs("button",{className:"w-full mt-3 p-3 rounded-lg border border-dashed border-[#3a3a4e] hover:border-[#14B8A6] hover:bg-[#14B8A6]/10 transition-colors text-center",onClick:()=>s(!0),children:[z.jsx("div",{className:"text-xs font-medium text-[#14B8A6]",children:"+ Custom Expedition"}),z.jsx("div",{className:"text-[10px] opacity-40 mt-0.5",children:"Ask a question about your codebase"})]})]})}),r&&z.jsx(HB,{onClose:()=>s(!1)})]})}function XB({text:i,stepIndex:e}){const[t,n]=te.useState(""),[r,s]=te.useState(!1),a=te.useRef(null);return te.useEffect(()=>{n(""),s(!1);let c=0;return a.current&&clearInterval(a.current),a.current=setInterval(()=>{c++,c>=i.length?(n(i),s(!0),a.current&&(clearInterval(a.current),a.current=null)):n(i.slice(0,c))},18),()=>{a.current&&(clearInterval(a.current),a.current=null)}},[i,e]),i?z.jsx("div",{className:`absolute bottom-24 left-1/2 -translate-x-1/2 w-full max-w-2xl px-4 z-30 transition-opacity duration-500 ${r?"opacity-70":"opacity-100"}`,children:z.jsx("div",{className:"bg-[#0a0a1a]/80 backdrop-blur-sm rounded-lg px-6 py-4 text-[#e2e8f0] border border-[#2a2a3e]",children:z.jsxs("p",{className:"text-sm leading-relaxed",children:[t,!r&&z.jsx("span",{className:"inline-block w-0.5 h-4 bg-[#e2e8f0] ml-0.5 animate-pulse"})]})})}):null}function YB(){const i=is(N=>N.activeExpedition),e=is(N=>N.currentStepIndex),t=is(N=>N.isPlaying),n=is(N=>N.isPaused),r=is(N=>N.nextStep),s=is(N=>N.prevStep),a=is(N=>N.pause),c=is(N=>N.resume),d=is(N=>N.stopExpedition),f=hn(N=>N.flyToModule),p=hn(N=>N.flyToFile),g=hn(N=>N.enterBuilding),v=hn(N=>N.setHighlights),y=hn(N=>N.clearHighlights),E=ni(N=>N.graph),T=te.useRef(null),w=te.useCallback(N=>{if(!i||!E)return;const O=i.steps[N];if(!O)return;const H=E.nodes.find(B=>B.id===O.nodeId);H&&(v(O.highlightNodes,O.highlightEdges),O.action==="enter_building"&&H.kind==="file"?g(H):O.zoomLevel===0?H.kind==="module"&&f(H):O.zoomLevel===3&&H.kind==="file"?g(H):H.kind==="module"?f(H):p(H))},[i,E,f,p,g,v]);if(te.useEffect(()=>{i&&w(e)},[i,e,w]),te.useEffect(()=>{if(T.current&&(clearTimeout(T.current),T.current=null),!i||!t||n)return;const N=i.steps[e];if(!N)return;const O=N.duration*1e3;if(!(O<=0))return T.current=setTimeout(()=>{r()},O),()=>{T.current&&(clearTimeout(T.current),T.current=null)}},[i,e,t,n,r]),te.useEffect(()=>{i||y()},[i,y]),!i)return null;const _=i.steps[e],C=i.steps.length,b=C>0?(e+1)/C*100:0,I=e>=C-1;return z.jsxs(z.Fragment,{children:[_&&z.jsx(XB,{text:_.narration,stepIndex:e}),z.jsxs("div",{className:"absolute bottom-0 left-0 right-0 z-40",children:[z.jsx("div",{className:"h-0.5 bg-[#1a1a2e]",children:z.jsx("div",{className:"h-full bg-[#6366f1] transition-all duration-300",style:{width:`${b}%`}})}),z.jsx("div",{className:"bg-[#0a0a1a]/90 backdrop-blur-sm border-t border-[#2a2a3e] px-6 py-3",children:z.jsxs("div",{className:"flex items-center gap-4 max-w-4xl mx-auto",children:[z.jsxs("div",{className:"flex-1 min-w-0",children:[z.jsx("div",{className:"text-xs font-medium text-[#e2e8f0] truncate",children:i.title}),z.jsxs("div",{className:"text-[10px] text-[#94a3b8] opacity-60",children:["Step ",e+1," / ",C]})]}),z.jsxs("div",{className:"flex items-center gap-2",children:[z.jsx("button",{className:"px-2 py-1.5 text-xs text-[#e2e8f0] rounded hover:bg-[#2a2a3e] transition-colors disabled:opacity-30 disabled:cursor-not-allowed",onClick:s,disabled:e===0,title:"Previous step",children:"|<"}),z.jsx("button",{className:"px-3 py-1.5 text-xs text-[#e2e8f0] rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] transition-colors font-medium min-w-[60px]",onClick:()=>{n||!t?c():a()},children:n||!t?"Play":"Pause"}),z.jsx("button",{className:"px-2 py-1.5 text-xs text-[#e2e8f0] rounded hover:bg-[#2a2a3e] transition-colors disabled:opacity-30 disabled:cursor-not-allowed",onClick:r,disabled:I,title:"Next step",children:">|"}),z.jsx("button",{className:"px-2 py-1.5 text-xs text-[#EF4444] rounded hover:bg-[#EF4444]/10 transition-colors ml-2",onClick:d,title:"Stop expedition",children:"X"})]})]})})]})]})}const ZB=[{label:"0.5x",value:4},{label:"1x",value:2},{label:"2x",value:1},{label:"4x",value:.5}];function qB(){const i=fr(_=>_.isTimelineActive),e=fr(_=>_.currentSnapshotIndex),t=fr(_=>_.totalSnapshots),n=fr(_=>_.isPlaying),r=fr(_=>_.playbackSpeed),s=fr(_=>_.visibleNodeIds),a=fr(_=>_.snapshots),c=fr(_=>_.setSnapshot),d=fr(_=>_.play),f=fr(_=>_.pause),p=fr(_=>_.setSpeed),g=fr(_=>_.deactivateTimeline),v=te.useRef(null);te.useEffect(()=>(v.current&&(clearInterval(v.current),v.current=null),n&&t>0&&(v.current=setInterval(()=>{const _=fr.getState();_.currentSnapshotIndex>=_.totalSnapshots-1?f():c(_.currentSnapshotIndex+1)},r*1e3)),()=>{v.current&&clearInterval(v.current)}),[n,r,t,c,f]);const y=te.useCallback(_=>{const C=parseInt(_.target.value,10);c(C),n&&f()},[c,n,f]),E=te.useCallback(()=>{c(0),d()},[c,d]);if(!i||t===0)return null;const T=a[e],w=T!=null&&T.timestamp?new Date(T.timestamp).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return z.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 pointer-events-auto",children:z.jsx("div",{className:"bg-[#0a0a1a]/85 backdrop-blur-md border-t border-[#2a2a3e] px-6 py-3",children:z.jsxs("div",{className:"max-w-4xl mx-auto",children:[z.jsxs("div",{className:"flex items-center justify-between mb-2",children:[z.jsxs("div",{className:"text-xs text-[#e2e8f0]",children:[z.jsx("span",{className:"opacity-60",children:"Snapshot"})," ",z.jsx("span",{className:"font-medium",children:e+1}),z.jsxs("span",{className:"opacity-40",children:[" / ",t]}),w&&z.jsx("span",{className:"ml-3 opacity-50",children:w}),(T==null?void 0:T.author)&&z.jsxs("span",{className:"ml-2 opacity-40",children:["by ",T.author]})]}),z.jsxs("div",{className:"flex items-center gap-3",children:[z.jsxs("span",{className:"text-xs opacity-40 text-[#e2e8f0]",children:[s.size," nodes"]}),z.jsx("button",{className:"text-xs px-2 py-0.5 rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0] transition-colors",onClick:g,children:"Close"})]})]}),z.jsxs("div",{className:"flex items-center gap-3",children:[z.jsx("div",{className:"flex items-center gap-1",children:n?z.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0] transition-colors",onClick:f,title:"Pause",children:z.jsx(QB,{})}):z.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e2e8f0] transition-colors",onClick:()=>{e>=t-1?E():d()},title:"Play",children:z.jsx(KB,{})})}),z.jsx("input",{type:"range",min:0,max:t-1,value:e,onChange:y,className:`flex-1 h-1.5 accent-[#6366f1] bg-[#2a2a3e] rounded-full appearance-none cursor-pointer
4797
4797
  [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
4798
4798
  [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[#818CF8]`}),z.jsx("div",{className:"flex items-center gap-1",children:ZB.map(_=>z.jsx("button",{className:`text-xs px-1.5 py-0.5 rounded transition-colors ${r===_.value?"bg-[#6366f1]/30 text-[#818CF8]":"text-[#e2e8f0] opacity-40 hover:opacity-70"}`,onClick:()=>p(_.value),children:_.label},_.label))})]}),(T==null?void 0:T.summary)&&z.jsx("div",{className:"mt-1.5 text-xs text-[#e2e8f0] opacity-50 truncate",children:T.summary})]})})})}function KB(){return z.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:z.jsx("polygon",{points:"2,0 12,6 2,12"})})}function QB(){return z.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",children:[z.jsx("rect",{x:"1",y:"0",width:"3.5",height:"12"}),z.jsx("rect",{x:"7.5",y:"0",width:"3.5",height:"12"})]})}function JB(){const i=ni(s=>s.loadGraph),e=ni(s=>s.connectLive),t=ni(s=>s.isLoading),n=ni(s=>s.error),r=ni(s=>s.graph);return te.useEffect(()=>{const a=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,c=new WebSocket(a);let d=!1;c.onopen=()=>{d||(d=!0,c.close(),e())},c.onerror=()=>{d||(d=!0,i())};const f=setTimeout(()=>{if(!d){d=!0;try{c.close()}catch{}i()}},1e3);return()=>{clearTimeout(f);try{c.close()}catch{}}},[i,e]),t?z.jsx(mM,{}):n?z.jsx(jF,{message:n}):r?z.jsxs("div",{className:"w-screen h-screen relative",children:[z.jsx(eN,{shadows:!0,camera:{fov:50,near:.1,far:500},gl:{antialias:!0,toneMapping:Bv,toneMappingExposure:1.2},children:z.jsx(te.Suspense,{fallback:null,children:z.jsx(WF,{})})}),z.jsx(XF,{}),z.jsx(JF,{}),z.jsx(kB,{}),z.jsx(jB,{}),z.jsx(YB,{}),z.jsx(qB,{})]}):z.jsx(mM,{})}wM.createRoot(document.getElementById("root")).render(z.jsx(te.StrictMode,{children:z.jsx(JB,{})}));