@osamash/floor-planner 1.0.3 → 1.0.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.
package/dist/floor-planner.es.js
CHANGED
|
@@ -31345,7 +31345,6 @@ const ME = ({
|
|
|
31345
31345
|
);
|
|
31346
31346
|
}, gg = 8, mg = 40, AE = (n) => {
|
|
31347
31347
|
const t = [{ label: "All Categories", value: "all" }], e = n.map((r) => r.info.tag);
|
|
31348
|
-
console.log({ paths: e });
|
|
31349
31348
|
for (const r of e) {
|
|
31350
31349
|
let i = t;
|
|
31351
31350
|
for (let s = 0; s < r.length; s++) {
|
|
@@ -31357,7 +31356,7 @@ const ME = ({
|
|
|
31357
31356
|
}, s < r.length - 1 && (a.options = [{ label: "All Categories", value: "all" }]), i.push(a)), s < r.length - 1 && a.options && (i = a.options);
|
|
31358
31357
|
}
|
|
31359
31358
|
}
|
|
31360
|
-
return
|
|
31359
|
+
return t;
|
|
31361
31360
|
}, i0 = ({
|
|
31362
31361
|
options: n,
|
|
31363
31362
|
selections: t,
|
|
@@ -31402,7 +31401,7 @@ const ME = ({
|
|
|
31402
31401
|
_.current = {
|
|
31403
31402
|
top: R + gg,
|
|
31404
31403
|
left: z + mg
|
|
31405
|
-
}, t.page === "objects" &&
|
|
31404
|
+
}, t.page === "objects" && l(AE(E));
|
|
31406
31405
|
}
|
|
31407
31406
|
}, [t]);
|
|
31408
31407
|
const S = () => {
|
|
@@ -79,7 +79,7 @@ best distance: ${f.d}`);const _=[f.x,f.y];return _.distance=f.d,_}function Ba(n,
|
|
|
79
79
|
* @license
|
|
80
80
|
* Copyright 2010-2025 Three.js Authors
|
|
81
81
|
* SPDX-License-Identifier: MIT
|
|
82
|
-
*/const Zg="179",Rc=0,iS=1,sS=2,Kg=1,Qg=100,tm=204,em=205,rm=3,nm=0,im=300,yn=1e3,Xa=1001,sm=1002,oS=1006,aS=1008,uS=1009,lS=1015,cS=1023,hS=0,om="",Yr="srgb",am="srgb-linear",um="linear",Lc="srgb",fs=7680,lm=519,cm=35044,Ja=2e3,hm=2001;class Za{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){const r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){const r=this._listeners;if(r===void 0)return;const i=r[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const r=e[t.type];if(r!==void 0){t.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}}const Be=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function ds(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Be[n&255]+Be[n>>8&255]+Be[n>>16&255]+Be[n>>24&255]+"-"+Be[t&255]+Be[t>>8&255]+"-"+Be[t>>16&15|64]+Be[t>>24&255]+"-"+Be[e&63|128]+Be[e>>8&255]+"-"+Be[e>>16&255]+Be[e>>24&255]+Be[r&255]+Be[r>>8&255]+Be[r>>16&255]+Be[r>>24&255]).toLowerCase()}function Lt(n,t,e){return Math.max(t,Math.min(e,n))}function fS(n,t){return(n%t+t)%t}function Fc(n,t,e){return(1-e)*n+e*t}function So(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function er(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}class Et{constructor(t=0,e=0){Et.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6],this.y=i[1]*e+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(Lt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*i+t.x,this.y=s*i+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ps{constructor(t=0,e=0,r=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=i}static slerpFlat(t,e,r,i,s,o,a){let l=r[i+0],c=r[i+1],h=r[i+2],f=r[i+3];const g=s[o+0],p=s[o+1],m=s[o+2],v=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f;return}if(a===1){t[e+0]=g,t[e+1]=p,t[e+2]=m,t[e+3]=v;return}if(f!==v||l!==g||c!==p||h!==m){let _=1-a;const S=l*g+c*p+h*m+f*v,M=S>=0?1:-1,C=1-S*S;if(C>Number.EPSILON){const E=Math.sqrt(C),z=Math.atan2(E,S*M);_=Math.sin(_*z)/E,a=Math.sin(a*z)/E}const O=a*M;if(l=l*_+g*O,c=c*_+p*O,h=h*_+m*O,f=f*_+v*O,_===1-a){const E=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=E,c*=E,h*=E,f*=E}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f}static multiplyQuaternionsFlat(t,e,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],h=r[i+3],f=s[o],g=s[o+1],p=s[o+2],m=s[o+3];return t[e]=a*m+h*f+l*p-c*g,t[e+1]=l*m+h*g+c*f-a*p,t[e+2]=c*m+h*p+a*g-l*f,t[e+3]=h*m-a*f-l*g-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const r=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(r/2),h=a(i/2),f=a(s/2),g=l(r/2),p=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"YXZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"ZXY":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"ZYX":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"YZX":this._x=g*h*f+c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f-g*p*m;break;case"XZY":this._x=g*h*f-c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f+g*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],f=e[10],g=r+a+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(r>a&&r>f){const p=2*Math.sqrt(1+r-a-f);this._w=(h-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-r-f);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+f-r-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Lt(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(r===0)return this;const i=Math.min(1,e/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const r=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=r*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-r*c,this._z=s*h+o*c+r*l-i*a,this._w=o*h-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*t._w+r*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-e;return this._w=p*o+e*this._w,this._x=p*r+e*this._x,this._y=p*i+e*this._y,this._z=p*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-e)*h)/c,g=Math.sin(e*h)/c;return this._w=o*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(t=0,e=0,r=0){D.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(fm.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(fm.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*i,this.y=s[1]*e+s[4]*r+s[7]*i,this.z=s[2]*e+s[5]*r+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*r),h=2*(a*e-s*i),f=2*(s*r-o*e);return this.x=e+l*c+o*f-a*h,this.y=r+l*h+a*c-s*f,this.z=i+l*f+s*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i,this.y=s[1]*e+s[5]*r+s[9]*i,this.z=s[2]*e+s[6]*r+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this.z=Lt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this.z=Lt(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Nc.copy(this).projectOnVector(t),this.sub(Nc)}reflect(t){return this.sub(Nc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(Lt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){const i=Math.sin(e)*t;return this.x=i*Math.sin(r),this.y=Math.cos(e)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Nc=new D,fm=new ps;class Qn{constructor(t,e,r,i,s,o,a,l,c){Qn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c)}set(t,e,r,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],g=r[2],p=r[5],m=r[8],v=i[0],_=i[3],S=i[6],M=i[1],C=i[4],O=i[7],E=i[2],z=i[5],R=i[8];return s[0]=o*v+a*M+l*E,s[3]=o*_+a*C+l*z,s[6]=o*S+a*O+l*R,s[1]=c*v+h*M+f*E,s[4]=c*_+h*C+f*z,s[7]=c*S+h*O+f*R,s[2]=g*v+p*M+m*E,s[5]=g*_+p*C+m*z,s[8]=g*S+p*O+m*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-r*s*h+r*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=h*o-a*c,g=a*l-h*s,p=c*s-o*l,m=e*f+r*g+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return t[0]=f*v,t[1]=(i*c-h*r)*v,t[2]=(a*r-i*o)*v,t[3]=g*v,t[4]=(h*e-i*l)*v,t[5]=(i*s-a*e)*v,t[6]=p*v,t[7]=(r*l-c*e)*v,t[8]=(o*e-r*s)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(jc.makeScale(t,e)),this}rotate(t){return this.premultiply(jc.makeRotation(-t)),this}translate(t,e){return this.premultiply(jc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<9;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const jc=new Qn;function dS(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}function Vc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}const dm={};function pm(n){n in dm||(dm[n]=!0,console.warn(n))}const gm=new Qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mm=new Qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pS(){const n={enabled:!0,workingColorSpace:am,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Lc&&(i.r=kn(i.r),i.g=kn(i.g),i.b=kn(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Lc&&(i.r=gs(i.r),i.g=gs(i.g),i.b=gs(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===om?um:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return pm("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return pm("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[am]:{primaries:t,whitePoint:r,transfer:um,toXYZ:gm,fromXYZ:mm,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Yr},outputColorSpaceConfig:{drawingBufferColorSpace:Yr}},[Yr]:{primaries:t,whitePoint:r,transfer:Lc,toXYZ:gm,fromXYZ:mm,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Yr}}}),n}const Xr=pS();function kn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let ms;class gS{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let r;if(t instanceof HTMLCanvasElement)r=t;else{ms===void 0&&(ms=Vc("canvas")),ms.width=t.width,ms.height=t.height;const i=ms.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),r=ms}return r.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Vc("canvas");e.width=t.width,e.height=t.height;const r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=kn(s[o]/255)*255;return r.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let r=0;r<e.length;r++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[r]=Math.floor(kn(e[r]/255)*255):e[r]=kn(e[r]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let mS=0;class yS{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mS++}),this.uuid=ds(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Dc(i[o].image)):s.push(Dc(i[o]))}else s=Dc(i);r.url=s}return e||(t.images[this.uuid]=r),r}}function Dc(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?gS.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let vS=0;const Bc=new D;class ti extends Za{constructor(t=ti.DEFAULT_IMAGE,e=ti.DEFAULT_MAPPING,r=Xa,i=Xa,s=oS,o=aS,a=cS,l=uS,c=ti.DEFAULT_ANISOTROPY,h=om){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vS++}),this.uuid=ds(),this.name="",this.source=new yS(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Et(0,0),this.repeat=new Et(1,1),this.center=new Et(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Qn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Bc).x}get height(){return this.source.getSize(Bc).y}get depth(){return this.source.getSize(Bc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==im)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case yn:t.x=t.x-Math.floor(t.x);break;case Xa:t.x=t.x<0?0:1;break;case sm:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case yn:t.y=t.y-Math.floor(t.y);break;case Xa:t.y=t.y<0?0:1;break;case sm:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ti.DEFAULT_IMAGE=null,ti.DEFAULT_MAPPING=im,ti.DEFAULT_ANISOTROPY=1;class Eo{constructor(t=0,e=0,r=0,i=1){Eo.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,i,s;const l=t.elements,c=l[0],h=l[4],f=l[8],g=l[1],p=l[5],m=l[9],v=l[2],_=l[6],S=l[10];if(Math.abs(h-g)<.01&&Math.abs(f-v)<.01&&Math.abs(m-_)<.01){if(Math.abs(h+g)<.1&&Math.abs(f+v)<.1&&Math.abs(m+_)<.1&&Math.abs(c+p+S-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const C=(c+1)/2,O=(p+1)/2,E=(S+1)/2,z=(h+g)/4,R=(f+v)/4,k=(m+_)/4;return C>O&&C>E?C<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(C),i=z/r,s=R/r):O>E?O<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(O),r=z/i,s=k/i):E<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),r=R/s,i=k/s),this.set(r,i,s,e),this}let M=Math.sqrt((_-m)*(_-m)+(f-v)*(f-v)+(g-h)*(g-h));return Math.abs(M)<.001&&(M=1),this.x=(_-m)/M,this.y=(f-v)/M,this.z=(g-h)/M,this.w=Math.acos((c+p+S-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this.z=Lt(this.z,t.z,e.z),this.w=Lt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this.z=Lt(this.z,t,e),this.w=Lt(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ys{constructor(t=new D(1/0,1/0,1/0),e=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e+=3)this.expandByPoint(Jr.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,r=t.count;e<r;e++)this.expandByPoint(Jr.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const r=Jr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const r=t.geometry;if(r!==void 0){const s=r.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Jr):Jr.fromBufferAttribute(s,o),Jr.applyMatrix4(t.matrixWorld),this.expandByPoint(Jr);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ka.copy(t.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ka.copy(r.boundingBox)),Ka.applyMatrix4(t.matrixWorld),this.union(Ka)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Jr),Jr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Mo),Qa.subVectors(this.max,Mo),vs.subVectors(t.a,Mo),xs.subVectors(t.b,Mo),_s.subVectors(t.c,Mo),ei.subVectors(xs,vs),ri.subVectors(_s,xs),Si.subVectors(vs,_s);let e=[0,-ei.z,ei.y,0,-ri.z,ri.y,0,-Si.z,Si.y,ei.z,0,-ei.x,ri.z,0,-ri.x,Si.z,0,-Si.x,-ei.y,ei.x,0,-ri.y,ri.x,0,-Si.y,Si.x,0];return!qc(e,vs,xs,_s,Qa)||(e=[1,0,0,0,1,0,0,0,1],!qc(e,vs,xs,_s,Qa))?!1:(tu.crossVectors(ei,ri),e=[tu.x,tu.y,tu.z],qc(e,vs,xs,_s,Qa))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Jr).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Jr).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Pn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Pn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Pn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Pn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Pn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Pn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Pn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Pn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Pn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Pn=[new D,new D,new D,new D,new D,new D,new D,new D],Jr=new D,Ka=new ys,vs=new D,xs=new D,_s=new D,ei=new D,ri=new D,Si=new D,Mo=new D,Qa=new D,tu=new D,Ei=new D;function qc(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){Ei.fromArray(n,s);const a=i.x*Math.abs(Ei.x)+i.y*Math.abs(Ei.y)+i.z*Math.abs(Ei.z),l=t.dot(Ei),c=e.dot(Ei),h=r.dot(Ei);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const xS=new ys,Ao=new D,$c=new D;class ym{constructor(t=new D,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const r=this.center;e!==void 0?r.copy(e):xS.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,r.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const r=this.center.distanceToSquared(t);return e.copy(t),r>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ao.subVectors(t,this.center);const e=Ao.lengthSq();if(e>this.radius*this.radius){const r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(Ao,i/r),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):($c.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ao.copy(t.center).add($c)),this.expandByPoint(Ao.copy(t.center).sub($c))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Rn=new D,Hc=new D,eu=new D,ni=new D,Gc=new D,ru=new D,Wc=new D;class _S{constructor(t=new D,e=new D(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Rn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Rn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Rn.copy(this.origin).addScaledVector(this.direction,e),Rn.distanceToSquared(t))}distanceSqToSegment(t,e,r,i){Hc.copy(t).add(e).multiplyScalar(.5),eu.copy(e).sub(t).normalize(),ni.copy(this.origin).sub(Hc);const s=t.distanceTo(e)*.5,o=-this.direction.dot(eu),a=ni.dot(this.direction),l=-ni.dot(eu),c=ni.lengthSq(),h=Math.abs(1-o*o);let f,g,p,m;if(h>0)if(f=o*l-a,g=o*a-l,m=s*h,f>=0)if(g>=-m)if(g<=m){const v=1/h;f*=v,g*=v,p=f*(f+o*g+2*a)+g*(o*f+g+2*l)+c}else g=s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g=-s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g<=-m?(f=Math.max(0,-(-o*s+a)),g=f>0?-s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c):g<=m?(f=0,g=Math.min(Math.max(-s,-l),s),p=g*(g+2*l)+c):(f=Math.max(0,-(o*s+a)),g=f>0?s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c);else g=o>0?-s:s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Hc).addScaledVector(eu,g),p}intersectSphere(t,e){Rn.subVectors(t.center,this.origin);const r=Rn.dot(this.direction),i=Rn.dot(Rn)-r*r,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(r=(t.min.x-g.x)*c,i=(t.max.x-g.x)*c):(r=(t.max.x-g.x)*c,i=(t.min.x-g.x)*c),h>=0?(s=(t.min.y-g.y)*h,o=(t.max.y-g.y)*h):(s=(t.max.y-g.y)*h,o=(t.min.y-g.y)*h),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(a=(t.min.z-g.z)*f,l=(t.max.z-g.z)*f):(a=(t.max.z-g.z)*f,l=(t.min.z-g.z)*f),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,Rn)!==null}intersectTriangle(t,e,r,i,s){Gc.subVectors(e,t),ru.subVectors(r,t),Wc.crossVectors(Gc,ru);let o=this.direction.dot(Wc),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ni.subVectors(this.origin,t);const l=a*this.direction.dot(ru.crossVectors(ni,ru));if(l<0)return null;const c=a*this.direction.dot(Gc.cross(ni));if(c<0||l+c>o)return null;const h=-a*ni.dot(Wc);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ue{constructor(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){Ue.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_)}set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){const S=this.elements;return S[0]=t,S[4]=e,S[8]=r,S[12]=i,S[1]=s,S[5]=o,S[9]=a,S[13]=l,S[2]=c,S[6]=h,S[10]=f,S[14]=g,S[3]=p,S[7]=m,S[11]=v,S[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ue().fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,r=t.elements,i=1/bs.setFromMatrixColumn(t,0).length(),s=1/bs.setFromMatrixColumn(t,1).length(),o=1/bs.setFromMatrixColumn(t,2).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,i=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=-l*f,e[8]=c,e[1]=p+m*c,e[5]=g-v*c,e[9]=-a*l,e[2]=v-g*c,e[6]=m+p*c,e[10]=o*l}else if(t.order==="YXZ"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g+v*a,e[4]=m*a-p,e[8]=o*c,e[1]=o*f,e[5]=o*h,e[9]=-a,e[2]=p*a-m,e[6]=v+g*a,e[10]=o*l}else if(t.order==="ZXY"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g-v*a,e[4]=-o*f,e[8]=m+p*a,e[1]=p+m*a,e[5]=o*h,e[9]=v-g*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=m*c-p,e[8]=g*c+v,e[1]=l*f,e[5]=v*c+g,e[9]=p*c-m,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=v-g*f,e[8]=m*f+p,e[1]=f,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=p*f+m,e[10]=g-v*f}else if(t.order==="XZY"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=-f,e[8]=c*h,e[1]=g*f+v,e[5]=o*h,e[9]=p*f-m,e[2]=m*f-p,e[6]=a*h,e[10]=v*f+g}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bS,t,wS)}lookAt(t,e,r){const i=this.elements;return hr.subVectors(t,e),hr.lengthSq()===0&&(hr.z=1),hr.normalize(),ii.crossVectors(r,hr),ii.lengthSq()===0&&(Math.abs(r.z)===1?hr.x+=1e-4:hr.z+=1e-4,hr.normalize(),ii.crossVectors(r,hr)),ii.normalize(),nu.crossVectors(hr,ii),i[0]=ii.x,i[4]=nu.x,i[8]=hr.x,i[1]=ii.y,i[5]=nu.y,i[9]=hr.y,i[2]=ii.z,i[6]=nu.z,i[10]=hr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],h=r[1],f=r[5],g=r[9],p=r[13],m=r[2],v=r[6],_=r[10],S=r[14],M=r[3],C=r[7],O=r[11],E=r[15],z=i[0],R=i[4],k=i[8],L=i[12],X=i[1],J=i[5],at=i[9],tt=i[13],bt=i[2],xt=i[6],yt=i[10],ht=i[14],Y=i[3],St=i[7],j=i[11],W=i[15];return s[0]=o*z+a*X+l*bt+c*Y,s[4]=o*R+a*J+l*xt+c*St,s[8]=o*k+a*at+l*yt+c*j,s[12]=o*L+a*tt+l*ht+c*W,s[1]=h*z+f*X+g*bt+p*Y,s[5]=h*R+f*J+g*xt+p*St,s[9]=h*k+f*at+g*yt+p*j,s[13]=h*L+f*tt+g*ht+p*W,s[2]=m*z+v*X+_*bt+S*Y,s[6]=m*R+v*J+_*xt+S*St,s[10]=m*k+v*at+_*yt+S*j,s[14]=m*L+v*tt+_*ht+S*W,s[3]=M*z+C*X+O*bt+E*Y,s[7]=M*R+C*J+O*xt+E*St,s[11]=M*k+C*at+O*yt+E*j,s[15]=M*L+C*tt+O*ht+E*W,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],f=t[6],g=t[10],p=t[14],m=t[3],v=t[7],_=t[11],S=t[15];return m*(+s*l*f-i*c*f-s*a*g+r*c*g+i*a*p-r*l*p)+v*(+e*l*p-e*c*g+s*o*g-i*o*p+i*c*h-s*l*h)+_*(+e*c*f-e*a*p-s*o*f+r*o*p+s*a*h-r*c*h)+S*(-i*a*h-e*l*f+e*a*g+i*o*f-r*o*g+r*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],v=t[13],_=t[14],S=t[15],M=f*_*c-v*g*c+v*l*p-a*_*p-f*l*S+a*g*S,C=m*g*c-h*_*c-m*l*p+o*_*p+h*l*S-o*g*S,O=h*v*c-m*f*c+m*a*p-o*v*p-h*a*S+o*f*S,E=m*f*l-h*v*l-m*a*g+o*v*g+h*a*_-o*f*_,z=e*M+r*C+i*O+s*E;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/z;return t[0]=M*R,t[1]=(v*g*s-f*_*s-v*i*p+r*_*p+f*i*S-r*g*S)*R,t[2]=(a*_*s-v*l*s+v*i*c-r*_*c-a*i*S+r*l*S)*R,t[3]=(f*l*s-a*g*s-f*i*c+r*g*c+a*i*p-r*l*p)*R,t[4]=C*R,t[5]=(h*_*s-m*g*s+m*i*p-e*_*p-h*i*S+e*g*S)*R,t[6]=(m*l*s-o*_*s-m*i*c+e*_*c+o*i*S-e*l*S)*R,t[7]=(o*g*s-h*l*s+h*i*c-e*g*c-o*i*p+e*l*p)*R,t[8]=O*R,t[9]=(m*f*s-h*v*s-m*r*p+e*v*p+h*r*S-e*f*S)*R,t[10]=(o*v*s-m*a*s+m*r*c-e*v*c-o*r*S+e*a*S)*R,t[11]=(h*a*s-o*f*s-h*r*c+e*f*c+o*r*p-e*a*p)*R,t[12]=E*R,t[13]=(h*v*i-m*f*i+m*r*g-e*v*g-h*r*_+e*f*_)*R,t[14]=(m*a*i-o*v*i-m*r*l+e*v*l+o*r*_-e*a*_)*R,t[15]=(o*f*i-h*a*i+h*r*l-e*f*l-o*r*g+e*a*g)*R,this}scale(t){const e=this.elements,r=t.x,i=t.y,s=t.z;return e[0]*=r,e[4]*=i,e[8]*=s,e[1]*=r,e[5]*=i,e[9]*=s,e[2]*=r,e[6]*=i,e[10]*=s,e[3]*=r,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,i))}makeTranslation(t,e,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),i=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+r,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,i,s,o){return this.set(1,r,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,r){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,f=a+a,g=s*c,p=s*h,m=s*f,v=o*h,_=o*f,S=a*f,M=l*c,C=l*h,O=l*f,E=r.x,z=r.y,R=r.z;return i[0]=(1-(v+S))*E,i[1]=(p+O)*E,i[2]=(m-C)*E,i[3]=0,i[4]=(p-O)*z,i[5]=(1-(g+S))*z,i[6]=(_+M)*z,i[7]=0,i[8]=(m+C)*R,i[9]=(_-M)*R,i[10]=(1-(g+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,r){const i=this.elements;let s=bs.set(i[0],i[1],i[2]).length();const o=bs.set(i[4],i[5],i[6]).length(),a=bs.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],Zr.copy(this);const c=1/s,h=1/o,f=1/a;return Zr.elements[0]*=c,Zr.elements[1]*=c,Zr.elements[2]*=c,Zr.elements[4]*=h,Zr.elements[5]*=h,Zr.elements[6]*=h,Zr.elements[8]*=f,Zr.elements[9]*=f,Zr.elements[10]*=f,e.setFromRotationMatrix(Zr),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,i,s,o,a=Ja,l=!1){const c=this.elements,h=2*s/(e-t),f=2*s/(r-i),g=(e+t)/(e-t),p=(r+i)/(r-i);let m,v;if(l)m=s/(o-s),v=o*s/(o-s);else if(a===Ja)m=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===hm)m=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=f,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,r,i,s,o,a=Ja,l=!1){const c=this.elements,h=2/(e-t),f=2/(r-i),g=-(e+t)/(e-t),p=-(r+i)/(r-i);let m,v;if(l)m=1/(o-s),v=o/(o-s);else if(a===Ja)m=-2/(o-s),v=-(o+s)/(o-s);else if(a===hm)m=-1/(o-s),v=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=f,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<16;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const bs=new D,Zr=new Ue,bS=new D(0,0,0),wS=new D(1,1,1),ii=new D,nu=new D,hr=new D,vm=new Ue,xm=new ps;class ws{constructor(t=0,e=0,r=0,i=ws.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,i=this._order){return this._x=t,this._y=e,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],f=i[2],g=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(Lt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Lt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return vm.makeRotationFromQuaternion(t),this.setFromRotationMatrix(vm,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return xm.setFromEuler(this),this.setFromQuaternion(xm,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ws.DEFAULT_ORDER="XYZ";class SS{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let ES=0;const _m=new D,Ss=new ps,Ln=new Ue,iu=new D,Oo=new D,MS=new D,AS=new ps,bm=new D(1,0,0),wm=new D(0,1,0),Sm=new D(0,0,1),Em={type:"added"},OS={type:"removed"},Es={type:"childadded",child:null},Uc={type:"childremoved",child:null};class vn extends Za{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ES++}),this.uuid=ds(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=vn.DEFAULT_UP.clone();const t=new D,e=new ws,r=new ps,i=new D(1,1,1);function s(){r.setFromEuler(e,!1)}function o(){e.setFromQuaternion(r,void 0,!1)}e._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ue},normalMatrix:{value:new Qn}}),this.matrix=new Ue,this.matrixWorld=new Ue,this.matrixAutoUpdate=vn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=vn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new SS,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.multiply(Ss),this}rotateOnWorldAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.premultiply(Ss),this}rotateX(t){return this.rotateOnAxis(bm,t)}rotateY(t){return this.rotateOnAxis(wm,t)}rotateZ(t){return this.rotateOnAxis(Sm,t)}translateOnAxis(t,e){return _m.copy(t).applyQuaternion(this.quaternion),this.position.add(_m.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(bm,t)}translateY(t){return this.translateOnAxis(wm,t)}translateZ(t){return this.translateOnAxis(Sm,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ln.copy(this.matrixWorld).invert())}lookAt(t,e,r){t.isVector3?iu.copy(t):iu.set(t,e,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Oo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ln.lookAt(Oo,iu,this.up):Ln.lookAt(iu,Oo,this.up),this.quaternion.setFromRotationMatrix(Ln),i&&(Ln.extractRotation(i.matrixWorld),Ss.setFromRotationMatrix(Ln),this.quaternion.premultiply(Ss.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Em),Es.child=t,this.dispatchEvent(Es),Es.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(OS),Uc.child=t,this.dispatchEvent(Uc),Uc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ln.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ln.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ln),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Em),Es.child=t,this.dispatchEvent(Es),Es.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,r=[]){this[t]===e&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,t,MS),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,AS,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].updateMatrixWorld(t)}updateWorldMatrix(t,e){const r=this.parent;if(t===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(t.shapes,f)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),f=o(t.shapes),g=o(t.skeletons),p=o(t.animations),m=o(t.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),h.length>0&&(r.images=h),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r<t.children.length;r++){const i=t.children[r];this.add(i.clone())}return this}}vn.DEFAULT_UP=new D(0,1,0),vn.DEFAULT_MATRIX_AUTO_UPDATE=!0,vn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Kr=new D,Fn=new D,Yc=new D,Nn=new D,Ms=new D,As=new D,Mm=new D,Xc=new D,Jc=new D,Zc=new D,Kc=new Eo,Qc=new Eo,th=new Eo;class Qr{constructor(t=new D,e=new D,r=new D){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,i){i.subVectors(r,e),Kr.subVectors(t,e),i.cross(Kr);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){Kr.subVectors(i,e),Fn.subVectors(r,e),Yc.subVectors(t,e);const o=Kr.dot(Kr),a=Kr.dot(Fn),l=Kr.dot(Yc),c=Fn.dot(Fn),h=Fn.dot(Yc),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const g=1/f,p=(c*l-a*h)*g,m=(o*h-a*l)*g;return s.set(1-p-m,m,p)}static containsPoint(t,e,r,i){return this.getBarycoord(t,e,r,i,Nn)===null?!1:Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(t,e,r,i,s,o,a,l){return this.getBarycoord(t,e,r,i,Nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Nn.x),l.addScaledVector(o,Nn.y),l.addScaledVector(a,Nn.z),l)}static getInterpolatedAttribute(t,e,r,i,s,o){return Kc.setScalar(0),Qc.setScalar(0),th.setScalar(0),Kc.fromBufferAttribute(t,e),Qc.fromBufferAttribute(t,r),th.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(Kc,s.x),o.addScaledVector(Qc,s.y),o.addScaledVector(th,s.z),o}static isFrontFacing(t,e,r,i){return Kr.subVectors(r,e),Fn.subVectors(t,e),Kr.cross(Fn).dot(i)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,r,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Kr.subVectors(this.c,this.b),Fn.subVectors(this.a,this.b),Kr.cross(Fn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Qr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Qr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,r,i,s){return Qr.getInterpolation(t,this.a,this.b,this.c,e,r,i,s)}containsPoint(t){return Qr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Qr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const r=this.a,i=this.b,s=this.c;let o,a;Ms.subVectors(i,r),As.subVectors(s,r),Xc.subVectors(t,r);const l=Ms.dot(Xc),c=As.dot(Xc);if(l<=0&&c<=0)return e.copy(r);Jc.subVectors(t,i);const h=Ms.dot(Jc),f=As.dot(Jc);if(h>=0&&f<=h)return e.copy(i);const g=l*f-h*c;if(g<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(r).addScaledVector(Ms,o);Zc.subVectors(t,s);const p=Ms.dot(Zc),m=As.dot(Zc);if(m>=0&&p<=m)return e.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(r).addScaledVector(As,a);const _=h*m-p*f;if(_<=0&&f-h>=0&&p-m>=0)return Mm.subVectors(s,i),a=(f-h)/(f-h+(p-m)),e.copy(i).addScaledVector(Mm,a);const S=1/(_+v+g);return o=v*S,a=g*S,e.copy(r).addScaledVector(Ms,o).addScaledVector(As,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Am={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},si={h:0,s:0,l:0},su={h:0,s:0,l:0};function eh(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}class Mi{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(e===void 0&&r===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,r);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Yr){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xr.colorSpaceToWorking(this,e),this}setRGB(t,e,r,i=Xr.workingColorSpace){return this.r=t,this.g=e,this.b=r,Xr.colorSpaceToWorking(this,i),this}setHSL(t,e,r,i=Xr.workingColorSpace){if(t=fS(t,1),e=Lt(e,0,1),r=Lt(r,0,1),e===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=eh(o,s,t+1/3),this.g=eh(o,s,t),this.b=eh(o,s,t-1/3)}return Xr.colorSpaceToWorking(this,i),this}setStyle(t,e=Yr){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Yr){const r=Am[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=kn(t.r),this.g=kn(t.g),this.b=kn(t.b),this}copyLinearToSRGB(t){return this.r=gs(t.r),this.g=gs(t.g),this.b=gs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Yr){return Xr.workingToColorSpace(qe.copy(this),t),Math.round(Lt(qe.r*255,0,255))*65536+Math.round(Lt(qe.g*255,0,255))*256+Math.round(Lt(qe.b*255,0,255))}getHexString(t=Yr){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xr.workingColorSpace){Xr.workingToColorSpace(qe.copy(this),e);const r=qe.r,i=qe.g,s=qe.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Xr.workingColorSpace){return Xr.workingToColorSpace(qe.copy(this),e),t.r=qe.r,t.g=qe.g,t.b=qe.b,t}getStyle(t=Yr){Xr.workingToColorSpace(qe.copy(this),t);const e=qe.r,r=qe.g,i=qe.b;return t!==Yr?`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(t,e,r){return this.getHSL(si),this.setHSL(si.h+t,si.s+e,si.l+r)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(si),t.getHSL(su);const r=Fc(si.h,su.h,e),i=Fc(si.s,su.s,e),s=Fc(si.l,su.l,e);return this.setHSL(r,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,r=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*r+s[6]*i,this.g=s[1]*e+s[4]*r+s[7]*i,this.b=s[2]*e+s[5]*r+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qe=new Mi;Mi.NAMES=Am;let zS=0;class Om extends Za{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zS++}),this.uuid=ds(),this.name="",this.type="Material",this.blending=Kg,this.side=Rc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=tm,this.blendDst=em,this.blendEquation=Qg,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mi(0,0,0),this.blendAlpha=0,this.depthFunc=rm,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fs,this.stencilZFail=fs,this.stencilZPass=fs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Kg&&(r.blending=this.blending),this.side!==Rc&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==tm&&(r.blendSrc=this.blendSrc),this.blendDst!==em&&(r.blendDst=this.blendDst),this.blendEquation!==Qg&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==rm&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==lm&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fs&&(r.stencilFail=this.stencilFail),this.stencilZFail!==fs&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==fs&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let r=null;if(e!==null){const i=e.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Os extends Om{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ws,this.combine=nm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const be=new D,ou=new Et;let TS=0;class zs{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:TS++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=cm,this.updateRanges=[],this.gpuType=lS,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)ou.fromBufferAttribute(this,e),ou.applyMatrix3(t),this.setXY(e,ou.x,ou.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyMatrix3(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyMatrix4(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyNormalMatrix(t),this.setXYZ(e,be.x,be.y,be.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.transformDirection(t),this.setXYZ(e,be.x,be.y,be.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let r=this.array[t*this.itemSize+e];return this.normalized&&(r=So(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=er(r,this.array)),this.array[t*this.itemSize+e]=r,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=So(e,this.array)),e}setX(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=So(e,this.array)),e}setY(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=So(e,this.array)),e}setZ(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=So(e,this.array)),e}setW(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array),i=er(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array),i=er(i,this.array),s=er(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==cm&&(t.usage=this.usage),t}}class CS extends zs{constructor(t,e,r){super(new Uint16Array(t),e,r)}}class IS extends zs{constructor(t,e,r){super(new Uint32Array(t),e,r)}}class jn extends zs{constructor(t,e,r){super(new Float32Array(t),e,r)}}let kS=0;const Tr=new Ue,rh=new vn,Ts=new D,fr=new ys,zo=new ys,ke=new D;class Ai extends Za{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kS++}),this.uuid=ds(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(dS(t)?IS:CS)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Qn().getNormalMatrix(t);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Tr.makeRotationFromQuaternion(t),this.applyMatrix4(Tr),this}rotateX(t){return Tr.makeRotationX(t),this.applyMatrix4(Tr),this}rotateY(t){return Tr.makeRotationY(t),this.applyMatrix4(Tr),this}rotateZ(t){return Tr.makeRotationZ(t),this.applyMatrix4(Tr),this}translate(t,e,r){return Tr.makeTranslation(t,e,r),this.applyMatrix4(Tr),this}scale(t,e,r){return Tr.makeScale(t,e,r),this.applyMatrix4(Tr),this}lookAt(t){return rh.lookAt(t),rh.updateMatrix(),this.applyMatrix4(rh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ts).negate(),this.translate(Ts.x,Ts.y,Ts.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const r=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new jn(r,3))}else{const r=Math.min(t.length,e.count);for(let i=0;i<r;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ys);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let r=0,i=e.length;r<i;r++){const s=e[r];fr.setFromBufferAttribute(s),this.morphTargetsRelative?(ke.addVectors(this.boundingBox.min,fr.min),this.boundingBox.expandByPoint(ke),ke.addVectors(this.boundingBox.max,fr.max),this.boundingBox.expandByPoint(ke)):(this.boundingBox.expandByPoint(fr.min),this.boundingBox.expandByPoint(fr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ym);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const r=this.boundingSphere.center;if(fr.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];zo.setFromBufferAttribute(a),this.morphTargetsRelative?(ke.addVectors(fr.min,zo.min),fr.expandByPoint(ke),ke.addVectors(fr.max,zo.max),fr.expandByPoint(ke)):(fr.expandByPoint(zo.min),fr.expandByPoint(zo.max))}fr.getCenter(r);let i=0;for(let s=0,o=t.count;s<o;s++)ke.fromBufferAttribute(t,s),i=Math.max(i,r.distanceToSquared(ke));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)ke.fromBufferAttribute(a,c),l&&(Ts.fromBufferAttribute(t,c),ke.add(Ts)),i=Math.max(i,r.distanceToSquared(ke))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new zs(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let k=0;k<r.count;k++)a[k]=new D,l[k]=new D;const c=new D,h=new D,f=new D,g=new Et,p=new Et,m=new Et,v=new D,_=new D;function S(k,L,X){c.fromBufferAttribute(r,k),h.fromBufferAttribute(r,L),f.fromBufferAttribute(r,X),g.fromBufferAttribute(s,k),p.fromBufferAttribute(s,L),m.fromBufferAttribute(s,X),h.sub(c),f.sub(c),p.sub(g),m.sub(g);const J=1/(p.x*m.y-m.x*p.y);isFinite(J)&&(v.copy(h).multiplyScalar(m.y).addScaledVector(f,-p.y).multiplyScalar(J),_.copy(f).multiplyScalar(p.x).addScaledVector(h,-m.x).multiplyScalar(J),a[k].add(v),a[L].add(v),a[X].add(v),l[k].add(_),l[L].add(_),l[X].add(_))}let M=this.groups;M.length===0&&(M=[{start:0,count:t.count}]);for(let k=0,L=M.length;k<L;++k){const X=M[k],J=X.start,at=X.count;for(let tt=J,bt=J+at;tt<bt;tt+=3)S(t.getX(tt+0),t.getX(tt+1),t.getX(tt+2))}const C=new D,O=new D,E=new D,z=new D;function R(k){E.fromBufferAttribute(i,k),z.copy(E);const L=a[k];C.copy(L),C.sub(E.multiplyScalar(E.dot(L))).normalize(),O.crossVectors(z,L);const J=O.dot(l[k])<0?-1:1;o.setXYZW(k,C.x,C.y,C.z,J)}for(let k=0,L=M.length;k<L;++k){const X=M[k],J=X.start,at=X.count;for(let tt=J,bt=J+at;tt<bt;tt+=3)R(t.getX(tt+0)),R(t.getX(tt+1)),R(t.getX(tt+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new zs(new Float32Array(e.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new D,s=new D,o=new D,a=new D,l=new D,c=new D,h=new D,f=new D;if(t)for(let g=0,p=t.count;g<p;g+=3){const m=t.getX(g+0),v=t.getX(g+1),_=t.getX(g+2);i.fromBufferAttribute(e,m),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,_),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,_),a.add(h),l.add(h),c.add(h),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(_,c.x,c.y,c.z)}else for(let g=0,p=e.count;g<p;g+=3)i.fromBufferAttribute(e,g+0),s.fromBufferAttribute(e,g+1),o.fromBufferAttribute(e,g+2),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),r.setXYZ(g+0,h.x,h.y,h.z),r.setXYZ(g+1,h.x,h.y,h.z),r.setXYZ(g+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)ke.fromBufferAttribute(t,e),ke.normalize(),t.setXYZ(e,ke.x,ke.y,ke.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,f=a.normalized,g=new c.constructor(l.length*h);let p=0,m=0;for(let v=0,_=l.length;v<_;v++){a.isInterleavedBufferAttribute?p=l[v]*a.data.stride+a.offset:p=l[v]*h;for(let S=0;S<h;S++)g[m++]=c[p++]}return new zs(g,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ai,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,r);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,f=c.length;h<f;h++){const g=c[h],p=t(g,r);l.push(p)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const r=this.attributes;for(const l in r){const c=r[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,g=c.length;f<g;f++){const p=c[f];h.push(p.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const r=t.index;r!==null&&this.setIndex(r.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],f=s[c];for(let g=0,p=f.length;g<p;g++)h.push(f[g].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const zm=new Ue,Oi=new _S,au=new ym,Tm=new D,uu=new D,lu=new D,cu=new D,nh=new D,hu=new D,Cm=new D,fu=new D;class Cs extends vn{constructor(t=new Ai,e=new Os){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){const i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){hu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],f=s[l];h!==0&&(nh.fromBufferAttribute(f,t),o?hu.addScaledVector(nh,h):hu.addScaledVector(nh.sub(e),h))}e.add(hu)}return e}raycast(t,e){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),au.copy(r.boundingSphere),au.applyMatrix4(s),Oi.copy(t.ray).recast(t.near),!(au.containsPoint(Oi.origin)===!1&&(Oi.intersectSphere(au,Tm)===null||Oi.origin.distanceToSquared(Tm)>(t.far-t.near)**2))&&(zm.copy(s).invert(),Oi.copy(t.ray).applyMatrix4(zm),!(r.boundingBox!==null&&Oi.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(t,e,Oi)))}_computeIntersections(t,e,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,g=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],M=Math.max(_.start,p.start),C=Math.min(a.count,Math.min(_.start+_.count,p.start+p.count));for(let O=M,E=C;O<E;O+=3){const z=a.getX(O),R=a.getX(O+1),k=a.getX(O+2);i=du(this,S,t,r,c,h,f,z,R,k),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const M=a.getX(_),C=a.getX(_+1),O=a.getX(_+2);i=du(this,o,t,r,c,h,f,M,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],M=Math.max(_.start,p.start),C=Math.min(l.count,Math.min(_.start+_.count,p.start+p.count));for(let O=M,E=C;O<E;O+=3){const z=O,R=O+1,k=O+2;i=du(this,S,t,r,c,h,f,z,R,k),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const M=_,C=_+1,O=_+2;i=du(this,o,t,r,c,h,f,M,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}}}function PS(n,t,e,r,i,s,o,a){let l;if(t.side===iS?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,t.side===Rc,a),l===null)return null;fu.copy(a),fu.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(fu);return c<e.near||c>e.far?null:{distance:c,point:fu.clone(),object:n}}function du(n,t,e,r,i,s,o,a,l,c){n.getVertexPosition(a,uu),n.getVertexPosition(l,lu),n.getVertexPosition(c,cu);const h=PS(n,t,e,r,uu,lu,cu,Cm);if(h){const f=new D;Qr.getBarycoord(Cm,uu,lu,cu,f),i&&(h.uv=Qr.getInterpolatedAttribute(i,a,l,c,f,new Et)),s&&(h.uv1=Qr.getInterpolatedAttribute(s,a,l,c,f,new Et)),o&&(h.normal=Qr.getInterpolatedAttribute(o,a,l,c,f,new D),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const g={a,b:l,c,normal:new D,materialIndex:0};Qr.getNormal(uu,lu,cu,g.normal),h.face=g,h.barycoord=f}return h}class pu extends Ai{constructor(t=1,e=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],f=[];let g=0,p=0;m("z","y","x",-1,-1,r,e,t,o,s,0),m("z","y","x",1,-1,r,e,-t,o,s,1),m("x","z","y",1,1,t,r,e,i,o,2),m("x","z","y",1,-1,t,r,-e,i,o,3),m("x","y","z",1,-1,t,e,r,i,s,4),m("x","y","z",-1,-1,t,e,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new jn(c,3)),this.setAttribute("normal",new jn(h,3)),this.setAttribute("uv",new jn(f,2));function m(v,_,S,M,C,O,E,z,R,k,L){const X=O/R,J=E/k,at=O/2,tt=E/2,bt=z/2,xt=R+1,yt=k+1;let ht=0,Y=0;const St=new D;for(let j=0;j<yt;j++){const W=j*J-tt;for(let ft=0;ft<xt;ft++){const et=ft*X-at;St[v]=et*M,St[_]=W*C,St[S]=bt,c.push(St.x,St.y,St.z),St[v]=0,St[_]=0,St[S]=z>0?1:-1,h.push(St.x,St.y,St.z),f.push(ft/R),f.push(1-j/k),ht+=1}}for(let j=0;j<k;j++)for(let W=0;W<R;W++){const ft=g+W+xt*j,et=g+W+xt*(j+1),rt=g+(W+1)+xt*(j+1),Z=g+(W+1)+xt*j;l.push(ft,et,Z),l.push(et,rt,Z),Y+=6}a.addGroup(p,Y,L),p+=Y,g+=ht}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pu(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class RS extends vn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class xn{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){const r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const r=this.getLengths();let i=0;const s=r.length;let o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const h=r[i],g=r[i+1]-h,p=(o-h)/g;return(i+p)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new Et:new D);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e=!1){const r=new D,i=[],s=[],o=[],a=new D,l=new Ue;for(let p=0;p<=t;p++){const m=p/t;i[p]=this.getTangentAt(m,new D)}s[0]=new D,o[0]=new D;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),f=Math.abs(i[0].y),g=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),f<=c&&(c=f,r.set(0,1,0)),g<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=t;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(Lt(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(i[p],s[p])}if(e===!0){let p=Math.acos(Lt(s[0].dot(s[t]),-1,1));p/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(p=-p);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],p*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ih extends xn{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new Et){const r=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),g=l-this.aX,p=c-this.aY;l=g*h-p*f+this.aX,c=g*f+p*h+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class LS extends ih{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function sh(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,f){let g=(o-s)/c-(a-s)/(c+h)+(a-o)/h,p=(a-o)/h-(l-o)/(h+f)+(l-a)/f;g*=h,p*=h,i(o,a,g,p)},calc:function(s){const o=s*s,a=o*s;return n+t*s+e*o+r*a}}}const gu=new D,oh=new sh,ah=new sh,uh=new sh;class FS extends xn{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new D){const r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(gu.subVectors(i[0],i[1]).add(i[0]),c=gu);const f=i[a%s],g=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(gu.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=gu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(f),p),v=Math.pow(f.distanceToSquared(g),p),_=Math.pow(g.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),_<1e-4&&(_=v),oh.initNonuniformCatmullRom(c.x,f.x,g.x,h.x,m,v,_),ah.initNonuniformCatmullRom(c.y,f.y,g.y,h.y,m,v,_),uh.initNonuniformCatmullRom(c.z,f.z,g.z,h.z,m,v,_)}else this.curveType==="catmullrom"&&(oh.initCatmullRom(c.x,f.x,g.x,h.x,this.tension),ah.initCatmullRom(c.y,f.y,g.y,h.y,this.tension),uh.initCatmullRom(c.z,f.z,g.z,h.z,this.tension));return r.set(oh.calc(l),ah.calc(l),uh.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new D().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Im(n,t,e,r,i){const s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function NS(n,t){const e=1-n;return e*e*t}function jS(n,t){return 2*(1-n)*n*t}function VS(n,t){return n*n*t}function To(n,t,e,r){return NS(n,t)+jS(n,e)+VS(n,r)}function DS(n,t){const e=1-n;return e*e*e*t}function BS(n,t){const e=1-n;return 3*e*e*n*t}function qS(n,t){return 3*(1-n)*n*n*t}function $S(n,t){return n*n*n*t}function Co(n,t,e,r,i){return DS(n,t)+BS(n,e)+qS(n,r)+$S(n,i)}class km extends xn{constructor(t=new Et,e=new Et,r=new Et,i=new Et){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new Et){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Co(t,i.x,s.x,o.x,a.x),Co(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class HS extends xn{constructor(t=new D,e=new D,r=new D,i=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Co(t,i.x,s.x,o.x,a.x),Co(t,i.y,s.y,o.y,a.y),Co(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Pm extends xn{constructor(t=new Et,e=new Et){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Et){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Et){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class GS extends xn{constructor(t=new D,e=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new D){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new D){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Rm extends xn{constructor(t=new Et,e=new Et,r=new Et){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new Et){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(To(t,i.x,s.x,o.x),To(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class WS extends xn{constructor(t=new D,e=new D,r=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(To(t,i.x,s.x,o.x),To(t,i.y,s.y,o.y),To(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Lm extends xn{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Et){const r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return r.set(Im(a,l.x,c.x,h.x,f.x),Im(a,l.y,c.y,h.y,f.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new Et().fromArray(i))}return this}}var Fm=Object.freeze({__proto__:null,ArcCurve:LS,CatmullRomCurve3:FS,CubicBezierCurve:km,CubicBezierCurve3:HS,EllipseCurve:ih,LineCurve:Pm,LineCurve3:GS,QuadraticBezierCurve:Rm,QuadraticBezierCurve3:WS,SplineCurve:Lm});class US extends xn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Fm[r](e,t))}return this}getPoint(t,e){const r=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(new Fm[i.type]().fromJSON(i))}return this}}class Nm extends US{constructor(t){super(),this.type="Path",this.currentPoint=new Et,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const r=new Pm(this.currentPoint.clone(),new Et(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){const s=new Rm(this.currentPoint.clone(),new Et(t,e),new Et(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){const a=new km(this.currentPoint.clone(),new Et(t,e),new Et(r,i),new Et(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),r=new Lm(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){const c=new ih(t,e,r,i,s,o,a,l);if(this.curves.length>0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class lh extends Nm{constructor(t){super(t),this.uuid=ds(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(new Nm().fromJSON(i))}return this}}function YS(n,t,e=2){const r=t&&t.length,i=r?t[0]*e:n.length;let s=jm(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=QS(n,t,s,e)),n.length>80*e){a=1/0,l=1/0;let h=-1/0,f=-1/0;for(let g=e;g<i;g+=e){const p=n[g],m=n[g+1];p<a&&(a=p),m<l&&(l=m),p>h&&(h=p),m>f&&(f=m)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return Io(s,o,e,a,l,c,0),o}function jm(n,t,e,r,i){let s;if(i===c2(n,t,e,r)>0)for(let o=t;o<e;o+=r)s=qm(o/r|0,n[o],n[o+1],s);else for(let o=e-r;o>=t;o-=r)s=qm(o/r|0,n[o],n[o+1],s);return s&&Is(s,s.next)&&(Ro(s),s=s.next),s}function zi(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(Is(e,e.next)||he(e.prev,e,e.next)===0)){if(Ro(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Io(n,t,e,r,i,s,o){if(!n)return;!o&&s&&i2(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?JS(n,r,i,s):XS(n)){t.push(l.i,n.i,c.i),Ro(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=ZS(zi(n),t),Io(n,t,e,r,i,s,2)):o===2&&KS(n,t,e,r,i,s):Io(zi(n),t,e,r,i,s,1);break}}}function XS(n){const t=n.prev,e=n,r=n.next;if(he(t,e,r)>=0)return!1;const i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,h=Math.min(i,s,o),f=Math.min(a,l,c),g=Math.max(i,s,o),p=Math.max(a,l,c);let m=r.next;for(;m!==t;){if(m.x>=h&&m.x<=g&&m.y>=f&&m.y<=p&&ko(i,a,s,l,o,c,m.x,m.y)&&he(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function JS(n,t,e,r){const i=n.prev,s=n,o=n.next;if(he(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,f=s.y,g=o.y,p=Math.min(a,l,c),m=Math.min(h,f,g),v=Math.max(a,l,c),_=Math.max(h,f,g),S=ch(p,m,t,e,r),M=ch(v,_,t,e,r);let C=n.prevZ,O=n.nextZ;for(;C&&C.z>=S&&O&&O.z<=M;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&ko(a,h,l,f,c,g,C.x,C.y)&&he(C.prev,C,C.next)>=0||(C=C.prevZ,O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&ko(a,h,l,f,c,g,O.x,O.y)&&he(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;C&&C.z>=S;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&ko(a,h,l,f,c,g,C.x,C.y)&&he(C.prev,C,C.next)>=0)return!1;C=C.prevZ}for(;O&&O.z<=M;){if(O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&ko(a,h,l,f,c,g,O.x,O.y)&&he(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function ZS(n,t){let e=n;do{const r=e.prev,i=e.next.next;!Is(r,i)&&Dm(r,e,e.next,i)&&Po(r,i)&&Po(i,r)&&(t.push(r.i,e.i,i.i),Ro(e),Ro(e.next),e=n=i),e=e.next}while(e!==n);return zi(e)}function KS(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&a2(o,a)){let l=Bm(o,a);o=zi(o,o.next),l=zi(l,l.next),Io(o,t,e,r,i,s,0),Io(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function QS(n,t,e,r){const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=jm(n,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push(o2(c))}i.sort(t2);for(let s=0;s<i.length;s++)e=e2(i[s],e);return e}function t2(n,t){let e=n.x-t.x;if(e===0&&(e=n.y-t.y,e===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=r-i}return e}function e2(n,t){const e=r2(n,t);if(!e)return t;const r=Bm(e,n);return zi(r,r.next),zi(e,e.next)}function r2(n,t){let e=t;const r=n.x,i=n.y;let s=-1/0,o;if(Is(n,e))return e;do{if(Is(n,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const f=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=r&&f>s&&(s=f,o=e.x<e.next.x?e:e.next,f===r))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;e=o;do{if(r>=e.x&&e.x>=l&&r!==e.x&&Vm(i<c?r:s,i,l,c,i<c?s:r,i,e.x,e.y)){const f=Math.abs(i-e.y)/(r-e.x);Po(e,n)&&(f<h||f===h&&(e.x>o.x||e.x===o.x&&n2(o,e)))&&(o=e,h=f)}e=e.next}while(e!==a);return o}function n2(n,t){return he(n.prev,n,t.prev)<0&&he(t.next,n,n.next)<0}function i2(n,t,e,r){let i=n;do i.z===0&&(i.z=ch(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,s2(i)}function s2(n){let t,e=1;do{let r=n,i;n=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let c=0;c<e&&(a++,o=o.nextZ,!!o);c++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,e*=2}while(t>1);return n}function ch(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function o2(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function Vm(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function ko(n,t,e,r,i,s,o,a){return!(n===o&&t===a)&&Vm(n,t,e,r,i,s,o,a)}function a2(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!u2(n,t)&&(Po(n,t)&&Po(t,n)&&l2(n,t)&&(he(n.prev,n,t.prev)||he(n,t.prev,t))||Is(n,t)&&he(n.prev,n,n.next)>0&&he(t.prev,t,t.next)>0)}function he(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function Is(n,t){return n.x===t.x&&n.y===t.y}function Dm(n,t,e,r){const i=yu(he(n,t,e)),s=yu(he(n,t,r)),o=yu(he(e,r,n)),a=yu(he(e,r,t));return!!(i!==s&&o!==a||i===0&&mu(n,e,t)||s===0&&mu(n,r,t)||o===0&&mu(e,n,r)||a===0&&mu(e,t,r))}function mu(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function yu(n){return n>0?1:n<0?-1:0}function u2(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&Dm(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function Po(n,t){return he(n.prev,n,n.next)<0?he(n,t,n.next)>=0&&he(n,n.prev,t)>=0:he(n,t,n.prev)<0||he(n,n.next,t)<0}function l2(n,t){let e=n,r=!1;const i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function Bm(n,t){const e=hh(n.i,n.x,n.y),r=hh(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function qm(n,t,e,r){const i=hh(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ro(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function hh(n,t,e){return{i:n,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function c2(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}class h2{static triangulate(t,e,r=2){return YS(t,e,r)}}class Lo{static area(t){const e=t.length;let r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return Lo.area(t)<0}static triangulateShape(t,e){const r=[],i=[],s=[];$m(t),Hm(r,t);let o=t.length;e.forEach($m);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,Hm(r,e[l]);const a=h2.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function $m(n){const t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function Hm(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}class fh extends Ai{constructor(t=new lh([new Et(0,.5),new Et(-.5,-.5),new Et(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const r=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new jn(i,3)),this.setAttribute("normal",new jn(s,3)),this.setAttribute("uv",new jn(o,2));function c(h){const f=i.length/3,g=h.extractPoints(e);let p=g.shape;const m=g.holes;Lo.isClockWise(p)===!1&&(p=p.reverse());for(let _=0,S=m.length;_<S;_++){const M=m[_];Lo.isClockWise(M)===!0&&(m[_]=M.reverse())}const v=Lo.triangulateShape(p,m);for(let _=0,S=m.length;_<S;_++){const M=m[_];p=p.concat(M)}for(let _=0,S=p.length;_<S;_++){const M=p[_];i.push(M.x,M.y,0),s.push(0,0,1),o.push(M.x,M.y)}for(let _=0,S=v.length;_<S;_++){const M=v[_],C=M[0]+f,O=M[1]+f,E=M[2]+f;r.push(C,O,E),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return f2(e,t)}static fromJSON(t,e){const r=[];for(let i=0,s=t.shapes.length;i<s;i++){const o=e[t.shapes[i]];r.push(o)}return new fh(r,t.curveSegments)}}function f2(n,t){if(t.shapes=[],Array.isArray(n))for(let e=0,r=n.length;e<r;e++){const i=n[e];t.shapes.push(i.uuid)}else t.shapes.push(n.uuid);return t}class d2 extends Om{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Mi(16777215),this.specular=new Mi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hS,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ws,this.combine=nm,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const dh={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class p2{constructor(t,e,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.abortController=new AbortController,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,g=c.length;f<g;f+=2){const p=c[f],m=c[f+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const g2=new p2;class ph{constructor(t){this.manager=t!==void 0?t:g2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}ph.DEFAULT_MATERIAL_NAME="__DEFAULT";const ks=new WeakMap;class m2 extends ph{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=dh.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0);else{let f=ks.get(o);f===void 0&&(f=[],ks.set(o,f)),f.push({onLoad:e,onError:i})}return o}const a=Vc("img");function l(){h(),e&&e(this);const f=ks.get(this)||[];for(let g=0;g<f.length;g++){const p=f[g];p.onLoad&&p.onLoad(this)}ks.delete(this),s.manager.itemEnd(t)}function c(f){h(),i&&i(f),dh.remove(`image:${t}`);const g=ks.get(this)||[];for(let p=0;p<g.length;p++){const m=g[p];m.onError&&m.onError(f)}ks.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),dh.add(`image:${t}`,a),s.manager.itemStart(t),a.src=t,a}}class Gm extends ph{constructor(t){super(t)}load(t,e,r,i){const s=new ti,o=new m2(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Zg}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Zg);class y2{constructor(t=ln){Vt(this,"elements");Vt(this,"categories");Vt(this,"propertyTypes");Vt(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=t,this.registerMultiplePropertyType([["color",qg,qg],["enum",$g,$g],["string",Hg,Hg],["number",Gg,Gg],["length-measure",Wg,Wg],["toggle",Ug,Ug],["checkbox",Yg,Yg],["hidden",Xg,Xg],["read-only",Jg,Jg]])}getElement(t){if(this.hasElement(t))return this.elements[t];throw new Error(`Element ${t} does not exist in catalog`)}getCategory(t){if(this.hasCategory(t))return this.categories[t];throw new Error(`Category ${t} does not exist in catalog`)}getPropertyType(t){if(this.propertyTypes.hasOwnProperty(t))return this.propertyTypes[t];throw new Error(`Element ${t} does not exist in catalog`)}registerElement(t){t.properties=t.properties||{},this.validateElement(t)&&(this.elements[t.name]=t,this.categories.root.elements.push(this.elements[t.name]))}registerMultipleElements(t){t.forEach(e=>this.registerElement(e))}registerPropertyType(t,e,r){this.propertyTypes[t]={type:t,Viewer:e,Editor:r}}registerMultiplePropertyType(t){t.forEach(e=>this.registerPropertyType(...e))}validateElement(t){if(!t.hasOwnProperty("name"))throw new Error("Element not valid");let e=t.name;if(!t.hasOwnProperty("prototype"))throw new Error(`Element ${e} doesn't have prototype`);if(!t.hasOwnProperty("info"))throw new Error(`Element ${e} doesn't have info`);if(!t.info.hasOwnProperty("tag"))throw new Error(`Element ${e} doesn't have tag`);if(!t.info.hasOwnProperty("description"))throw new Error(`Element ${e} doesn't have description`);if(!t.info.hasOwnProperty("image"))throw new Error(`Element ${e} doesn't have image`);if(!t.hasOwnProperty("render2D"))throw new Error(`Element ${e} doesn't have render2D handler`);if(!t.hasOwnProperty("render3D"))throw new Error(`Element ${e} doesn't have render3D handler`);if(!t.hasOwnProperty("properties"))throw new Error(`Element ${e} doesn't have properties`);for(let r in t.properties){let i=t.properties[r];if(!i.hasOwnProperty("type"))throw new Error(`Element ${e}, Property ${r} doesn't have type`);if(!i.hasOwnProperty("defaultValue"))throw new Error(`Element ${e}, Property ${r} doesn't have defaultValue`)}return!0}hasElement(t){return this.elements.hasOwnProperty(t)}registerCategory(t,e,r){return this.validateCategory(t,e)?(this.categories[t]={name:t,label:e,categories:[],elements:[]},this.categories.root.categories.push(this.categories[t]),r&&r.length&&r.forEach(i=>this.addToCategory(t,i)),this.categories[t]):null}addToCategory(t,e){if(this.hasElement(e.name))this.categories[t].elements.push(e),this.categories.root.elements.splice(this.categories.root.elements.indexOf(e),1);else if(this.hasCategory(e.name))this.categories[t].categories.push(e),this.categories.root.categories.splice(this.categories.root.categories.indexOf(e),1);else throw new Error(`child ${e} is either category nor element`)}categoryHasElement(t,e){return this.hasCategory(t)&&this.categories[t].elements.some(r=>r.name===e)}validateCategory(t,e){if(!t)throw new Error("Category has undefined name");if(t==="")throw new Error("Category has empty name");if(this.hasCategory(t))throw new Error("Category has already been registered");return!0}hasCategory(t){return this.categories.hasOwnProperty(t)}}function v2(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(n)}const x2=({term:n="",placeholder:t="Search",noSpacing:e=!1,onClick:r=()=>!1,isStatic:i=!1,hasDropDown:s=!1,onSearch:o,className:a})=>{const[l,c]=F.useState("");return w.jsxs("div",{className:Hr(`relative w-full ${e?"mt-1":"mt-2"}`,a),onClick:r??(()=>!1),children:[w.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${e?"":"ml-2"}`,style:{zIndex:2},children:w.jsx(v2,{size:18})}),i?w.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:n}):w.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:t,onChange:h=>{o(h.target.value,h),c(h.target.value)},value:l,onClick:r??(()=>!1)}),r!==null&&s&&w.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${e?"":"ml-2"}`,style:{zIndex:1},children:w.jsx(F1,{className:"-mb-1"})})]})},Wm=8,Um=40,_2=n=>{const t=[{label:"All Categories",value:"all"}],e=n.map(r=>r.info.tag);console.log({paths:e});for(const r of e){let i=t;for(let s=0;s<r.length;s++){const o=r[s];let a=i.find(l=>l.label===o);a||(a={label:o,value:o},s<r.length-1&&(a.options=[{label:"All Categories",value:"all"}]),i.push(a)),s<r.length-1&&a.options&&(i=a.options)}}return console.log({result:t}),t},Ym=({options:n,selections:t,level:e,onChange:r})=>{var i,s;return w.jsxs(w.Fragment,{children:[w.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:t[e]||"all",onChange:o=>r(e,o.target.value),children:n.map(o=>w.jsx("option",{className:"capitalize",value:o.value,children:o.label},o.value))}),t[e]&&t[e]!=="all"&&((i=n.find(o=>o.value===t[e]))==null?void 0:i.options)&&w.jsx(Ym,{options:((s=n.find(o=>o.value===t[e]))==null?void 0:s.options)||[],level:e+1,selections:t,onChange:r})]})},b2=({catalog:n,popupEvent:t,onClose:e})=>{const{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=ne(),[a,l]=F.useState([]),[c,h]=F.useState(["all"]),[f,g]=F.useState([]),[p,m]=F.useState(""),v=F.useRef(null),_=F.useRef(null);F.useEffect(()=>{if(t){const E=n.getCategory(t.page).elements.filter(k=>k.info.visibility?k.info.visibility.catalog:!0);v.current=t.page,g(E);const{x:z,y:R}=t.rect;_.current={top:R+Wm,left:z+Um},t.page==="objects"&&(console.log({elementsToDisplay:E}),l(_2(E)))}},[t]);const S=()=>{e()},M=O=>{S(),setTimeout(()=>{switch(O.prototype){case"lines":r(O.name);break;case"items":i(O.name);break;case"holes":s(O.name);break}o(O)},0)},C=(O,E)=>{const z=[...c.slice(0,O),E];h(z)};return w.jsxs(w.Fragment,{children:[t&&w.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:S}),w.jsxs("div",{style:t&&t.rect?{top:t.rect.y+Wm,left:t.rect.x+Um}:_.current?_.current:{},className:Hr("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-5 fp_side-bar !min-h-[250px] !max-h-[510px] transition-all duration-200 ease-out transform",t?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[w.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[w.jsx("div",{className:"flex items-center gap-1",children:w.jsx("span",{className:Hr("flex flex-col gap-0.5"),children:w.jsx("span",{className:"fp-sidebar-label capitalize",children:(t==null?void 0:t.page)??v.current})})}),w.jsxs("div",{className:Hr("fp-highlight"),children:[w.jsx(Ym,{options:a,level:0,selections:c,onChange:C}),w.jsx(x2,{className:"mt-0",placeholder:"Search",onSearch:(O,E)=>{E.preventDefault(),E.stopPropagation(),m(O)}})]})]}),f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(E=>E==="all"||O.info.tag.includes(E))).length>0?w.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:O=>O.stopPropagation(),children:f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(E=>E==="all"||O.info.tag.includes(E))).map(O=>w.jsxs("div",{className:"w-full space-y-1.5",children:[w.jsx("div",{className:"fp-aspect-ratio-container",children:w.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:()=>M(O),children:w.jsx("img",{draggable:!1,className:"fp-item-image",alt:O.info.title,src:O.info.image})})}),w.jsx("p",{className:"text-xs font-semibold capitalize",children:O.info.description})]},O.name.replace(/\s+/g,"_")))}):w.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:w.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function w2(n){return ge({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(n)}function S2(n){return ge({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(n)}function E2({catalog:n}){const{planner:t,selectTool3DView:e,setMode:r,selectTool3DFirstPerson:i,selectToolDrawingLine:s}=ne(),{mode:o,alterate:a}=t,[l,c]=F.useState(null);return w.jsxs(w.Fragment,{children:[w.jsxs("aside",{className:"floor_planner-toolbar max-h-full max-w-[50px] p-2.5 space-y-4 bg-[#2b2b2b]",children:[w.jsx(In,{active:[Lr,or].includes(o),tooltip:"Draw wall",onClick:()=>s("wall"),children:w.jsx(tS,{})}),w.jsx(In,{active:!!([ar].includes(o)&&l&&l.page==="windows"),tooltip:"Place windows",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"windows"})},children:w.jsx(Q1,{size:26})}),w.jsx(In,{active:!!([ar].includes(o)&&l&&l.page==="doors"),tooltip:"Place doors",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"doors"})},children:w.jsx(w2,{size:26})}),w.jsx(In,{active:!!([Sr].includes(o)&&l&&l.page==="objects"),tooltip:"Place objects",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"objects"})},children:w.jsx(S2,{size:26})}),w.jsx(Qw,{mode:o})]}),w.jsx(b2,{catalog:n,popupEvent:l,onClose:()=>c(null)})]})}const Fo=window.hasOwnProperty("localStorage")?window.localStorage:!1,M2=500;let gh=null;function A2(n,t){return(e,r,i)=>{let s;if(t=t||M2,!!n&&Fo){if(r){e.setPlan(r);const o=r.floors[0].floorDesign;s=JSON.parse(o)}else if(Fo.getItem(n)!==null){const o=Fo.getItem(n);s=JSON.parse(o)}s&&e.loadProject(s),ne.subscribe(o=>{gh&&clearTimeout(gh),gh=setTimeout(()=>{const a=Fo.getItem(n),l=JSON.stringify(o.planner.scene.toJS());if(a!==l&&(Fo.setItem(n,l),o.plan))try{const c=o.plan.floors[o.activeFloor];i&&i({floor:{floorID:c.floorID,title:c.floorTitle,description:c.floorDescription,design:l}})}catch{}},t)})}}}function O2(){return n=>{window.addEventListener("keydown",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case Er.BACKSPACE:case Er.DELETE:{[fe,Qi,vi].includes(r)&&n.remove();break}case Er.ESC:{n.rollback();break}case Er.Z:{(t.getModifierState("Control")||t.getModifierState("Meta"))&&(t.getModifierState("Shift")?n.redo():n.undo());break}case Er.ALT:{Tl.includes(r)&&n.toggleSnap(e.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:e.snapMask.toJS()}));break}case Er.C:{let i=e.getIn(["scene","selectedLayer"]),s=e.getIn(["scene","layers",i,"selected"]);if((r===fe||r===vi)&&(s.holes.size||s.areas.size||s.items.size||s.lines.size)){if(s.holes.size){let o=e.getIn(["scene","layers",i,"holes",s.holes.get(0)]);n.copyProperties(o.get("properties"))}else if(s.areas.size){const o=e.getIn(["scene","layers",i,"areas",s.areas.get(0)]);n.copyProperties(o.properties)}else if(s.items.size){const o=e.getIn(["scene","layers",i,"items",s.items.get(0)]);n.copyProperties(o.properties)}else if(s.lines.size){const o=e.getIn(["scene","layers",i,"lines",s.lines.get(0)]);n.copyProperties(o.properties)}}break}case Er.V:{n.pasteProperties();break}case Er.CTRL:{n.setAlterateState();break}}}),window.addEventListener("keyup",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case Er.ALT:{Tl.includes(r)&&n.toggleSnap(e.snapMask.merge(e.snapMask.get("tempSnapConfiguartion")));break}case Er.CTRL:{n.setAlterateState();break}}})}}const z2=({onBack:n,onSave:t})=>{const{undo:e,redo:r,plan:i,setPlan:s}=ne(),[o,a]=F.useState(!1),l=()=>{a(!0)},c=h=>{if(!i)return;a(!1);const f=h.target.value.trim();if(f&&f!==(i==null?void 0:i.planTitle)){s({...i,planTitle:f});try{t&&t({title:f,description:""})}catch{}}};return w.jsxs("div",{className:"floor_planner-headerbar border-b border-b-[#5e5e5e] absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] w-full select-none cursor-default top-0 leading-[14px] text-white m-0",children:[w.jsx(In,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{n&&n()},children:w.jsx(pg,{})}),w.jsx("div",{className:"flex flex-col items-center justify-center",children:o?w.jsx("input",{autoFocus:!0,type:"text",defaultValue:i==null?void 0:i.planTitle,onBlur:c,onKeyDown:h=>{(h.key==="Enter"||h.key==="Escape")&&c(h)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):w.jsx("span",{onDoubleClick:l,className:"projectName__fp text-lg",title:(i==null?void 0:i.planTitle)??"Example House",children:(i==null?void 0:i.planTitle)??"Example House"})}),w.jsxs("div",{className:"flex items-center gap-2 relative right-40",children:[w.jsx(In,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:e,children:w.jsx(Z1,{})}),w.jsx(In,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:r,children:w.jsx(J1,{})})]})]})};var mh={exports:{}},Xm;function Jm(){if(Xm)return mh.exports;Xm=1;var n=mh.exports={};return n.forEach=function(t,e){for(var r=0;r<t.length;r++){var i=e(t[r]);if(i)return i}},mh.exports}var yh,Zm;function T2(){return Zm||(Zm=1,yh=function(n){var t=n.stateHandler.getState;function e(o){var a=t(o);return a&&!!a.isDetectable}function r(o){t(o).isDetectable=!0}function i(o){return!!t(o).busy}function s(o,a){t(o).busy=!!a}return{isDetectable:e,markAsDetectable:r,isBusy:i,markBusy:s}}),yh}var vh,Km;function C2(){return Km||(Km=1,vh=function(n){var t={};function e(o){var a=n.get(o);return a===void 0?[]:t[a]||[]}function r(o,a){var l=n.get(o);t[l]||(t[l]=[]),t[l].push(a)}function i(o,a){for(var l=e(o),c=0,h=l.length;c<h;++c)if(l[c]===a){l.splice(c,1);break}}function s(o){var a=e(o);a&&(a.length=0)}return{get:e,add:r,removeListener:i,removeAllListeners:s}}),vh}var xh,Qm;function I2(){return Qm||(Qm=1,xh=function(){var n=1;function t(){return n++}return{generate:t}}),xh}var _h,ty;function k2(){return ty||(ty=1,_h=function(n){var t=n.idGenerator,e=n.stateHandler.getState;function r(s){var o=e(s);return o&&o.id!==void 0?o.id:null}function i(s){var o=e(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=t.generate();return o.id=a,a}return{get:r,set:i}}),_h}var bh,ey;function P2(){return ey||(ey=1,bh=function(n){function t(){}var e={log:t,warn:t,error:t};if(!n&&window.console){var r=function(i,s){i[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var l=0;l<arguments.length;l++)a(arguments[l])}};r(e,"log"),r(e,"warn"),r(e,"error")}return e}),bh}var wh={exports:{}},ry;function ny(){if(ry)return wh.exports;ry=1;var n=wh.exports={};return n.isIE=function(t){function e(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!e())return!1;if(!t)return!0;var r=function(){var i,s=3,o=document.createElement("div"),a=o.getElementsByTagName("i");do o.innerHTML="<!--[if gt IE "+ ++s+"]><i></i><![endif]-->";while(a[0]);return s>4?s:i}();return t===r},n.isLegacyOpera=function(){return!!window.opera},wh.exports}var Sh={exports:{}},iy;function R2(){if(iy)return Sh.exports;iy=1;var n=Sh.exports={};n.getOption=t;function t(e,r,i){var s=e[r];return s==null&&i!==void 0?i:s}return Sh.exports}var Eh,sy;function L2(){if(sy)return Eh;sy=1;var n=R2();Eh=function(r){r=r||{};var i=r.reporter,s=n.getOption(r,"async",!0),o=n.getOption(r,"auto",!0);o&&!s&&(i&&i.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),s=!0);var a=t(),l,c=!1;function h(_,S){!c&&o&&s&&a.size()===0&&p(),a.add(_,S)}function f(){for(c=!0;a.size();){var _=a;a=t(),_.process()}c=!1}function g(_){c||(_===void 0&&(_=s),l&&(m(l),l=null),_?p():f())}function p(){l=v(f)}function m(_){var S=clearTimeout;return S(_)}function v(_){var S=function(M){return setTimeout(M,0)};return S(_)}return{add:h,force:g}};function t(){var e={},r=0,i=0,s=0;function o(c,h){h||(h=c,c=0),c>i?i=c:c<s&&(s=c),e[c]||(e[c]=[]),e[c].push(h),r++}function a(){for(var c=s;c<=i;c++)for(var h=e[c],f=0;f<h.length;f++){var g=h[f];g()}}function l(){return r}return{add:o,process:a,size:l}}return Eh}var Mh,oy;function F2(){if(oy)return Mh;oy=1;var n="_erd";function t(i){return i[n]={},e(i)}function e(i){return i[n]}function r(i){delete i[n]}return Mh={initState:t,getState:e,cleanState:r},Mh}var Ah,ay;function N2(){if(ay)return Ah;ay=1;var n=ny();return Ah=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;if(!e)throw new Error("Missing required dependency: reporter.");function s(h,f){function g(){f(h)}if(n.isIE(8))i(h).object={proxy:g},h.attachEvent("onresize",g);else{var p=l(h);if(!p)throw new Error("Element is not detectable by this strategy.");p.contentDocument.defaultView.addEventListener("resize",g)}}function o(h){var f=t.important?" !important; ":"; ";return(h.join(f)+f).trim()}function a(h,f,g){g||(g=f,f=h,h=null),h=h||{},h.debug;function p(m,v){var _=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),S=!1,M=window.getComputedStyle(m),C=m.offsetWidth,O=m.offsetHeight;i(m).startSize={width:C,height:O};function E(){function z(){if(M.position==="static"){m.style.setProperty("position","relative",h.important?"important":"");var L=function(X,J,at,tt){function bt(yt){return yt.replace(/[^-\d\.]/g,"")}var xt=at[tt];xt!=="auto"&&bt(xt)!=="0"&&(X.warn("An element that is positioned static has style."+tt+"="+xt+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+tt+" will be set to 0. Element: ",J),J.style.setProperty(tt,"0",h.important?"important":""))};L(e,m,M,"top"),L(e,m,M,"right"),L(e,m,M,"bottom"),L(e,m,M,"left")}}function R(){S||z();function L(J,at){if(!J.contentDocument){var tt=i(J);tt.checkForObjectDocumentTimeoutId&&window.clearTimeout(tt.checkForObjectDocumentTimeoutId),tt.checkForObjectDocumentTimeoutId=setTimeout(function(){tt.checkForObjectDocumentTimeoutId=0,L(J,at)},100);return}at(J.contentDocument)}var X=this;L(X,function(at){v(m)})}M.position!==""&&(z(),S=!0);var k=document.createElement("object");k.style.cssText=_,k.tabIndex=-1,k.type="text/html",k.setAttribute("aria-hidden","true"),k.onload=R,n.isIE()||(k.data="about:blank"),i(m)&&(m.appendChild(k),i(m).object=k,n.isIE()&&(k.data="about:blank"))}r?r.add(E):E()}n.isIE(8)?g(f):p(f,g)}function l(h){return i(h).object}function c(h){if(i(h)){var f=l(h);f&&(n.isIE(8)?h.detachEvent("onresize",f.proxy):h.removeChild(f),i(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(h).checkForObjectDocumentTimeoutId),delete i(h).object)}}return{makeDetectable:a,addListener:s,uninstall:c}},Ah}var Oh,uy;function j2(){if(uy)return Oh;uy=1;var n=Jm().forEach;return Oh=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;t.stateHandler.hasState;var s=t.idHandler;if(!r)throw new Error("Missing required dependency: batchProcessor");if(!e)throw new Error("Missing required dependency: reporter.");var o=f(),a="erd_scroll_detection_scrollbar_style",l="erd_scroll_detection_container";function c(E){g(E,a,l)}c(window.document);function h(E){var z=t.important?" !important; ":"; ";return(E.join(z)+z).trim()}function f(){var E=500,z=500,R=document.createElement("div");R.style.cssText=h(["position: absolute","width: "+E*2+"px","height: "+z*2+"px","visibility: hidden","margin: 0","padding: 0"]);var k=document.createElement("div");k.style.cssText=h(["position: absolute","width: "+E+"px","height: "+z+"px","overflow: scroll","visibility: none","top: "+-E*3+"px","left: "+-z*3+"px","visibility: hidden","margin: 0","padding: 0"]),k.appendChild(R),document.body.insertBefore(k,document.body.firstChild);var L=E-k.clientWidth,X=z-k.clientHeight;return document.body.removeChild(k),{width:L,height:X}}function g(E,z,R){function k(at,tt){tt=tt||function(xt){E.head.appendChild(xt)};var bt=E.createElement("style");return bt.innerHTML=at,bt.id=z,tt(bt),bt}if(!E.getElementById(z)){var L=R+"_animation",X=R+"_animation_active",J=`/* Created by the element-resize-detector library. */
|
|
82
|
+
*/const Zg="179",Rc=0,iS=1,sS=2,Kg=1,Qg=100,tm=204,em=205,rm=3,nm=0,im=300,yn=1e3,Xa=1001,sm=1002,oS=1006,aS=1008,uS=1009,lS=1015,cS=1023,hS=0,om="",Yr="srgb",am="srgb-linear",um="linear",Lc="srgb",fs=7680,lm=519,cm=35044,Ja=2e3,hm=2001;class Za{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){const r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){const r=this._listeners;if(r===void 0)return;const i=r[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const r=e[t.type];if(r!==void 0){t.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}}const Be=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function ds(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Be[n&255]+Be[n>>8&255]+Be[n>>16&255]+Be[n>>24&255]+"-"+Be[t&255]+Be[t>>8&255]+"-"+Be[t>>16&15|64]+Be[t>>24&255]+"-"+Be[e&63|128]+Be[e>>8&255]+"-"+Be[e>>16&255]+Be[e>>24&255]+Be[r&255]+Be[r>>8&255]+Be[r>>16&255]+Be[r>>24&255]).toLowerCase()}function Lt(n,t,e){return Math.max(t,Math.min(e,n))}function fS(n,t){return(n%t+t)%t}function Fc(n,t,e){return(1-e)*n+e*t}function So(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function er(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}class Et{constructor(t=0,e=0){Et.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6],this.y=i[1]*e+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(Lt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*i+t.x,this.y=s*i+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ps{constructor(t=0,e=0,r=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=i}static slerpFlat(t,e,r,i,s,o,a){let l=r[i+0],c=r[i+1],h=r[i+2],f=r[i+3];const g=s[o+0],p=s[o+1],m=s[o+2],v=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f;return}if(a===1){t[e+0]=g,t[e+1]=p,t[e+2]=m,t[e+3]=v;return}if(f!==v||l!==g||c!==p||h!==m){let _=1-a;const S=l*g+c*p+h*m+f*v,M=S>=0?1:-1,C=1-S*S;if(C>Number.EPSILON){const E=Math.sqrt(C),z=Math.atan2(E,S*M);_=Math.sin(_*z)/E,a=Math.sin(a*z)/E}const O=a*M;if(l=l*_+g*O,c=c*_+p*O,h=h*_+m*O,f=f*_+v*O,_===1-a){const E=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=E,c*=E,h*=E,f*=E}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f}static multiplyQuaternionsFlat(t,e,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],h=r[i+3],f=s[o],g=s[o+1],p=s[o+2],m=s[o+3];return t[e]=a*m+h*f+l*p-c*g,t[e+1]=l*m+h*g+c*f-a*p,t[e+2]=c*m+h*p+a*g-l*f,t[e+3]=h*m-a*f-l*g-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const r=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(r/2),h=a(i/2),f=a(s/2),g=l(r/2),p=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"YXZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"ZXY":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"ZYX":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"YZX":this._x=g*h*f+c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f-g*p*m;break;case"XZY":this._x=g*h*f-c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f+g*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],f=e[10],g=r+a+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(r>a&&r>f){const p=2*Math.sqrt(1+r-a-f);this._w=(h-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-r-f);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+f-r-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Lt(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(r===0)return this;const i=Math.min(1,e/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const r=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=r*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-r*c,this._z=s*h+o*c+r*l-i*a,this._w=o*h-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*t._w+r*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-e;return this._w=p*o+e*this._w,this._x=p*r+e*this._x,this._y=p*i+e*this._y,this._z=p*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-e)*h)/c,g=Math.sin(e*h)/c;return this._w=o*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(t=0,e=0,r=0){D.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(fm.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(fm.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*i,this.y=s[1]*e+s[4]*r+s[7]*i,this.z=s[2]*e+s[5]*r+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*r),h=2*(a*e-s*i),f=2*(s*r-o*e);return this.x=e+l*c+o*f-a*h,this.y=r+l*h+a*c-s*f,this.z=i+l*f+s*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i,this.y=s[1]*e+s[5]*r+s[9]*i,this.z=s[2]*e+s[6]*r+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this.z=Lt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this.z=Lt(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Nc.copy(this).projectOnVector(t),this.sub(Nc)}reflect(t){return this.sub(Nc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(Lt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){const i=Math.sin(e)*t;return this.x=i*Math.sin(r),this.y=Math.cos(e)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Nc=new D,fm=new ps;class Qn{constructor(t,e,r,i,s,o,a,l,c){Qn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c)}set(t,e,r,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],g=r[2],p=r[5],m=r[8],v=i[0],_=i[3],S=i[6],M=i[1],C=i[4],O=i[7],E=i[2],z=i[5],R=i[8];return s[0]=o*v+a*M+l*E,s[3]=o*_+a*C+l*z,s[6]=o*S+a*O+l*R,s[1]=c*v+h*M+f*E,s[4]=c*_+h*C+f*z,s[7]=c*S+h*O+f*R,s[2]=g*v+p*M+m*E,s[5]=g*_+p*C+m*z,s[8]=g*S+p*O+m*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-r*s*h+r*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=h*o-a*c,g=a*l-h*s,p=c*s-o*l,m=e*f+r*g+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return t[0]=f*v,t[1]=(i*c-h*r)*v,t[2]=(a*r-i*o)*v,t[3]=g*v,t[4]=(h*e-i*l)*v,t[5]=(i*s-a*e)*v,t[6]=p*v,t[7]=(r*l-c*e)*v,t[8]=(o*e-r*s)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(jc.makeScale(t,e)),this}rotate(t){return this.premultiply(jc.makeRotation(-t)),this}translate(t,e){return this.premultiply(jc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<9;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const jc=new Qn;function dS(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}function Vc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}const dm={};function pm(n){n in dm||(dm[n]=!0,console.warn(n))}const gm=new Qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mm=new Qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pS(){const n={enabled:!0,workingColorSpace:am,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Lc&&(i.r=kn(i.r),i.g=kn(i.g),i.b=kn(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Lc&&(i.r=gs(i.r),i.g=gs(i.g),i.b=gs(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===om?um:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return pm("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return pm("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[am]:{primaries:t,whitePoint:r,transfer:um,toXYZ:gm,fromXYZ:mm,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Yr},outputColorSpaceConfig:{drawingBufferColorSpace:Yr}},[Yr]:{primaries:t,whitePoint:r,transfer:Lc,toXYZ:gm,fromXYZ:mm,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Yr}}}),n}const Xr=pS();function kn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let ms;class gS{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let r;if(t instanceof HTMLCanvasElement)r=t;else{ms===void 0&&(ms=Vc("canvas")),ms.width=t.width,ms.height=t.height;const i=ms.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),r=ms}return r.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Vc("canvas");e.width=t.width,e.height=t.height;const r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=kn(s[o]/255)*255;return r.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let r=0;r<e.length;r++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[r]=Math.floor(kn(e[r]/255)*255):e[r]=kn(e[r]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let mS=0;class yS{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mS++}),this.uuid=ds(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Dc(i[o].image)):s.push(Dc(i[o]))}else s=Dc(i);r.url=s}return e||(t.images[this.uuid]=r),r}}function Dc(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?gS.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let vS=0;const Bc=new D;class ti extends Za{constructor(t=ti.DEFAULT_IMAGE,e=ti.DEFAULT_MAPPING,r=Xa,i=Xa,s=oS,o=aS,a=cS,l=uS,c=ti.DEFAULT_ANISOTROPY,h=om){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vS++}),this.uuid=ds(),this.name="",this.source=new yS(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Et(0,0),this.repeat=new Et(1,1),this.center=new Et(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Qn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Bc).x}get height(){return this.source.getSize(Bc).y}get depth(){return this.source.getSize(Bc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==im)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case yn:t.x=t.x-Math.floor(t.x);break;case Xa:t.x=t.x<0?0:1;break;case sm:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case yn:t.y=t.y-Math.floor(t.y);break;case Xa:t.y=t.y<0?0:1;break;case sm:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ti.DEFAULT_IMAGE=null,ti.DEFAULT_MAPPING=im,ti.DEFAULT_ANISOTROPY=1;class Eo{constructor(t=0,e=0,r=0,i=1){Eo.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,i,s;const l=t.elements,c=l[0],h=l[4],f=l[8],g=l[1],p=l[5],m=l[9],v=l[2],_=l[6],S=l[10];if(Math.abs(h-g)<.01&&Math.abs(f-v)<.01&&Math.abs(m-_)<.01){if(Math.abs(h+g)<.1&&Math.abs(f+v)<.1&&Math.abs(m+_)<.1&&Math.abs(c+p+S-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const C=(c+1)/2,O=(p+1)/2,E=(S+1)/2,z=(h+g)/4,R=(f+v)/4,k=(m+_)/4;return C>O&&C>E?C<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(C),i=z/r,s=R/r):O>E?O<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(O),r=z/i,s=k/i):E<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),r=R/s,i=k/s),this.set(r,i,s,e),this}let M=Math.sqrt((_-m)*(_-m)+(f-v)*(f-v)+(g-h)*(g-h));return Math.abs(M)<.001&&(M=1),this.x=(_-m)/M,this.y=(f-v)/M,this.z=(g-h)/M,this.w=Math.acos((c+p+S-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this.z=Lt(this.z,t.z,e.z),this.w=Lt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this.z=Lt(this.z,t,e),this.w=Lt(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ys{constructor(t=new D(1/0,1/0,1/0),e=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e+=3)this.expandByPoint(Jr.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,r=t.count;e<r;e++)this.expandByPoint(Jr.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const r=Jr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const r=t.geometry;if(r!==void 0){const s=r.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Jr):Jr.fromBufferAttribute(s,o),Jr.applyMatrix4(t.matrixWorld),this.expandByPoint(Jr);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ka.copy(t.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ka.copy(r.boundingBox)),Ka.applyMatrix4(t.matrixWorld),this.union(Ka)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Jr),Jr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Mo),Qa.subVectors(this.max,Mo),vs.subVectors(t.a,Mo),xs.subVectors(t.b,Mo),_s.subVectors(t.c,Mo),ei.subVectors(xs,vs),ri.subVectors(_s,xs),Si.subVectors(vs,_s);let e=[0,-ei.z,ei.y,0,-ri.z,ri.y,0,-Si.z,Si.y,ei.z,0,-ei.x,ri.z,0,-ri.x,Si.z,0,-Si.x,-ei.y,ei.x,0,-ri.y,ri.x,0,-Si.y,Si.x,0];return!qc(e,vs,xs,_s,Qa)||(e=[1,0,0,0,1,0,0,0,1],!qc(e,vs,xs,_s,Qa))?!1:(tu.crossVectors(ei,ri),e=[tu.x,tu.y,tu.z],qc(e,vs,xs,_s,Qa))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Jr).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Jr).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Pn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Pn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Pn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Pn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Pn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Pn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Pn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Pn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Pn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Pn=[new D,new D,new D,new D,new D,new D,new D,new D],Jr=new D,Ka=new ys,vs=new D,xs=new D,_s=new D,ei=new D,ri=new D,Si=new D,Mo=new D,Qa=new D,tu=new D,Ei=new D;function qc(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){Ei.fromArray(n,s);const a=i.x*Math.abs(Ei.x)+i.y*Math.abs(Ei.y)+i.z*Math.abs(Ei.z),l=t.dot(Ei),c=e.dot(Ei),h=r.dot(Ei);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const xS=new ys,Ao=new D,$c=new D;class ym{constructor(t=new D,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const r=this.center;e!==void 0?r.copy(e):xS.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,r.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const r=this.center.distanceToSquared(t);return e.copy(t),r>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ao.subVectors(t,this.center);const e=Ao.lengthSq();if(e>this.radius*this.radius){const r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(Ao,i/r),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):($c.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ao.copy(t.center).add($c)),this.expandByPoint(Ao.copy(t.center).sub($c))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Rn=new D,Hc=new D,eu=new D,ni=new D,Gc=new D,ru=new D,Wc=new D;class _S{constructor(t=new D,e=new D(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Rn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Rn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Rn.copy(this.origin).addScaledVector(this.direction,e),Rn.distanceToSquared(t))}distanceSqToSegment(t,e,r,i){Hc.copy(t).add(e).multiplyScalar(.5),eu.copy(e).sub(t).normalize(),ni.copy(this.origin).sub(Hc);const s=t.distanceTo(e)*.5,o=-this.direction.dot(eu),a=ni.dot(this.direction),l=-ni.dot(eu),c=ni.lengthSq(),h=Math.abs(1-o*o);let f,g,p,m;if(h>0)if(f=o*l-a,g=o*a-l,m=s*h,f>=0)if(g>=-m)if(g<=m){const v=1/h;f*=v,g*=v,p=f*(f+o*g+2*a)+g*(o*f+g+2*l)+c}else g=s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g=-s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g<=-m?(f=Math.max(0,-(-o*s+a)),g=f>0?-s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c):g<=m?(f=0,g=Math.min(Math.max(-s,-l),s),p=g*(g+2*l)+c):(f=Math.max(0,-(o*s+a)),g=f>0?s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c);else g=o>0?-s:s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Hc).addScaledVector(eu,g),p}intersectSphere(t,e){Rn.subVectors(t.center,this.origin);const r=Rn.dot(this.direction),i=Rn.dot(Rn)-r*r,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(r=(t.min.x-g.x)*c,i=(t.max.x-g.x)*c):(r=(t.max.x-g.x)*c,i=(t.min.x-g.x)*c),h>=0?(s=(t.min.y-g.y)*h,o=(t.max.y-g.y)*h):(s=(t.max.y-g.y)*h,o=(t.min.y-g.y)*h),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(a=(t.min.z-g.z)*f,l=(t.max.z-g.z)*f):(a=(t.max.z-g.z)*f,l=(t.min.z-g.z)*f),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,Rn)!==null}intersectTriangle(t,e,r,i,s){Gc.subVectors(e,t),ru.subVectors(r,t),Wc.crossVectors(Gc,ru);let o=this.direction.dot(Wc),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ni.subVectors(this.origin,t);const l=a*this.direction.dot(ru.crossVectors(ni,ru));if(l<0)return null;const c=a*this.direction.dot(Gc.cross(ni));if(c<0||l+c>o)return null;const h=-a*ni.dot(Wc);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ue{constructor(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){Ue.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_)}set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){const S=this.elements;return S[0]=t,S[4]=e,S[8]=r,S[12]=i,S[1]=s,S[5]=o,S[9]=a,S[13]=l,S[2]=c,S[6]=h,S[10]=f,S[14]=g,S[3]=p,S[7]=m,S[11]=v,S[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ue().fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,r=t.elements,i=1/bs.setFromMatrixColumn(t,0).length(),s=1/bs.setFromMatrixColumn(t,1).length(),o=1/bs.setFromMatrixColumn(t,2).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,i=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=-l*f,e[8]=c,e[1]=p+m*c,e[5]=g-v*c,e[9]=-a*l,e[2]=v-g*c,e[6]=m+p*c,e[10]=o*l}else if(t.order==="YXZ"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g+v*a,e[4]=m*a-p,e[8]=o*c,e[1]=o*f,e[5]=o*h,e[9]=-a,e[2]=p*a-m,e[6]=v+g*a,e[10]=o*l}else if(t.order==="ZXY"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g-v*a,e[4]=-o*f,e[8]=m+p*a,e[1]=p+m*a,e[5]=o*h,e[9]=v-g*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=m*c-p,e[8]=g*c+v,e[1]=l*f,e[5]=v*c+g,e[9]=p*c-m,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=v-g*f,e[8]=m*f+p,e[1]=f,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=p*f+m,e[10]=g-v*f}else if(t.order==="XZY"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=-f,e[8]=c*h,e[1]=g*f+v,e[5]=o*h,e[9]=p*f-m,e[2]=m*f-p,e[6]=a*h,e[10]=v*f+g}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bS,t,wS)}lookAt(t,e,r){const i=this.elements;return hr.subVectors(t,e),hr.lengthSq()===0&&(hr.z=1),hr.normalize(),ii.crossVectors(r,hr),ii.lengthSq()===0&&(Math.abs(r.z)===1?hr.x+=1e-4:hr.z+=1e-4,hr.normalize(),ii.crossVectors(r,hr)),ii.normalize(),nu.crossVectors(hr,ii),i[0]=ii.x,i[4]=nu.x,i[8]=hr.x,i[1]=ii.y,i[5]=nu.y,i[9]=hr.y,i[2]=ii.z,i[6]=nu.z,i[10]=hr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],h=r[1],f=r[5],g=r[9],p=r[13],m=r[2],v=r[6],_=r[10],S=r[14],M=r[3],C=r[7],O=r[11],E=r[15],z=i[0],R=i[4],k=i[8],L=i[12],X=i[1],J=i[5],at=i[9],tt=i[13],bt=i[2],xt=i[6],yt=i[10],ht=i[14],Y=i[3],St=i[7],j=i[11],W=i[15];return s[0]=o*z+a*X+l*bt+c*Y,s[4]=o*R+a*J+l*xt+c*St,s[8]=o*k+a*at+l*yt+c*j,s[12]=o*L+a*tt+l*ht+c*W,s[1]=h*z+f*X+g*bt+p*Y,s[5]=h*R+f*J+g*xt+p*St,s[9]=h*k+f*at+g*yt+p*j,s[13]=h*L+f*tt+g*ht+p*W,s[2]=m*z+v*X+_*bt+S*Y,s[6]=m*R+v*J+_*xt+S*St,s[10]=m*k+v*at+_*yt+S*j,s[14]=m*L+v*tt+_*ht+S*W,s[3]=M*z+C*X+O*bt+E*Y,s[7]=M*R+C*J+O*xt+E*St,s[11]=M*k+C*at+O*yt+E*j,s[15]=M*L+C*tt+O*ht+E*W,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],f=t[6],g=t[10],p=t[14],m=t[3],v=t[7],_=t[11],S=t[15];return m*(+s*l*f-i*c*f-s*a*g+r*c*g+i*a*p-r*l*p)+v*(+e*l*p-e*c*g+s*o*g-i*o*p+i*c*h-s*l*h)+_*(+e*c*f-e*a*p-s*o*f+r*o*p+s*a*h-r*c*h)+S*(-i*a*h-e*l*f+e*a*g+i*o*f-r*o*g+r*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],v=t[13],_=t[14],S=t[15],M=f*_*c-v*g*c+v*l*p-a*_*p-f*l*S+a*g*S,C=m*g*c-h*_*c-m*l*p+o*_*p+h*l*S-o*g*S,O=h*v*c-m*f*c+m*a*p-o*v*p-h*a*S+o*f*S,E=m*f*l-h*v*l-m*a*g+o*v*g+h*a*_-o*f*_,z=e*M+r*C+i*O+s*E;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/z;return t[0]=M*R,t[1]=(v*g*s-f*_*s-v*i*p+r*_*p+f*i*S-r*g*S)*R,t[2]=(a*_*s-v*l*s+v*i*c-r*_*c-a*i*S+r*l*S)*R,t[3]=(f*l*s-a*g*s-f*i*c+r*g*c+a*i*p-r*l*p)*R,t[4]=C*R,t[5]=(h*_*s-m*g*s+m*i*p-e*_*p-h*i*S+e*g*S)*R,t[6]=(m*l*s-o*_*s-m*i*c+e*_*c+o*i*S-e*l*S)*R,t[7]=(o*g*s-h*l*s+h*i*c-e*g*c-o*i*p+e*l*p)*R,t[8]=O*R,t[9]=(m*f*s-h*v*s-m*r*p+e*v*p+h*r*S-e*f*S)*R,t[10]=(o*v*s-m*a*s+m*r*c-e*v*c-o*r*S+e*a*S)*R,t[11]=(h*a*s-o*f*s-h*r*c+e*f*c+o*r*p-e*a*p)*R,t[12]=E*R,t[13]=(h*v*i-m*f*i+m*r*g-e*v*g-h*r*_+e*f*_)*R,t[14]=(m*a*i-o*v*i-m*r*l+e*v*l+o*r*_-e*a*_)*R,t[15]=(o*f*i-h*a*i+h*r*l-e*f*l-o*r*g+e*a*g)*R,this}scale(t){const e=this.elements,r=t.x,i=t.y,s=t.z;return e[0]*=r,e[4]*=i,e[8]*=s,e[1]*=r,e[5]*=i,e[9]*=s,e[2]*=r,e[6]*=i,e[10]*=s,e[3]*=r,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,i))}makeTranslation(t,e,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),i=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+r,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,i,s,o){return this.set(1,r,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,r){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,f=a+a,g=s*c,p=s*h,m=s*f,v=o*h,_=o*f,S=a*f,M=l*c,C=l*h,O=l*f,E=r.x,z=r.y,R=r.z;return i[0]=(1-(v+S))*E,i[1]=(p+O)*E,i[2]=(m-C)*E,i[3]=0,i[4]=(p-O)*z,i[5]=(1-(g+S))*z,i[6]=(_+M)*z,i[7]=0,i[8]=(m+C)*R,i[9]=(_-M)*R,i[10]=(1-(g+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,r){const i=this.elements;let s=bs.set(i[0],i[1],i[2]).length();const o=bs.set(i[4],i[5],i[6]).length(),a=bs.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],Zr.copy(this);const c=1/s,h=1/o,f=1/a;return Zr.elements[0]*=c,Zr.elements[1]*=c,Zr.elements[2]*=c,Zr.elements[4]*=h,Zr.elements[5]*=h,Zr.elements[6]*=h,Zr.elements[8]*=f,Zr.elements[9]*=f,Zr.elements[10]*=f,e.setFromRotationMatrix(Zr),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,i,s,o,a=Ja,l=!1){const c=this.elements,h=2*s/(e-t),f=2*s/(r-i),g=(e+t)/(e-t),p=(r+i)/(r-i);let m,v;if(l)m=s/(o-s),v=o*s/(o-s);else if(a===Ja)m=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===hm)m=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=f,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,r,i,s,o,a=Ja,l=!1){const c=this.elements,h=2/(e-t),f=2/(r-i),g=-(e+t)/(e-t),p=-(r+i)/(r-i);let m,v;if(l)m=1/(o-s),v=o/(o-s);else if(a===Ja)m=-2/(o-s),v=-(o+s)/(o-s);else if(a===hm)m=-1/(o-s),v=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=f,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<16;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const bs=new D,Zr=new Ue,bS=new D(0,0,0),wS=new D(1,1,1),ii=new D,nu=new D,hr=new D,vm=new Ue,xm=new ps;class ws{constructor(t=0,e=0,r=0,i=ws.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,i=this._order){return this._x=t,this._y=e,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],f=i[2],g=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(Lt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Lt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return vm.makeRotationFromQuaternion(t),this.setFromRotationMatrix(vm,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return xm.setFromEuler(this),this.setFromQuaternion(xm,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ws.DEFAULT_ORDER="XYZ";class SS{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let ES=0;const _m=new D,Ss=new ps,Ln=new Ue,iu=new D,Oo=new D,MS=new D,AS=new ps,bm=new D(1,0,0),wm=new D(0,1,0),Sm=new D(0,0,1),Em={type:"added"},OS={type:"removed"},Es={type:"childadded",child:null},Uc={type:"childremoved",child:null};class vn extends Za{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ES++}),this.uuid=ds(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=vn.DEFAULT_UP.clone();const t=new D,e=new ws,r=new ps,i=new D(1,1,1);function s(){r.setFromEuler(e,!1)}function o(){e.setFromQuaternion(r,void 0,!1)}e._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ue},normalMatrix:{value:new Qn}}),this.matrix=new Ue,this.matrixWorld=new Ue,this.matrixAutoUpdate=vn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=vn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new SS,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.multiply(Ss),this}rotateOnWorldAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.premultiply(Ss),this}rotateX(t){return this.rotateOnAxis(bm,t)}rotateY(t){return this.rotateOnAxis(wm,t)}rotateZ(t){return this.rotateOnAxis(Sm,t)}translateOnAxis(t,e){return _m.copy(t).applyQuaternion(this.quaternion),this.position.add(_m.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(bm,t)}translateY(t){return this.translateOnAxis(wm,t)}translateZ(t){return this.translateOnAxis(Sm,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ln.copy(this.matrixWorld).invert())}lookAt(t,e,r){t.isVector3?iu.copy(t):iu.set(t,e,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Oo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ln.lookAt(Oo,iu,this.up):Ln.lookAt(iu,Oo,this.up),this.quaternion.setFromRotationMatrix(Ln),i&&(Ln.extractRotation(i.matrixWorld),Ss.setFromRotationMatrix(Ln),this.quaternion.premultiply(Ss.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Em),Es.child=t,this.dispatchEvent(Es),Es.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(OS),Uc.child=t,this.dispatchEvent(Uc),Uc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ln.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ln.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ln),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Em),Es.child=t,this.dispatchEvent(Es),Es.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,r=[]){this[t]===e&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,t,MS),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,AS,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].updateMatrixWorld(t)}updateWorldMatrix(t,e){const r=this.parent;if(t===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(t.shapes,f)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),f=o(t.shapes),g=o(t.skeletons),p=o(t.animations),m=o(t.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),h.length>0&&(r.images=h),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r<t.children.length;r++){const i=t.children[r];this.add(i.clone())}return this}}vn.DEFAULT_UP=new D(0,1,0),vn.DEFAULT_MATRIX_AUTO_UPDATE=!0,vn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Kr=new D,Fn=new D,Yc=new D,Nn=new D,Ms=new D,As=new D,Mm=new D,Xc=new D,Jc=new D,Zc=new D,Kc=new Eo,Qc=new Eo,th=new Eo;class Qr{constructor(t=new D,e=new D,r=new D){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,i){i.subVectors(r,e),Kr.subVectors(t,e),i.cross(Kr);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){Kr.subVectors(i,e),Fn.subVectors(r,e),Yc.subVectors(t,e);const o=Kr.dot(Kr),a=Kr.dot(Fn),l=Kr.dot(Yc),c=Fn.dot(Fn),h=Fn.dot(Yc),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const g=1/f,p=(c*l-a*h)*g,m=(o*h-a*l)*g;return s.set(1-p-m,m,p)}static containsPoint(t,e,r,i){return this.getBarycoord(t,e,r,i,Nn)===null?!1:Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(t,e,r,i,s,o,a,l){return this.getBarycoord(t,e,r,i,Nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Nn.x),l.addScaledVector(o,Nn.y),l.addScaledVector(a,Nn.z),l)}static getInterpolatedAttribute(t,e,r,i,s,o){return Kc.setScalar(0),Qc.setScalar(0),th.setScalar(0),Kc.fromBufferAttribute(t,e),Qc.fromBufferAttribute(t,r),th.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(Kc,s.x),o.addScaledVector(Qc,s.y),o.addScaledVector(th,s.z),o}static isFrontFacing(t,e,r,i){return Kr.subVectors(r,e),Fn.subVectors(t,e),Kr.cross(Fn).dot(i)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,r,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Kr.subVectors(this.c,this.b),Fn.subVectors(this.a,this.b),Kr.cross(Fn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Qr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Qr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,r,i,s){return Qr.getInterpolation(t,this.a,this.b,this.c,e,r,i,s)}containsPoint(t){return Qr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Qr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const r=this.a,i=this.b,s=this.c;let o,a;Ms.subVectors(i,r),As.subVectors(s,r),Xc.subVectors(t,r);const l=Ms.dot(Xc),c=As.dot(Xc);if(l<=0&&c<=0)return e.copy(r);Jc.subVectors(t,i);const h=Ms.dot(Jc),f=As.dot(Jc);if(h>=0&&f<=h)return e.copy(i);const g=l*f-h*c;if(g<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(r).addScaledVector(Ms,o);Zc.subVectors(t,s);const p=Ms.dot(Zc),m=As.dot(Zc);if(m>=0&&p<=m)return e.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(r).addScaledVector(As,a);const _=h*m-p*f;if(_<=0&&f-h>=0&&p-m>=0)return Mm.subVectors(s,i),a=(f-h)/(f-h+(p-m)),e.copy(i).addScaledVector(Mm,a);const S=1/(_+v+g);return o=v*S,a=g*S,e.copy(r).addScaledVector(Ms,o).addScaledVector(As,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Am={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},si={h:0,s:0,l:0},su={h:0,s:0,l:0};function eh(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}class Mi{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(e===void 0&&r===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,r);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Yr){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xr.colorSpaceToWorking(this,e),this}setRGB(t,e,r,i=Xr.workingColorSpace){return this.r=t,this.g=e,this.b=r,Xr.colorSpaceToWorking(this,i),this}setHSL(t,e,r,i=Xr.workingColorSpace){if(t=fS(t,1),e=Lt(e,0,1),r=Lt(r,0,1),e===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=eh(o,s,t+1/3),this.g=eh(o,s,t),this.b=eh(o,s,t-1/3)}return Xr.colorSpaceToWorking(this,i),this}setStyle(t,e=Yr){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Yr){const r=Am[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=kn(t.r),this.g=kn(t.g),this.b=kn(t.b),this}copyLinearToSRGB(t){return this.r=gs(t.r),this.g=gs(t.g),this.b=gs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Yr){return Xr.workingToColorSpace(qe.copy(this),t),Math.round(Lt(qe.r*255,0,255))*65536+Math.round(Lt(qe.g*255,0,255))*256+Math.round(Lt(qe.b*255,0,255))}getHexString(t=Yr){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xr.workingColorSpace){Xr.workingToColorSpace(qe.copy(this),e);const r=qe.r,i=qe.g,s=qe.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Xr.workingColorSpace){return Xr.workingToColorSpace(qe.copy(this),e),t.r=qe.r,t.g=qe.g,t.b=qe.b,t}getStyle(t=Yr){Xr.workingToColorSpace(qe.copy(this),t);const e=qe.r,r=qe.g,i=qe.b;return t!==Yr?`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(t,e,r){return this.getHSL(si),this.setHSL(si.h+t,si.s+e,si.l+r)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(si),t.getHSL(su);const r=Fc(si.h,su.h,e),i=Fc(si.s,su.s,e),s=Fc(si.l,su.l,e);return this.setHSL(r,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,r=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*r+s[6]*i,this.g=s[1]*e+s[4]*r+s[7]*i,this.b=s[2]*e+s[5]*r+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qe=new Mi;Mi.NAMES=Am;let zS=0;class Om extends Za{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zS++}),this.uuid=ds(),this.name="",this.type="Material",this.blending=Kg,this.side=Rc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=tm,this.blendDst=em,this.blendEquation=Qg,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mi(0,0,0),this.blendAlpha=0,this.depthFunc=rm,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fs,this.stencilZFail=fs,this.stencilZPass=fs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Kg&&(r.blending=this.blending),this.side!==Rc&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==tm&&(r.blendSrc=this.blendSrc),this.blendDst!==em&&(r.blendDst=this.blendDst),this.blendEquation!==Qg&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==rm&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==lm&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fs&&(r.stencilFail=this.stencilFail),this.stencilZFail!==fs&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==fs&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let r=null;if(e!==null){const i=e.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Os extends Om{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ws,this.combine=nm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const be=new D,ou=new Et;let TS=0;class zs{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:TS++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=cm,this.updateRanges=[],this.gpuType=lS,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)ou.fromBufferAttribute(this,e),ou.applyMatrix3(t),this.setXY(e,ou.x,ou.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyMatrix3(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyMatrix4(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyNormalMatrix(t),this.setXYZ(e,be.x,be.y,be.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.transformDirection(t),this.setXYZ(e,be.x,be.y,be.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let r=this.array[t*this.itemSize+e];return this.normalized&&(r=So(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=er(r,this.array)),this.array[t*this.itemSize+e]=r,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=So(e,this.array)),e}setX(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=So(e,this.array)),e}setY(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=So(e,this.array)),e}setZ(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=So(e,this.array)),e}setW(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array),i=er(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array),i=er(i,this.array),s=er(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==cm&&(t.usage=this.usage),t}}class CS extends zs{constructor(t,e,r){super(new Uint16Array(t),e,r)}}class IS extends zs{constructor(t,e,r){super(new Uint32Array(t),e,r)}}class jn extends zs{constructor(t,e,r){super(new Float32Array(t),e,r)}}let kS=0;const Tr=new Ue,rh=new vn,Ts=new D,fr=new ys,zo=new ys,ke=new D;class Ai extends Za{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kS++}),this.uuid=ds(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(dS(t)?IS:CS)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Qn().getNormalMatrix(t);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Tr.makeRotationFromQuaternion(t),this.applyMatrix4(Tr),this}rotateX(t){return Tr.makeRotationX(t),this.applyMatrix4(Tr),this}rotateY(t){return Tr.makeRotationY(t),this.applyMatrix4(Tr),this}rotateZ(t){return Tr.makeRotationZ(t),this.applyMatrix4(Tr),this}translate(t,e,r){return Tr.makeTranslation(t,e,r),this.applyMatrix4(Tr),this}scale(t,e,r){return Tr.makeScale(t,e,r),this.applyMatrix4(Tr),this}lookAt(t){return rh.lookAt(t),rh.updateMatrix(),this.applyMatrix4(rh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ts).negate(),this.translate(Ts.x,Ts.y,Ts.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const r=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new jn(r,3))}else{const r=Math.min(t.length,e.count);for(let i=0;i<r;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ys);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let r=0,i=e.length;r<i;r++){const s=e[r];fr.setFromBufferAttribute(s),this.morphTargetsRelative?(ke.addVectors(this.boundingBox.min,fr.min),this.boundingBox.expandByPoint(ke),ke.addVectors(this.boundingBox.max,fr.max),this.boundingBox.expandByPoint(ke)):(this.boundingBox.expandByPoint(fr.min),this.boundingBox.expandByPoint(fr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ym);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const r=this.boundingSphere.center;if(fr.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];zo.setFromBufferAttribute(a),this.morphTargetsRelative?(ke.addVectors(fr.min,zo.min),fr.expandByPoint(ke),ke.addVectors(fr.max,zo.max),fr.expandByPoint(ke)):(fr.expandByPoint(zo.min),fr.expandByPoint(zo.max))}fr.getCenter(r);let i=0;for(let s=0,o=t.count;s<o;s++)ke.fromBufferAttribute(t,s),i=Math.max(i,r.distanceToSquared(ke));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)ke.fromBufferAttribute(a,c),l&&(Ts.fromBufferAttribute(t,c),ke.add(Ts)),i=Math.max(i,r.distanceToSquared(ke))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new zs(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let k=0;k<r.count;k++)a[k]=new D,l[k]=new D;const c=new D,h=new D,f=new D,g=new Et,p=new Et,m=new Et,v=new D,_=new D;function S(k,L,X){c.fromBufferAttribute(r,k),h.fromBufferAttribute(r,L),f.fromBufferAttribute(r,X),g.fromBufferAttribute(s,k),p.fromBufferAttribute(s,L),m.fromBufferAttribute(s,X),h.sub(c),f.sub(c),p.sub(g),m.sub(g);const J=1/(p.x*m.y-m.x*p.y);isFinite(J)&&(v.copy(h).multiplyScalar(m.y).addScaledVector(f,-p.y).multiplyScalar(J),_.copy(f).multiplyScalar(p.x).addScaledVector(h,-m.x).multiplyScalar(J),a[k].add(v),a[L].add(v),a[X].add(v),l[k].add(_),l[L].add(_),l[X].add(_))}let M=this.groups;M.length===0&&(M=[{start:0,count:t.count}]);for(let k=0,L=M.length;k<L;++k){const X=M[k],J=X.start,at=X.count;for(let tt=J,bt=J+at;tt<bt;tt+=3)S(t.getX(tt+0),t.getX(tt+1),t.getX(tt+2))}const C=new D,O=new D,E=new D,z=new D;function R(k){E.fromBufferAttribute(i,k),z.copy(E);const L=a[k];C.copy(L),C.sub(E.multiplyScalar(E.dot(L))).normalize(),O.crossVectors(z,L);const J=O.dot(l[k])<0?-1:1;o.setXYZW(k,C.x,C.y,C.z,J)}for(let k=0,L=M.length;k<L;++k){const X=M[k],J=X.start,at=X.count;for(let tt=J,bt=J+at;tt<bt;tt+=3)R(t.getX(tt+0)),R(t.getX(tt+1)),R(t.getX(tt+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new zs(new Float32Array(e.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new D,s=new D,o=new D,a=new D,l=new D,c=new D,h=new D,f=new D;if(t)for(let g=0,p=t.count;g<p;g+=3){const m=t.getX(g+0),v=t.getX(g+1),_=t.getX(g+2);i.fromBufferAttribute(e,m),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,_),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,_),a.add(h),l.add(h),c.add(h),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(_,c.x,c.y,c.z)}else for(let g=0,p=e.count;g<p;g+=3)i.fromBufferAttribute(e,g+0),s.fromBufferAttribute(e,g+1),o.fromBufferAttribute(e,g+2),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),r.setXYZ(g+0,h.x,h.y,h.z),r.setXYZ(g+1,h.x,h.y,h.z),r.setXYZ(g+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)ke.fromBufferAttribute(t,e),ke.normalize(),t.setXYZ(e,ke.x,ke.y,ke.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,f=a.normalized,g=new c.constructor(l.length*h);let p=0,m=0;for(let v=0,_=l.length;v<_;v++){a.isInterleavedBufferAttribute?p=l[v]*a.data.stride+a.offset:p=l[v]*h;for(let S=0;S<h;S++)g[m++]=c[p++]}return new zs(g,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ai,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,r);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,f=c.length;h<f;h++){const g=c[h],p=t(g,r);l.push(p)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const r=this.attributes;for(const l in r){const c=r[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,g=c.length;f<g;f++){const p=c[f];h.push(p.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const r=t.index;r!==null&&this.setIndex(r.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],f=s[c];for(let g=0,p=f.length;g<p;g++)h.push(f[g].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const zm=new Ue,Oi=new _S,au=new ym,Tm=new D,uu=new D,lu=new D,cu=new D,nh=new D,hu=new D,Cm=new D,fu=new D;class Cs extends vn{constructor(t=new Ai,e=new Os){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){const i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){hu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],f=s[l];h!==0&&(nh.fromBufferAttribute(f,t),o?hu.addScaledVector(nh,h):hu.addScaledVector(nh.sub(e),h))}e.add(hu)}return e}raycast(t,e){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),au.copy(r.boundingSphere),au.applyMatrix4(s),Oi.copy(t.ray).recast(t.near),!(au.containsPoint(Oi.origin)===!1&&(Oi.intersectSphere(au,Tm)===null||Oi.origin.distanceToSquared(Tm)>(t.far-t.near)**2))&&(zm.copy(s).invert(),Oi.copy(t.ray).applyMatrix4(zm),!(r.boundingBox!==null&&Oi.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(t,e,Oi)))}_computeIntersections(t,e,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,g=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],M=Math.max(_.start,p.start),C=Math.min(a.count,Math.min(_.start+_.count,p.start+p.count));for(let O=M,E=C;O<E;O+=3){const z=a.getX(O),R=a.getX(O+1),k=a.getX(O+2);i=du(this,S,t,r,c,h,f,z,R,k),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const M=a.getX(_),C=a.getX(_+1),O=a.getX(_+2);i=du(this,o,t,r,c,h,f,M,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],M=Math.max(_.start,p.start),C=Math.min(l.count,Math.min(_.start+_.count,p.start+p.count));for(let O=M,E=C;O<E;O+=3){const z=O,R=O+1,k=O+2;i=du(this,S,t,r,c,h,f,z,R,k),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const M=_,C=_+1,O=_+2;i=du(this,o,t,r,c,h,f,M,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}}}function PS(n,t,e,r,i,s,o,a){let l;if(t.side===iS?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,t.side===Rc,a),l===null)return null;fu.copy(a),fu.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(fu);return c<e.near||c>e.far?null:{distance:c,point:fu.clone(),object:n}}function du(n,t,e,r,i,s,o,a,l,c){n.getVertexPosition(a,uu),n.getVertexPosition(l,lu),n.getVertexPosition(c,cu);const h=PS(n,t,e,r,uu,lu,cu,Cm);if(h){const f=new D;Qr.getBarycoord(Cm,uu,lu,cu,f),i&&(h.uv=Qr.getInterpolatedAttribute(i,a,l,c,f,new Et)),s&&(h.uv1=Qr.getInterpolatedAttribute(s,a,l,c,f,new Et)),o&&(h.normal=Qr.getInterpolatedAttribute(o,a,l,c,f,new D),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const g={a,b:l,c,normal:new D,materialIndex:0};Qr.getNormal(uu,lu,cu,g.normal),h.face=g,h.barycoord=f}return h}class pu extends Ai{constructor(t=1,e=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],f=[];let g=0,p=0;m("z","y","x",-1,-1,r,e,t,o,s,0),m("z","y","x",1,-1,r,e,-t,o,s,1),m("x","z","y",1,1,t,r,e,i,o,2),m("x","z","y",1,-1,t,r,-e,i,o,3),m("x","y","z",1,-1,t,e,r,i,s,4),m("x","y","z",-1,-1,t,e,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new jn(c,3)),this.setAttribute("normal",new jn(h,3)),this.setAttribute("uv",new jn(f,2));function m(v,_,S,M,C,O,E,z,R,k,L){const X=O/R,J=E/k,at=O/2,tt=E/2,bt=z/2,xt=R+1,yt=k+1;let ht=0,Y=0;const St=new D;for(let j=0;j<yt;j++){const W=j*J-tt;for(let ft=0;ft<xt;ft++){const et=ft*X-at;St[v]=et*M,St[_]=W*C,St[S]=bt,c.push(St.x,St.y,St.z),St[v]=0,St[_]=0,St[S]=z>0?1:-1,h.push(St.x,St.y,St.z),f.push(ft/R),f.push(1-j/k),ht+=1}}for(let j=0;j<k;j++)for(let W=0;W<R;W++){const ft=g+W+xt*j,et=g+W+xt*(j+1),rt=g+(W+1)+xt*(j+1),Z=g+(W+1)+xt*j;l.push(ft,et,Z),l.push(et,rt,Z),Y+=6}a.addGroup(p,Y,L),p+=Y,g+=ht}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pu(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class RS extends vn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class xn{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){const r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const r=this.getLengths();let i=0;const s=r.length;let o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const h=r[i],g=r[i+1]-h,p=(o-h)/g;return(i+p)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new Et:new D);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e=!1){const r=new D,i=[],s=[],o=[],a=new D,l=new Ue;for(let p=0;p<=t;p++){const m=p/t;i[p]=this.getTangentAt(m,new D)}s[0]=new D,o[0]=new D;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),f=Math.abs(i[0].y),g=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),f<=c&&(c=f,r.set(0,1,0)),g<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=t;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(Lt(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(i[p],s[p])}if(e===!0){let p=Math.acos(Lt(s[0].dot(s[t]),-1,1));p/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(p=-p);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],p*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ih extends xn{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new Et){const r=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),g=l-this.aX,p=c-this.aY;l=g*h-p*f+this.aX,c=g*f+p*h+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class LS extends ih{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function sh(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,f){let g=(o-s)/c-(a-s)/(c+h)+(a-o)/h,p=(a-o)/h-(l-o)/(h+f)+(l-a)/f;g*=h,p*=h,i(o,a,g,p)},calc:function(s){const o=s*s,a=o*s;return n+t*s+e*o+r*a}}}const gu=new D,oh=new sh,ah=new sh,uh=new sh;class FS extends xn{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new D){const r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(gu.subVectors(i[0],i[1]).add(i[0]),c=gu);const f=i[a%s],g=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(gu.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=gu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(f),p),v=Math.pow(f.distanceToSquared(g),p),_=Math.pow(g.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),_<1e-4&&(_=v),oh.initNonuniformCatmullRom(c.x,f.x,g.x,h.x,m,v,_),ah.initNonuniformCatmullRom(c.y,f.y,g.y,h.y,m,v,_),uh.initNonuniformCatmullRom(c.z,f.z,g.z,h.z,m,v,_)}else this.curveType==="catmullrom"&&(oh.initCatmullRom(c.x,f.x,g.x,h.x,this.tension),ah.initCatmullRom(c.y,f.y,g.y,h.y,this.tension),uh.initCatmullRom(c.z,f.z,g.z,h.z,this.tension));return r.set(oh.calc(l),ah.calc(l),uh.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new D().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Im(n,t,e,r,i){const s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function NS(n,t){const e=1-n;return e*e*t}function jS(n,t){return 2*(1-n)*n*t}function VS(n,t){return n*n*t}function To(n,t,e,r){return NS(n,t)+jS(n,e)+VS(n,r)}function DS(n,t){const e=1-n;return e*e*e*t}function BS(n,t){const e=1-n;return 3*e*e*n*t}function qS(n,t){return 3*(1-n)*n*n*t}function $S(n,t){return n*n*n*t}function Co(n,t,e,r,i){return DS(n,t)+BS(n,e)+qS(n,r)+$S(n,i)}class km extends xn{constructor(t=new Et,e=new Et,r=new Et,i=new Et){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new Et){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Co(t,i.x,s.x,o.x,a.x),Co(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class HS extends xn{constructor(t=new D,e=new D,r=new D,i=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Co(t,i.x,s.x,o.x,a.x),Co(t,i.y,s.y,o.y,a.y),Co(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Pm extends xn{constructor(t=new Et,e=new Et){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Et){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Et){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class GS extends xn{constructor(t=new D,e=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new D){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new D){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Rm extends xn{constructor(t=new Et,e=new Et,r=new Et){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new Et){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(To(t,i.x,s.x,o.x),To(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class WS extends xn{constructor(t=new D,e=new D,r=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(To(t,i.x,s.x,o.x),To(t,i.y,s.y,o.y),To(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Lm extends xn{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Et){const r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return r.set(Im(a,l.x,c.x,h.x,f.x),Im(a,l.y,c.y,h.y,f.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new Et().fromArray(i))}return this}}var Fm=Object.freeze({__proto__:null,ArcCurve:LS,CatmullRomCurve3:FS,CubicBezierCurve:km,CubicBezierCurve3:HS,EllipseCurve:ih,LineCurve:Pm,LineCurve3:GS,QuadraticBezierCurve:Rm,QuadraticBezierCurve3:WS,SplineCurve:Lm});class US extends xn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Fm[r](e,t))}return this}getPoint(t,e){const r=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(new Fm[i.type]().fromJSON(i))}return this}}class Nm extends US{constructor(t){super(),this.type="Path",this.currentPoint=new Et,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const r=new Pm(this.currentPoint.clone(),new Et(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){const s=new Rm(this.currentPoint.clone(),new Et(t,e),new Et(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){const a=new km(this.currentPoint.clone(),new Et(t,e),new Et(r,i),new Et(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),r=new Lm(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){const c=new ih(t,e,r,i,s,o,a,l);if(this.curves.length>0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class lh extends Nm{constructor(t){super(t),this.uuid=ds(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(new Nm().fromJSON(i))}return this}}function YS(n,t,e=2){const r=t&&t.length,i=r?t[0]*e:n.length;let s=jm(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=QS(n,t,s,e)),n.length>80*e){a=1/0,l=1/0;let h=-1/0,f=-1/0;for(let g=e;g<i;g+=e){const p=n[g],m=n[g+1];p<a&&(a=p),m<l&&(l=m),p>h&&(h=p),m>f&&(f=m)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return Io(s,o,e,a,l,c,0),o}function jm(n,t,e,r,i){let s;if(i===c2(n,t,e,r)>0)for(let o=t;o<e;o+=r)s=qm(o/r|0,n[o],n[o+1],s);else for(let o=e-r;o>=t;o-=r)s=qm(o/r|0,n[o],n[o+1],s);return s&&Is(s,s.next)&&(Ro(s),s=s.next),s}function zi(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(Is(e,e.next)||he(e.prev,e,e.next)===0)){if(Ro(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Io(n,t,e,r,i,s,o){if(!n)return;!o&&s&&i2(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?JS(n,r,i,s):XS(n)){t.push(l.i,n.i,c.i),Ro(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=ZS(zi(n),t),Io(n,t,e,r,i,s,2)):o===2&&KS(n,t,e,r,i,s):Io(zi(n),t,e,r,i,s,1);break}}}function XS(n){const t=n.prev,e=n,r=n.next;if(he(t,e,r)>=0)return!1;const i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,h=Math.min(i,s,o),f=Math.min(a,l,c),g=Math.max(i,s,o),p=Math.max(a,l,c);let m=r.next;for(;m!==t;){if(m.x>=h&&m.x<=g&&m.y>=f&&m.y<=p&&ko(i,a,s,l,o,c,m.x,m.y)&&he(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function JS(n,t,e,r){const i=n.prev,s=n,o=n.next;if(he(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,f=s.y,g=o.y,p=Math.min(a,l,c),m=Math.min(h,f,g),v=Math.max(a,l,c),_=Math.max(h,f,g),S=ch(p,m,t,e,r),M=ch(v,_,t,e,r);let C=n.prevZ,O=n.nextZ;for(;C&&C.z>=S&&O&&O.z<=M;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&ko(a,h,l,f,c,g,C.x,C.y)&&he(C.prev,C,C.next)>=0||(C=C.prevZ,O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&ko(a,h,l,f,c,g,O.x,O.y)&&he(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;C&&C.z>=S;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&ko(a,h,l,f,c,g,C.x,C.y)&&he(C.prev,C,C.next)>=0)return!1;C=C.prevZ}for(;O&&O.z<=M;){if(O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&ko(a,h,l,f,c,g,O.x,O.y)&&he(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function ZS(n,t){let e=n;do{const r=e.prev,i=e.next.next;!Is(r,i)&&Dm(r,e,e.next,i)&&Po(r,i)&&Po(i,r)&&(t.push(r.i,e.i,i.i),Ro(e),Ro(e.next),e=n=i),e=e.next}while(e!==n);return zi(e)}function KS(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&a2(o,a)){let l=Bm(o,a);o=zi(o,o.next),l=zi(l,l.next),Io(o,t,e,r,i,s,0),Io(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function QS(n,t,e,r){const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=jm(n,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push(o2(c))}i.sort(t2);for(let s=0;s<i.length;s++)e=e2(i[s],e);return e}function t2(n,t){let e=n.x-t.x;if(e===0&&(e=n.y-t.y,e===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=r-i}return e}function e2(n,t){const e=r2(n,t);if(!e)return t;const r=Bm(e,n);return zi(r,r.next),zi(e,e.next)}function r2(n,t){let e=t;const r=n.x,i=n.y;let s=-1/0,o;if(Is(n,e))return e;do{if(Is(n,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const f=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=r&&f>s&&(s=f,o=e.x<e.next.x?e:e.next,f===r))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;e=o;do{if(r>=e.x&&e.x>=l&&r!==e.x&&Vm(i<c?r:s,i,l,c,i<c?s:r,i,e.x,e.y)){const f=Math.abs(i-e.y)/(r-e.x);Po(e,n)&&(f<h||f===h&&(e.x>o.x||e.x===o.x&&n2(o,e)))&&(o=e,h=f)}e=e.next}while(e!==a);return o}function n2(n,t){return he(n.prev,n,t.prev)<0&&he(t.next,n,n.next)<0}function i2(n,t,e,r){let i=n;do i.z===0&&(i.z=ch(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,s2(i)}function s2(n){let t,e=1;do{let r=n,i;n=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let c=0;c<e&&(a++,o=o.nextZ,!!o);c++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,e*=2}while(t>1);return n}function ch(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function o2(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function Vm(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function ko(n,t,e,r,i,s,o,a){return!(n===o&&t===a)&&Vm(n,t,e,r,i,s,o,a)}function a2(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!u2(n,t)&&(Po(n,t)&&Po(t,n)&&l2(n,t)&&(he(n.prev,n,t.prev)||he(n,t.prev,t))||Is(n,t)&&he(n.prev,n,n.next)>0&&he(t.prev,t,t.next)>0)}function he(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function Is(n,t){return n.x===t.x&&n.y===t.y}function Dm(n,t,e,r){const i=yu(he(n,t,e)),s=yu(he(n,t,r)),o=yu(he(e,r,n)),a=yu(he(e,r,t));return!!(i!==s&&o!==a||i===0&&mu(n,e,t)||s===0&&mu(n,r,t)||o===0&&mu(e,n,r)||a===0&&mu(e,t,r))}function mu(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function yu(n){return n>0?1:n<0?-1:0}function u2(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&Dm(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function Po(n,t){return he(n.prev,n,n.next)<0?he(n,t,n.next)>=0&&he(n,n.prev,t)>=0:he(n,t,n.prev)<0||he(n,n.next,t)<0}function l2(n,t){let e=n,r=!1;const i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function Bm(n,t){const e=hh(n.i,n.x,n.y),r=hh(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function qm(n,t,e,r){const i=hh(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ro(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function hh(n,t,e){return{i:n,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function c2(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}class h2{static triangulate(t,e,r=2){return YS(t,e,r)}}class Lo{static area(t){const e=t.length;let r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return Lo.area(t)<0}static triangulateShape(t,e){const r=[],i=[],s=[];$m(t),Hm(r,t);let o=t.length;e.forEach($m);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,Hm(r,e[l]);const a=h2.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function $m(n){const t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function Hm(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}class fh extends Ai{constructor(t=new lh([new Et(0,.5),new Et(-.5,-.5),new Et(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const r=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new jn(i,3)),this.setAttribute("normal",new jn(s,3)),this.setAttribute("uv",new jn(o,2));function c(h){const f=i.length/3,g=h.extractPoints(e);let p=g.shape;const m=g.holes;Lo.isClockWise(p)===!1&&(p=p.reverse());for(let _=0,S=m.length;_<S;_++){const M=m[_];Lo.isClockWise(M)===!0&&(m[_]=M.reverse())}const v=Lo.triangulateShape(p,m);for(let _=0,S=m.length;_<S;_++){const M=m[_];p=p.concat(M)}for(let _=0,S=p.length;_<S;_++){const M=p[_];i.push(M.x,M.y,0),s.push(0,0,1),o.push(M.x,M.y)}for(let _=0,S=v.length;_<S;_++){const M=v[_],C=M[0]+f,O=M[1]+f,E=M[2]+f;r.push(C,O,E),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return f2(e,t)}static fromJSON(t,e){const r=[];for(let i=0,s=t.shapes.length;i<s;i++){const o=e[t.shapes[i]];r.push(o)}return new fh(r,t.curveSegments)}}function f2(n,t){if(t.shapes=[],Array.isArray(n))for(let e=0,r=n.length;e<r;e++){const i=n[e];t.shapes.push(i.uuid)}else t.shapes.push(n.uuid);return t}class d2 extends Om{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Mi(16777215),this.specular=new Mi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hS,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ws,this.combine=nm,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const dh={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class p2{constructor(t,e,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.abortController=new AbortController,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,g=c.length;f<g;f+=2){const p=c[f],m=c[f+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const g2=new p2;class ph{constructor(t){this.manager=t!==void 0?t:g2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}ph.DEFAULT_MATERIAL_NAME="__DEFAULT";const ks=new WeakMap;class m2 extends ph{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=dh.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0);else{let f=ks.get(o);f===void 0&&(f=[],ks.set(o,f)),f.push({onLoad:e,onError:i})}return o}const a=Vc("img");function l(){h(),e&&e(this);const f=ks.get(this)||[];for(let g=0;g<f.length;g++){const p=f[g];p.onLoad&&p.onLoad(this)}ks.delete(this),s.manager.itemEnd(t)}function c(f){h(),i&&i(f),dh.remove(`image:${t}`);const g=ks.get(this)||[];for(let p=0;p<g.length;p++){const m=g[p];m.onError&&m.onError(f)}ks.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),dh.add(`image:${t}`,a),s.manager.itemStart(t),a.src=t,a}}class Gm extends ph{constructor(t){super(t)}load(t,e,r,i){const s=new ti,o=new m2(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Zg}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Zg);class y2{constructor(t=ln){Vt(this,"elements");Vt(this,"categories");Vt(this,"propertyTypes");Vt(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=t,this.registerMultiplePropertyType([["color",qg,qg],["enum",$g,$g],["string",Hg,Hg],["number",Gg,Gg],["length-measure",Wg,Wg],["toggle",Ug,Ug],["checkbox",Yg,Yg],["hidden",Xg,Xg],["read-only",Jg,Jg]])}getElement(t){if(this.hasElement(t))return this.elements[t];throw new Error(`Element ${t} does not exist in catalog`)}getCategory(t){if(this.hasCategory(t))return this.categories[t];throw new Error(`Category ${t} does not exist in catalog`)}getPropertyType(t){if(this.propertyTypes.hasOwnProperty(t))return this.propertyTypes[t];throw new Error(`Element ${t} does not exist in catalog`)}registerElement(t){t.properties=t.properties||{},this.validateElement(t)&&(this.elements[t.name]=t,this.categories.root.elements.push(this.elements[t.name]))}registerMultipleElements(t){t.forEach(e=>this.registerElement(e))}registerPropertyType(t,e,r){this.propertyTypes[t]={type:t,Viewer:e,Editor:r}}registerMultiplePropertyType(t){t.forEach(e=>this.registerPropertyType(...e))}validateElement(t){if(!t.hasOwnProperty("name"))throw new Error("Element not valid");let e=t.name;if(!t.hasOwnProperty("prototype"))throw new Error(`Element ${e} doesn't have prototype`);if(!t.hasOwnProperty("info"))throw new Error(`Element ${e} doesn't have info`);if(!t.info.hasOwnProperty("tag"))throw new Error(`Element ${e} doesn't have tag`);if(!t.info.hasOwnProperty("description"))throw new Error(`Element ${e} doesn't have description`);if(!t.info.hasOwnProperty("image"))throw new Error(`Element ${e} doesn't have image`);if(!t.hasOwnProperty("render2D"))throw new Error(`Element ${e} doesn't have render2D handler`);if(!t.hasOwnProperty("render3D"))throw new Error(`Element ${e} doesn't have render3D handler`);if(!t.hasOwnProperty("properties"))throw new Error(`Element ${e} doesn't have properties`);for(let r in t.properties){let i=t.properties[r];if(!i.hasOwnProperty("type"))throw new Error(`Element ${e}, Property ${r} doesn't have type`);if(!i.hasOwnProperty("defaultValue"))throw new Error(`Element ${e}, Property ${r} doesn't have defaultValue`)}return!0}hasElement(t){return this.elements.hasOwnProperty(t)}registerCategory(t,e,r){return this.validateCategory(t,e)?(this.categories[t]={name:t,label:e,categories:[],elements:[]},this.categories.root.categories.push(this.categories[t]),r&&r.length&&r.forEach(i=>this.addToCategory(t,i)),this.categories[t]):null}addToCategory(t,e){if(this.hasElement(e.name))this.categories[t].elements.push(e),this.categories.root.elements.splice(this.categories.root.elements.indexOf(e),1);else if(this.hasCategory(e.name))this.categories[t].categories.push(e),this.categories.root.categories.splice(this.categories.root.categories.indexOf(e),1);else throw new Error(`child ${e} is either category nor element`)}categoryHasElement(t,e){return this.hasCategory(t)&&this.categories[t].elements.some(r=>r.name===e)}validateCategory(t,e){if(!t)throw new Error("Category has undefined name");if(t==="")throw new Error("Category has empty name");if(this.hasCategory(t))throw new Error("Category has already been registered");return!0}hasCategory(t){return this.categories.hasOwnProperty(t)}}function v2(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(n)}const x2=({term:n="",placeholder:t="Search",noSpacing:e=!1,onClick:r=()=>!1,isStatic:i=!1,hasDropDown:s=!1,onSearch:o,className:a})=>{const[l,c]=F.useState("");return w.jsxs("div",{className:Hr(`relative w-full ${e?"mt-1":"mt-2"}`,a),onClick:r??(()=>!1),children:[w.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${e?"":"ml-2"}`,style:{zIndex:2},children:w.jsx(v2,{size:18})}),i?w.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:n}):w.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:t,onChange:h=>{o(h.target.value,h),c(h.target.value)},value:l,onClick:r??(()=>!1)}),r!==null&&s&&w.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${e?"":"ml-2"}`,style:{zIndex:1},children:w.jsx(F1,{className:"-mb-1"})})]})},Wm=8,Um=40,_2=n=>{const t=[{label:"All Categories",value:"all"}],e=n.map(r=>r.info.tag);for(const r of e){let i=t;for(let s=0;s<r.length;s++){const o=r[s];let a=i.find(l=>l.label===o);a||(a={label:o,value:o},s<r.length-1&&(a.options=[{label:"All Categories",value:"all"}]),i.push(a)),s<r.length-1&&a.options&&(i=a.options)}}return t},Ym=({options:n,selections:t,level:e,onChange:r})=>{var i,s;return w.jsxs(w.Fragment,{children:[w.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:t[e]||"all",onChange:o=>r(e,o.target.value),children:n.map(o=>w.jsx("option",{className:"capitalize",value:o.value,children:o.label},o.value))}),t[e]&&t[e]!=="all"&&((i=n.find(o=>o.value===t[e]))==null?void 0:i.options)&&w.jsx(Ym,{options:((s=n.find(o=>o.value===t[e]))==null?void 0:s.options)||[],level:e+1,selections:t,onChange:r})]})},b2=({catalog:n,popupEvent:t,onClose:e})=>{const{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=ne(),[a,l]=F.useState([]),[c,h]=F.useState(["all"]),[f,g]=F.useState([]),[p,m]=F.useState(""),v=F.useRef(null),_=F.useRef(null);F.useEffect(()=>{if(t){const E=n.getCategory(t.page).elements.filter(k=>k.info.visibility?k.info.visibility.catalog:!0);v.current=t.page,g(E);const{x:z,y:R}=t.rect;_.current={top:R+Wm,left:z+Um},t.page==="objects"&&l(_2(E))}},[t]);const S=()=>{e()},M=O=>{S(),setTimeout(()=>{switch(O.prototype){case"lines":r(O.name);break;case"items":i(O.name);break;case"holes":s(O.name);break}o(O)},0)},C=(O,E)=>{const z=[...c.slice(0,O),E];h(z)};return w.jsxs(w.Fragment,{children:[t&&w.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:S}),w.jsxs("div",{style:t&&t.rect?{top:t.rect.y+Wm,left:t.rect.x+Um}:_.current?_.current:{},className:Hr("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-5 fp_side-bar !min-h-[250px] !max-h-[510px] transition-all duration-200 ease-out transform",t?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[w.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[w.jsx("div",{className:"flex items-center gap-1",children:w.jsx("span",{className:Hr("flex flex-col gap-0.5"),children:w.jsx("span",{className:"fp-sidebar-label capitalize",children:(t==null?void 0:t.page)??v.current})})}),w.jsxs("div",{className:Hr("fp-highlight"),children:[w.jsx(Ym,{options:a,level:0,selections:c,onChange:C}),w.jsx(x2,{className:"mt-0",placeholder:"Search",onSearch:(O,E)=>{E.preventDefault(),E.stopPropagation(),m(O)}})]})]}),f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(E=>E==="all"||O.info.tag.includes(E))).length>0?w.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:O=>O.stopPropagation(),children:f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(E=>E==="all"||O.info.tag.includes(E))).map(O=>w.jsxs("div",{className:"w-full space-y-1.5",children:[w.jsx("div",{className:"fp-aspect-ratio-container",children:w.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:()=>M(O),children:w.jsx("img",{draggable:!1,className:"fp-item-image",alt:O.info.title,src:O.info.image})})}),w.jsx("p",{className:"text-xs font-semibold capitalize",children:O.info.description})]},O.name.replace(/\s+/g,"_")))}):w.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:w.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function w2(n){return ge({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(n)}function S2(n){return ge({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(n)}function E2({catalog:n}){const{planner:t,selectTool3DView:e,setMode:r,selectTool3DFirstPerson:i,selectToolDrawingLine:s}=ne(),{mode:o,alterate:a}=t,[l,c]=F.useState(null);return w.jsxs(w.Fragment,{children:[w.jsxs("aside",{className:"floor_planner-toolbar max-h-full max-w-[50px] p-2.5 space-y-4 bg-[#2b2b2b]",children:[w.jsx(In,{active:[Lr,or].includes(o),tooltip:"Draw wall",onClick:()=>s("wall"),children:w.jsx(tS,{})}),w.jsx(In,{active:!!([ar].includes(o)&&l&&l.page==="windows"),tooltip:"Place windows",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"windows"})},children:w.jsx(Q1,{size:26})}),w.jsx(In,{active:!!([ar].includes(o)&&l&&l.page==="doors"),tooltip:"Place doors",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"doors"})},children:w.jsx(w2,{size:26})}),w.jsx(In,{active:!!([Sr].includes(o)&&l&&l.page==="objects"),tooltip:"Place objects",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"objects"})},children:w.jsx(S2,{size:26})}),w.jsx(Qw,{mode:o})]}),w.jsx(b2,{catalog:n,popupEvent:l,onClose:()=>c(null)})]})}const Fo=window.hasOwnProperty("localStorage")?window.localStorage:!1,M2=500;let gh=null;function A2(n,t){return(e,r,i)=>{let s;if(t=t||M2,!!n&&Fo){if(r){e.setPlan(r);const o=r.floors[0].floorDesign;s=JSON.parse(o)}else if(Fo.getItem(n)!==null){const o=Fo.getItem(n);s=JSON.parse(o)}s&&e.loadProject(s),ne.subscribe(o=>{gh&&clearTimeout(gh),gh=setTimeout(()=>{const a=Fo.getItem(n),l=JSON.stringify(o.planner.scene.toJS());if(a!==l&&(Fo.setItem(n,l),o.plan))try{const c=o.plan.floors[o.activeFloor];i&&i({floor:{floorID:c.floorID,title:c.floorTitle,description:c.floorDescription,design:l}})}catch{}},t)})}}}function O2(){return n=>{window.addEventListener("keydown",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case Er.BACKSPACE:case Er.DELETE:{[fe,Qi,vi].includes(r)&&n.remove();break}case Er.ESC:{n.rollback();break}case Er.Z:{(t.getModifierState("Control")||t.getModifierState("Meta"))&&(t.getModifierState("Shift")?n.redo():n.undo());break}case Er.ALT:{Tl.includes(r)&&n.toggleSnap(e.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:e.snapMask.toJS()}));break}case Er.C:{let i=e.getIn(["scene","selectedLayer"]),s=e.getIn(["scene","layers",i,"selected"]);if((r===fe||r===vi)&&(s.holes.size||s.areas.size||s.items.size||s.lines.size)){if(s.holes.size){let o=e.getIn(["scene","layers",i,"holes",s.holes.get(0)]);n.copyProperties(o.get("properties"))}else if(s.areas.size){const o=e.getIn(["scene","layers",i,"areas",s.areas.get(0)]);n.copyProperties(o.properties)}else if(s.items.size){const o=e.getIn(["scene","layers",i,"items",s.items.get(0)]);n.copyProperties(o.properties)}else if(s.lines.size){const o=e.getIn(["scene","layers",i,"lines",s.lines.get(0)]);n.copyProperties(o.properties)}}break}case Er.V:{n.pasteProperties();break}case Er.CTRL:{n.setAlterateState();break}}}),window.addEventListener("keyup",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case Er.ALT:{Tl.includes(r)&&n.toggleSnap(e.snapMask.merge(e.snapMask.get("tempSnapConfiguartion")));break}case Er.CTRL:{n.setAlterateState();break}}})}}const z2=({onBack:n,onSave:t})=>{const{undo:e,redo:r,plan:i,setPlan:s}=ne(),[o,a]=F.useState(!1),l=()=>{a(!0)},c=h=>{if(!i)return;a(!1);const f=h.target.value.trim();if(f&&f!==(i==null?void 0:i.planTitle)){s({...i,planTitle:f});try{t&&t({title:f,description:""})}catch{}}};return w.jsxs("div",{className:"floor_planner-headerbar border-b border-b-[#5e5e5e] absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] w-full select-none cursor-default top-0 leading-[14px] text-white m-0",children:[w.jsx(In,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{n&&n()},children:w.jsx(pg,{})}),w.jsx("div",{className:"flex flex-col items-center justify-center",children:o?w.jsx("input",{autoFocus:!0,type:"text",defaultValue:i==null?void 0:i.planTitle,onBlur:c,onKeyDown:h=>{(h.key==="Enter"||h.key==="Escape")&&c(h)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):w.jsx("span",{onDoubleClick:l,className:"projectName__fp text-lg",title:(i==null?void 0:i.planTitle)??"Example House",children:(i==null?void 0:i.planTitle)??"Example House"})}),w.jsxs("div",{className:"flex items-center gap-2 relative right-40",children:[w.jsx(In,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:e,children:w.jsx(Z1,{})}),w.jsx(In,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:r,children:w.jsx(J1,{})})]})]})};var mh={exports:{}},Xm;function Jm(){if(Xm)return mh.exports;Xm=1;var n=mh.exports={};return n.forEach=function(t,e){for(var r=0;r<t.length;r++){var i=e(t[r]);if(i)return i}},mh.exports}var yh,Zm;function T2(){return Zm||(Zm=1,yh=function(n){var t=n.stateHandler.getState;function e(o){var a=t(o);return a&&!!a.isDetectable}function r(o){t(o).isDetectable=!0}function i(o){return!!t(o).busy}function s(o,a){t(o).busy=!!a}return{isDetectable:e,markAsDetectable:r,isBusy:i,markBusy:s}}),yh}var vh,Km;function C2(){return Km||(Km=1,vh=function(n){var t={};function e(o){var a=n.get(o);return a===void 0?[]:t[a]||[]}function r(o,a){var l=n.get(o);t[l]||(t[l]=[]),t[l].push(a)}function i(o,a){for(var l=e(o),c=0,h=l.length;c<h;++c)if(l[c]===a){l.splice(c,1);break}}function s(o){var a=e(o);a&&(a.length=0)}return{get:e,add:r,removeListener:i,removeAllListeners:s}}),vh}var xh,Qm;function I2(){return Qm||(Qm=1,xh=function(){var n=1;function t(){return n++}return{generate:t}}),xh}var _h,ty;function k2(){return ty||(ty=1,_h=function(n){var t=n.idGenerator,e=n.stateHandler.getState;function r(s){var o=e(s);return o&&o.id!==void 0?o.id:null}function i(s){var o=e(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=t.generate();return o.id=a,a}return{get:r,set:i}}),_h}var bh,ey;function P2(){return ey||(ey=1,bh=function(n){function t(){}var e={log:t,warn:t,error:t};if(!n&&window.console){var r=function(i,s){i[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var l=0;l<arguments.length;l++)a(arguments[l])}};r(e,"log"),r(e,"warn"),r(e,"error")}return e}),bh}var wh={exports:{}},ry;function ny(){if(ry)return wh.exports;ry=1;var n=wh.exports={};return n.isIE=function(t){function e(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!e())return!1;if(!t)return!0;var r=function(){var i,s=3,o=document.createElement("div"),a=o.getElementsByTagName("i");do o.innerHTML="<!--[if gt IE "+ ++s+"]><i></i><![endif]-->";while(a[0]);return s>4?s:i}();return t===r},n.isLegacyOpera=function(){return!!window.opera},wh.exports}var Sh={exports:{}},iy;function R2(){if(iy)return Sh.exports;iy=1;var n=Sh.exports={};n.getOption=t;function t(e,r,i){var s=e[r];return s==null&&i!==void 0?i:s}return Sh.exports}var Eh,sy;function L2(){if(sy)return Eh;sy=1;var n=R2();Eh=function(r){r=r||{};var i=r.reporter,s=n.getOption(r,"async",!0),o=n.getOption(r,"auto",!0);o&&!s&&(i&&i.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),s=!0);var a=t(),l,c=!1;function h(_,S){!c&&o&&s&&a.size()===0&&p(),a.add(_,S)}function f(){for(c=!0;a.size();){var _=a;a=t(),_.process()}c=!1}function g(_){c||(_===void 0&&(_=s),l&&(m(l),l=null),_?p():f())}function p(){l=v(f)}function m(_){var S=clearTimeout;return S(_)}function v(_){var S=function(M){return setTimeout(M,0)};return S(_)}return{add:h,force:g}};function t(){var e={},r=0,i=0,s=0;function o(c,h){h||(h=c,c=0),c>i?i=c:c<s&&(s=c),e[c]||(e[c]=[]),e[c].push(h),r++}function a(){for(var c=s;c<=i;c++)for(var h=e[c],f=0;f<h.length;f++){var g=h[f];g()}}function l(){return r}return{add:o,process:a,size:l}}return Eh}var Mh,oy;function F2(){if(oy)return Mh;oy=1;var n="_erd";function t(i){return i[n]={},e(i)}function e(i){return i[n]}function r(i){delete i[n]}return Mh={initState:t,getState:e,cleanState:r},Mh}var Ah,ay;function N2(){if(ay)return Ah;ay=1;var n=ny();return Ah=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;if(!e)throw new Error("Missing required dependency: reporter.");function s(h,f){function g(){f(h)}if(n.isIE(8))i(h).object={proxy:g},h.attachEvent("onresize",g);else{var p=l(h);if(!p)throw new Error("Element is not detectable by this strategy.");p.contentDocument.defaultView.addEventListener("resize",g)}}function o(h){var f=t.important?" !important; ":"; ";return(h.join(f)+f).trim()}function a(h,f,g){g||(g=f,f=h,h=null),h=h||{},h.debug;function p(m,v){var _=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),S=!1,M=window.getComputedStyle(m),C=m.offsetWidth,O=m.offsetHeight;i(m).startSize={width:C,height:O};function E(){function z(){if(M.position==="static"){m.style.setProperty("position","relative",h.important?"important":"");var L=function(X,J,at,tt){function bt(yt){return yt.replace(/[^-\d\.]/g,"")}var xt=at[tt];xt!=="auto"&&bt(xt)!=="0"&&(X.warn("An element that is positioned static has style."+tt+"="+xt+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+tt+" will be set to 0. Element: ",J),J.style.setProperty(tt,"0",h.important?"important":""))};L(e,m,M,"top"),L(e,m,M,"right"),L(e,m,M,"bottom"),L(e,m,M,"left")}}function R(){S||z();function L(J,at){if(!J.contentDocument){var tt=i(J);tt.checkForObjectDocumentTimeoutId&&window.clearTimeout(tt.checkForObjectDocumentTimeoutId),tt.checkForObjectDocumentTimeoutId=setTimeout(function(){tt.checkForObjectDocumentTimeoutId=0,L(J,at)},100);return}at(J.contentDocument)}var X=this;L(X,function(at){v(m)})}M.position!==""&&(z(),S=!0);var k=document.createElement("object");k.style.cssText=_,k.tabIndex=-1,k.type="text/html",k.setAttribute("aria-hidden","true"),k.onload=R,n.isIE()||(k.data="about:blank"),i(m)&&(m.appendChild(k),i(m).object=k,n.isIE()&&(k.data="about:blank"))}r?r.add(E):E()}n.isIE(8)?g(f):p(f,g)}function l(h){return i(h).object}function c(h){if(i(h)){var f=l(h);f&&(n.isIE(8)?h.detachEvent("onresize",f.proxy):h.removeChild(f),i(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(h).checkForObjectDocumentTimeoutId),delete i(h).object)}}return{makeDetectable:a,addListener:s,uninstall:c}},Ah}var Oh,uy;function j2(){if(uy)return Oh;uy=1;var n=Jm().forEach;return Oh=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;t.stateHandler.hasState;var s=t.idHandler;if(!r)throw new Error("Missing required dependency: batchProcessor");if(!e)throw new Error("Missing required dependency: reporter.");var o=f(),a="erd_scroll_detection_scrollbar_style",l="erd_scroll_detection_container";function c(E){g(E,a,l)}c(window.document);function h(E){var z=t.important?" !important; ":"; ";return(E.join(z)+z).trim()}function f(){var E=500,z=500,R=document.createElement("div");R.style.cssText=h(["position: absolute","width: "+E*2+"px","height: "+z*2+"px","visibility: hidden","margin: 0","padding: 0"]);var k=document.createElement("div");k.style.cssText=h(["position: absolute","width: "+E+"px","height: "+z+"px","overflow: scroll","visibility: none","top: "+-E*3+"px","left: "+-z*3+"px","visibility: hidden","margin: 0","padding: 0"]),k.appendChild(R),document.body.insertBefore(k,document.body.firstChild);var L=E-k.clientWidth,X=z-k.clientHeight;return document.body.removeChild(k),{width:L,height:X}}function g(E,z,R){function k(at,tt){tt=tt||function(xt){E.head.appendChild(xt)};var bt=E.createElement("style");return bt.innerHTML=at,bt.id=z,tt(bt),bt}if(!E.getElementById(z)){var L=R+"_animation",X=R+"_animation_active",J=`/* Created by the element-resize-detector library. */
|
|
83
83
|
`;J+="."+R+" > div::-webkit-scrollbar { "+h(["display: none"])+` }
|
|
84
84
|
|
|
85
85
|
`,J+="."+X+" { "+h(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+L,"animation-name: "+L])+` }
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.4",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "vite",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"zustand": "^5.0.7"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@osamash/floor-planner": "^1.0.
|
|
48
|
+
"@osamash/floor-planner": "^1.0.3",
|
|
49
49
|
"area-polygon": "^1.0.1",
|
|
50
50
|
"autoprefixer": "^10.4.21",
|
|
51
51
|
"axios": "^1.11.0",
|