shaders 2.0.670 → 2.0.671

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.
@@ -434,7 +434,7 @@ var<${r}> ${t} : ${n};`}},N9=class{constructor(t){this.backend=t}getCurrentDepth
434
434
  * @license
435
435
  * Copyright 2010-2025 Three.js Authors
436
436
  * SPDX-License-Identifier: MIT
437
- */const r3="177",TJ=0,Ff=3,Pb=0,oy=1,wJ=0,Ib=1,nM=100,aM=204,oM=205,lM=3,SJ=0,Vb=0,Gv=300,ag=301,Ob=302,MJ=306,uM=1e3,bd=1001,hM=1002,$s=1003,ps=1006,i3=1008,_J=1008,s3=1009,NJ=1013,n3=1014,gc=1015,wo=1016,jv=1023,cM=1026,EJ=1027,So=1030,dM=0,AJ=1,og="",Ps="srgb",lg="srgb-linear",mM="linear",Ld="srgb",dh=7680,pM=519,CJ=513,ug=35044,vd=35048,va=2e3,Ru=2001;class Du{addEventListener(e,r){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(r)===-1&&i[e].push(r)}hasEventListener(e,r){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(r)!==-1}removeEventListener(e,r){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const n=s.indexOf(r);n!==-1&&s.splice(n,1)}}dispatchEvent(e){const r=this._listeners;if(r===void 0)return;const i=r[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let n=0,a=s.length;n<a;n++)s[n].call(this,e);e.target=null}}}const di=["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"];let fM=1234567;const Fd=Math.PI/180,hg=180/Math.PI;function Ca(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(di[t&255]+di[t>>8&255]+di[t>>16&255]+di[t>>24&255]+"-"+di[e&255]+di[e>>8&255]+"-"+di[e>>16&15|64]+di[e>>24&255]+"-"+di[r&63|128]+di[r>>8&255]+"-"+di[r>>16&255]+di[r>>24&255]+di[i&255]+di[i>>8&255]+di[i>>16&255]+di[i>>24&255]).toLowerCase()}function tt(t,e,r){return Math.max(e,Math.min(r,t))}function Wv(t,e){return(t%e+e)%e}function RJ(t,e,r,i,s){return i+(t-e)*(s-i)/(r-e)}function PJ(t,e,r){return t!==e?(r-t)/(e-t):0}function zd(t,e,r){return(1-r)*t+r*e}function IJ(t,e,r,i){return zd(t,e,1-Math.exp(-r*i))}function VJ(t,e=1){return e-Math.abs(Wv(t,e*2)-e)}function OJ(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*(3-2*t))}function LJ(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*t*(t*(t*6-15)+10))}function FJ(t,e){return t+Math.floor(Math.random()*(e-t+1))}function zJ(t,e){return t+Math.random()*(e-t)}function BJ(t){return t*(.5-Math.random())}function kJ(t){t!==void 0&&(fM=t);let e=fM+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function UJ(t){return t*Fd}function DJ(t){return t*hg}function $J(t){return(t&t-1)===0&&t!==0}function GJ(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function jJ(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function WJ(t,e,r,i,s){const n=Math.cos,a=Math.sin,o=n(r/2),l=a(r/2),h=n((e+i)/2),u=a((e+i)/2),c=n((e-i)/2),d=a((e-i)/2),m=n((i-e)/2),p=a((i-e)/2);switch(s){case"XYX":t.set(o*u,l*c,l*d,o*h);break;case"YZY":t.set(l*d,o*u,l*c,o*h);break;case"ZXZ":t.set(l*c,l*d,o*u,o*h);break;case"XZX":t.set(o*u,l*p,l*m,o*h);break;case"YXY":t.set(l*m,o*u,l*p,o*h);break;case"ZYZ":t.set(l*p,l*m,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function un(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function St(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const a3={DEG2RAD:Fd,RAD2DEG:hg,generateUUID:Ca,clamp:tt,euclideanModulo:Wv,mapLinear:RJ,inverseLerp:PJ,lerp:zd,damp:IJ,pingpong:VJ,smoothstep:OJ,smootherstep:LJ,randInt:FJ,randFloat:zJ,randFloatSpread:BJ,seededRandom:kJ,degToRad:UJ,radToDeg:DJ,isPowerOfTwo:$J,ceilPowerOfTwo:GJ,floorPowerOfTwo:jJ,setQuaternionFromProperEuler:WJ,normalize:St,denormalize:un};class Jt{constructor(e=0,r=0){Jt.prototype.isVector2=!0,this.x=e,this.y=r}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,r){return this.x=e,this.y=r,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const r=this.x,i=this.y,s=e.elements;return this.x=s[0]*r+s[3]*i+s[6],this.y=s[1]*r+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,r){return this.x=tt(this.x,e.x,r.x),this.y=tt(this.y,e.y,r.y),this}clampScalar(e,r){return this.x=tt(this.x,e,r),this.y=tt(this.y,e,r),this}clampLength(e,r){const i=this.length();return this.divideScalar(i||1).multiplyScalar(tt(i,e,r))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;const i=this.dot(e)/r;return Math.acos(tt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const r=this.x-e.x,i=this.y-e.y;return r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this}rotateAround(e,r){const i=Math.cos(r),s=Math.sin(r),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*s+e.x,this.y=n*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class _m{constructor(e=0,r=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=r,this._z=i,this._w=s}static slerpFlat(e,r,i,s,n,a,o){let l=i[s+0],h=i[s+1],u=i[s+2],c=i[s+3];const d=n[a+0],m=n[a+1],p=n[a+2],f=n[a+3];if(o===0){e[r+0]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c;return}if(o===1){e[r+0]=d,e[r+1]=m,e[r+2]=p,e[r+3]=f;return}if(c!==f||l!==d||h!==m||u!==p){let g=1-o;const y=l*d+h*m+u*p+c*f,T=y>=0?1:-1,S=1-y*y;if(S>Number.EPSILON){const _=Math.sqrt(S),M=Math.atan2(_,y*T);g=Math.sin(g*M)/_,o=Math.sin(o*M)/_}const w=o*T;if(l=l*g+d*w,h=h*g+m*w,u=u*g+p*w,c=c*g+f*w,g===1-o){const _=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=_,h*=_,u*=_,c*=_}}e[r]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c}static multiplyQuaternionsFlat(e,r,i,s,n,a){const o=i[s],l=i[s+1],h=i[s+2],u=i[s+3],c=n[a],d=n[a+1],m=n[a+2],p=n[a+3];return e[r]=o*p+u*c+l*m-h*d,e[r+1]=l*p+u*d+h*c-o*m,e[r+2]=h*p+u*m+o*d-l*c,e[r+3]=u*p-o*c-l*d-h*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,r,i,s){return this._x=e,this._y=r,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,r=!0){const i=e._x,s=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,h=o(i/2),u=o(s/2),c=o(n/2),d=l(i/2),m=l(s/2),p=l(n/2);switch(a){case"XYZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"YXZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"ZXY":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"ZYX":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"YZX":this._x=d*u*c+h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c-d*m*p;break;case"XZY":this._x=d*u*c-h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c+d*m*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,r){const i=r/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const r=e.elements,i=r[0],s=r[4],n=r[8],a=r[1],o=r[5],l=r[9],h=r[2],u=r[6],c=r[10],d=i+o+c;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-l)*m,this._y=(n-h)*m,this._z=(a-s)*m}else if(i>o&&i>c){const m=2*Math.sqrt(1+i-o-c);this._w=(u-l)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(n+h)/m}else if(o>c){const m=2*Math.sqrt(1+o-i-c);this._w=(n-h)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+c-i-o);this._w=(a-s)/m,this._x=(n+h)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,r){let i=e.dot(r)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*r.z-e.z*r.y,this._y=e.z*r.x-e.x*r.z,this._z=e.x*r.y-e.y*r.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(tt(this.dot(e),-1,1)))}rotateTowards(e,r){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,r/i);return this.slerp(e,s),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,r){const i=e._x,s=e._y,n=e._z,a=e._w,o=r._x,l=r._y,h=r._z,u=r._w;return this._x=i*u+a*o+s*h-n*l,this._y=s*u+a*l+n*o-i*h,this._z=n*u+a*h+i*l-s*o,this._w=a*u-i*o-s*l-n*h,this._onChangeCallback(),this}slerp(e,r){if(r===0)return this;if(r===1)return this.copy(e);const i=this._x,s=this._y,n=this._z,a=this._w;let o=a*e._w+i*e._x+s*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=s,this._z=n,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-r;return this._w=m*a+r*this._w,this._x=m*i+r*this._x,this._y=m*s+r*this._y,this._z=m*n+r*this._z,this.normalize(),this}const h=Math.sqrt(l),u=Math.atan2(h,o),c=Math.sin((1-r)*u)/h,d=Math.sin(r*u)/h;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=s*c+this._y*d,this._z=n*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,r,i){return this.copy(e).slerp(r,i)}random(){const e=2*Math.PI*Math.random(),r=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),n*Math.sin(r),n*Math.cos(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,r=0){return this._x=e[r],this._y=e[r+1],this._z=e[r+2],this._w=e[r+3],this._onChangeCallback(),this}toArray(e=[],r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,e}fromBufferAttribute(e,r){return this._x=e.getX(r),this._y=e.getY(r),this._z=e.getZ(r),this._w=e.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ${constructor(e=0,r=0,i=0){$.prototype.isVector3=!0,this.x=e,this.y=r,this.z=i}set(e,r,i){return i===void 0&&(i=this.z),this.x=e,this.y=r,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,r){return this.x=e.x*r.x,this.y=e.y*r.y,this.z=e.z*r.z,this}applyEuler(e){return this.applyQuaternion(gM.setFromEuler(e))}applyAxisAngle(e,r){return this.applyQuaternion(gM.setFromAxisAngle(e,r))}applyMatrix3(e){const r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[3]*i+n[6]*s,this.y=n[1]*r+n[4]*i+n[7]*s,this.z=n[2]*r+n[5]*i+n[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const r=this.x,i=this.y,s=this.z,n=e.elements,a=1/(n[3]*r+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*r+n[4]*i+n[8]*s+n[12])*a,this.y=(n[1]*r+n[5]*i+n[9]*s+n[13])*a,this.z=(n[2]*r+n[6]*i+n[10]*s+n[14])*a,this}applyQuaternion(e){const r=this.x,i=this.y,s=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*s-o*i),u=2*(o*r-n*s),c=2*(n*i-a*r);return this.x=r+l*h+a*c-o*u,this.y=i+l*u+o*h-n*c,this.z=s+l*c+n*u-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[4]*i+n[8]*s,this.y=n[1]*r+n[5]*i+n[9]*s,this.z=n[2]*r+n[6]*i+n[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,r){return this.x=tt(this.x,e.x,r.x),this.y=tt(this.y,e.y,r.y),this.z=tt(this.z,e.z,r.z),this}clampScalar(e,r){return this.x=tt(this.x,e,r),this.y=tt(this.y,e,r),this.z=tt(this.z,e,r),this}clampLength(e,r){const i=this.length();return this.divideScalar(i||1).multiplyScalar(tt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,r){const i=e.x,s=e.y,n=e.z,a=r.x,o=r.y,l=r.z;return this.x=s*l-n*o,this.y=n*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const r=e.lengthSq();if(r===0)return this.set(0,0,0);const i=e.dot(this)/r;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return k0.copy(this).projectOnVector(e),this.sub(k0)}reflect(e){return this.sub(k0.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;const i=this.dot(e)/r;return Math.acos(tt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const r=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return r*r+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,r,i){const s=Math.sin(r)*e;return this.x=s*Math.sin(i),this.y=Math.cos(r)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,r,i){return this.x=e*Math.sin(r),this.y=i,this.z=e*Math.cos(r),this}setFromMatrixPosition(e){const r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(e){const r=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=r,this.y=i,this.z=s,this}setFromMatrixColumn(e,r){return this.fromArray(e.elements,r*4)}setFromMatrix3Column(e,r){return this.fromArray(e.elements,r*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,r=Math.random()*2-1,i=Math.sqrt(1-r*r);return this.x=i*Math.cos(e),this.y=r,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const k0=new $,gM=new _m;class qs{constructor(e,r,i,s,n,a,o,l,h){qs.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h)}set(e,r,i,s,n,a,o,l,h){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=r,u[4]=n,u[5]=l,u[6]=i,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],this}extractBasis(e,r,i){return e.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const r=e.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){const i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],u=i[4],c=i[7],d=i[2],m=i[5],p=i[8],f=s[0],g=s[3],y=s[6],T=s[1],S=s[4],w=s[7],_=s[2],M=s[5],E=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*S+l*M,n[6]=a*y+o*w+l*E,n[1]=h*f+u*T+c*_,n[4]=h*g+u*S+c*M,n[7]=h*y+u*w+c*E,n[2]=d*f+m*T+p*_,n[5]=d*g+m*S+p*M,n[8]=d*y+m*w+p*E,this}multiplyScalar(e){const r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=e,r[4]*=e,r[7]*=e,r[2]*=e,r[5]*=e,r[8]*=e,this}determinant(){const e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8];return r*a*u-r*o*h-i*n*u+i*o*l+s*n*h-s*a*l}invert(){const e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=u*a-o*h,d=o*l-u*n,m=h*n-a*l,p=r*c+i*d+s*m;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=c*f,e[1]=(s*h-u*i)*f,e[2]=(o*i-s*a)*f,e[3]=d*f,e[4]=(u*r-s*l)*f,e[5]=(s*n-o*r)*f,e[6]=m*f,e[7]=(i*l-h*r)*f,e[8]=(a*r-i*n)*f,this}transpose(){let e;const r=this.elements;return e=r[1],r[1]=r[3],r[3]=e,e=r[2],r[2]=r[6],r[6]=e,e=r[5],r[5]=r[7],r[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const r=this.elements;return e[0]=r[0],e[1]=r[3],e[2]=r[6],e[3]=r[1],e[4]=r[4],e[5]=r[7],e[6]=r[2],e[7]=r[5],e[8]=r[8],this}setUvTransform(e,r,i,s,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-s*h,s*l,-s*(-h*a+l*o)+o+r,0,0,1),this}scale(e,r){return this.premultiply(U0.makeScale(e,r)),this}rotate(e){return this.premultiply(U0.makeRotation(-e)),this}translate(e,r){return this.premultiply(U0.makeTranslation(e,r)),this}makeTranslation(e,r){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,r,0,0,1),this}makeRotation(e){const r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,i,r,0,0,0,1),this}makeScale(e,r){return this.set(e,0,0,0,r,0,0,0,1),this}equals(e){const r=this.elements,i=e.elements;for(let s=0;s<9;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<9;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){const i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const U0=new qs;function HJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Lb(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const yM={};function xM(t){t in yM||(yM[t]=!0,console.warn(t))}const bM=new qs().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),vM=new qs().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function qJ(){const t={enabled:!0,workingColorSpace:lg,spaces:{},convert:function(s,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Ld&&(s.r=Ra(s.r),s.g=Ra(s.g),s.b=Ra(s.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ld&&(s.r=tc(s.r),s.g=tc(s.g),s.b=tc(s.b))),s},workingToColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},colorSpaceToWorking:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===og?mM:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,a){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,n){return xM("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(s,n)},toWorkingColorSpace:function(s,n){return xM("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(s,n)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[lg]:{primaries:e,whitePoint:i,transfer:mM,toXYZ:bM,fromXYZ:vM,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:Ps},outputColorSpaceConfig:{drawingBufferColorSpace:Ps}},[Ps]:{primaries:e,whitePoint:i,transfer:Ld,toXYZ:bM,fromXYZ:vM,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:Ps}}}),t}const or=qJ();function Ra(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function tc(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let mh;class XJ{static getDataURL(e,r="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{mh===void 0&&(mh=Lb("canvas")),mh.width=e.width,mh.height=e.height;const s=mh.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=mh}return i.toDataURL(r)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const r=Lb("canvas");r.width=e.width,r.height=e.height;const i=r.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),n=s.data;for(let a=0;a<n.length;a++)n[a]=Ra(n[a]/255)*255;return i.putImageData(s,0,0),r}else if(e.data){const r=e.data.slice(0);for(let i=0;i<r.length;i++)r instanceof Uint8Array||r instanceof Uint8ClampedArray?r[i]=Math.floor(Ra(r[i]/255)*255):r[i]=Ra(r[i]);return{data:r,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let YJ=0;class Hv{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:YJ++}),this.uuid=Ca(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const r=this.data;return r instanceof HTMLVideoElement?e.set(r.videoWidth,r.videoHeight):r!==null?e.set(r.width,r.height,r.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const r=e===void 0||typeof e=="string";if(!r&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?n.push(D0(s[a].image)):n.push(D0(s[a]))}else n=D0(s);i.url=n}return r||(e.images[this.uuid]=i),i}}function D0(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?XJ.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ZJ=0;const $0=new $;class vi extends Du{constructor(e=vi.DEFAULT_IMAGE,r=vi.DEFAULT_MAPPING,i=bd,s=bd,n=ps,a=i3,o=jv,l=s3,h=vi.DEFAULT_ANISOTROPY,u=og){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ZJ++}),this.uuid=Ca(),this.name="",this.source=new Hv(e),this.mipmaps=[],this.mapping=r,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Jt(0,0),this.repeat=new Jt(1,1),this.center=new Jt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qs,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize($0).x}get height(){return this.source.getSize($0).y}get depth(){return this.source.getSize($0).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,r){this.updateRanges.push({start:e,count:r})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const r in e){const i=e[r];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${r}' has value of undefined.`);continue}const s=this[r];if(s===void 0){console.warn(`THREE.Texture.setValues(): property '${r}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[r]=i}}toJSON(e){const r=e===void 0||typeof e=="string";if(!r&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(i.userData=this.userData),r||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case uM:e.x=e.x-Math.floor(e.x);break;case bd:e.x=e.x<0?0:1;break;case hM:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case uM:e.y=e.y-Math.floor(e.y);break;case bd:e.y=e.y<0?0:1;break;case hM:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}vi.DEFAULT_IMAGE=null;vi.DEFAULT_MAPPING=Gv;vi.DEFAULT_ANISOTROPY=1;class Si{constructor(e=0,r=0,i=0,s=1){Si.prototype.isVector4=!0,this.x=e,this.y=r,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,r,i,s){return this.x=e,this.y=r,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this.w=e.w+r.w,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this.w+=e.w*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this.w=e.w-r.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const r=this.x,i=this.y,s=this.z,n=this.w,a=e.elements;return this.x=a[0]*r+a[4]*i+a[8]*s+a[12]*n,this.y=a[1]*r+a[5]*i+a[9]*s+a[13]*n,this.z=a[2]*r+a[6]*i+a[10]*s+a[14]*n,this.w=a[3]*r+a[7]*i+a[11]*s+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const r=Math.sqrt(1-e.w*e.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/r,this.y=e.y/r,this.z=e.z/r),this}setAxisAngleFromRotationMatrix(e){let r,i,s,n;const l=e.elements,h=l[0],u=l[4],c=l[8],d=l[1],m=l[5],p=l[9],f=l[2],g=l[6],y=l[10];if(Math.abs(u-d)<.01&&Math.abs(c-f)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+d)<.1&&Math.abs(c+f)<.1&&Math.abs(p+g)<.1&&Math.abs(h+m+y-3)<.1)return this.set(1,0,0,0),this;r=Math.PI;const S=(h+1)/2,w=(m+1)/2,_=(y+1)/2,M=(u+d)/4,E=(c+f)/4,A=(p+g)/4;return S>w&&S>_?S<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(S),s=M/i,n=E/i):w>_?w<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=M/s,n=A/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=E/n,s=A/n),this.set(i,s,n,r),this}let T=Math.sqrt((g-p)*(g-p)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(T)<.001&&(T=1),this.x=(g-p)/T,this.y=(c-f)/T,this.z=(d-u)/T,this.w=Math.acos((h+m+y-1)/2),this}setFromMatrixPosition(e){const r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this.w=r[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,r){return this.x=tt(this.x,e.x,r.x),this.y=tt(this.y,e.y,r.y),this.z=tt(this.z,e.z,r.z),this.w=tt(this.w,e.w,r.w),this}clampScalar(e,r){return this.x=tt(this.x,e,r),this.y=tt(this.y,e,r),this.z=tt(this.z,e,r),this.w=tt(this.w,e,r),this}clampLength(e,r){const i=this.length();return this.divideScalar(i||1).multiplyScalar(tt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this.w+=(e.w-this.w)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this.w=e.w+(r.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this.w=e[r+3],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e[r+3]=this.w,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this.w=e.getW(r),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 Nm extends Du{constructor(e=1,r=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ps,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=r,this.depth=i.depth,this.scissor=new Si(0,0,e,r),this.scissorTest=!1,this.viewport=new Si(0,0,e,r);const s={width:e,height:r,depth:i.depth},n=new vi(s);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const r={minFilter:ps,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(r.mapping=e.mapping),e.wrapS!==void 0&&(r.wrapS=e.wrapS),e.wrapT!==void 0&&(r.wrapT=e.wrapT),e.wrapR!==void 0&&(r.wrapR=e.wrapR),e.magFilter!==void 0&&(r.magFilter=e.magFilter),e.minFilter!==void 0&&(r.minFilter=e.minFilter),e.format!==void 0&&(r.format=e.format),e.type!==void 0&&(r.type=e.type),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(r.colorSpace=e.colorSpace),e.flipY!==void 0&&(r.flipY=e.flipY),e.generateMipmaps!==void 0&&(r.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(r.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(r)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,r,i=1){if(this.width!==e||this.height!==r||this.depth!==i){this.width=e,this.height=r,this.depth=i;for(let s=0,n=this.textures.length;s<n;s++)this.textures[s].image.width=e,this.textures[s].image.height=r,this.textures[s].image.depth=i,this.textures[s].isArrayTexture=this.textures[s].image.depth>1;this.dispose()}this.viewport.set(0,0,e,r),this.scissor.set(0,0,e,r)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let r=0,i=e.textures.length;r<i;r++){this.textures[r]=e.textures[r].clone(),this.textures[r].isRenderTargetTexture=!0,this.textures[r].renderTarget=this;const s=Object.assign({},e.textures[r].image);this.textures[r].source=new Hv(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class JJ extends vi{constructor(e=null,r=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:r,height:i,depth:s},this.magFilter=$s,this.minFilter=$s,this.wrapR=bd,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Em{constructor(e=new $(1/0,1/0,1/0),r=new $(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=r}set(e,r){return this.min.copy(e),this.max.copy(r),this}setFromArray(e){this.makeEmpty();for(let r=0,i=e.length;r<i;r+=3)this.expandByPoint(tn.fromArray(e,r));return this}setFromBufferAttribute(e){this.makeEmpty();for(let r=0,i=e.count;r<i;r++)this.expandByPoint(tn.fromBufferAttribute(e,r));return this}setFromPoints(e){this.makeEmpty();for(let r=0,i=e.length;r<i;r++)this.expandByPoint(e[r]);return this}setFromCenterAndSize(e,r){const i=tn.copy(r).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,r=!1){return this.makeEmpty(),this.expandByObject(e,r)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,r=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const n=i.getAttribute("position");if(r===!0&&n!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,tn):tn.fromBufferAttribute(n,a),tn.applyMatrix4(e.matrixWorld),this.expandByPoint(tn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Op.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Op.copy(i.boundingBox)),Op.applyMatrix4(e.matrixWorld),this.union(Op)}const s=e.children;for(let n=0,a=s.length;n<a;n++)this.expandByObject(s[n],r);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,r){return r.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,tn),tn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let r,i;return e.normal.x>0?(r=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(r=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(r+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(r+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(r+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(r+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),r<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(td),Lp.subVectors(this.max,td),ph.subVectors(e.a,td),fh.subVectors(e.b,td),gh.subVectors(e.c,td),ro.subVectors(fh,ph),io.subVectors(gh,fh),rl.subVectors(ph,gh);let r=[0,-ro.z,ro.y,0,-io.z,io.y,0,-rl.z,rl.y,ro.z,0,-ro.x,io.z,0,-io.x,rl.z,0,-rl.x,-ro.y,ro.x,0,-io.y,io.x,0,-rl.y,rl.x,0];return!G0(r,ph,fh,gh,Lp)||(r=[1,0,0,0,1,0,0,0,1],!G0(r,ph,fh,gh,Lp))?!1:(Fp.crossVectors(ro,io),r=[Fp.x,Fp.y,Fp.z],G0(r,ph,fh,gh,Lp))}clampPoint(e,r){return r.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,tn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(tn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ua[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ua[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ua[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ua[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ua[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ua[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ua[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ua[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ua),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const ua=[new $,new $,new $,new $,new $,new $,new $,new $],tn=new $,Op=new Em,ph=new $,fh=new $,gh=new $,ro=new $,io=new $,rl=new $,td=new $,Lp=new $,Fp=new $,il=new $;function G0(t,e,r,i,s){for(let n=0,a=t.length-3;n<=a;n+=3){il.fromArray(t,n);const o=s.x*Math.abs(il.x)+s.y*Math.abs(il.y)+s.z*Math.abs(il.z),l=e.dot(il),h=r.dot(il),u=i.dot(il);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}const KJ=new Em,rd=new $,j0=new $;class qv{constructor(e=new $,r=-1){this.isSphere=!0,this.center=e,this.radius=r}set(e,r){return this.center.copy(e),this.radius=r,this}setFromPoints(e,r){const i=this.center;r!==void 0?i.copy(r):KJ.setFromPoints(e).getCenter(i);let s=0;for(let n=0,a=e.length;n<a;n++)s=Math.max(s,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const r=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=r*r}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,r){const i=this.center.distanceToSquared(e);return r.copy(e),i>this.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;rd.subVectors(e,this.center);const r=rd.lengthSq();if(r>this.radius*this.radius){const i=Math.sqrt(r),s=(i-this.radius)*.5;this.center.addScaledVector(rd,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(j0.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rd.copy(e.center).add(j0)),this.expandByPoint(rd.copy(e.center).sub(j0))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const ha=new $,W0=new $,zp=new $,so=new $,H0=new $,Bp=new $,q0=new $;class QJ{constructor(e=new $,r=new $(0,0,-1)){this.origin=e,this.direction=r}set(e,r){return this.origin.copy(e),this.direction.copy(r),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,r){return r.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ha)),this}closestPointToPoint(e,r){r.subVectors(e,this.origin);const i=r.dot(this.direction);return i<0?r.copy(this.origin):r.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const r=ha.subVectors(e,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(e):(ha.copy(this.origin).addScaledVector(this.direction,r),ha.distanceToSquared(e))}distanceSqToSegment(e,r,i,s){W0.copy(e).add(r).multiplyScalar(.5),zp.copy(r).sub(e).normalize(),so.copy(this.origin).sub(W0);const n=e.distanceTo(r)*.5,a=-this.direction.dot(zp),o=so.dot(this.direction),l=-so.dot(zp),h=so.lengthSq(),u=Math.abs(1-a*a);let c,d,m,p;if(u>0)if(c=a*l-o,d=a*o-l,p=n*u,c>=0)if(d>=-p)if(d<=p){const f=1/u;c*=f,d*=f,m=c*(c+a*d+2*o)+d*(a*c+d+2*l)+h}else d=n,c=Math.max(0,-(a*d+o)),m=-c*c+d*(d+2*l)+h;else d=-n,c=Math.max(0,-(a*d+o)),m=-c*c+d*(d+2*l)+h;else d<=-p?(c=Math.max(0,-(-a*n+o)),d=c>0?-n:Math.min(Math.max(-n,-l),n),m=-c*c+d*(d+2*l)+h):d<=p?(c=0,d=Math.min(Math.max(-n,-l),n),m=d*(d+2*l)+h):(c=Math.max(0,-(a*n+o)),d=c>0?n:Math.min(Math.max(-n,-l),n),m=-c*c+d*(d+2*l)+h);else d=a>0?-n:n,c=Math.max(0,-(a*d+o)),m=-c*c+d*(d+2*l)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,c),s&&s.copy(W0).addScaledVector(zp,d),m}intersectSphere(e,r){ha.subVectors(e.center,this.origin);const i=ha.dot(this.direction),s=ha.dot(ha)-i*i,n=e.radius*e.radius;if(s>n)return null;const a=Math.sqrt(n-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,r):this.at(o,r)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const r=e.normal.dot(this.direction);if(r===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/r;return i>=0?i:null}intersectPlane(e,r){const i=this.distanceToPlane(e);return i===null?null:this.at(i,r)}intersectsPlane(e){const r=e.distanceToPoint(this.origin);return r===0||e.normal.dot(this.direction)*r<0}intersectBox(e,r){let i,s,n,a,o,l;const h=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,d=this.origin;return h>=0?(i=(e.min.x-d.x)*h,s=(e.max.x-d.x)*h):(i=(e.max.x-d.x)*h,s=(e.min.x-d.x)*h),u>=0?(n=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(n=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||n>s||((n>i||isNaN(i))&&(i=n),(a<s||isNaN(s))&&(s=a),c>=0?(o=(e.min.z-d.z)*c,l=(e.max.z-d.z)*c):(o=(e.max.z-d.z)*c,l=(e.min.z-d.z)*c),i>l||o>s)||((o>i||i!==i)&&(i=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(i>=0?i:s,r)}intersectsBox(e){return this.intersectBox(e,ha)!==null}intersectTriangle(e,r,i,s,n){H0.subVectors(r,e),Bp.subVectors(i,e),q0.crossVectors(H0,Bp);let a=this.direction.dot(q0),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;so.subVectors(this.origin,e);const l=o*this.direction.dot(Bp.crossVectors(so,Bp));if(l<0)return null;const h=o*this.direction.dot(H0.cross(so));if(h<0||l+h>a)return null;const u=-o*so.dot(q0);return u<0?null:this.at(u/a,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Rt{constructor(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){Rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g)}set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){const y=this.elements;return y[0]=e,y[4]=r,y[8]=i,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=u,y[10]=c,y[14]=d,y[3]=m,y[7]=p,y[11]=f,y[15]=g,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 Rt().fromArray(this.elements)}copy(e){const r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],this}copyPosition(e){const r=this.elements,i=e.elements;return r[12]=i[12],r[13]=i[13],r[14]=i[14],this}setFromMatrix3(e){const r=e.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(e,r,i){return e.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,r,i){return this.set(e.x,r.x,i.x,0,e.y,r.y,i.y,0,e.z,r.z,i.z,0,0,0,0,1),this}extractRotation(e){const r=this.elements,i=e.elements,s=1/yh.setFromMatrixColumn(e,0).length(),n=1/yh.setFromMatrixColumn(e,1).length(),a=1/yh.setFromMatrixColumn(e,2).length();return r[0]=i[0]*s,r[1]=i[1]*s,r[2]=i[2]*s,r[3]=0,r[4]=i[4]*n,r[5]=i[5]*n,r[6]=i[6]*n,r[7]=0,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(e){const r=this.elements,i=e.x,s=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(s),h=Math.sin(s),u=Math.cos(n),c=Math.sin(n);if(e.order==="XYZ"){const d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=-l*c,r[8]=h,r[1]=m+p*h,r[5]=d-f*h,r[9]=-o*l,r[2]=f-d*h,r[6]=p+m*h,r[10]=a*l}else if(e.order==="YXZ"){const d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d+f*o,r[4]=p*o-m,r[8]=a*h,r[1]=a*c,r[5]=a*u,r[9]=-o,r[2]=m*o-p,r[6]=f+d*o,r[10]=a*l}else if(e.order==="ZXY"){const d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d-f*o,r[4]=-a*c,r[8]=p+m*o,r[1]=m+p*o,r[5]=a*u,r[9]=f-d*o,r[2]=-a*h,r[6]=o,r[10]=a*l}else if(e.order==="ZYX"){const d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=p*h-m,r[8]=d*h+f,r[1]=l*c,r[5]=f*h+d,r[9]=m*h-p,r[2]=-h,r[6]=o*l,r[10]=a*l}else if(e.order==="YZX"){const d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=f-d*c,r[8]=p*c+m,r[1]=c,r[5]=a*u,r[9]=-o*u,r[2]=-h*u,r[6]=m*c+p,r[10]=d-f*c}else if(e.order==="XZY"){const d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=-c,r[8]=h*u,r[1]=d*c+f,r[5]=a*u,r[9]=m*c-p,r[2]=p*c-m,r[6]=o*u,r[10]=f*c+d}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(e){return this.compose(eK,e,tK)}lookAt(e,r,i){const s=this.elements;return rs.subVectors(e,r),rs.lengthSq()===0&&(rs.z=1),rs.normalize(),no.crossVectors(i,rs),no.lengthSq()===0&&(Math.abs(i.z)===1?rs.x+=1e-4:rs.z+=1e-4,rs.normalize(),no.crossVectors(i,rs)),no.normalize(),kp.crossVectors(rs,no),s[0]=no.x,s[4]=kp.x,s[8]=rs.x,s[1]=no.y,s[5]=kp.y,s[9]=rs.y,s[2]=no.z,s[6]=kp.z,s[10]=rs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){const i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],u=i[1],c=i[5],d=i[9],m=i[13],p=i[2],f=i[6],g=i[10],y=i[14],T=i[3],S=i[7],w=i[11],_=i[15],M=s[0],E=s[4],A=s[8],U=s[12],Q=s[1],J=s[5],re=s[9],ie=s[13],se=s[2],ve=s[6],me=s[10],Me=s[14],ye=s[3],Te=s[7],ge=s[11],be=s[15];return n[0]=a*M+o*Q+l*se+h*ye,n[4]=a*E+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*U+o*ie+l*Me+h*be,n[1]=u*M+c*Q+d*se+m*ye,n[5]=u*E+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*U+c*ie+d*Me+m*be,n[2]=p*M+f*Q+g*se+y*ye,n[6]=p*E+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*U+f*ie+g*Me+y*be,n[3]=T*M+S*Q+w*se+_*ye,n[7]=T*E+S*J+w*ve+_*Te,n[11]=T*A+S*re+w*me+_*ge,n[15]=T*U+S*ie+w*Me+_*be,this}multiplyScalar(e){const r=this.elements;return r[0]*=e,r[4]*=e,r[8]*=e,r[12]*=e,r[1]*=e,r[5]*=e,r[9]*=e,r[13]*=e,r[2]*=e,r[6]*=e,r[10]*=e,r[14]*=e,r[3]*=e,r[7]*=e,r[11]*=e,r[15]*=e,this}determinant(){const e=this.elements,r=e[0],i=e[4],s=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],u=e[2],c=e[6],d=e[10],m=e[14],p=e[3],f=e[7],g=e[11],y=e[15];return p*(+n*l*c-s*h*c-n*o*d+i*h*d+s*o*m-i*l*m)+f*(+r*l*m-r*h*d+n*a*d-s*a*m+s*h*u-n*l*u)+g*(+r*h*c-r*o*m-n*a*c+i*a*m+n*o*u-i*h*u)+y*(-s*o*u-r*l*c+r*o*d+s*a*c-i*a*d+i*l*u)}transpose(){const e=this.elements;let r;return r=e[1],e[1]=e[4],e[4]=r,r=e[2],e[2]=e[8],e[8]=r,r=e[6],e[6]=e[9],e[9]=r,r=e[3],e[3]=e[12],e[12]=r,r=e[7],e[7]=e[13],e[13]=r,r=e[11],e[11]=e[14],e[14]=r,this}setPosition(e,r,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=r,s[14]=i),this}invert(){const e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],m=e[11],p=e[12],f=e[13],g=e[14],y=e[15],T=c*g*h-f*d*h+f*l*m-o*g*m-c*l*y+o*d*y,S=p*d*h-u*g*h-p*l*m+a*g*m+u*l*y-a*d*y,w=u*f*h-p*c*h+p*o*m-a*f*m-u*o*y+a*c*y,_=p*c*l-u*f*l-p*o*d+a*f*d+u*o*g-a*c*g,M=r*T+i*S+s*w+n*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/M;return e[0]=T*E,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*E,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*E,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*E,e[4]=S*E,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*E,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*E,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*E,e[8]=w*E,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*E,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*E,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*E,e[12]=_*E,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*E,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*E,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*E,this}scale(e){const r=this.elements,i=e.x,s=e.y,n=e.z;return r[0]*=i,r[4]*=s,r[8]*=n,r[1]*=i,r[5]*=s,r[9]*=n,r[2]*=i,r[6]*=s,r[10]*=n,r[3]*=i,r[7]*=s,r[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(r,i,s))}makeTranslation(e,r,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,r,0,0,1,i,0,0,0,1),this}makeRotationX(e){const r=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,r,-i,0,0,i,r,0,0,0,0,1),this}makeRotationY(e){const r=Math.cos(e),i=Math.sin(e);return this.set(r,0,i,0,0,1,0,0,-i,0,r,0,0,0,0,1),this}makeRotationZ(e){const r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,0,i,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,r){const i=Math.cos(r),s=Math.sin(r),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,u=n*o;return this.set(h*a+i,h*o-s*l,h*l+s*o,0,h*o+s*l,u*o+i,u*l-s*a,0,h*l-s*o,u*l+s*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,r,i){return this.set(e,0,0,0,0,r,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,r,i,s,n,a){return this.set(1,i,n,0,e,1,a,0,r,s,1,0,0,0,0,1),this}compose(e,r,i){const s=this.elements,n=r._x,a=r._y,o=r._z,l=r._w,h=n+n,u=a+a,c=o+o,d=n*h,m=n*u,p=n*c,f=a*u,g=a*c,y=o*c,T=l*h,S=l*u,w=l*c,_=i.x,M=i.y,E=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-S)*_,s[3]=0,s[4]=(m-w)*M,s[5]=(1-(d+y))*M,s[6]=(g+T)*M,s[7]=0,s[8]=(p+S)*E,s[9]=(g-T)*E,s[10]=(1-(d+f))*E,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,r,i){const s=this.elements;let n=yh.set(s[0],s[1],s[2]).length();const a=yh.set(s[4],s[5],s[6]).length(),o=yh.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),e.x=s[12],e.y=s[13],e.z=s[14],rn.copy(this);const h=1/n,u=1/a,c=1/o;return rn.elements[0]*=h,rn.elements[1]*=h,rn.elements[2]*=h,rn.elements[4]*=u,rn.elements[5]*=u,rn.elements[6]*=u,rn.elements[8]*=c,rn.elements[9]*=c,rn.elements[10]*=c,r.setFromRotationMatrix(rn),i.x=n,i.y=a,i.z=o,this}makePerspective(e,r,i,s,n,a,o=va){const l=this.elements,h=2*n/(r-e),u=2*n/(i-s),c=(r+e)/(r-e),d=(i+s)/(i-s);let m,p;if(o===va)m=-(a+n)/(a-n),p=-2*a*n/(a-n);else if(o===Ru)m=-a/(a-n),p=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,r,i,s,n,a,o=va){const l=this.elements,h=1/(r-e),u=1/(i-s),c=1/(a-n),d=(r+e)*h,m=(i+s)*u;let p,f;if(o===va)p=(a+n)*c,f=-2*c;else if(o===Ru)p=n*c,f=-1*c;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=f,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const r=this.elements,i=e.elements;for(let s=0;s<16;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<16;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){const i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e[r+9]=i[9],e[r+10]=i[10],e[r+11]=i[11],e[r+12]=i[12],e[r+13]=i[13],e[r+14]=i[14],e[r+15]=i[15],e}}const yh=new $,rn=new Rt,eK=new $(0,0,0),tK=new $(1,1,1),no=new $,kp=new $,rs=new $,TM=new Rt,wM=new _m;class $u{constructor(e=0,r=0,i=0,s=$u.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=r,this._z=i,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,r,i,s=this._order){return this._x=e,this._y=r,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,r=this._order,i=!0){const s=e.elements,n=s[0],a=s[4],o=s[8],l=s[1],h=s[5],u=s[9],c=s[2],d=s[6],m=s[10];switch(r){case"XYZ":this._y=Math.asin(tt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-tt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(tt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,m),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-tt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(tt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-tt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+r)}return this._order=r,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,r,i){return TM.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TM,r,i)}setFromVector3(e,r=this._order){return this.set(e.x,e.y,e.z,r)}reorder(e){return wM.setFromEuler(this),this.setFromQuaternion(wM,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}$u.DEFAULT_ORDER="XYZ";class rK{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let iK=0;const SM=new $,xh=new _m,ca=new Rt,Up=new $,id=new $,sK=new $,nK=new _m,MM=new $(1,0,0),_M=new $(0,1,0),NM=new $(0,0,1),EM={type:"added"},aK={type:"removed"},bh={type:"childadded",child:null},X0={type:"childremoved",child:null};class yn extends Du{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:iK++}),this.uuid=Ca(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=yn.DEFAULT_UP.clone();const e=new $,r=new $u,i=new _m,s=new $(1,1,1);function n(){i.setFromEuler(r,!1)}function a(){r.setFromQuaternion(i,void 0,!1)}r._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:r},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Rt},normalMatrix:{value:new qs}}),this.matrix=new Rt,this.matrixWorld=new Rt,this.matrixAutoUpdate=yn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=yn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rK,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,r){this.quaternion.setFromAxisAngle(e,r)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,r){return xh.setFromAxisAngle(e,r),this.quaternion.multiply(xh),this}rotateOnWorldAxis(e,r){return xh.setFromAxisAngle(e,r),this.quaternion.premultiply(xh),this}rotateX(e){return this.rotateOnAxis(MM,e)}rotateY(e){return this.rotateOnAxis(_M,e)}rotateZ(e){return this.rotateOnAxis(NM,e)}translateOnAxis(e,r){return SM.copy(e).applyQuaternion(this.quaternion),this.position.add(SM.multiplyScalar(r)),this}translateX(e){return this.translateOnAxis(MM,e)}translateY(e){return this.translateOnAxis(_M,e)}translateZ(e){return this.translateOnAxis(NM,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ca.copy(this.matrixWorld).invert())}lookAt(e,r,i){e.isVector3?Up.copy(e):Up.set(e,r,i);const s=this.parent;this.updateWorldMatrix(!0,!1),id.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ca.lookAt(id,Up,this.up):ca.lookAt(Up,id,this.up),this.quaternion.setFromRotationMatrix(ca),s&&(ca.extractRotation(s.matrixWorld),xh.setFromRotationMatrix(ca),this.quaternion.premultiply(xh.invert()))}add(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(EM),bh.child=e,this.dispatchEvent(bh),bh.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const r=this.children.indexOf(e);return r!==-1&&(e.parent=null,this.children.splice(r,1),e.dispatchEvent(aK),X0.child=e,this.dispatchEvent(X0),X0.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ca.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ca.multiply(e.parent.matrixWorld)),e.applyMatrix4(ca),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(EM),bh.child=e,this.dispatchEvent(bh),bh.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,r){if(this[e]===r)return this;for(let i=0,s=this.children.length;i<s;i++){const a=this.children[i].getObjectByProperty(e,r);if(a!==void 0)return a}}getObjectsByProperty(e,r,i=[]){this[e]===r&&i.push(this);const s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].getObjectsByProperty(e,r,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(id,e,sK),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(id,nK,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const r=this.matrixWorld.elements;return e.set(r[8],r[9],r[10]).normalize()}raycast(){}traverse(e){e(this);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].traverseVisible(e)}traverseAncestors(e){const r=this.parent;r!==null&&(e(r),r.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].updateMatrixWorld(e)}updateWorldMatrix(e,r){const i=this.parent;if(e===!0&&i!==null&&i.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)),r===!0){const s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(e){const r=e===void 0||typeof e=="string",i={};r&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,u=l.length;h<u;h++){const c=l[h];n(e.shapes,c)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(e.materials,this.material[l]));s.material=o}else s.material=n(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(n(e.animations,l))}}if(r){const o=a(e.geometries),l=a(e.materials),h=a(e.textures),u=a(e.images),c=a(e.shapes),d=a(e.skeletons),m=a(e.animations),p=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),u.length>0&&(i.images=u),c.length>0&&(i.shapes=c),d.length>0&&(i.skeletons=d),m.length>0&&(i.animations=m),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const h in o){const u=o[h];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,r=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let i=0;i<e.children.length;i++){const s=e.children[i];this.add(s.clone())}return this}}yn.DEFAULT_UP=new $(0,1,0);yn.DEFAULT_MATRIX_AUTO_UPDATE=!0;yn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const sn=new $,da=new $,Y0=new $,ma=new $,vh=new $,Th=new $,AM=new $,Z0=new $,J0=new $,K0=new $,Q0=new Si,ex=new Si,tx=new Si;class hn{constructor(e=new $,r=new $,i=new $){this.a=e,this.b=r,this.c=i}static getNormal(e,r,i,s){s.subVectors(i,r),sn.subVectors(e,r),s.cross(sn);const n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(e,r,i,s,n){sn.subVectors(s,r),da.subVectors(i,r),Y0.subVectors(e,r);const a=sn.dot(sn),o=sn.dot(da),l=sn.dot(Y0),h=da.dot(da),u=da.dot(Y0),c=a*h-o*o;if(c===0)return n.set(0,0,0),null;const d=1/c,m=(h*l-o*u)*d,p=(a*u-o*l)*d;return n.set(1-m-p,p,m)}static containsPoint(e,r,i,s){return this.getBarycoord(e,r,i,s,ma)===null?!1:ma.x>=0&&ma.y>=0&&ma.x+ma.y<=1}static getInterpolation(e,r,i,s,n,a,o,l){return this.getBarycoord(e,r,i,s,ma)===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(n,ma.x),l.addScaledVector(a,ma.y),l.addScaledVector(o,ma.z),l)}static getInterpolatedAttribute(e,r,i,s,n,a){return Q0.setScalar(0),ex.setScalar(0),tx.setScalar(0),Q0.fromBufferAttribute(e,r),ex.fromBufferAttribute(e,i),tx.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Q0,n.x),a.addScaledVector(ex,n.y),a.addScaledVector(tx,n.z),a}static isFrontFacing(e,r,i,s){return sn.subVectors(i,r),da.subVectors(e,r),sn.cross(da).dot(s)<0}set(e,r,i){return this.a.copy(e),this.b.copy(r),this.c.copy(i),this}setFromPointsAndIndices(e,r,i,s){return this.a.copy(e[r]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,r,i,s){return this.a.fromBufferAttribute(e,r),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return sn.subVectors(this.c,this.b),da.subVectors(this.a,this.b),sn.cross(da).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return hn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,r){return hn.getBarycoord(e,this.a,this.b,this.c,r)}getInterpolation(e,r,i,s,n){return hn.getInterpolation(e,this.a,this.b,this.c,r,i,s,n)}containsPoint(e){return hn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return hn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,r){const i=this.a,s=this.b,n=this.c;let a,o;vh.subVectors(s,i),Th.subVectors(n,i),Z0.subVectors(e,i);const l=vh.dot(Z0),h=Th.dot(Z0);if(l<=0&&h<=0)return r.copy(i);J0.subVectors(e,s);const u=vh.dot(J0),c=Th.dot(J0);if(u>=0&&c<=u)return r.copy(s);const d=l*c-u*h;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),r.copy(i).addScaledVector(vh,a);K0.subVectors(e,n);const m=vh.dot(K0),p=Th.dot(K0);if(p>=0&&m<=p)return r.copy(n);const f=m*h-l*p;if(f<=0&&h>=0&&p<=0)return o=h/(h-p),r.copy(i).addScaledVector(Th,o);const g=u*p-m*c;if(g<=0&&c-u>=0&&m-p>=0)return AM.subVectors(n,s),o=(c-u)/(c-u+(m-p)),r.copy(s).addScaledVector(AM,o);const y=1/(g+f+d);return a=f*y,o=d*y,r.copy(i).addScaledVector(vh,a).addScaledVector(Th,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const o3={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},ao={h:0,s:0,l:0},Dp={h:0,s:0,l:0};function rx(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*6*(2/3-r):t}class ja{constructor(e,r,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,r,i)}set(e,r,i){if(r===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,r,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,r=Ps){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,or.colorSpaceToWorking(this,r),this}setRGB(e,r,i,s=or.workingColorSpace){return this.r=e,this.g=r,this.b=i,or.colorSpaceToWorking(this,s),this}setHSL(e,r,i,s=or.workingColorSpace){if(e=Wv(e,1),r=tt(r,0,1),i=tt(i,0,1),r===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+r):i+r-i*r,a=2*i-n;this.r=rx(a,n,e+1/3),this.g=rx(a,n,e),this.b=rx(a,n,e-1/3)}return or.colorSpaceToWorking(this,s),this}setStyle(e,r=Ps){function i(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,r);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,r);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=s[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,r);if(a===6)return this.setHex(parseInt(n,16),r);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,r);return this}setColorName(e,r=Ps){const i=o3[e.toLowerCase()];return i!==void 0?this.setHex(i,r):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ra(e.r),this.g=Ra(e.g),this.b=Ra(e.b),this}copyLinearToSRGB(e){return this.r=tc(e.r),this.g=tc(e.g),this.b=tc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ps){return or.workingToColorSpace(mi.copy(this),e),Math.round(tt(mi.r*255,0,255))*65536+Math.round(tt(mi.g*255,0,255))*256+Math.round(tt(mi.b*255,0,255))}getHexString(e=Ps){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,r=or.workingColorSpace){or.workingToColorSpace(mi.copy(this),r);const i=mi.r,s=mi.g,n=mi.b,a=Math.max(i,s,n),o=Math.min(i,s,n);let l,h;const u=(o+a)/2;if(o===a)l=0,h=0;else{const c=a-o;switch(h=u<=.5?c/(a+o):c/(2-a-o),a){case i:l=(s-n)/c+(s<n?6:0);break;case s:l=(n-i)/c+2;break;case n:l=(i-s)/c+4;break}l/=6}return e.h=l,e.s=h,e.l=u,e}getRGB(e,r=or.workingColorSpace){return or.workingToColorSpace(mi.copy(this),r),e.r=mi.r,e.g=mi.g,e.b=mi.b,e}getStyle(e=Ps){or.workingToColorSpace(mi.copy(this),e);const r=mi.r,i=mi.g,s=mi.b;return e!==Ps?`color(${e} ${r.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(r*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,r,i){return this.getHSL(ao),this.setHSL(ao.h+e,ao.s+r,ao.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,r){return this.r=e.r+r.r,this.g=e.g+r.g,this.b=e.b+r.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,r){return this.r+=(e.r-this.r)*r,this.g+=(e.g-this.g)*r,this.b+=(e.b-this.b)*r,this}lerpColors(e,r,i){return this.r=e.r+(r.r-e.r)*i,this.g=e.g+(r.g-e.g)*i,this.b=e.b+(r.b-e.b)*i,this}lerpHSL(e,r){this.getHSL(ao),e.getHSL(Dp);const i=zd(ao.h,Dp.h,r),s=zd(ao.s,Dp.s,r),n=zd(ao.l,Dp.l,r);return this.setHSL(i,s,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const r=this.r,i=this.g,s=this.b,n=e.elements;return this.r=n[0]*r+n[3]*i+n[6]*s,this.g=n[1]*r+n[4]*i+n[7]*s,this.b=n[2]*r+n[5]*i+n[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,r=0){return this.r=e[r],this.g=e[r+1],this.b=e[r+2],this}toArray(e=[],r=0){return e[r]=this.r,e[r+1]=this.g,e[r+2]=this.b,e}fromBufferAttribute(e,r){return this.r=e.getX(r),this.g=e.getY(r),this.b=e.getZ(r),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const mi=new ja;ja.NAMES=o3;let oK=0;class Fb extends Du{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:oK++}),this.uuid=Ca(),this.name="",this.type="Material",this.blending=Ib,this.side=Pb,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=aM,this.blendDst=oM,this.blendEquation=nM,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ja(0,0,0),this.blendAlpha=0,this.depthFunc=lM,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pM,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=dh,this.stencilZFail=dh,this.stencilZPass=dh,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const r in e){const i=e[r];if(i===void 0){console.warn(`THREE.Material: parameter '${r}' has value of undefined.`);continue}const s=this[r];if(s===void 0){console.warn(`THREE.Material: '${r}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[r]=i}}toJSON(e){const r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ib&&(i.blending=this.blending),this.side!==Pb&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==aM&&(i.blendSrc=this.blendSrc),this.blendDst!==oM&&(i.blendDst=this.blendDst),this.blendEquation!==nM&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==lM&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==pM&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==dh&&(i.stencilFail=this.stencilFail),this.stencilZFail!==dh&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==dh&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(r){const n=s(e.textures),a=s(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const r=e.clippingPlanes;let i=null;if(r!==null){const s=r.length;i=new Array(s);for(let n=0;n!==s;++n)i[n]=r[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class l3 extends Fb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ja(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 $u,this.combine=SJ,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const wr=new $,$p=new Jt;let lK=0;class Bs{constructor(e,r,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lK++}),this.name="",this.array=e,this.itemSize=r,this.count=e!==void 0?e.length/r:0,this.normalized=i,this.usage=ug,this.updateRanges=[],this.gpuType=gc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,r){this.updateRanges.push({start:e,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,r,i){e*=this.itemSize,i*=r.itemSize;for(let s=0,n=this.itemSize;s<n;s++)this.array[e+s]=r.array[i+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let r=0,i=this.count;r<i;r++)$p.fromBufferAttribute(this,r),$p.applyMatrix3(e),this.setXY(r,$p.x,$p.y);else if(this.itemSize===3)for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.applyMatrix3(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}applyMatrix4(e){for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.applyMatrix4(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}applyNormalMatrix(e){for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.applyNormalMatrix(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}transformDirection(e){for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.transformDirection(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}set(e,r=0){return this.array.set(e,r),this}getComponent(e,r){let i=this.array[e*this.itemSize+r];return this.normalized&&(i=un(i,this.array)),i}setComponent(e,r,i){return this.normalized&&(i=St(i,this.array)),this.array[e*this.itemSize+r]=i,this}getX(e){let r=this.array[e*this.itemSize];return this.normalized&&(r=un(r,this.array)),r}setX(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize]=r,this}getY(e){let r=this.array[e*this.itemSize+1];return this.normalized&&(r=un(r,this.array)),r}setY(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize+1]=r,this}getZ(e){let r=this.array[e*this.itemSize+2];return this.normalized&&(r=un(r,this.array)),r}setZ(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize+2]=r,this}getW(e){let r=this.array[e*this.itemSize+3];return this.normalized&&(r=un(r,this.array)),r}setW(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize+3]=r,this}setXY(e,r,i){return e*=this.itemSize,this.normalized&&(r=St(r,this.array),i=St(i,this.array)),this.array[e+0]=r,this.array[e+1]=i,this}setXYZ(e,r,i,s){return e*=this.itemSize,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array)),this.array[e+0]=r,this.array[e+1]=i,this.array[e+2]=s,this}setXYZW(e,r,i,s,n){return e*=this.itemSize,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array),n=St(n,this.array)),this.array[e+0]=r,this.array[e+1]=i,this.array[e+2]=s,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ug&&(e.usage=this.usage),e}}class uK extends Bs{constructor(e,r,i){super(new Uint16Array(e),r,i)}}class hK extends Bs{constructor(e,r,i){super(new Uint32Array(e),r,i)}}class rc extends Bs{constructor(e,r,i){super(new Float32Array(e),r,i)}}let cK=0;const Ms=new Rt,ix=new yn,wh=new $,is=new Em,sd=new Em,Zr=new $;class Cc extends Du{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cK++}),this.uuid=Ca(),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(e){return Array.isArray(e)?this.index=new(HJ(e)?hK:uK)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,r){return this.attributes[e]=r,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,r,i=0){this.groups.push({start:e,count:r,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,r){this.drawRange.start=e,this.drawRange.count=r}applyMatrix4(e){const r=this.attributes.position;r!==void 0&&(r.applyMatrix4(e),r.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new qs().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ms.makeRotationFromQuaternion(e),this.applyMatrix4(Ms),this}rotateX(e){return Ms.makeRotationX(e),this.applyMatrix4(Ms),this}rotateY(e){return Ms.makeRotationY(e),this.applyMatrix4(Ms),this}rotateZ(e){return Ms.makeRotationZ(e),this.applyMatrix4(Ms),this}translate(e,r,i){return Ms.makeTranslation(e,r,i),this.applyMatrix4(Ms),this}scale(e,r,i){return Ms.makeScale(e,r,i),this.applyMatrix4(Ms),this}lookAt(e){return ix.lookAt(e),ix.updateMatrix(),this.applyMatrix4(ix.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wh).negate(),this.translate(wh.x,wh.y,wh.z),this}setFromPoints(e){const r=this.getAttribute("position");if(r===void 0){const i=[];for(let s=0,n=e.length;s<n;s++){const a=e[s];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new rc(i,3))}else{const i=Math.min(e.length,r.count);for(let s=0;s<i;s++){const n=e[s];r.setXYZ(s,n.x,n.y,n.z||0)}e.length>r.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),r.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Em);const e=this.attributes.position,r=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new $(-1/0,-1/0,-1/0),new $(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),r)for(let i=0,s=r.length;i<s;i++){const n=r[i];is.setFromBufferAttribute(n),this.morphTargetsRelative?(Zr.addVectors(this.boundingBox.min,is.min),this.boundingBox.expandByPoint(Zr),Zr.addVectors(this.boundingBox.max,is.max),this.boundingBox.expandByPoint(Zr)):(this.boundingBox.expandByPoint(is.min),this.boundingBox.expandByPoint(is.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 qv);const e=this.attributes.position,r=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new $,1/0);return}if(e){const i=this.boundingSphere.center;if(is.setFromBufferAttribute(e),r)for(let n=0,a=r.length;n<a;n++){const o=r[n];sd.setFromBufferAttribute(o),this.morphTargetsRelative?(Zr.addVectors(is.min,sd.min),is.expandByPoint(Zr),Zr.addVectors(is.max,sd.max),is.expandByPoint(Zr)):(is.expandByPoint(sd.min),is.expandByPoint(sd.max))}is.getCenter(i);let s=0;for(let n=0,a=e.count;n<a;n++)Zr.fromBufferAttribute(e,n),s=Math.max(s,i.distanceToSquared(Zr));if(r)for(let n=0,a=r.length;n<a;n++){const o=r[n],l=this.morphTargetsRelative;for(let h=0,u=o.count;h<u;h++)Zr.fromBufferAttribute(o,h),l&&(wh.fromBufferAttribute(e,h),Zr.add(wh)),s=Math.max(s,i.distanceToSquared(Zr))}this.boundingSphere.radius=Math.sqrt(s),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 e=this.index,r=this.attributes;if(e===null||r.position===void 0||r.normal===void 0||r.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=r.position,s=r.normal,n=r.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Bs(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let A=0;A<i.count;A++)o[A]=new $,l[A]=new $;const h=new $,u=new $,c=new $,d=new Jt,m=new Jt,p=new Jt,f=new $,g=new $;function y(A,U,Q){h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,U),c.fromBufferAttribute(i,Q),d.fromBufferAttribute(n,A),m.fromBufferAttribute(n,U),p.fromBufferAttribute(n,Q),u.sub(h),c.sub(h),m.sub(d),p.sub(d);const J=1/(m.x*p.y-p.x*m.y);isFinite(J)&&(f.copy(u).multiplyScalar(p.y).addScaledVector(c,-m.y).multiplyScalar(J),g.copy(c).multiplyScalar(m.x).addScaledVector(u,-p.x).multiplyScalar(J),o[A].add(f),o[U].add(f),o[Q].add(f),l[A].add(g),l[U].add(g),l[Q].add(g))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let A=0,U=T.length;A<U;++A){const Q=T[A],J=Q.start,re=Q.count;for(let ie=J,se=J+re;ie<se;ie+=3)y(e.getX(ie+0),e.getX(ie+1),e.getX(ie+2))}const S=new $,w=new $,_=new $,M=new $;function E(A){_.fromBufferAttribute(s,A),M.copy(_);const U=o[A];S.copy(U),S.sub(_.multiplyScalar(_.dot(U))).normalize(),w.crossVectors(M,U);const J=w.dot(l[A])<0?-1:1;a.setXYZW(A,S.x,S.y,S.z,J)}for(let A=0,U=T.length;A<U;++A){const Q=T[A],J=Q.start,re=Q.count;for(let ie=J,se=J+re;ie<se;ie+=3)E(e.getX(ie+0)),E(e.getX(ie+1)),E(e.getX(ie+2))}}computeVertexNormals(){const e=this.index,r=this.getAttribute("position");if(r!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Bs(new Float32Array(r.count*3),3),this.setAttribute("normal",i);else for(let d=0,m=i.count;d<m;d++)i.setXYZ(d,0,0,0);const s=new $,n=new $,a=new $,o=new $,l=new $,h=new $,u=new $,c=new $;if(e)for(let d=0,m=e.count;d<m;d+=3){const p=e.getX(d+0),f=e.getX(d+1),g=e.getX(d+2);s.fromBufferAttribute(r,p),n.fromBufferAttribute(r,f),a.fromBufferAttribute(r,g),u.subVectors(a,n),c.subVectors(s,n),u.cross(c),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,f),h.fromBufferAttribute(i,g),o.add(u),l.add(u),h.add(u),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(f,l.x,l.y,l.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let d=0,m=r.count;d<m;d+=3)s.fromBufferAttribute(r,d+0),n.fromBufferAttribute(r,d+1),a.fromBufferAttribute(r,d+2),u.subVectors(a,n),c.subVectors(s,n),u.cross(c),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let r=0,i=e.count;r<i;r++)Zr.fromBufferAttribute(e,r),Zr.normalize(),e.setXYZ(r,Zr.x,Zr.y,Zr.z)}toNonIndexed(){function e(o,l){const h=o.array,u=o.itemSize,c=o.normalized,d=new h.constructor(l.length*u);let m=0,p=0;for(let f=0,g=l.length;f<g;f++){o.isInterleavedBufferAttribute?m=l[f]*o.data.stride+o.offset:m=l[f]*u;for(let y=0;y<u;y++)d[p++]=h[m++]}return new Bs(d,u,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const r=new Cc,i=this.index.array,s=this.attributes;for(const o in s){const l=s[o],h=e(l,i);r.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let u=0,c=h.length;u<c;u++){const d=h[u],m=e(d,i);l.push(m)}r.morphAttributes[o]=l}r.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];r.addGroup(h.start,h.count,h.materialIndex)}return r}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const r=this.index;r!==null&&(e.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const s={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],u=[];for(let c=0,d=h.length;c<d;c++){const m=h[c];u.push(m.toJSON(e.data))}u.length>0&&(s[l]=u,n=!0)}n&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const r={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const h in s){const u=s[h];this.setAttribute(h,u.clone(r))}const n=e.morphAttributes;for(const h in n){const u=[],c=n[h];for(let d=0,m=c.length;d<m;d++)u.push(c[d].clone(r));this.morphAttributes[h]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,u=a.length;h<u;h++){const c=a[h];this.addGroup(c.start,c.count,c.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const CM=new Rt,sl=new QJ,Gp=new qv,RM=new $,jp=new $,Wp=new $,Hp=new $,sx=new $,qp=new $,PM=new $,Xp=new $;class cg extends yn{constructor(e=new Cc,r=new l3){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=r,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,r){return super.copy(e,r),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const r=this.geometry.morphAttributes,i=Object.keys(r);if(i.length>0){const s=r[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,a=s.length;n<a;n++){const o=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}getVertexPosition(e,r){const i=this.geometry,s=i.attributes.position,n=i.morphAttributes.position,a=i.morphTargetsRelative;r.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(n&&o){qp.set(0,0,0);for(let l=0,h=n.length;l<h;l++){const u=o[l],c=n[l];u!==0&&(sx.fromBufferAttribute(c,e),a?qp.addScaledVector(sx,u):qp.addScaledVector(sx.sub(r),u))}r.add(qp)}return r}raycast(e,r){const i=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Gp.copy(i.boundingSphere),Gp.applyMatrix4(n),sl.copy(e.ray).recast(e.near),!(Gp.containsPoint(sl.origin)===!1&&(sl.intersectSphere(Gp,RM)===null||sl.origin.distanceToSquared(RM)>(e.far-e.near)**2))&&(CM.copy(n).invert(),sl.copy(e.ray).applyMatrix4(CM),!(i.boundingBox!==null&&sl.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,r,sl)))}_computeIntersections(e,r,i){let s;const n=this.geometry,a=this.material,o=n.index,l=n.attributes.position,h=n.attributes.uv,u=n.attributes.uv1,c=n.attributes.normal,d=n.groups,m=n.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,f=d.length;p<f;p++){const g=d[p],y=a[g.materialIndex],T=Math.max(g.start,m.start),S=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=S;w<_;w+=3){const M=o.getX(w),E=o.getX(w+1),A=o.getX(w+2);s=Yp(this,y,e,i,h,u,c,M,E,A),s&&(s.faceIndex=Math.floor(w/3),s.face.materialIndex=g.materialIndex,r.push(s))}}else{const p=Math.max(0,m.start),f=Math.min(o.count,m.start+m.count);for(let g=p,y=f;g<y;g+=3){const T=o.getX(g),S=o.getX(g+1),w=o.getX(g+2);s=Yp(this,a,e,i,h,u,c,T,S,w),s&&(s.faceIndex=Math.floor(g/3),r.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,f=d.length;p<f;p++){const g=d[p],y=a[g.materialIndex],T=Math.max(g.start,m.start),S=Math.min(l.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=S;w<_;w+=3){const M=w,E=w+1,A=w+2;s=Yp(this,y,e,i,h,u,c,M,E,A),s&&(s.faceIndex=Math.floor(w/3),s.face.materialIndex=g.materialIndex,r.push(s))}}else{const p=Math.max(0,m.start),f=Math.min(l.count,m.start+m.count);for(let g=p,y=f;g<y;g+=3){const T=g,S=g+1,w=g+2;s=Yp(this,a,e,i,h,u,c,T,S,w),s&&(s.faceIndex=Math.floor(g/3),r.push(s))}}}}function dK(t,e,r,i,s,n,a,o){let l;if(e.side===oy?l=i.intersectTriangle(a,n,s,!0,o):l=i.intersectTriangle(s,n,a,e.side===Pb,o),l===null)return null;Xp.copy(o),Xp.applyMatrix4(t.matrixWorld);const h=r.ray.origin.distanceTo(Xp);return h<r.near||h>r.far?null:{distance:h,point:Xp.clone(),object:t}}function Yp(t,e,r,i,s,n,a,o,l,h){t.getVertexPosition(o,jp),t.getVertexPosition(l,Wp),t.getVertexPosition(h,Hp);const u=dK(t,e,r,i,jp,Wp,Hp,PM);if(u){const c=new $;hn.getBarycoord(PM,jp,Wp,Hp,c),s&&(u.uv=hn.getInterpolatedAttribute(s,o,l,h,c,new Jt)),n&&(u.uv1=hn.getInterpolatedAttribute(n,o,l,h,c,new Jt)),a&&(u.normal=hn.getInterpolatedAttribute(a,o,l,h,c,new $),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c:h,normal:new $,materialIndex:0};hn.getNormal(jp,Wp,Hp,d.normal),u.face=d,u.barycoord=c}return u}class Xv extends Cc{constructor(e=1,r=1,i=1,s=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:r,depth:i,widthSegments:s,heightSegments:n,depthSegments:a};const o=this;s=Math.floor(s),n=Math.floor(n),a=Math.floor(a);const l=[],h=[],u=[],c=[];let d=0,m=0;p("z","y","x",-1,-1,i,r,e,a,n,0),p("z","y","x",1,-1,i,r,-e,a,n,1),p("x","z","y",1,1,e,i,r,s,a,2),p("x","z","y",1,-1,e,i,-r,s,a,3),p("x","y","z",1,-1,e,r,i,s,n,4),p("x","y","z",-1,-1,e,r,-i,s,n,5),this.setIndex(l),this.setAttribute("position",new rc(h,3)),this.setAttribute("normal",new rc(u,3)),this.setAttribute("uv",new rc(c,2));function p(f,g,y,T,S,w,_,M,E,A,U){const Q=w/E,J=_/A,re=w/2,ie=_/2,se=M/2,ve=E+1,me=A+1;let Me=0,ye=0;const Te=new $;for(let ge=0;ge<me;ge++){const be=ge*J-ie;for(let Je=0;Je<ve;Je++){const wt=Je*Q-re;Te[f]=wt*T,Te[g]=be*S,Te[y]=se,h.push(Te.x,Te.y,Te.z),Te[f]=0,Te[g]=0,Te[y]=M>0?1:-1,u.push(Te.x,Te.y,Te.z),c.push(Je/E),c.push(1-ge/A),Me+=1}}for(let ge=0;ge<A;ge++)for(let be=0;be<E;be++){const Je=d+be+ve*ge,wt=d+be+ve*(ge+1),Bt=d+(be+1)+ve*(ge+1),He=d+(be+1)+ve*ge;l.push(Je,wt,He),l.push(wt,Bt,He),ye+=6}o.addGroup(m,ye,U),m+=ye,d+=Me}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class u3 extends yn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=va}copy(e,r){return super.copy(e,r),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const oo=new $,IM=new Jt,VM=new Jt;class mK extends u3{constructor(e=50,r=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=r,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,r){return super.copy(e,r),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const r=.5*this.getFilmHeight()/e;this.fov=hg*2*Math.atan(r),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Fd*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return hg*2*Math.atan(Math.tan(Fd*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,r,i){oo.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(oo.x,oo.y).multiplyScalar(-e/oo.z),oo.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(oo.x,oo.y).multiplyScalar(-e/oo.z)}getViewSize(e,r){return this.getViewBounds(e,IM,VM),r.subVectors(VM,IM)}setViewOffset(e,r,i,s,n,a){this.aspect=e/r,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=r,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let r=e*Math.tan(Fd*.5*this.fov)/this.zoom,i=2*r,s=this.aspect*i,n=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,h=a.fullHeight;n+=a.offsetX*s/l,r-=a.offsetY*i/h,s*=a.width/l,i*=a.height/h}const o=this.filmOffset;o!==0&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+s,r,r-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const r=super.toJSON(e);return r.object.fov=this.fov,r.object.zoom=this.zoom,r.object.near=this.near,r.object.far=this.far,r.object.focus=this.focus,r.object.aspect=this.aspect,this.view!==null&&(r.object.view=Object.assign({},this.view)),r.object.filmGauge=this.filmGauge,r.object.filmOffset=this.filmOffset,r}}class pK extends vi{constructor(e=[],r=ag,i,s,n,a,o,l,h,u){super(e,r,i,s,n,a,o,l,h,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class h3{constructor(e,r){this.isInterleavedBuffer=!0,this.array=e,this.stride=r,this.count=e!==void 0?e.length/r:0,this.usage=ug,this.updateRanges=[],this.version=0,this.uuid=Ca()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,r){this.updateRanges.push({start:e,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,r,i){e*=this.stride,i*=r.stride;for(let s=0,n=this.stride;s<n;s++)this.array[e+s]=r.array[i+s];return this}set(e,r=0){return this.array.set(e,r),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const r=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(r,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ai=new $;class Yv{constructor(e,r,i,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=r,this.offset=i,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let r=0,i=this.data.count;r<i;r++)Ai.fromBufferAttribute(this,r),Ai.applyMatrix4(e),this.setXYZ(r,Ai.x,Ai.y,Ai.z);return this}applyNormalMatrix(e){for(let r=0,i=this.count;r<i;r++)Ai.fromBufferAttribute(this,r),Ai.applyNormalMatrix(e),this.setXYZ(r,Ai.x,Ai.y,Ai.z);return this}transformDirection(e){for(let r=0,i=this.count;r<i;r++)Ai.fromBufferAttribute(this,r),Ai.transformDirection(e),this.setXYZ(r,Ai.x,Ai.y,Ai.z);return this}getComponent(e,r){let i=this.array[e*this.data.stride+this.offset+r];return this.normalized&&(i=un(i,this.array)),i}setComponent(e,r,i){return this.normalized&&(i=St(i,this.array)),this.data.array[e*this.data.stride+this.offset+r]=i,this}setX(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset]=r,this}setY(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset+1]=r,this}setZ(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset+2]=r,this}setW(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset+3]=r,this}getX(e){let r=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(r=un(r,this.array)),r}getY(e){let r=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(r=un(r,this.array)),r}getZ(e){let r=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(r=un(r,this.array)),r}getW(e){let r=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(r=un(r,this.array)),r}setXY(e,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(r=St(r,this.array),i=St(i,this.array)),this.data.array[e+0]=r,this.data.array[e+1]=i,this}setXYZ(e,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array)),this.data.array[e+0]=r,this.data.array[e+1]=i,this.data.array[e+2]=s,this}setXYZW(e,r,i,s,n){return e=e*this.data.stride+this.offset,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array),n=St(n,this.array)),this.data.array[e+0]=r,this.data.array[e+1]=i,this.data.array[e+2]=s,this.data.array[e+3]=n,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const r=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)r.push(this.data.array[s+n])}return new Bs(new this.array.constructor(r),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Yv(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const r=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)r.push(this.data.array[s+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:r,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class em extends vi{constructor(e=null,r=1,i=1,s,n,a,o,l,h=$s,u=$s,c,d){super(null,a,o,l,h,u,s,n,c,d),this.isDataTexture=!0,this.image={data:e,width:r,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ic extends Bs{constructor(e,r,i,s=1){super(e,r,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const nx=new $,fK=new $,gK=new qs;class yK{constructor(e=new $(1,0,0),r=0){this.isPlane=!0,this.normal=e,this.constant=r}set(e,r){return this.normal.copy(e),this.constant=r,this}setComponents(e,r,i,s){return this.normal.set(e,r,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,r){return this.normal.copy(e),this.constant=-r.dot(this.normal),this}setFromCoplanarPoints(e,r,i){const s=nx.subVectors(i,r).cross(fK.subVectors(e,r)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,r){return r.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,r){const i=e.delta(nx),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(e.start)===0?r.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/s;return n<0||n>1?null:r.copy(e.start).addScaledVector(i,n)}intersectsLine(e){const r=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return r<0&&i>0||i<0&&r>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,r){const i=r||gK.getNormalMatrix(e),s=this.coplanarPoint(nx).applyMatrix4(e),n=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(n),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}class c3 extends vi{constructor(e,r){super({width:e,height:r}),this.isFramebufferTexture=!0,this.magFilter=$s,this.minFilter=$s,this.generateMipmaps=!1,this.needsUpdate=!0}}class Am extends vi{constructor(e,r,i=n3,s,n,a,o=$s,l=$s,h,u=cM,c=1){if(u!==cM&&u!==EJ)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:r,depth:c};super(d,s,n,a,o,l,u,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Hv(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const r=super.toJSON(e);return this.compareFunction!==null&&(r.compareFunction=this.compareFunction),r}}const OM={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class xK{constructor(e,r,i){const s=this;let n=!1,a=0,o=0,l;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=r,this.onError=i,this.itemStart=function(u){o++,n===!1&&s.onStart!==void 0&&s.onStart(u,a,o),n=!0},this.itemEnd=function(u){a++,s.onProgress!==void 0&&s.onProgress(u,a,o),a===o&&(n=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(u){s.onError!==void 0&&s.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,c){return h.push(u,c),this},this.removeHandler=function(u){const c=h.indexOf(u);return c!==-1&&h.splice(c,2),this},this.getHandler=function(u){for(let c=0,d=h.length;c<d;c+=2){const m=h[c],p=h[c+1];if(m.global&&(m.lastIndex=0),m.test(u))return p}return null}}}const bK=new xK;class Zv{constructor(e){this.manager=e!==void 0?e:bK,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,r){const i=this;return new Promise(function(s,n){i.load(e,s,r,n)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Zv.DEFAULT_MATERIAL_NAME="__DEFAULT";class vK extends Zv{constructor(e){super(e)}load(e,r,i,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=OM.get(e);if(a!==void 0)return n.manager.itemStart(e),setTimeout(function(){r&&r(a),n.manager.itemEnd(e)},0),a;const o=Lb("img");function l(){u(),OM.add(e,this),r&&r(this),n.manager.itemEnd(e)}function h(c){u(),s&&s(c),n.manager.itemError(e),n.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),n.manager.itemStart(e),o.src=e,o}}class TK extends Zv{constructor(e){super(e)}load(e,r,i,s){const n=new vi,a=new vK(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){n.image=o,n.needsUpdate=!0,r!==void 0&&r(n)},i,s),n}}class d3 extends u3{constructor(e=-1,r=1,i=1,s=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=r,this.top=i,this.bottom=s,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(e,r){return super.copy(e,r),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,r,i,s,n,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=r,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),r=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let n=i-e,a=i+e,o=s+r,l=s-r;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,a=n+h*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(n,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const r=super.toJSON(e);return r.object.zoom=this.zoom,r.object.left=this.left,r.object.right=this.right,r.object.top=this.top,r.object.bottom=this.bottom,r.object.near=this.near,r.object.far=this.far,this.view!==null&&(r.object.view=Object.assign({},this.view)),r}}class wK extends h3{constructor(e,r,i=1){super(e,r),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const r=super.clone(e);return r.meshPerAttribute=this.meshPerAttribute,r}toJSON(e){const r=super.toJSON(e);return r.isInstancedInterleavedBuffer=!0,r.meshPerAttribute=this.meshPerAttribute,r}}class Jv{constructor(e,r,i,s){Jv.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,r,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,r=0){for(let i=0;i<4;i++)this.elements[i]=e[i+r];return this}set(e,r,i,s){const n=this.elements;return n[0]=e,n[2]=r,n[1]=i,n[3]=s,this}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:r3}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=r3);const El={name:"Ascii",category:"Effects",requiresRTT:!0,props:{characters:{default:"@%#*+=-:.",description:"Characters to use for ASCII effect (light to dark)",ui:{type:"text",label:"Characters"}},cellSize:{default:30,description:"Size of each ASCII character cell in pixels",ui:{type:"range",min:8,max:100,step:1,label:"Cell Size"}},fontFamily:{default:"jetbrains mono",description:"Font family for characters",ui:{type:"select",options:[{label:"JetBrains Mono",value:"jetbrains mono"},{label:"Courier New",value:"courier new"},{label:"Monaco",value:"monaco"},{label:"Consolas",value:"consolas"}],label:"Font Family"}},spacing:{default:1,description:"Character padding within each cell (1.0 = no padding, 0.5 = 50% padding)",ui:{type:"range",min:.1,max:1,step:.05,label:"Spacing"}}},fragmentNode:({uniforms:t,childNode:e,onCleanup:r,onBeforeRender:i,dimensions:s})=>{let{vec2:n,vec3:a,vec4:o,floor:l,fract:h,dot:u,ceil:c,sqrt:d,screenUV:m,convertToTexture:p,texture:f}=Ve;if(!e)return o(0,0,0,0);let g=Math.round(s.width),y=Math.round(s.height),T=p(e,g,y),S=1024,w=(Mi,ri,_i)=>{let Ni=Mi.length,ws=Math.max(2,Math.ceil(Math.sqrt(Ni))),ta=Math.max(12,ri*.8),Vr=document.createElement("canvas");Vr.width=S,Vr.height=S;let zi=Vr.getContext("2d");zi.fillStyle="#000000",zi.fillRect(0,0,Vr.width,Vr.height),zi.fillStyle="#ffffff",zi.font=`${ta}px ${_i}`,zi.textAlign="center",zi.textBaseline="middle";let ii=Math.max(32,ri*2),he=Math.floor(S/ii)*ii,oe=Math.min(ii,he/ws);for(let ut=0;ut<Ni;ut++){let ht=Mi[ut],Pt=Math.floor(ut/ws),Lt=ut%ws,ar=Lt*oe+oe/2,yt=Pt*oe+oe/2;zi.fillText(ht,ar,yt)}let xe=zi.getImageData(0,0,Vr.width,Vr.height),ce=new Uint8Array(xe.data),qe=ws*oe/S;return{data:ce,width:S,height:S,atlasSize:ws,cellSize:ri,charCount:Ni,characters:Mi,fontFamily:_i,uvScale:qe}},_=w(t.characters.uniform.value,t.cellSize.uniform.value,t.fontFamily.uniform.value);_=w(t.characters.uniform.value,t.cellSize.uniform.value,t.fontFamily.uniform.value);let M=new em(_.data,S,S,jv,s3);M.minFilter=$s,M.magFilter=$s,M.generateMipmaps=!1,M.needsUpdate=!0;let E=f(M),A=t.characters.uniform.value,U=t.cellSize.uniform.value,Q=t.fontFamily.uniform.value,J=0;i(()=>{let Mi=Date.now();if(Mi-J<16)return;let ri=t.characters.uniform.value,_i=t.cellSize.uniform.value,Ni=t.fontFamily.uniform.value;(ri!==A||_i!==U||Ni!==Q)&&(console.log(`Updating atlas texture: cellSize ${U} → ${_i}`),J=Mi,_=w(ri,_i,Ni),M.image.data=_.data,M.needsUpdate=!0,re.value=_.charCount,ie.value=_.cellSize,se.value=_.uvScale,A=ri,U=_i,Q=Ni)}),r(()=>{M.dispose()});let re=Od(_.charCount),ie=Od(_.cellSize),se=Od(_.uvScale),ve=ie.mul(1.5),me=n(g,y).div(ve),Me=m.mul(me),ye=l(Me),Te=h(Me),ge=t.spacing.uniform,be=Te.mul(ge),Je=Eb(1).sub(ge).mul(.5),wt=be.add(Je),Bt=ye.add(n(.5)).div(me),He=T.sample(Bt),Wr=u(He.rgb,a(.299,.587,.114)),Hr=re,Qt=Wr.mul(.8).add(.1),Ot=Qt.mul(Hr),br=l(Ot.min(Hr.sub(1e-4))),vr=c(d(Hr)),qr=br.mod(vr),Wt=l(br.div(vr)),Ir=Eb(1).div(vr).mul(se),ui=n(qr,Wt).mul(Ir).add(wt.mul(Ir)),Zi=E.sample(ui);return o(Zi.rgb.mul(He.rgb),He.a)}};function qt(t,e){let r=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(e[0])||(e=e.map(a=>[a]));let i=e[0].length,s=e[0].map((a,o)=>e.map(l=>l[o])),n=t.map(a=>s.map(o=>{let l=0;if(!Array.isArray(a)){for(let h of o)l+=a*h;return l}for(let h=0;h<a.length;h++)l+=a[h]*(o[h]||0);return l}));return r===1&&(n=n[0]),i===1?n.map(a=>a[0]):n}function Cm(t){return Co(t)==="string"}function Co(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function dg(t,{precision:e,unit:r}){return Vo(t)?"none":m3(t,e)+(r??"")}function Vo(t){return Number.isNaN(t)||t instanceof Number&&t?.none}function Er(t){return Vo(t)?0:t}function m3(t,e){if(t===0)return 0;let r=~~t,i=0;r&&e&&(i=~~Math.log10(Math.abs(r))+1);let s=10**(e-i);return Math.floor(t*s+.5)/s}const SK={deg:1,grad:.9,rad:180/Math.PI,turn:360};function p3(t){if(!t)return;t=t.trim();let e=/^([a-z]+)\((.+?)\)$/i,r=/^-?[\d.]+$/,i=/%|deg|g?rad|turn$/,s=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,n=t.match(e);if(n){let a=[];return n[2].replace(s,(o,l)=>{let h=l.match(i),u=l;if(h){let c=h[0],d=u.slice(0,-c.length);c==="%"?(u=new Number(d/100),u.type="<percentage>"):(u=new Number(d*SK[c]),u.type="<angle>",u.unit=c)}else r.test(u)?(u=new Number(u),u.type="<number>"):u==="none"&&(u=new Number(NaN),u.none=!0);o.startsWith("/")&&(u=u instanceof Number?u:new Number(u),u.alpha=!0),typeof u=="object"&&u instanceof Number&&(u.raw=l),a.push(u)}),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:a}}}function f3(t){return t[t.length-1]}function tm(t,e,r){return isNaN(t)?e:isNaN(e)?t:t+(e-t)*r}function g3(t,e,r){return(r-t)/(e-t)}function Kv(t,e,r){return tm(e[0],e[1],g3(t[0],t[1],r))}function y3(t){return t.map(e=>e.split("|").map(r=>{r=r.trim();let i=r.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(i){let s=new String(i[1]);return s.range=[+i[2],+i[3]],s}return r}))}function x3(t,e,r){return Math.max(Math.min(r,e),t)}function ly(t,e){return Math.sign(t)===Math.sign(e)?t:-t}function Cn(t,e){return ly(Math.abs(t)**e,t)}function Qv(t,e){return e===0?0:t/e}function b3(t,e,r=0,i=t.length){for(;r<i;){let s=r+i>>1;t[s]<e?r=s+1:i=s}return r}var MK=Object.freeze({__proto__:null,bisectLeft:b3,clamp:x3,copySign:ly,interpolate:tm,interpolateInv:g3,isNone:Vo,isString:Cm,last:f3,mapRange:Kv,multiplyMatrices:qt,parseCoordGrammar:y3,parseFunction:p3,serializeNumber:dg,skipNone:Er,spow:Cn,toPrecision:m3,type:Co,zdiv:Qv}),_K=class{add(e,r,i){if(typeof arguments[0]!="string"){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(s){this[s]=this[s]||[],r&&this[s][i?"unshift":"push"](r)},this)}run(e,r){this[e]=this[e]||[],this[e].forEach(function(i){i.call(r&&r.context?r.context:r,r)})}};const Oo=new _K;var vs={gamut_mapping:"css",precision:5,deltaE:"76",verbose:globalThis?.process?.env?.NODE_ENV?.toLowerCase()!=="test",warn:function(t){this.verbose&&globalThis?.console?.warn?.(t)}};const Oi={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function zb(t){return Array.isArray(t)?t:Oi[t]}function mg(t,e,r,i={}){if(t=zb(t),e=zb(e),!t||!e)throw TypeError(`Missing white point to convert ${t?"":"from"}${!t&&!e?"/":""}${e?"":"to"}`);if(t===e)return r;let s={W1:t,W2:e,XYZ:r,options:i};if(Oo.run("chromatic-adaptation-start",s),s.M||(s.W1===Oi.D65&&s.W2===Oi.D50?s.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:s.W1===Oi.D50&&s.W2===Oi.D65&&(s.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),Oo.run("chromatic-adaptation-end",s),s.M)return qt(s.M,s.XYZ);throw TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const NK=new Set(["<number>","<percentage>","<angle>"]);function LM(t,e,r,i){return Object.entries(t.coords).map(([n,a],o)=>{let l=e.coordGrammar[o],h=i[o],u=h?.type,c;if(c=h.none?l.find(p=>NK.has(p)):l.find(p=>p==u),!c){let p=a.name||n;throw TypeError(`${u??h.raw} not allowed for ${p} in ${r}()`)}let d=c.range;u==="<percentage>"&&(d||(d=[0,1]));let m=a.range||a.refRange;return d&&m&&(i[o]=Kv(d,m,i[o])),c})}function v3(t,{meta:e}={}){let r={str:String(t)?.trim()};if(Oo.run("parse-start",r),r.color)return r.color;if(r.parsed=p3(r.str),r.parsed){let i=r.parsed.name;if(i==="color"){let s=r.parsed.args.shift(),n=s.startsWith("--")?s.substring(2):`--${s}`,a=[s,n],o=r.parsed.rawArgs.indexOf("/")>0?r.parsed.args.pop():1;for(let u of Ce.all){let c=u.getFormat("color");if(c&&(a.includes(c.id)||c.ids?.filter(d=>a.includes(d)).length)){let d=Object.keys(u.coords).map((p,f)=>r.parsed.args[f]||0),m;return c.coordGrammar&&(m=LM(u,c,"color",d)),e&&Object.assign(e,{formatId:"color",types:m}),c.id.startsWith("--")&&!s.startsWith("--")&&vs.warn(`${u.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${c.id}) instead of color(${s}).`),s.startsWith("--")&&!c.id.startsWith("--")&&vs.warn(`${u.name} is a standard space and supported in the CSS spec. Use color(${c.id}) instead of prefixed color(${s}).`),{spaceId:u.id,coords:d,alpha:o}}}let l="",h=s in Ce.registry?s:n;if(h in Ce.registry){let u=Ce.registry[h].formats?.color?.id;u&&(l=`Did you mean color(${u})?`)}throw TypeError(`Cannot parse color(${s}). `+(l||"Missing a plugin?"))}else for(let s of Ce.all){let n=s.getFormat(i);if(n&&n.type==="function"){let a=1;(n.lastAlpha||f3(r.parsed.args).alpha)&&(a=r.parsed.args.pop());let o=r.parsed.args,l;return n.coordGrammar&&(l=LM(s,n,i,o)),e&&Object.assign(e,{formatId:n.name,types:l}),{spaceId:s.id,coords:o,alpha:a}}}}else for(let i of Ce.all)for(let s in i.formats){let n=i.formats[s];if(n.type!=="custom"||n.test&&!n.test(r.str))continue;let a=n.parse(r.str);if(a)return a.alpha??(a.alpha=1),e&&(e.formatId=s),a}throw TypeError(`Could not parse ${t} as a color. Missing a plugin?`)}function We(t){if(Array.isArray(t))return t.map(We);if(!t)throw TypeError("Empty color reference");Cm(t)&&(t=v3(t));let e=t.space||t.spaceId;return e instanceof Ce||(t.space=Ce.get(e)),t.alpha===void 0&&(t.alpha=1),t}var ni,Ce=(ni=class{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?ni.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let r=e.coords??this.base.coords;for(let s in r)"name"in r[s]||(r[s].name=s);this.coords=r;let i=e.white??this.base.white??"D65";for(let s in this.white=zb(i),this.formats=e.formats??{},this.formats){let n=this.formats[s];n.type||(n.type="function"),n.name||(n.name=s)}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace=e.gamutSpace==="self"?this:ni.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(s,n)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:EK(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),Oo.run("colorspace-init-end",this)}inGamut(e,{epsilon:r=75e-6}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:r});let i=Object.values(this.coords);return e.every((s,n)=>{let a=i[n];if(a.type!=="angle"&&a.range){if(Number.isNaN(s))return!0;let[o,l]=a.range;return(o===void 0||s>=o-r)&&(l===void 0||s<=l+r)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!("range"in e))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type==="angle")return!0;return!1}getFormat(e){if(typeof e=="object")return e=FM(e,this),e;let r;return r=e==="default"?Object.values(this.formats)[0]:this.formats[e],r?(r=FM(r,this),r):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(e,r){if(arguments.length===1){let o=We(e);[e,r]=[o.space,o.coords]}if(e=ni.get(e),this.equals(e))return r;r=r.map(o=>Number.isNaN(o)?0:o);let i=this.path,s=e.path,n,a;for(let o=0;o<i.length&&i[o].equals(s[o]);o++)n=i[o],a=o;if(!n)throw Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let o=i.length-1;o>a;o--)r=i[o].toBase(r);for(let o=a+1;o<s.length;o++)r=s[o].fromBase(r);return r}from(e,r){if(arguments.length===1){let i=We(e);[e,r]=[i.space,i.coords]}return e=ni.get(e),e.to(this,r)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let r in this.coords){let i=this.coords[r],s=i.range||i.refRange;e.push(s?.min??0)}return e}static get all(){return[...new Set(Object.values(ni.registry))]}static register(e,r){if(arguments.length===1&&(r=arguments[0],e=r.id),r=this.get(r),this.registry[e]&&this.registry[e]!==r)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=r,arguments.length===1&&r.aliases)for(let i of r.aliases)this.register(i,r);return r}static get(e,...r){if(!e||e instanceof ni)return e;if(Co(e)==="string"){let s=ni.registry[e.toLowerCase()];if(!s)throw TypeError(`No color space found with id = "${e}"`);return s}if(r.length)return ni.get(...r);throw TypeError(`${e} is not a valid color space`)}static resolveCoord(e,r){let i=Co(e),s,n;if(i==="string"?e.includes(".")?[s,n]=e.split("."):[s,n]=[,e]:Array.isArray(e)?[s,n]=e:(s=e.space,n=e.coordId),s=ni.get(s),s||(s=r),!s)throw TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(i=Co(n),i==="number"||i==="string"&&n>=0){let l=Object.entries(s.coords)[n];if(l)return{space:s,id:l[0],index:n,...l[1]}}s=ni.get(s);let a=n.toLowerCase(),o=0;for(let l in s.coords){let h=s.coords[l];if(l.toLowerCase()===a||h.name?.toLowerCase()===a)return{space:s,id:l,index:o,...h};o++}throw TypeError(`No "${n}" coordinate found in ${s.name}. Its coordinates are: ${Object.keys(s.coords).join(", ")}`)}},Iy(ni,"registry",{}),Iy(ni,"DEFAULT_FORMAT",{type:"functions",name:"color"}),ni);function EK(t){let e=[t];for(let r=t;r=r.base;)e.push(r);return e}function FM(t,{coords:e}={}){if(t.coords&&!t.coordGrammar){t.type||(t.type="function"),t.name||(t.name="color"),t.coordGrammar=y3(t.coords);let r=Object.entries(e).map(([i,s],n)=>{let a=t.coordGrammar[n][0],o=s.range||s.refRange,l=a.range,h="";return a=="<percentage>"?(l=[0,100],h="%"):a=="<angle>"&&(h="deg"),{fromRange:o,toRange:l,suffix:h}});t.serializeCoords=(i,s)=>i.map((n,a)=>{let{fromRange:o,toRange:l,suffix:h}=r[a];return o&&l&&(n=Kv(o,l,n)),n=dg(n,{precision:s,unit:h}),n})}return t}var ai=new Ce({id:"xyz-d65",name:"XYZ D65",coords:{x:{name:"X"},y:{name:"Y"},z:{name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]}),Yi=class extends Ce{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=ai),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??(e.toBase=r=>{let i=qt(e.toXYZ_M,r);return this.white!==this.base.white&&(i=mg(this.white,this.base.white,i)),i}),e.fromBase??(e.fromBase=r=>(r=mg(this.base.white,this.white,r),qt(e.fromXYZ_M,r)))),e.referred??(e.referred="display"),super(e)}};function Rm(t,e){return t=We(t),!e||t.space.equals(e)?t.coords.slice():(e=Ce.get(e),e.from(t))}function fs(t,e){t=We(t);let{space:r,index:i}=Ce.resolveCoord(e,t.space);return Rm(t,r)[i]}function eT(t,e,r){return t=We(t),e=Ce.get(e),t.coords=e.to(t.space,r),t}eT.returns="color";function Fa(t,e,r){if(t=We(t),arguments.length===2&&Co(arguments[1])==="object"){let i=arguments[1];for(let s in i)Fa(t,s,i[s])}else{typeof r=="function"&&(r=r(fs(t,e)));let{space:i,index:s}=Ce.resolveCoord(e,t.space),n=Rm(t,i);n[s]=r,eT(t,i,n)}return t}Fa.returns="color";var tT=new Ce({id:"xyz-d50",name:"XYZ D50",white:"D50",base:ai,fromBase:t=>mg(ai.white,"D50",t),toBase:t=>mg("D50",ai.white,t)});const zM=24/116,Zp=24389/27;let ax=Oi.D50;var gs=new Ce({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:ax,base:tT,fromBase(t){let e=t.map((i,s)=>i/ax[s]),r=e.map(i=>i>.008856451679035631?Math.cbrt(i):(Zp*i+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>zM?e[0]**3:(116*e[0]-16)/Zp,t[0]>8?((t[0]+16)/116)**3:t[0]/Zp,e[2]>zM?e[2]**3:(116*e[2]-16)/Zp].map((i,s)=>i*ax[s])},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Kn(t){return(t%360+360)%360}function AK(t,e){if(t==="raw")return e;let[r,i]=e.map(Kn),s=i-r;return t==="increasing"?s<0&&(i+=360):t==="decreasing"?s>0&&(r+=360):t==="longer"?-180<s&&s<180&&(s>0?r+=360:i+=360):t==="shorter"&&(s>180?r+=360:s<-180&&(i+=360)),[r,i]}var rm=new Ce({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:gs,fromBase(t){let[e,r,i]=t,s,n=.02;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){let[e,r,i]=t;return r<0&&(r=0),isNaN(i)&&(i=0),[e,r*Math.cos(i*Math.PI/180),r*Math.sin(i*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const BM=25**7,pg=Math.PI,kM=180/pg,Sh=pg/180;function UM(t){let e=t*t;return e*e*e*t}function T3(t,e,{kL:r=1,kC:i=1,kH:s=1}={}){[t,e]=We([t,e]);let[n,a,o]=gs.from(t),l=rm.from(gs,[n,a,o])[1],[h,u,c]=gs.from(e),d=rm.from(gs,[h,u,c])[1];l<0&&(l=0),d<0&&(d=0);let m=(l+d)/2,p=UM(m),f=.5*(1-Math.sqrt(p/(p+BM))),g=(1+f)*a,y=(1+f)*u,T=Math.sqrt(g**2+o**2),S=Math.sqrt(y**2+c**2),w=g===0&&o===0?0:Math.atan2(o,g),_=y===0&&c===0?0:Math.atan2(c,y);w<0&&(w+=2*pg),_<0&&(_+=2*pg),w*=kM,_*=kM;let M=h-n,E=S-T,A=_-w,U=w+_,Q=Math.abs(A),J;T*S===0?J=0:Q<=180?J=A:A>180?J=A-360:A<-180?J=A+360:vs.warn("the unthinkable has happened");let re=2*Math.sqrt(S*T)*Math.sin(J*Sh/2),ie=(n+h)/2,se=(T+S)/2,ve=UM(se),me;me=T*S===0?U:Q<=180?U/2:U<360?(U+360)/2:(U-360)/2;let Me=(ie-50)**2,ye=1+.015*Me/Math.sqrt(20+Me),Te=1+.045*se,ge=1;ge-=.17*Math.cos((me-30)*Sh),ge+=.24*Math.cos(2*me*Sh),ge+=.32*Math.cos((3*me+6)*Sh),ge-=.2*Math.cos((4*me-63)*Sh);let be=1+.015*se*ge,Je=30*Math.exp(-1*((me-275)/25)**2),wt=2*Math.sqrt(ve/(ve+BM)),Bt=-1*Math.sin(2*Je*Sh)*wt,He=(M/(r*ye))**2;return He+=(E/(i*Te))**2,He+=(re/(s*be))**2,He+=Bt*(E/(i*Te))*(re/(s*be)),Math.sqrt(He)}const CK=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],RK=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],PK=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],IK=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var yc=new Ce({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:ai,fromBase(t){let e=qt(CK,t),r=e.map(i=>Math.cbrt(i));return qt(PK,r)},toBase(t){let e=qt(IK,t),r=e.map(i=>i**3);return qt(RK,r)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Bb(t,e){[t,e]=We([t,e]);let[r,i,s]=yc.from(t),[n,a,o]=yc.from(e),l=r-n,h=i-a,u=s-o;return Math.sqrt(l**2+h**2+u**2)}function Al(t,e,{epsilon:r=75e-6}={}){t=We(t),e||(e=t.space),e=Ce.get(e);let i=t.coords;return e!==t.space&&(i=e.from(t)),e.inGamut(i,{epsilon:r})}function xc(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}function w3(t,e,r="lab"){r=Ce.get(r);let i=r.from(t),s=r.from(e);return Math.sqrt(i.reduce((n,a,o)=>{let l=s[o];return isNaN(a)||isNaN(l)?n:n+(l-a)**2},0))}function VK(t,e){return w3(t,e,"lab")}const OK=Math.PI,DM=OK/180;function LK(t,e,{l:r=2,c:i=1}={}){[t,e]=We([t,e]);let[s,n,a]=gs.from(t),[,o,l]=rm.from(gs,[s,n,a]),[h,u,c]=gs.from(e),d=rm.from(gs,[h,u,c])[1];o<0&&(o=0),d<0&&(d=0);let m=s-h,p=o-d,f=n-u,g=a-c,y=f**2+g**2-p**2,T=.511;s>=16&&(T=.040975*s/(1+.01765*s));let S=.0638*o/(1+.0131*o)+.638,w;Number.isNaN(l)&&(l=0),w=l>=164&&l<=345?.56+Math.abs(.2*Math.cos((l+168)*DM)):.36+Math.abs(.4*Math.cos((l+35)*DM));let _=o**4,M=Math.sqrt(_/(_+1900)),E=S*(M*w+1-M),A=(m/(r*T))**2;return A+=(p/(i*S))**2,A+=y/E**2,Math.sqrt(A)}var rT=new Ce({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:ai,fromBase(t){return t.map(e=>Math.max(e*203,0))},toBase(t){return t.map(e=>Math.max(e/203,0))}});const Jp=1.15,Kp=.66,$M=2610/2**14,FK=2**14/2610,GM=3424/2**12,jM=2413/2**7,WM=2392/2**7,HM=2**5/(1.7*2523),Qp=-.56,ox=16295499532821565e-27,zK=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],BK=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],kK=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],UK=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var S3=new Ce({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:rT,fromBase(t){let[e,r,i]=t,s=Jp*e-(Jp-1)*i,n=Kp*r-(Kp-1)*e,a=qt(zK,[s,n,i]),o=a.map(function(d){let m=GM+jM*(d/1e4)**$M,p=1+WM*(d/1e4)**$M;return(m/p)**134.03437499999998}),[l,h,u]=qt(kK,o);return[(1+Qp)*l/(1+Qp*l)-ox,h,u]},toBase(t){let[e,r,i]=t,s=(e+ox)/(1+Qp-Qp*(e+ox)),n=qt(UK,[s,r,i]),a=n.map(function(d){let m=GM-d**HM,p=WM*d**HM-jM;return 1e4*(m/p)**FK}),[o,l,h]=qt(BK,a),u=(o+(Jp-1)*h)/Jp,c=(l+(Kp-1)*u)/Kp;return[u,c,h]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),kb=new Ce({id:"jzczhz",name:"JzCzHz",coords:{jz:{refRange:[0,1],name:"Jz"},cz:{refRange:[0,1],name:"Chroma"},hz:{refRange:[0,360],type:"angle",name:"Hue"}},base:S3,fromBase(t){let[e,r,i]=t,s,n=2e-4;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]}});function DK(t,e){[t,e]=We([t,e]);let[r,i,s]=kb.from(t),[n,a,o]=kb.from(e),l=r-n,h=i-a;Number.isNaN(s)&&Number.isNaN(o)?(s=0,o=0):Number.isNaN(s)?s=o:Number.isNaN(o)&&(o=s);let u=s-o,c=2*Math.sqrt(i*a)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(l**2+h**2+c**2)}const M3=3424/4096,_3=2413/128,N3=2392/128,qM=2610/16384,XM=32/2523,$K=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],GK=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],jK=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],WK=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var Ub=new Ce({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:rT,fromBase(t){let e=qt($K,t);return HK(e)},toBase(t){let e=qK(t);return qt(WK,e)}});function HK(t){let e=t.map(function(r){let i=M3+_3*(r/1e4)**qM,s=1+N3*(r/1e4)**qM;return(i/s)**78.84375});return qt(GK,e)}function qK(t){return qt(jK,t).map(function(i){let s=Math.max(i**XM-M3,0),n=_3-N3*i**XM;return 1e4*(s/n)**6.277394636015326})}function XK(t,e){[t,e]=We([t,e]);let[r,i,s]=Ub.from(t),[n,a,o]=Ub.from(e);return 720*Math.sqrt((r-n)**2+.25*(i-a)**2+(s-o)**2)}const YK=Oi.D65,E3=.42,YM=1/E3,lx=2*Math.PI,A3=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],ZK=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],JK=[[460,451,288],[460,-891,-261],[460,-220,-6300]],KK={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},fl={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},QK=180/Math.PI,ZM=Math.PI/180;function C3(t,e){return t.map(i=>{let s=Cn(e*Math.abs(i)*.01,E3);return 400*ly(s,i)/(s+27.13)})}function eQ(t,e){let r=100/e*27.13**YM;return t.map(i=>{let s=Math.abs(i);return ly(r*Cn(s/(400-s),YM),i)})}function tQ(t){let e=Kn(t);e<=fl.h[0]&&(e+=360);let r=b3(fl.h,e)-1,[i,s]=fl.h.slice(r,r+2),[n,a]=fl.e.slice(r,r+2),o=fl.H[r],l=(e-i)/n;return o+100*l/(l+(s-e)/a)}function rQ(t){let e=(t%400+400)%400,r=Math.floor(.01*e);e%=100;let[i,s]=fl.h.slice(r,r+2),[n,a]=fl.e.slice(r,r+2);return Kn((e*(a*i-n*s)-100*i*a)/(e*(a-n)-100*a))}function R3(t,e,r,i,s){let n={};n.discounting=s,n.refWhite=t,n.surround=i;let a=t.map(f=>f*100);n.la=e,n.yb=r;let o=a[1],l=qt(A3,a);i=KK[n.surround];let h=i[0];n.c=i[1],n.nc=i[2];let u=1/(5*n.la+1),c=u**4;n.fl=c*n.la+.1*(1-c)*(1-c)*Math.cbrt(5*n.la),n.flRoot=n.fl**.25,n.n=n.yb/o,n.z=1.48+Math.sqrt(n.n),n.nbb=.725*n.n**-.2,n.ncb=n.nbb;let d=Math.max(Math.min(h*(1-1/3.6*Math.exp((-n.la-42)/92)),1),0);n.dRgb=l.map(f=>tm(1,o/f,d)),n.dRgbInv=n.dRgb.map(f=>1/f);let m=l.map((f,g)=>f*n.dRgb[g]),p=C3(m,n.fl);return n.aW=n.nbb*(2*p[0]+p[1]+.05*p[2]),n}const JM=R3(YK,64/Math.PI*.2,20,"average",!1);function Db(t,e){if(!(t.J!==void 0^t.Q!==void 0))throw Error("Conversion requires one and only one: 'J' or 'Q'");if(!(t.C!==void 0^t.M!==void 0^t.s!==void 0))throw Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(t.h!==void 0^t.H!==void 0))throw Error("Conversion requires one and only one: 'h' or 'H'");if(t.J===0||t.Q===0)return[0,0,0];let r=0;r=t.h===void 0?rQ(t.H)*ZM:Kn(t.h)*ZM;let i=Math.cos(r),s=Math.sin(r),n=0;t.J===void 0?t.Q!==void 0&&(n=.25*e.c*t.Q/((e.aW+4)*e.flRoot)):n=Cn(t.J,1/2)*.1;let a=0;t.C===void 0?t.M===void 0?t.s!==void 0&&(a=4e-4*t.s**2*(e.aW+4)/e.c):a=t.M/e.flRoot/n:a=t.C/n;let o=Cn(a*(1.64-.29**e.n)**-.73,10/9),l=.25*(Math.cos(r+2)+3.8),h=e.aW*Cn(n,2/e.c/e.z),u=5e4/13*e.nc*e.ncb*l,c=h/e.nbb,d=23*(c+.305)*Qv(o,23*u+o*(11*i+108*s)),m=d*i,p=d*s,f=eQ(qt(JK,[c,m,p]).map(g=>g*1/1403),e.fl);return qt(ZK,f.map((g,y)=>g*e.dRgbInv[y])).map(g=>g/100)}function P3(t,e){let r=t.map(S=>S*100),i=C3(qt(A3,r).map((S,w)=>S*e.dRgb[w]),e.fl),s=i[0]+(-12*i[1]+i[2])/11,n=(i[0]+i[1]-2*i[2])/9,a=(Math.atan2(n,s)%lx+lx)%lx,o=.25*(Math.cos(a+2)+3.8),l=5e4/13*e.nc*e.ncb*Qv(o*Math.sqrt(s**2+n**2),i[0]+i[1]+1.05*i[2]+.305),h=Cn(l,.9)*(1.64-.29**e.n)**.73,u=e.nbb*(2*i[0]+i[1]+.05*i[2]),c=Cn(u/e.aW,.5*e.c*e.z),d=100*Cn(c,2),m=4/e.c*c*(e.aW+4)*e.flRoot,p=h*c,f=p*e.flRoot,g=Kn(a*QK),y=tQ(g),T=50*Cn(e.c*h/(e.aW+4),1/2);return{J:d,C:p,h:g,s:T,Q:m,M:f,H:y}}var iQ=new Ce({id:"cam16-jmh",cssId:"--cam16-jmh",name:"CAM16-JMh",coords:{j:{refRange:[0,100],name:"J"},m:{refRange:[0,105],name:"Colorfulness"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:ai,fromBase(t){let e=P3(t,JM);return[e.J,e.M,e.h]},toBase(t){return Db({J:t[0],M:t[1],h:t[2]},JM)}});const sQ=Oi.D65,I3=24389/27;function nQ(t){return 116*(t>.008856451679035631?Math.cbrt(t):(I3*t+16)/116)-16}function $b(t){return t>8?((t+16)/116)**3:t/I3}function aQ(t,e){let[r,i,s]=t,n=[],a=0;if(s===0)return[0,0,0];let o=$b(s);a=s>0?.00379058511492914*s**2+.608983189401032*s+.9155088574762233:9514440756550361e-21*s**2+.08693057439788597*s-21.928975842194614;let l=0,h=1/0;for(;l<=15;){n=Db({J:a,C:i,h:r},e);let u=Math.abs(n[1]-o);if(u<h){if(u<=2e-12)return n;h=u}a-=(n[1]-o)*a/(2*n[1]),l+=1}return Db({J:a,C:i,h:r},e)}function oQ(t,e){let r=nQ(t[1]);if(r===0)return[0,0,0];let i=P3(t,iT);return[Kn(i.h),i.C,r]}const iT=R3(sQ,200/Math.PI*$b(50),$b(50)*100,"average",!1);var im=new Ce({id:"hct",name:"HCT",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},c:{refRange:[0,145],name:"Colorfulness"},t:{refRange:[0,100],name:"Tone"}},base:ai,fromBase(t){return oQ(t)},toBase(t){return aQ(t,iT)},formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const lQ=Math.PI/180,KM=[1,.007,.0228];function QM(t){t[1]<0&&(t=im.fromBase(im.toBase(t)));let e=Math.log(Math.max(1+KM[2]*t[1]*iT.flRoot,1))/KM[2],r=t[0]*lQ,i=e*Math.cos(r),s=e*Math.sin(r);return[t[2],i,s]}function uQ(t,e){[t,e]=We([t,e]);let[r,i,s]=QM(im.from(t)),[n,a,o]=QM(im.from(e));return Math.sqrt((r-n)**2+(i-a)**2+(s-o)**2)}var bc={deltaE76:VK,deltaECMC:LK,deltaE2000:T3,deltaEJz:DK,deltaEITP:XK,deltaEOK:Bb,deltaEHCT:uQ};function hQ(t){let e=t?Math.floor(Math.log10(Math.abs(t))):0;return Math.max(parseFloat(`1e${e-2}`),1e-6)}const e_={hct:{method:"hct.c",jnd:2,deltaEMethod:"hct",blackWhiteClamp:{}},"hct-tonal":{method:"hct.c",jnd:0,deltaEMethod:"hct",blackWhiteClamp:{channel:"hct.t",min:0,max:100}}};function Lo(t,{method:e=vs.gamut_mapping,space:r=void 0,deltaEMethod:i="",jnd:s=2,blackWhiteClamp:n={}}={}){if(t=We(t),Cm(arguments[1])?r=arguments[1]:r||(r=t.space),r=Ce.get(r),Al(t,r,{epsilon:0}))return t;let a;if(e==="css")a=cQ(t,{space:r});else{if(e!=="clip"&&!Al(t,r)){Object.prototype.hasOwnProperty.call(e_,e)&&({method:e,jnd:s,deltaEMethod:i,blackWhiteClamp:n}=e_[e]);let o=T3;if(i!==""){for(let h in bc)if("deltae"+i.toLowerCase()===h.toLowerCase()){o=bc[h];break}}let l=Lo(Ht(t,r),{method:"clip",space:r});if(o(t,l)>s){if(Object.keys(n).length===3){let T=Ce.resolveCoord(n.channel),S=fs(Ht(t,T.space),T.id);if(Vo(S)&&(S=0),S>=n.max)return Ht({space:"xyz-d65",coords:Oi.D65},t.space);if(S<=n.min)return Ht({space:"xyz-d65",coords:[0,0,0]},t.space)}let h=Ce.resolveCoord(e),u=h.space,c=h.id,d=Ht(t,u);d.coords.forEach((T,S)=>{Vo(T)&&(d.coords[S]=0)});let m=h.range||h.refRange,p=m[0],f=hQ(s),g=p,y=fs(d,c);for(;y-g>f;){let T=xc(d);T=Lo(T,{space:r,method:"clip"}),o(d,T)-s<f?g=fs(d,c):y=fs(d,c),Fa(d,c,(g+y)/2)}a=Ht(d,r)}else a=l}else a=Ht(t,r);if(e==="clip"||!Al(a,r,{epsilon:0})){let o=Object.values(r.coords).map(l=>l.range||[]);a.coords=a.coords.map((l,h)=>{let[u,c]=o[h];return u!==void 0&&(l=Math.max(u,l)),c!==void 0&&(l=Math.min(l,c)),l})}}return r!==t.space&&(a=Ht(a,t.space)),t.coords=a.coords,t}Lo.returns="color";const t_={WHITE:{space:yc,coords:[1,0,0]},BLACK:{space:yc,coords:[0,0,0]}};function cQ(t,{space:e}={}){let r=.02,i=1e-4;t=We(t),e||(e=t.space),e=Ce.get(e);let s=Ce.get("oklch");if(e.isUnbounded)return Ht(t,e);let n=Ht(t,s),a=n.coords[0];if(a>=1){let p=Ht(t_.WHITE,e);return p.alpha=t.alpha,Ht(p,e)}if(a<=0){let p=Ht(t_.BLACK,e);return p.alpha=t.alpha,Ht(p,e)}if(Al(n,e,{epsilon:0}))return Ht(n,e);function o(p){let f=Ht(p,e),g=Object.values(e.coords);return f.coords=f.coords.map((y,T)=>{if("range"in g[T]){let[S,w]=g[T].range;return x3(S,y,w)}return y}),f}let l=0,h=n.coords[1],u=!0,c=xc(n),d=o(c),m=Bb(d,c);if(m<r)return d;for(;h-l>i;){let p=(l+h)/2;if(c.coords[1]=p,u&&Al(c,e,{epsilon:0}))l=p;else if(d=o(c),m=Bb(d,c),m<r){if(r-m<i)break;u=!1,l=p}else h=p}return d}function Ht(t,e,{inGamut:r}={}){t=We(t),e=Ce.get(e);let i=e.from(t),s={space:e,coords:i,alpha:t.alpha};return r&&(s=Lo(s,r===!0?void 0:r)),s}Ht.returns="color";function Bd(t,{precision:e=vs.precision,format:r="default",inGamut:i=!0,...s}={}){let n;t=We(t);let a=r;r=t.space.getFormat(r)??t.space.getFormat("default")??Ce.DEFAULT_FORMAT;let o=t.coords.slice();if(i||(i=r.toGamut),i&&!Al(t)&&(o=Lo(xc(t),i===!0?void 0:i).coords),r.type==="custom")if(s.precision=e,r.serialize)n=r.serialize(o,t.alpha,s);else throw TypeError(`format ${a} can only be used to parse colors, not for serialization`);else{let l=r.name||"color";r.serializeCoords?o=r.serializeCoords(o,e):e!==null&&(o=o.map(d=>dg(d,{precision:e})));let h=[...o];if(l==="color"){let d=r.id||r.ids?.[0]||t.space.id;h.unshift(d)}let u=t.alpha;e!==null&&(u=dg(u,{precision:e}));let c=t.alpha>=1||r.noAlpha?"":`${r.commas?",":" /"} ${u}`;n=`${l}(${h.join(r.commas?", ":" ")}${c})`}return n}const dQ=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],mQ=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var uy=new Yi({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:dQ,fromXYZ_M:mQ});const ef=1.09929682680944,r_=.018053968510807;var V3=new Yi({id:"rec2020",name:"REC.2020",base:uy,toBase(t){return t.map(function(e){return e<r_*4.5?e/4.5:((e+ef-1)/ef)**(1/.45)})},fromBase(t){return t.map(function(e){return e>=r_?ef*e**.45-(ef-1):4.5*e})}});const pQ=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fQ=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var O3=new Yi({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:pQ,fromXYZ_M:fQ});const gQ=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],Br=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var L3=new Yi({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:gQ,fromXYZ_M:Br}),i_={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let s_=[,,,].fill("<percentage> | <number>[0, 255]"),n_=[,,,].fill("<number>[0, 255]");var vc=new Yi({id:"srgb",name:"sRGB",base:L3,fromBase:t=>t.map(e=>{let r=e<0?-1:1,i=e*r;return i>.0031308?r*(1.055*i**(1/2.4)-.055):12.92*e}),toBase:t=>t.map(e=>{let r=e<0?-1:1,i=e*r;return i<=.04045?e/12.92:r*((i+.055)/1.055)**2.4}),formats:{rgb:{coords:s_},rgb_number:{name:"rgb",commas:!0,coords:n_,noAlpha:!0},color:{},rgba:{coords:s_,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:n_},hex:{type:"custom",toGamut:!0,test:t=>/^#([a-f0-9]{3,4}){1,2}$/i.test(t),parse(t){t.length<=5&&(t=t.replace(/[a-f0-9]/gi,"$&$&"));let e=[];return t.replace(/[a-f0-9]{2}/gi,r=>{e.push(parseInt(r,16)/255)}),{spaceId:"srgb",coords:e.slice(0,3),alpha:e.slice(3)[0]}},serialize:(t,e,{collapse:r=!0}={})=>{e<1&&t.push(e),t=t.map(n=>Math.round(n*255));let i=r&&t.every(n=>n%17==0);return"#"+t.map(n=>i?(n/17).toString(16):n.toString(16).padStart(2,"0")).join("")}},keyword:{type:"custom",test:t=>/^[a-z]+$/i.test(t),parse(t){t=t.toLowerCase();let e={spaceId:"srgb",coords:null,alpha:1};if(t==="transparent"?(e.coords=i_.black,e.alpha=0):e.coords=i_[t],e.coords)return e}}}}),F3=new Yi({id:"p3",cssId:"display-p3",name:"P3",base:O3,fromBase:vc.fromBase,toBase:vc.toBase});vs.display_space=vc;let yQ;if(typeof CSS<"u"&&CSS.supports)for(let t of[gs,V3,F3]){let e=t.getMinCoords(),r={space:t,coords:e,alpha:1},i=Bd(r);if(CSS.supports("color",i)){vs.display_space=t;break}}function xQ(t,{space:e=vs.display_space,...r}={}){let i=Bd(t,r);if(typeof CSS>"u"||CSS.supports("color",i)||!vs.display_space)i=new String(i),i.color=t;else{let s=t;if((t.coords.some(Vo)||Vo(t.alpha))&&!(yQ??(yQ=CSS.supports("color","hsl(none 50% 50%)")))&&(s=xc(t),s.coords=s.coords.map(Er),s.alpha=Er(s.alpha),i=Bd(s,r),CSS.supports("color",i)))return i=new String(i),i.color=s,i;s=Ht(s,e),i=new String(Bd(s,r)),i.color=s}return i}function bQ(t,e){return t=We(t),e=We(e),t.space===e.space&&t.alpha===e.alpha&&t.coords.every((r,i)=>r===e.coords[i])}function Fo(t){return fs(t,[ai,"y"])}function z3(t,e){Fa(t,[ai,"y"],e)}function vQ(t){Object.defineProperty(t.prototype,"luminance",{get(){return Fo(this)},set(e){z3(this,e)}})}var TQ=Object.freeze({__proto__:null,getLuminance:Fo,register:vQ,setLuminance:z3});function wQ(t,e){t=We(t),e=We(e);let r=Math.max(Fo(t),0),i=Math.max(Fo(e),0);return i>r&&([r,i]=[i,r]),(r+.05)/(i+.05)}const a_=.022,o_=.027;function l_(t){return t>=a_?t:t+(a_-t)**1.414}function Mh(t){let e=t<0?-1:1,r=Math.abs(t);return e*r**2.4}function SQ(t,e){e=We(e),t=We(t);let r,i,s,n,a,o;e=Ht(e,"srgb"),[n,a,o]=e.coords;let l=Mh(n)*.2126729+Mh(a)*.7151522+Mh(o)*.072175;t=Ht(t,"srgb"),[n,a,o]=t.coords;let h=Mh(n)*.2126729+Mh(a)*.7151522+Mh(o)*.072175,u=l_(l),c=l_(h),d=c>u;return Math.abs(c-u)<5e-4?i=0:d?(r=c**.56-u**.57,i=r*1.14):(r=c**.65-u**.62,i=r*1.14),s=Math.abs(i)<.1?0:i>0?i-o_:i+o_,s*100}function MQ(t,e){t=We(t),e=We(e);let r=Math.max(Fo(t),0),i=Math.max(Fo(e),0);i>r&&([r,i]=[i,r]);let s=r+i;return s===0?0:(r-i)/s}function _Q(t,e){t=We(t),e=We(e);let r=Math.max(Fo(t),0),i=Math.max(Fo(e),0);return i>r&&([r,i]=[i,r]),i===0?5e4:(r-i)/i}function NQ(t,e){t=We(t),e=We(e);let r=fs(t,[gs,"l"]),i=fs(e,[gs,"l"]);return Math.abs(r-i)}const u_=24/116,tf=24389/27;let ux=Oi.D65;var Gb=new Ce({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:ux,base:ai,fromBase(t){let e=t.map((i,s)=>i/ux[s]),r=e.map(i=>i>.008856451679035631?Math.cbrt(i):(tf*i+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>u_?e[0]**3:(116*e[0]-16)/tf,t[0]>8?((t[0]+16)/116)**3:t[0]/tf,e[2]>u_?e[2]**3:(116*e[2]-16)/tf].map((i,s)=>i*ux[s])},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const EQ=5**.5*.5+.5;function AQ(t,e){t=We(t),e=We(e);let r=fs(t,[Gb,"l"]),i=fs(e,[Gb,"l"]),s=Math.abs(r**1.618033988749895-i**1.618033988749895),n=s**(1/EQ)*Math.SQRT2-40;return n<7.5?0:n}var zf=Object.freeze({__proto__:null,contrastAPCA:SQ,contrastDeltaPhi:AQ,contrastLstar:NQ,contrastMichelson:MQ,contrastWCAG21:wQ,contrastWeber:_Q});function CQ(t,e,r={}){Cm(r)&&(r={algorithm:r});let{algorithm:i,...s}=r;if(!i){let n=Object.keys(zf).map(a=>a.replace(/^contrast/,"")).join(", ");throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${n}`)}for(let n in t=We(t),e=We(e),zf)if("contrast"+i.toLowerCase()===n.toLowerCase())return zf[n](t,e,s);throw TypeError(`Unknown contrast algorithm: ${i}`)}function hy(t){let[e,r,i]=Rm(t,ai),s=e+15*r+3*i;return[4*e/s,9*r/s]}function B3(t){let[e,r,i]=Rm(t,ai),s=e+r+i;return[e/s,r/s]}function RQ(t){Object.defineProperty(t.prototype,"uv",{get(){return hy(this)}}),Object.defineProperty(t.prototype,"xy",{get(){return B3(this)}})}var PQ=Object.freeze({__proto__:null,register:RQ,uv:hy,xy:B3});function Td(t,e,r={}){Cm(r)&&(r={method:r});let{method:i=vs.deltaE,...s}=r;for(let n in bc)if("deltae"+i.toLowerCase()===n.toLowerCase())return bc[n](t,e,s);throw TypeError(`Unknown deltaE method: ${i}`)}function IQ(t,e=.25){let r=Ce.get("oklch","lch");return Fa(t,[r,"l"],s=>s*(1+e))}function VQ(t,e=.25){let r=Ce.get("oklch","lch");return Fa(t,[r,"l"],s=>s*(1-e))}var OQ=Object.freeze({__proto__:null,darken:VQ,lighten:IQ});function k3(t,e,r=.5,i={}){return[t,e]=[We(t),We(e)],Co(r)==="object"&&([r,i]=[.5,r]),Pm(t,e,i)(r)}function U3(t,e,r={}){let i;sT(t)&&([i,r]=[t,e],[t,e]=i.rangeArgs.colors);let{maxDeltaE:s,deltaEMethod:n,steps:a=2,maxSteps:o=1e3,...l}=r;i||([t,e]=[We(t),We(e)],i=Pm(t,e,l));let h=Td(t,e),u=s>0?Math.max(a,Math.ceil(h/s)+1):a,c=[];if(o!==void 0&&(u=Math.min(u,o)),u===1)c=[{p:.5,color:i(.5)}];else{let d=1/(u-1);c=Array.from({length:u},(m,p)=>{let f=p*d;return{p:f,color:i(f)}})}if(s>0){let d=c.reduce((m,p,f)=>{if(f===0)return 0;let g=Td(p.color,c[f-1].color,n);return Math.max(m,g)},0);for(;d>s;){d=0;for(let m=1;m<c.length&&c.length<o;m++){let p=c[m-1],f=c[m],g=(f.p+p.p)/2,y=i(g);d=Math.max(d,Td(y,p.color),Td(y,f.color)),c.splice(m,0,{p:g,color:i(g)}),m++}}}return c=c.map(d=>d.color),c}function Pm(t,e,r={}){if(sT(t)){let[l,h]=[t,e];return Pm(...l.rangeArgs.colors,{...l.rangeArgs.options,...h})}let{space:i,outputSpace:s,progression:n,premultiplied:a}=r;t=We(t),e=We(e),t=xc(t),e=xc(e);let o={colors:[t,e],options:r};if(i=i?Ce.get(i):Ce.registry[vs.interpolationSpace]||t.space,s=s?Ce.get(s):i,t=Ht(t,i),e=Ht(e,i),t=Lo(t),e=Lo(e),i.coords.h&&i.coords.h.type==="angle"){let l=r.hue=r.hue||"shorter",h=[i,"h"],[u,c]=[fs(t,h),fs(e,h)];isNaN(u)&&!isNaN(c)?u=c:isNaN(c)&&!isNaN(u)&&(c=u),[u,c]=AK(l,[u,c]),Fa(t,h,u),Fa(e,h,c)}return a&&(t.coords=t.coords.map(l=>l*t.alpha),e.coords=e.coords.map(l=>l*e.alpha)),Object.assign(l=>{l=n?n(l):l;let h=t.coords.map((d,m)=>{let p=e.coords[m];return tm(d,p,l)}),u=tm(t.alpha,e.alpha,l),c={space:i,coords:h,alpha:u};return a&&(c.coords=c.coords.map(d=>d/u)),s!==i&&(c=Ht(c,s)),c},{rangeArgs:o})}function sT(t){return Co(t)==="function"&&!!t.rangeArgs}vs.interpolationSpace="lab";function LQ(t){t.defineFunction("mix",k3,{returns:"color"}),t.defineFunction("range",Pm,{returns:"function<color>"}),t.defineFunction("steps",U3,{returns:"array<color>"})}var FQ=Object.freeze({__proto__:null,isRange:sT,mix:k3,range:Pm,register:LQ,steps:U3}),D3=new Ce({id:"hsl",name:"HSL",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:vc,fromBase:t=>{let e=Math.max(...t),r=Math.min(...t),[i,s,n]=t,[a,o,l]=[NaN,0,(r+e)/2],h=e-r;if(h!==0){switch(o=l===0||l===1?0:(e-l)/Math.min(l,1-l),e){case i:a=(s-n)/h+(s<n?6:0);break;case s:a=(n-i)/h+2;break;case n:a=(i-s)/h+4}a*=60}return o<0&&(a+=180,o=Math.abs(o)),a>=360&&(a-=360),[a,o*100,l*100]},toBase:t=>{let[e,r,i]=t;e%=360,e<0&&(e+=360),r/=100,i/=100;function s(n){let a=(n+e/30)%12,o=r*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(a-3,9-a,1))}return[s(0),s(8),s(4)]},formats:{hsl:{coords:["<number> | <angle>","<percentage>","<percentage>"]},hsla:{coords:["<number> | <angle>","<percentage>","<percentage>"],commas:!0,lastAlpha:!0}}}),$3=new Ce({id:"hsv",name:"HSV",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},v:{range:[0,100],name:"Value"}},base:D3,fromBase(t){let[e,r,i]=t;r/=100,i/=100;let s=i+r*Math.min(i,1-i);return[e,s===0?0:200*(1-i/s),100*s]},toBase(t){let[e,r,i]=t;r/=100,i/=100;let s=i*(1-r/2);return[e,s===0||s===1?0:(i-s)/Math.min(s,1-s)*100,s*100]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),zQ=new Ce({id:"hwb",name:"HWB",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},w:{range:[0,100],name:"Whiteness"},b:{range:[0,100],name:"Blackness"}},base:$3,fromBase(t){let[e,r,i]=t;return[e,i*(100-r)/100,100-i]},toBase(t){let[e,r,i]=t;r/=100,i/=100;let s=r+i;if(s>=1){let o=r/s;return[e,0,o*100]}let n=1-i,a=n===0?0:1-r/n;return[e,a*100,n*100]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const BQ=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],kQ=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var G3=new Yi({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:BQ,fromXYZ_M:kQ}),UQ=new Yi({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:G3,toBase:t=>t.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:t=>t.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const DQ=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],$Q=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var j3=new Yi({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:tT,toXYZ_M:DQ,fromXYZ_M:$Q}),GQ=new Yi({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:j3,toBase(t){return t.map(e=>e<.03125?e/16:e**1.8)},fromBase(t){return t.map(e=>e>=.001953125?e**(1/1.8):16*e)}}),jQ=new Ce({id:"oklch",name:"Oklch",coords:{l:{refRange:[0,1],name:"Lightness"},c:{refRange:[0,.4],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},white:"D65",base:yc,fromBase(t){let[e,r,i]=t,s,n=2e-4;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){let[e,r,i]=t,s,n;return isNaN(i)?(s=0,n=0):(s=r*Math.cos(i*Math.PI/180),n=r*Math.sin(i*Math.PI/180)),[e,s,n]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let W3=Oi.D65;const h_=24389/27,[c_,d_]=hy({space:ai,coords:W3});var H3=new Ce({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:W3,base:ai,fromBase(t){let e=[Er(t[0]),Er(t[1]),Er(t[2])],r=e[1],[i,s]=hy({space:ai,coords:e});if(!Number.isFinite(i)||!Number.isFinite(s))return[0,0,0];let n=r<=.008856451679035631?h_*r:116*Math.cbrt(r)-16;return[n,13*n*(i-c_),13*n*(s-d_)]},toBase(t){let[e,r,i]=t;if(e===0||Vo(e))return[0,0,0];r=Er(r),i=Er(i);let s=r/(13*e)+c_,n=i/(13*e)+d_,a=e<=8?e/h_:((e+16)/116)**3;return[a*(9*s/(4*n)),a,a*((12-3*s-20*n)/(4*n))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),nT=new Ce({id:"lchuv",name:"LChuv",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,220],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:H3,fromBase(t){let[e,r,i]=t,s,n=.02;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){let[e,r,i]=t;return r<0&&(r=0),isNaN(i)&&(i=0),[e,r*Math.cos(i*Math.PI/180),r*Math.sin(i*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const m_=Br[0][0],p_=Br[0][1],hx=Br[0][2],f_=Br[1][0],g_=Br[1][1],cx=Br[1][2],y_=Br[2][0],x_=Br[2][1],dx=Br[2][2];function _h(t,e,r){let i=e/(Math.sin(r)-t*Math.cos(r));return i<0?1/0:i}function fg(t){let e=(t+16)**3/1560896,r=e>.008856451679035631?e:t/903.2962962962963,i=r*(284517*m_-94839*hx),s=r*(838422*hx+769860*p_+731718*m_),n=r*(632260*hx-126452*p_),a=r*(284517*f_-94839*cx),o=r*(838422*cx+769860*g_+731718*f_),l=r*(632260*cx-126452*g_),h=r*(284517*y_-94839*dx),u=r*(838422*dx+769860*x_+731718*y_),c=r*(632260*dx-126452*x_);return{r0s:i/n,r0i:s*t/n,r1s:i/(n+126452),r1i:(s-769860)*t/(n+126452),g0s:a/l,g0i:o*t/l,g1s:a/(l+126452),g1i:(o-769860)*t/(l+126452),b0s:h/c,b0i:u*t/c,b1s:h/(c+126452),b1i:(u-769860)*t/(c+126452)}}function b_(t,e){let r=e/360*Math.PI*2,i=_h(t.r0s,t.r0i,r),s=_h(t.r1s,t.r1i,r),n=_h(t.g0s,t.g0i,r),a=_h(t.g1s,t.g1i,r),o=_h(t.b0s,t.b0i,r),l=_h(t.b1s,t.b1i,r);return Math.min(i,s,n,a,o,l)}var WQ=new Ce({id:"hsluv",name:"HSLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:nT,gamutSpace:vc,fromBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(e>99.9999999)s=0,e=100;else if(e<1e-8)s=0,e=0;else{let n=fg(e),a=b_(n,i);s=r/a*100}return[i,s,e]},toBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(i>99.9999999)i=100,s=0;else if(i<1e-8)i=0,s=0;else{let n=fg(i);s=b_(n,e)/100*r}return[i,s,e]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});Br[0][0],Br[0][1],Br[0][2],Br[1][0],Br[1][1],Br[1][2],Br[2][0],Br[2][1],Br[2][2];function Nh(t,e){return Math.abs(e)/Math.sqrt(t**2+1)}function v_(t){let e=Nh(t.r0s,t.r0i),r=Nh(t.r1s,t.r1i),i=Nh(t.g0s,t.g0i),s=Nh(t.g1s,t.g1i),n=Nh(t.b0s,t.b0i),a=Nh(t.b1s,t.b1i);return Math.min(e,r,i,s,n,a)}var HQ=new Ce({id:"hpluv",name:"HPLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:nT,gamutSpace:"self",fromBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(e>99.9999999)s=0,e=100;else if(e<1e-8)s=0,e=0;else{let n=fg(e),a=v_(n);s=r/a*100}return[i,s,e]},toBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(i>99.9999999)i=100,s=0;else if(i<1e-8)i=0,s=0;else{let n=fg(i);s=v_(n)/100*r}return[i,s,e]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const T_=2610/2**14,qQ=2**14/2610,w_=2**5/2523,S_=3424/2**12,M_=2413/2**7,__=2392/2**7;var XQ=new Yi({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:uy,toBase(t){return t.map(function(e){return(Math.max(e**w_-S_,0)/(M_-__*e**w_))**qQ*1e4/203})},fromBase(t){return t.map(function(e){let r=Math.max(e*203/1e4,0),i=S_+M_*r**T_,s=1+__*r**T_;return(i/s)**78.84375})}});const N_=.17883277,E_=.28466892,A_=.55991073,mx=3.7743;var YQ=new Yi({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:uy,toBase(t){return t.map(function(e){return e<=.5?e**2/3*mx:(Math.exp((e-A_)/N_)+E_)/12*mx})},fromBase(t){return t.map(function(e){return e/=mx,e<=1/12?Math.sqrt(3*e):N_*Math.log(12*e-E_)+A_})}});const q3={};Oo.add("chromatic-adaptation-start",t=>{t.options.method&&(t.M=C_(t.W1,t.W2,t.options.method))}),Oo.add("chromatic-adaptation-end",t=>{t.M||(t.M=C_(t.W1,t.W2,t.options.method))});function rf({id:t,toCone_M:e,fromCone_M:r}){q3[t]=arguments[0]}function C_(t,e,r="Bradford"){let i=q3[r],[s,n,a]=qt(i.toCone_M,t),[o,l,h]=qt(i.toCone_M,e),u=[[o/s,0,0],[0,l/n,0],[0,0,h/a]],c=qt(u,i.toCone_M);return qt(i.fromCone_M,c)}rf({id:"von Kries",toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),rf({id:"Bradford",toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),rf({id:"CAT02",toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),rf({id:"CAT16",toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(Oi,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),Oi.ACES=[.32168/.33767,1,.34065/.33767];const ZQ=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],JQ=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var X3=new Yi({id:"acescg",cssId:"--acescg",name:"ACEScg",coords:{r:{range:[0,65504],name:"Red"},g:{range:[0,65504],name:"Green"},b:{range:[0,65504],name:"Blue"}},referred:"scene",white:Oi.ACES,toXYZ_M:ZQ,fromXYZ_M:JQ});const sf=2**-16,px=-.35828683,nf=(Math.log2(65504)+9.72)/17.52;var KQ=new Yi({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[px,nf],name:"Red"},g:{range:[px,nf],name:"Green"},b:{range:[px,nf],name:"Blue"}},referred:"scene",base:X3,toBase(t){return t.map(function(e){return e<=-.3013698630136986?(2**(e*17.52-9.72)-sf)*2:e<nf?2**(e*17.52-9.72):65504})},fromBase(t){return t.map(function(e){return e<=0?(Math.log2(sf)+9.72)/17.52:e<sf?(Math.log2(sf+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),R_=Object.freeze({__proto__:null,A98RGB:UQ,A98RGB_Linear:G3,ACEScc:KQ,ACEScg:X3,CAM16_JMh:iQ,HCT:im,HPLuv:HQ,HSL:D3,HSLuv:WQ,HSV:$3,HWB:zQ,ICTCP:Ub,JzCzHz:kb,Jzazbz:S3,LCH:rm,LCHuv:nT,Lab:gs,Lab_D65:Gb,Luv:H3,OKLCH:jQ,OKLab:yc,P3:F3,P3_Linear:O3,ProPhoto:GQ,ProPhoto_Linear:j3,REC_2020:V3,REC_2020_Linear:uy,REC_2100_HLG:YQ,REC_2100_PQ:XQ,XYZ_ABS_D65:rT,XYZ_D50:tT,XYZ_D65:ai,sRGB:vc,sRGB_Linear:L3}),as=class Bi{constructor(...e){let r;e.length===1&&(r=We(e[0]));let i,s,n;r?(i=r.space||r.spaceId,s=r.coords,n=r.alpha):[i,s,n]=e,Object.defineProperty(this,"space",{value:Ce.get(i),writable:!1,enumerable:!0,configurable:!0}),this.coords=s?s.slice():[0,0,0],this.alpha=n>1||n===void 0?1:n<0?0:n;for(let a=0;a<this.coords.length;a++)this.coords[a]==="NaN"&&(this.coords[a]=NaN);for(let a in this.space.coords)Object.defineProperty(this,a,{get:()=>this.get(a),set:o=>this.set(a,o)})}get spaceId(){return this.space.id}clone(){return new Bi(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...e){let r=xQ(this,...e);return r.color=new Bi(r.color),r}static get(e,...r){return e instanceof Bi?e:new Bi(e,...r)}static defineFunction(e,r,i=r){let{instance:s=!0,returns:n}=i,a=function(...o){let l=r(...o);if(n==="color")l=Bi.get(l);else if(n==="function<color>"){let h=l;l=function(...u){let c=h(...u);return Bi.get(c)},Object.assign(l,h)}else n==="array<color>"&&(l=l.map(h=>Bi.get(h)));return l};e in Bi||(Bi[e]=a),s&&(Bi.prototype[e]=function(...o){return a(this,...o)})}static defineFunctions(e){for(let r in e)Bi.defineFunction(r,e[r],e[r])}static extend(e){if(e.register)e.register(Bi);else for(let r in e)Bi.defineFunction(r,e[r])}};as.defineFunctions({get:fs,getAll:Rm,set:Fa,setAll:eT,to:Ht,equals:bQ,inGamut:Al,toGamut:Lo,distance:w3,toString:Bd}),Object.assign(as,{util:MK,hooks:Oo,WHITES:Oi,Space:Ce,spaces:Ce.registry,parse:v3,defaults:vs});for(let t of Object.keys(R_))Ce.register(R_[t]);for(let t in Ce.registry)jb(t,Ce.registry[t]);Oo.add("colorspace-init-end",t=>{jb(t.id,t),t.aliases?.forEach(e=>{jb(e,t)})});function jb(t,e){let r=t.replace(/-/g,"_");Object.defineProperty(as.prototype,r,{get(){let i=this.getAll(t);return typeof Proxy>"u"?i:new Proxy(i,{has:(s,n)=>{try{return Ce.resolveCoord([e,n]),!0}catch{}return Reflect.has(s,n)},get:(s,n,a)=>{if(n&&typeof n!="symbol"&&!(n in s)){let{index:o}=Ce.resolveCoord([e,n]);if(o>=0)return s[o]}return Reflect.get(s,n,a)},set:(s,n,a,o)=>{if(n&&typeof n!="symbol"&&!(n in s)||n>=0){let{index:l}=Ce.resolveCoord([e,n]);if(l>=0)return s[l]=a,this.setAll(t,s),!0}return Reflect.set(s,n,a,o)}})},set(i){this.setAll(t,i)},configurable:!0,enumerable:!0})}as.extend(bc),as.extend({deltaE:Td}),Object.assign(as,{deltaEMethods:bc}),as.extend(OQ),as.extend({contrast:CQ}),as.extend(PQ),as.extend(TQ),as.extend(FQ),as.extend(zf);const{vec2:QQ,vec4:eee}=Ve,Nt=t=>{let e=new as(t);return eee(...e.to("p3-linear").coords,e.alpha).value},Gu=t=>{let e=.5,r=.5,i=(s,n=!1)=>{if(typeof s=="number")return s;let a=s.toLowerCase().trim();if(n){if(a==="top")return 0;if(a==="bottom")return 1;if(a==="center")return .5}else{if(a==="left")return 0;if(a==="right")return 1;if(a==="center")return .5}return console.warn(`Invalid position value: ${s}. Defaulting to center.`),.5};if(typeof t=="string"){let s=t.toLowerCase().trim().split(/\s+/);s.includes("left")?e=0:s.includes("right")?e=1:(s.includes("center")||s.length===1&&(s[0]==="top"||s[0]==="bottom"))&&(e=.5),s.includes("top")?r=0:s.includes("bottom")?r=1:(s.includes("center")||s.length===1&&(s[0]==="left"||s[0]==="right"))&&(r=.5),s.length===1&&s[0]==="center"&&(e=.5,r=.5)}else typeof t=="object"&&t?(e=i(t.x,!1),r=i(t.y,!0)):console.warn(`Invalid position value provided: ${t}. Defaulting to center.`);return QQ(e,1-r).value},aT=t=>{if(typeof t=="number")return(t%360+360)%360;let e=t.toLowerCase().trim();switch(e){case"to right":return 0;case"to bottom":return 90;case"to left":return 180;case"to top":return 270;case"to bottom right":case"to right bottom":return 45;case"to bottom left":case"to left bottom":return 135;case"to top left":case"to left top":return 225;case"to top right":case"to right top":return 315;case"from left":return 0;case"from top":return 90;case"from right":return 180;case"from bottom":return 270;case"from top left":return 45;case"from top right":return 135;case"from bottom right":return 225;case"from bottom left":return 315;default:let r=e.match(/^(-?\d*\.?\d+)(deg|rad|turn)?$/);if(r){let[,i,s="deg"]=r,n=parseFloat(i);switch(s){case"deg":return(n%360+360)%360;case"rad":return(n*180/Math.PI%360+360)%360;case"turn":return(n*360%360+360)%360;default:return(n%360+360)%360}}return console.warn(`Invalid angle value: ${t}. Defaulting to 0 degrees.`),0}},Cl={name:"Blob",category:"Shapes & Masks",props:{colorA:{default:"#ff6b35",transform:Nt,description:"Primary color of the blob",ui:{type:"color",label:"Color A"}},colorB:{default:"#e91e63",transform:Nt,description:"Secondary color of the blob",ui:{type:"color",label:"Color B"}},colorC:{default:"#9c27b0",transform:Nt,description:"Tertiary color of the blob",ui:{type:"color",label:"Color C"}},size:{default:.5,description:"Size of the blob",ui:{type:"range",min:0,max:1,step:.01,label:"Size"}},conformity:{default:.5,description:"How organic and blobby the shape is (0 = circle, 1 = very blobby)",ui:{type:"range",min:0,max:1,step:.01,label:"Conformity"}},edgeWidth:{default:.1,description:"Width of edge transition (distance over which blob fades out)",ui:{type:"range",min:0,max:.5,step:.001,label:"Edge Width"}},edgeCurve:{default:.3,description:"Edge transition curve (< 1.0 = ease-in, 1.0 = linear, > 1.0 = ease-out)",ui:{type:"range",min:.1,max:3,step:.1,label:"Edge Curve"}},highlightIntensity:{default:.5,description:"Intensity of specular highlight effect",ui:{type:"range",min:0,max:1,step:.01,label:"Highlight Intensity"}},highlightLightX:{default:.4,description:"Light direction X component",ui:{type:"range",min:-1,max:1,step:.01,label:"Light X"}},highlightLightY:{default:-.4,description:"Light direction Y component",ui:{type:"range",min:-1,max:1,step:.01,label:"Light Y"}},highlightLightZ:{default:.2,description:"Light direction Z component",ui:{type:"range",min:-1,max:1,step:.01,label:"Light Z"}},highlightColor:{default:"#f4dfb5",transform:Nt,description:"Color of the specular highlight",ui:{type:"color",label:"Highlight Color"}},speed:{default:.5,description:"Animation speed",ui:{type:"range",min:0,max:2,step:.1,label:"Speed"}},seed:{default:1,description:"Animation seed offset for creating different animation states",ui:{type:"range",min:0,max:100,step:1,label:"Seed"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the blob",ui:{type:"position",label:"Center Position"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec3:r,vec4:i,float:s,screenUV:n,smoothstep:a,sin:o,length:l,timerLocal:h,viewportSize:u,mix:c,pow:d,max:m,normalize:p,dot:f,reflect:g}=Ve,y=h().mul(t.speed.uniform).add(t.seed.uniform),T=t.colorA.uniform,S=t.colorB.uniform,w=t.colorC.uniform,_=t.size.uniform,M=t.conformity.uniform,E=t.edgeWidth.uniform,A=t.edgeCurve.uniform,U=t.highlightIntensity.uniform,Q=t.highlightLightX.uniform,J=t.highlightLightY.uniform,re=t.highlightLightZ.uniform,ie=t.highlightColor.uniform,se=s(.5),ve=u.x.div(u.y),me=e(n.x.mul(ve),n.y),Me=e(t.center.uniform.x.mul(ve),t.center.uniform.y.oneMinus()),ye=me.sub(Me),Te=l(ye),ge=_,be=s(4),Je=o(ye.x.mul(be.mul(s(.8))).add(y.mul(s(.8)))).mul(o(ye.y.mul(be.mul(s(.7))).add(y.mul(s(.6))))).add(o(ye.x.mul(be.mul(s(1.2))).sub(ye.y.mul(be.mul(s(.9))).add(y.mul(s(.4)))))).mul(s(.15)).mul(M),wt=o(ye.x.mul(be.mul(s(1.4))).sub(y.mul(s(.5)))).mul(o(ye.y.mul(be.mul(s(1.1))).add(y.mul(s(.7))))).mul(s(.12)).mul(M).mul(a(s(.15),s(.25),se)),Bt=o(ye.x.mul(be.mul(s(1.8))).add(ye.y.mul(be.mul(s(1.6))).add(y.mul(s(.3))))).add(o(ye.x.mul(be.mul(s(.6))).sub(y.mul(s(.9))))).mul(s(.1)).mul(M).mul(a(s(.3),s(.4),se)),He=o(ye.x.mul(be.mul(s(2.2))).add(y.mul(s(.2)))).mul(o(ye.y.mul(be.mul(s(1.9))).sub(y.mul(s(.8))))).mul(s(.08)).mul(M).mul(a(s(.45),s(.55),se)),Wr=o(ye.x.mul(be.mul(s(2.8))).sub(ye.y.mul(be.mul(s(2.4))).add(y.mul(s(.6))))).mul(s(.06)).mul(M).mul(a(s(.6),s(.7),se)),Hr=o(ye.x.mul(be.mul(s(3.2))).add(y.mul(s(1.1)))).add(o(ye.y.mul(be.mul(s(3.5))).sub(y.mul(s(.4))))).mul(s(.04)).mul(M).mul(a(s(.75),s(.85),se)),Qt=Je.add(wt).add(Bt).add(He).add(Wr).add(Hr),Ot=ge.add(Qt),br=a(Ot.add(E),Ot.sub(E),Te),vr=d(br,A),qr=l(ye),Wt=Ot,Ir=a(s(0),Wt,qr),ui=s(1).sub(Ir.mul(s(.1))),Zi=p(r(ye.x.mul(Ir.add(s(.2))),ye.y.mul(Ir.add(s(.2))),ui)),Mi=p(r(Q,J,re)),ri=r(s(0),s(0),s(1)),_i=g(Mi.negate(),Zi),Ni=s(32),ws=m(s(0),f(_i,ri)),ta=d(ws,Ni),Vr=Ir.mul(s(.5)).add(s(.5)),zi=ta.mul(Vr),ii=zi.mul(U).mul(vr),he=ye.x.mul(s(3)),oe=ye.y.mul(s(3)),xe=o(he.add(y.mul(s(.4)))).mul(o(oe.add(y.mul(s(.3))))).add(o(he.mul(s(.7)).add(oe.mul(s(.8))).add(y.mul(s(.2))))).mul(s(.5)).add(s(.5)),ce=o(he.mul(s(1.3)).sub(y.mul(s(.5)))).mul(o(oe.mul(s(1.1)).add(y.mul(s(.6))))).add(o(he.mul(s(.5)).sub(oe.mul(s(.6)).sub(y.mul(s(.3)))))).mul(s(.5)).add(s(.5)),qe=o(he.mul(s(.8)).add(oe.mul(s(1.2)).add(y.mul(s(.1))))).mul(s(.3)).add(s(.5)),ut=a(s(.1),s(.9),xe),ht=a(s(.08),s(.99),ce.mul(qe)),Pt=c(T.rgb,S.rgb,ut),Lt=c(Pt,w.rgb,ht),ar=T.a.add(S.a).add(w.a).div(s(3)),yt=ie.rgb.mul(ii),st=Lt.add(yt);return i(st,ar.mul(vr))}},Rl={name:"Blur",category:"Effects",requiresRTT:!0,props:{intensity:{default:5,description:"Blur intensity (higher = more blur)",ui:{type:"range",min:0,max:20,step:.5,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,float:n,screenUV:a,convertToTexture:o,viewportSize:l}=Ve;if(!e)return s(0,0,0,0);let h=Math.round(r.width),u=Math.round(r.height),c=o(e,h,u),d=t.intensity.uniform.div(l.x.min(l.y)),m=[i(-1,-1),i(0,-1),i(1,-1),i(-1,0),i(0,0),i(1,0),i(-1,1),i(0,1),i(1,1)],p=[.0625,.125,.0625,.125,.25,.125,.0625,.125,.0625],f=s(0);for(let g=0;g<m.length;g++){let y=m[g].mul(d),T=a.add(y),S=n(p[g]),w=c.sample(T);f=f.add(w.mul(S))}return f}},Pl={name:"Bulge",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Il={name:"Checkerboard",category:"Shapes & Masks",props:{colorA:{default:"#cccccc",transform:Nt,description:"First color of the checkerboard pattern",ui:{type:"color",label:"Color A"}},colorB:{default:"#999999",transform:Nt,description:"Second color of the checkerboard pattern",ui:{type:"color",label:"Color B"}},cells:{default:8,description:"Number of cells along the shortest canvas edge (creates square cells)",ui:{type:"range",min:1,max:50,step:1,label:"Cells"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,floor:i,mod:s,screenUV:n,viewportSize:a}=Ve,o=a.x.div(a.y),l=e(n.x.mul(o),n.y.oneMinus()),h=t.cells.uniform,u=l.mul(h),c=i(u),d=s(c.x.add(c.y),2);return r(t.colorA.uniform,t.colorB.uniform,d)}},Vl={name:"ChromaFlow",category:"Gradients & Colors",props:{baseColor:{default:"#0066ff",transform:Nt,description:"Base liquid color",ui:{type:"color",label:"Base Color"}},upColor:{default:"#00ff00",transform:Nt,description:"Color for upward movement",ui:{type:"color",label:"Up Color"}},downColor:{default:"#ff0000",transform:Nt,description:"Color for downward movement",ui:{type:"color",label:"Down Color"}},leftColor:{default:"#0000ff",transform:Nt,description:"Color for leftward movement",ui:{type:"color",label:"Left Color"}},rightColor:{default:"#ffff00",transform:Nt,description:"Color for rightward movement",ui:{type:"color",label:"Right Color"}},intensity:{default:1,description:"Strength of the liquid effect",ui:{type:"range",min:.5,max:1.5,step:.1,label:"Intensity"}},duration:{default:3,description:"How long the liquid persists (higher = longer)",ui:{type:"range",min:0,max:10,step:.1,label:"Duration"}},radius:{default:2,description:"Radius of the liquid effect",ui:{type:"range",min:0,max:3,step:.01,label:"Radius"}},momentum:{default:30,description:"How much momentum colors retain in their flow direction",ui:{type:"range",min:10,max:60,step:1,label:"Momentum"}}},fragmentNode:({uniforms:t,onBeforeRender:e,onCleanup:r})=>{let{vec2:i,vec4:s,float:n,uniform:a,screenUV:o,texture:l,smoothstep:h,mix:u}=Ve,c=new Float32Array(16384*2),d=new Float32Array(16384*2),m=new em(c,128,128,So,gc);m.magFilter=ps,m.minFilter=ps,m.needsUpdate=!0;let p=new em(d,128,128,So,gc);p.magFilter=ps,p.minFilter=ps,p.needsUpdate=!0;let f=l(m),g=l(p),y=a(.5),T=a(.5),S=a(0),w=a(0),_=.5,M=.5,E=Date.now();e(({pointer:Vr})=>{let zi=Date.now(),ii=Math.min((zi-E)/1e3,.016);E=zi;let he=ii>0?(Vr.x-_)/ii:0,oe=ii>0?(Vr.y-M)/ii:0;S.value=S.value*.85+he*.15,w.value=w.value*.85+oe*.15,y.value=Vr.x,T.value=Vr.y;let xe=t.duration.uniform.value,ce=t.intensity.uniform.value,qe=t.radius.uniform.value*.05,ut=t.momentum.uniform.value,ht=new Float32Array(c),Pt=new Float32Array(d),Lt=1-ii/Math.max(xe/150*5,1);for(let ar=0;ar<16384*2;ar++)ht[ar]=c[ar]*Lt;for(let ar=0;ar<128;ar++)for(let yt=0;yt<128;yt++){let st=(ar*128+yt)*2,ct=1-ii/Math.max(xe/150*20,1);if(Pt[st]=d[st]*ct,Pt[st+1]=d[st+1]*ct,Math.abs(c[st])>.001||Math.abs(c[st+1])>.001){let Xr=ut*50*ii,Ji=yt-c[st]*Xr,Wo=ar-c[st+1]*Xr,ra=Math.floor(Ji),ia=Math.floor(Wo),Oc=ra+1,Ho=ia+1;if(ra>=0&&ia>=0&&Oc<128&&Ho<128){let qa=Ji-ra,qu=Wo-ia,fL=(ia*128+ra)*2,gL=(ia*128+Oc)*2,yL=(Ho*128+ra)*2,xL=(Ho*128+Oc)*2,bL=d[fL]*(1-qa)*(1-qu)+d[gL]*qa*(1-qu)+d[yL]*(1-qa)*qu+d[xL]*qa*qu;Pt[st]=bL*ct}}}for(let ar=0;ar<128;ar++)for(let yt=0;yt<128;yt++){let st=(ar*128+yt)*2,ct=(yt+.5)/128,Xr=(ar+.5)/128,Ji=ct-Vr.x,Wo=Xr-Vr.y,ra=Math.sqrt(Ji*Ji+Wo*Wo),ia=Math.sqrt(S.value*S.value+w.value*w.value),Oc=Math.min(ia*ia*20,1),Ho=qe*Oc;if(ra<Ho*2&&Math.abs(he)+Math.abs(oe)>.01){let qa=Math.exp(-ra*ra/(Ho*Ho));ht[st]+=S.value*qa*(ce*100)*ii*.01,ht[st+1]+=w.value*qa*(ce*100)*ii*.01;let qu=Math.min(ia*10,1);Pt[st]+=qa*(ce*100)*ii*.01*qu,Pt[st+1]=0}ht[st]=Math.max(-1,Math.min(1,ht[st])),ht[st+1]=Math.max(-1,Math.min(1,ht[st+1])),Pt[st]=Math.max(0,Math.min(1,Pt[st])),Pt[st+1]=0}c.set(ht),d.set(Pt),m.needsUpdate=!0,p.needsUpdate=!0,_=Vr.x,M=Vr.y}),r(()=>{m.dispose(),p.dispose()});let A=g.sample(o).x,U=i(n(1/128),n(1/128)),Q=g.sample(o.add(i(U.x,n(0)))).x,J=g.sample(o.add(i(n(0),U.y))).x,re=g.sample(o.add(i(U.x.negate(),n(0)))).x,ie=g.sample(o.add(i(n(0),U.y.negate()))).x,se=A.add(Q).add(J).add(re).add(ie).mul(n(.2)),ve=h(n(0),n(.1),se),me=i(n(1/128),n(1/128)),Me=f.sample(o).xy,ye=f.sample(o.add(i(me.x,n(0)))).xy,Te=f.sample(o.add(i(n(0),me.y))).xy,ge=f.sample(o.add(i(me.x.negate(),n(0)))).xy,be=f.sample(o.add(i(n(0),me.y.negate()))).xy,Je=Me.add(ye).add(Te).add(ge).add(be).mul(n(.2)),wt=t.baseColor.uniform,Bt=t.upColor.uniform,He=t.downColor.uniform,Wr=t.leftColor.uniform,Hr=t.rightColor.uniform,Qt=Je.x.mul(Je.x).add(Je.y.mul(Je.y)).sqrt(),Ot=h(n(.01),n(.1),Qt),br=Je.x.div(Qt.add(n(.001))),vr=Je.y.div(Qt.add(n(.001))),qr=h(n(0),n(.7),br.max(n(0))),Wt=h(n(0),n(.7),br.negate().max(n(0))),Ir=h(n(0),n(.7),vr.max(n(0))),ui=h(n(0),n(.7),vr.negate().max(n(0))),Zi=Wr.mul(Wt).add(Hr.mul(qr)),Mi=He.mul(ui).add(Bt.mul(Ir)),ri=Wt.add(qr),_i=Ir.add(ui),Ni=ri.add(_i).add(n(.001)),ws=Zi.mul(ri.div(Ni)).add(Mi.mul(_i.div(Ni))),ta=u(wt,ws,Ot);return s(ta.rgb.mul(ve),ta.a.mul(ve))}},Ol={name:"ChromaticAberration",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Ll={name:"Circle",category:"Shapes & Masks",props:{color:{default:"#ffffff",transform:Nt,description:"The color of the circle",ui:{type:"color",label:"Color"}},radius:{default:1,description:"The radius of the circle. A value of one (1) is sets the circle to fit the canvas.",ui:{type:"range",min:0,max:2,step:.01,label:"Radius"}},softness:{default:0,description:"Edge softness. Lower values like zero (0) are sharp, higher values like one (1) are softer.",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the circle",ui:{type:"position",label:"Center Position"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,length:i,smoothstep:s,screenUV:n,viewportSize:a}=Ve,o=a.x.div(a.y),l=e(n.x.mul(o),n.y),h=e(t.center.uniform.x.mul(o),t.center.uniform.y.oneMinus()),u=i(l.sub(h)),c=t.softness.uniform,d=t.radius.uniform.mul(.5),m=s(d,d.sub(c),u);return r(t.color.uniform.rgb,t.color.uniform.a.mul(m))}},Fl={name:"ColorMapping",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},zl={name:"CRTScreen",category:"Effects",requiresRTT:!0,props:{pixelSize:{default:128,description:"Size of individual TV pixels (lower = more pixels)",ui:{type:"range",min:8,max:128,step:1,label:"Pixel Size"}},colorShift:{default:1,description:"Chromatic aberration amount",ui:{type:"range",min:0,max:10,step:.1,label:"Color Shift"}},scanlineIntensity:{default:.3,description:"Strength of horizontal scanlines",ui:{type:"range",min:0,max:1,step:.01,label:"Scanline Intensity"}},scanlineFrequency:{default:200,description:"Number of scanlines across screen",ui:{type:"range",min:100,max:800,step:10,label:"Scanline Frequency"}},brightness:{default:1.1,description:"Screen brightness boost",ui:{type:"range",min:.5,max:2,step:.01,label:"Brightness"}},contrast:{default:1.2,description:"Screen contrast enhancement",ui:{type:"range",min:.5,max:2,step:.01,label:"Contrast"}},curvature:{default:.2,description:"CRT screen curvature effect",ui:{type:"range",min:0,max:.3,step:.01,label:"Curvature"}},scaleToFill:{default:0,description:"Automatically scale to eliminate curvature whitespace",ui:{type:"checkbox",label:"Scale to Fill"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec3:s,vec4:n,float:a,screenUV:o,sin:l,fract:h,smoothstep:u,mix:c,length:d,convertToTexture:m}=Ve;if(!e)return n(0,0,0,0);let p=Math.round(r.width),f=Math.round(r.height),g=m(e,p,f),y=t.pixelSize.uniform,T=t.colorShift.uniform,S=t.scanlineIntensity.uniform,w=t.scanlineFrequency.uniform,_=t.brightness.uniform,M=t.contrast.uniform,E=t.curvature.uniform,A=t.scaleToFill.uniform,U=A.greaterThan(a(.5)).select(a(1).add(E.mul(a(2))),a(1)),Q=o.sub(i(.5,.5)).div(U).add(i(.5,.5)),J=Q.sub(i(.5,.5)),re=d(J),ie=E.mul(re.mul(re)),se=Q.add(J.mul(ie)),ve=se.x.lessThan(a(0)).or(se.x.greaterThan(a(1))).or(se.y.lessThan(a(0))).or(se.y.greaterThan(a(1))),me=T.mul(a(.002)),Me=se.add(i(me,a(0))),ye=se,Te=se.sub(i(me,a(0))),ge=g.sample(Me).r,be=g.sample(ye).g,Je=g.sample(Te).b,wt=s(ge,be,Je),Bt=wt.sub(a(.5)).mul(M).add(a(.5)).mul(_),He=se.y.mul(w),Wr=l(He.mul(a(3.14159*2))),Hr=a(1).sub(S.mul(Wr.mul(a(.5)).add(a(.5)))),Qt=Bt.mul(Hr),Ot=y.mul(a(.5)),br=h(se.mul(Ot)),vr=l(br.x.mul(a(6.28318))).mul(a(.1)).add(a(.95)),qr=l(br.x.mul(a(6.28318)).add(a(2.09))).mul(a(.1)).add(a(.95)),Wt=l(br.x.mul(a(6.28318)).add(a(4.18))).mul(a(.1)).add(a(.95)),Ir=s(Qt.r.mul(vr),Qt.g.mul(qr),Qt.b.mul(Wt)),ui=d(J),Zi=u(a(.8),a(.3),ui),Mi=Ir.mul(Zi),ri=c(s(0,0,0),Mi,ve.select(a(0),a(1)));return n(ri,a(1))}},Bl={name:"Dither",category:"Effects",props:{pixelSize:{default:4,description:"Size of dithering pixels",ui:{type:"range",min:1,max:20,step:1,label:"Pixel Size"}},threshold:{default:.5,description:"Luminance threshold for dithering",ui:{type:"range",min:0,max:1,step:.01,label:"Threshold"}},colorA:{default:"transparent",transform:Nt,description:"Dark color for dithering",ui:{type:"color",label:"Dark Color"}},colorB:{default:"#ffffff",transform:Nt,description:"Light color for dithering",ui:{type:"color",label:"Light Color"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec2:r,vec3:i,vec4:s,floor:n,screenUV:a,viewportSize:o,dot:l,step:h,mix:u}=Ve;if(!e)return s(0);let c=e,d=l(c.rgb,i(.299,.587,.114)),m=d.mul(c.a),p=t.pixelSize.uniform,f=n(a.mul(o).div(p)),g=f.mod(r(4)),y=g.x,T=g.y,S=T.equal(0).select(y.equal(0).select(0/16,y.equal(1).select(8/16,y.equal(2).select(2/16,10/16))),T.equal(1).select(y.equal(0).select(12/16,y.equal(1).select(4/16,y.equal(2).select(14/16,6/16))),T.equal(2).select(y.equal(0).select(3/16,y.equal(1).select(11/16,y.equal(2).select(1/16,9/16))),y.equal(0).select(15/16,y.equal(1).select(7/16,y.equal(2).select(13/16,5/16)))))),w=t.threshold.uniform,_=h(S,m.add(w.sub(.5))),M=u(t.colorA.uniform.rgb,t.colorB.uniform.rgb,_),E=u(t.colorA.uniform.a,t.colorB.uniform.a,_);return s(M,E)}},kl={name:"DotGrid",category:"Shapes & Masks",props:{color:{default:"#ffffff",description:"The color of the dot",transform:Nt,ui:{type:"color",label:"Color"}},density:{default:100,description:"The number of dots on the longest canvas edge",ui:{type:"range",min:10,max:500,step:10,label:"Density"}},dotSize:{default:.3,description:"The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps",ui:{type:"range",min:0,max:1,step:.01,label:"Dot Size"}},twinkle:{default:0,description:"Intensity of the twinkle effect (0 = off, 1 = full twinkle)",ui:{type:"range",min:0,max:1,step:.01,label:"Twinkle"}}},fragmentNode:({uniforms:t})=>{let{screenUV:e,vec4:r,vec2:i,smoothstep:s,length:n,floor:a,float:o,viewportSize:l,time:h,sin:u,mix:c}=Ve,d=e,m=t.density.uniform,p=t.dotSize.uniform,f=t.color.uniform,g=t.twinkle.uniform,y=l,T=y.x.div(y.y),S=i(d.x.mul(T),d.y.oneMinus()),w=S.mul(m),_=w.sub(a(w)),M=n(_.sub(.5)),E=n(JR(S.mul(m))),A=o(1).sub(s(p.mul(.5),p.mul(.5).add(E.mul(.5)),M)),U=a(w),Q=U.x.mul(12.9898).add(U.y.mul(78.233)).sin().mul(43758.5453).fract(),J=h.mul(2).add(Q.mul(6.28318)),re=u(J).mul(.5).add(.5),ie=c(o(1),re,g),se=A.mul(ie);return r(f.rgb,se)}},Ul={name:"Duotone",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Dl={name:"Exposure",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},$l={name:"FilmGrain",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Gl={name:"GlassTiles",category:"Distortions",requiresRTT:!0,props:{intensity:{default:1,description:"The intensity of the glass tiles effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},tileCount:{default:100,description:"Number of tiles across the shortest dimension",ui:{type:"range",min:1,max:200,step:1,label:"Tile Count"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,floor:n,mul:a,div:o,sub:l,add:h,convertToTexture:u,screenUV:c,uniform:d}=Ve;if(!e)return console.error("You must pass a child component into the Glass Tiles shader."),s(0);let m=Math.round(r.width),p=Math.round(r.height),f=u(e,m,p),g=d(r.width/r.height),y=c,T=t.intensity.uniform,S=t.tileCount.uniform,w=i(g.greaterThanEqual(1).select(a(S,g),S),g.lessThan(1).select(o(S,g),S)),_=o(n(a(y,w)),w),M=l(y,_),E=i(.5,.5),A=a(T,.025),U=o(M,o(i(1),w)),Q=l(U,E),J=a(Q,A),re=h(M,J),ie=h(re,_);return s(f.sample(ie))}},jl={name:"Glitch",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Wl={name:"Glow",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Hl={name:"Godrays",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},af={VERTEX:"vertex"},po={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Im=["x","y","z","w"],pi="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".split(".");let P_=1234567;const Y3=Math.PI/180,Z3=180/Math.PI;function Bf(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(pi[t&255]+pi[t>>8&255]+pi[t>>16&255]+pi[t>>24&255]+"-"+pi[e&255]+pi[e>>8&255]+"-"+pi[e>>16&15|64]+pi[e>>24&255]+"-"+pi[r&63|128]+pi[r>>8&255]+"-"+pi[r>>16&255]+pi[r>>24&255]+pi[i&255]+pi[i>>8&255]+pi[i>>16&255]+pi[i>>24&255]).toLowerCase()}function xt(t,e,r){return Math.max(e,Math.min(r,t))}function oT(t,e){return(t%e+e)%e}function tee(t,e,r,i,s){return i+(t-e)*(s-i)/(r-e)}function ree(t,e,r){return t===e?0:(r-t)/(e-t)}function kd(t,e,r){return(1-r)*t+r*e}function iee(t,e,r,i){return kd(t,e,1-Math.exp(-r*i))}function see(t,e=1){return e-Math.abs(oT(t,e*2)-e)}function nee(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*(3-2*t))}function aee(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*t*(t*(t*6-15)+10))}function oee(t,e){return t+Math.floor(Math.random()*(e-t+1))}function lee(t,e){return t+Math.random()*(e-t)}function uee(t){return t*(.5-Math.random())}function hee(t){t!==void 0&&(P_=t);let e=P_+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function cee(t){return t*Y3}function dee(t){return t*Z3}function mee(t){return(t&t-1)==0&&t!==0}function pee(t){return 2**Math.ceil(Math.log(t)/Math.LN2)}function fee(t){return 2**Math.floor(Math.log(t)/Math.LN2)}function gee(t,e,r,i,s){let n=Math.cos,a=Math.sin,o=n(r/2),l=a(r/2),h=n((e+i)/2),u=a((e+i)/2),c=n((e-i)/2),d=a((e-i)/2),m=n((i-e)/2),p=a((i-e)/2);switch(s){case"XYX":t.set(o*u,l*c,l*d,o*h);break;case"YZY":t.set(l*d,o*u,l*c,o*h);break;case"ZXZ":t.set(l*c,l*d,o*u,o*h);break;case"XZX":t.set(o*u,l*p,l*m,o*h);break;case"YXY":t.set(l*m,o*u,l*p,o*h);break;case"ZYZ":t.set(l*p,l*m,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function cn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}function Mt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw Error("Invalid component type.")}}const yee={DEG2RAD:Y3,RAD2DEG:Z3,generateUUID:Bf,clamp:xt,euclideanModulo:oT,mapLinear:tee,inverseLerp:ree,lerp:kd,damp:iee,pingpong:see,smoothstep:nee,smootherstep:aee,randInt:oee,randFloat:lee,randFloatSpread:uee,seededRandom:hee,degToRad:cee,radToDeg:dee,isPowerOfTwo:mee,ceilPowerOfTwo:pee,floorPowerOfTwo:fee,setQuaternionFromProperEuler:gee,normalize:Mt,denormalize:cn},ln="srgb",I_="srgb-linear",V_="linear",Ud="srgb",gg=35044,Tl=2e3,Wb=2001;var Vm=class J3{constructor(e,r,i,s,n,a,o,l,h){J3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h)}set(e,r,i,s,n,a,o,l,h){let u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=r,u[4]=n,u[5]=l,u[6]=i,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],this}extractBasis(e,r,i){return e.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let r=e.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],u=i[4],c=i[7],d=i[2],m=i[5],p=i[8],f=s[0],g=s[3],y=s[6],T=s[1],S=s[4],w=s[7],_=s[2],M=s[5],E=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*S+l*M,n[6]=a*y+o*w+l*E,n[1]=h*f+u*T+c*_,n[4]=h*g+u*S+c*M,n[7]=h*y+u*w+c*E,n[2]=d*f+m*T+p*_,n[5]=d*g+m*S+p*M,n[8]=d*y+m*w+p*E,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=e,r[4]*=e,r[7]*=e,r[2]*=e,r[5]*=e,r[8]*=e,this}determinant(){let e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8];return r*a*u-r*o*h-i*n*u+i*o*l+s*n*h-s*a*l}invert(){let e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=u*a-o*h,d=o*l-u*n,m=h*n-a*l,p=r*c+i*d+s*m;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(s*h-u*i)*f,e[2]=(o*i-s*a)*f,e[3]=d*f,e[4]=(u*r-s*l)*f,e[5]=(s*n-o*r)*f,e[6]=m*f,e[7]=(i*l-h*r)*f,e[8]=(a*r-i*n)*f,this}transpose(){let e,r=this.elements;return e=r[1],r[1]=r[3],r[3]=e,e=r[2],r[2]=r[6],r[6]=e,e=r[5],r[5]=r[7],r[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let r=this.elements;return e[0]=r[0],e[1]=r[3],e[2]=r[6],e[3]=r[1],e[4]=r[4],e[5]=r[7],e[6]=r[2],e[7]=r[5],e[8]=r[8],this}setUvTransform(e,r,i,s,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-s*h,s*l,-s*(-h*a+l*o)+o+r,0,0,1),this}scale(e,r){return this.premultiply(fx.makeScale(e,r)),this}rotate(e){return this.premultiply(fx.makeRotation(-e)),this}translate(e,r){return this.premultiply(fx.makeTranslation(e,r)),this}makeTranslation(e,r){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,r,0,0,1),this}makeRotation(e){let r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,i,r,0,0,0,1),this}makeScale(e,r){return this.set(e,0,0,0,r,0,0,0,1),this}equals(e){let r=this.elements,i=e.elements;for(let s=0;s<9;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<9;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){let i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const fx=new Vm,O_={};function L_(t){t in O_||(O_[t]=!0,console.warn(t))}const F_=new Vm().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),z_=new Vm().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xee(){let t={enabled:!0,workingColorSpace:I_,spaces:{},convert:function(s,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Ud&&(s.r=sc(s.r),s.g=sc(s.g),s.b=sc(s.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ud&&(s.r=nc(s.r),s.g=nc(s.g),s.b=nc(s.b))),s},workingToColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},colorSpaceToWorking:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===""?V_:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,a){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,n){return L_("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(s,n)},toWorkingColorSpace:function(s,n){return L_("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(s,n)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[I_]:{primaries:e,whitePoint:i,transfer:V_,toXYZ:F_,fromXYZ:z_,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:ln},outputColorSpaceConfig:{drawingBufferColorSpace:ln}},[ln]:{primaries:e,whitePoint:i,transfer:Ud,toXYZ:F_,fromXYZ:z_,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:ln}}}),t}const _r=xee();function sc(t){return t<.04045?t*.0773993808:(t*.9478672986+.0521327014)**2.4}function nc(t){return t<.0031308?t*12.92:1.055*t**.41666-.055}const K3={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},lo={h:0,s:0,l:0},of={h:0,s:0,l:0};function gx(t,e,r){return r<0&&(r+=1),r>1&&--r,r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*6*(2/3-r):t}var lT=class{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){let 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=ln){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,_r.colorSpaceToWorking(this,e),this}setRGB(t,e,r,i=_r.workingColorSpace){return this.r=t,this.g=e,this.b=r,_r.colorSpaceToWorking(this,i),this}setHSL(t,e,r,i=_r.workingColorSpace){if(t=oT(t,1),e=xt(e,0,1),r=xt(r,0,1),e===0)this.r=this.g=this.b=r;else{let s=r<=.5?r*(1+e):r+e-r*e,n=2*r-s;this.r=gx(n,s,t+1/3),this.g=gx(n,s,t),this.b=gx(n,s,t-1/3)}return _r.colorSpaceToWorking(this,i),this}setStyle(t,e=ln){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,n=i[1],a=i[2];switch(n){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)){let s=i[1],n=s.length;if(n===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(n===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=ln){let r=K3[t.toLowerCase()];return r===void 0?console.warn("THREE.Color: Unknown color "+t):this.setHex(r,e),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=sc(t.r),this.g=sc(t.g),this.b=sc(t.b),this}copyLinearToSRGB(t){return this.r=nc(t.r),this.g=nc(t.g),this.b=nc(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ln){return _r.workingToColorSpace(fi.copy(this),t),Math.round(xt(fi.r*255,0,255))*65536+Math.round(xt(fi.g*255,0,255))*256+Math.round(xt(fi.b*255,0,255))}getHexString(t=ln){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=_r.workingColorSpace){_r.workingToColorSpace(fi.copy(this),e);let r=fi.r,i=fi.g,s=fi.b,n=Math.max(r,i,s),a=Math.min(r,i,s),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case r:o=(i-s)/u+(i<s?6:0);break;case i:o=(s-r)/u+2;break;case s:o=(r-i)/u+4;break}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=_r.workingColorSpace){return _r.workingToColorSpace(fi.copy(this),e),t.r=fi.r,t.g=fi.g,t.b=fi.b,t}getStyle(t=ln){_r.workingToColorSpace(fi.copy(this),t);let e=fi.r,r=fi.g,i=fi.b;return t===ln?`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(i*255)})`:`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`}offsetHSL(t,e,r){return this.getHSL(lo),this.setHSL(lo.h+t,lo.s+e,lo.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(lo),t.getHSL(of);let r=kd(lo.h,of.h,e),i=kd(lo.s,of.s,e),s=kd(lo.l,of.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){let 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 fi=new lT;lT.NAMES=K3;var bee=class Q3{constructor(e,r,i,s){Q3.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,r,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,r=0){for(let i=0;i<4;i++)this.elements[i]=e[i+r];return this}set(e,r,i,s){let n=this.elements;return n[0]=e,n[2]=r,n[1]=i,n[3]=s,this}},vee=class{constructor(e=0,r=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=r,this._z=i,this._w=s}static slerpFlat(e,r,i,s,n,a,o){let l=i[s+0],h=i[s+1],u=i[s+2],c=i[s+3],d=n[a+0],m=n[a+1],p=n[a+2],f=n[a+3];if(o===0){e[r+0]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c;return}if(o===1){e[r+0]=d,e[r+1]=m,e[r+2]=p,e[r+3]=f;return}if(c!==f||l!==d||h!==m||u!==p){let g=1-o,y=l*d+h*m+u*p+c*f,T=y>=0?1:-1,S=1-y*y;if(S>2**-52){let _=Math.sqrt(S),M=Math.atan2(_,y*T);g=Math.sin(g*M)/_,o=Math.sin(o*M)/_}let w=o*T;if(l=l*g+d*w,h=h*g+m*w,u=u*g+p*w,c=c*g+f*w,g===1-o){let _=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=_,h*=_,u*=_,c*=_}}e[r]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c}static multiplyQuaternionsFlat(e,r,i,s,n,a){let o=i[s],l=i[s+1],h=i[s+2],u=i[s+3],c=n[a],d=n[a+1],m=n[a+2],p=n[a+3];return e[r]=o*p+u*c+l*m-h*d,e[r+1]=l*p+u*d+h*c-o*m,e[r+2]=h*p+u*m+o*d-l*c,e[r+3]=u*p-o*c-l*d-h*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,r,i,s){return this._x=e,this._y=r,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,r=!0){let i=e._x,s=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,h=o(i/2),u=o(s/2),c=o(n/2),d=l(i/2),m=l(s/2),p=l(n/2);switch(a){case"XYZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"YXZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"ZXY":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"ZYX":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"YZX":this._x=d*u*c+h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c-d*m*p;break;case"XZY":this._x=d*u*c-h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c+d*m*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,r){let i=r/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let r=e.elements,i=r[0],s=r[4],n=r[8],a=r[1],o=r[5],l=r[9],h=r[2],u=r[6],c=r[10],d=i+o+c;if(d>0){let m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-l)*m,this._y=(n-h)*m,this._z=(a-s)*m}else if(i>o&&i>c){let m=2*Math.sqrt(1+i-o-c);this._w=(u-l)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(n+h)/m}else if(o>c){let m=2*Math.sqrt(1+o-i-c);this._w=(n-h)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(l+u)/m}else{let m=2*Math.sqrt(1+c-i-o);this._w=(a-s)/m,this._x=(n+h)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,r){let i=e.dot(r)+1;return i<2**-52?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*r.z-e.z*r.y,this._y=e.z*r.x-e.x*r.z,this._z=e.x*r.y-e.y*r.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(xt(this.dot(e),-1,1)))}rotateTowards(e,r){let i=this.angleTo(e);if(i===0)return this;let s=Math.min(1,r/i);return this.slerp(e,s),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,r){let i=e._x,s=e._y,n=e._z,a=e._w,o=r._x,l=r._y,h=r._z,u=r._w;return this._x=i*u+a*o+s*h-n*l,this._y=s*u+a*l+n*o-i*h,this._z=n*u+a*h+i*l-s*o,this._w=a*u-i*o-s*l-n*h,this._onChangeCallback(),this}slerp(e,r){if(r===0)return this;if(r===1)return this.copy(e);let i=this._x,s=this._y,n=this._z,a=this._w,o=a*e._w+i*e._x+s*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=s,this._z=n,this;let l=1-o*o;if(l<=2**-52){let m=1-r;return this._w=m*a+r*this._w,this._x=m*i+r*this._x,this._y=m*s+r*this._y,this._z=m*n+r*this._z,this.normalize(),this}let h=Math.sqrt(l),u=Math.atan2(h,o),c=Math.sin((1-r)*u)/h,d=Math.sin(r*u)/h;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=s*c+this._y*d,this._z=n*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,r,i){return this.copy(e).slerp(r,i)}random(){let e=2*Math.PI*Math.random(),r=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),n*Math.sin(r),n*Math.cos(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,r=0){return this._x=e[r],this._y=e[r+1],this._z=e[r+2],this._w=e[r+3],this._onChangeCallback(),this}toArray(e=[],r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,e}fromBufferAttribute(e,r){return this._x=e.getX(r),this._y=e.getY(r),this._z=e.getZ(r),this._w=e.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Tn=class e5{constructor(e=0,r=0,i=0){e5.prototype.isVector3=!0,this.x=e,this.y=r,this.z=i}set(e,r,i){return i===void 0&&(i=this.z),this.x=e,this.y=r,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,r){return this.x=e.x*r.x,this.y=e.y*r.y,this.z=e.z*r.z,this}applyEuler(e){return this.applyQuaternion(B_.setFromEuler(e))}applyAxisAngle(e,r){return this.applyQuaternion(B_.setFromAxisAngle(e,r))}applyMatrix3(e){let r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[3]*i+n[6]*s,this.y=n[1]*r+n[4]*i+n[7]*s,this.z=n[2]*r+n[5]*i+n[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let r=this.x,i=this.y,s=this.z,n=e.elements,a=1/(n[3]*r+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*r+n[4]*i+n[8]*s+n[12])*a,this.y=(n[1]*r+n[5]*i+n[9]*s+n[13])*a,this.z=(n[2]*r+n[6]*i+n[10]*s+n[14])*a,this}applyQuaternion(e){let r=this.x,i=this.y,s=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*s-o*i),u=2*(o*r-n*s),c=2*(n*i-a*r);return this.x=r+l*h+a*c-o*u,this.y=i+l*u+o*h-n*c,this.z=s+l*c+n*u-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[4]*i+n[8]*s,this.y=n[1]*r+n[5]*i+n[9]*s,this.z=n[2]*r+n[6]*i+n[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,r){return this.x=xt(this.x,e.x,r.x),this.y=xt(this.y,e.y,r.y),this.z=xt(this.z,e.z,r.z),this}clampScalar(e,r){return this.x=xt(this.x,e,r),this.y=xt(this.y,e,r),this.z=xt(this.z,e,r),this}clampLength(e,r){let i=this.length();return this.divideScalar(i||1).multiplyScalar(xt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,r){let i=e.x,s=e.y,n=e.z,a=r.x,o=r.y,l=r.z;return this.x=s*l-n*o,this.y=n*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){let r=e.lengthSq();if(r===0)return this.set(0,0,0);let i=e.dot(this)/r;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yx.copy(this).projectOnVector(e),this.sub(yx)}reflect(e){return this.sub(yx.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let i=this.dot(e)/r;return Math.acos(xt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return r*r+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,r,i){let s=Math.sin(r)*e;return this.x=s*Math.sin(i),this.y=Math.cos(r)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,r,i){return this.x=e*Math.sin(r),this.y=i,this.z=e*Math.cos(r),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(e){let r=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=r,this.y=i,this.z=s,this}setFromMatrixColumn(e,r){return this.fromArray(e.elements,r*4)}setFromMatrix3Column(e,r){return this.fromArray(e.elements,r*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,r=Math.random()*2-1,i=Math.sqrt(1-r*r);return this.x=i*Math.cos(e),this.y=r,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const yx=new Tn,B_=new vee;var t5=class Hb{constructor(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){Hb.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g)}set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){let y=this.elements;return y[0]=e,y[4]=r,y[8]=i,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=u,y[10]=c,y[14]=d,y[3]=m,y[7]=p,y[11]=f,y[15]=g,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 Hb().fromArray(this.elements)}copy(e){let r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],this}copyPosition(e){let r=this.elements,i=e.elements;return r[12]=i[12],r[13]=i[13],r[14]=i[14],this}setFromMatrix3(e){let r=e.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(e,r,i){return e.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,r,i){return this.set(e.x,r.x,i.x,0,e.y,r.y,i.y,0,e.z,r.z,i.z,0,0,0,0,1),this}extractRotation(e){let r=this.elements,i=e.elements,s=1/Eh.setFromMatrixColumn(e,0).length(),n=1/Eh.setFromMatrixColumn(e,1).length(),a=1/Eh.setFromMatrixColumn(e,2).length();return r[0]=i[0]*s,r[1]=i[1]*s,r[2]=i[2]*s,r[3]=0,r[4]=i[4]*n,r[5]=i[5]*n,r[6]=i[6]*n,r[7]=0,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(e){let r=this.elements,i=e.x,s=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(s),h=Math.sin(s),u=Math.cos(n),c=Math.sin(n);if(e.order==="XYZ"){let d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=-l*c,r[8]=h,r[1]=m+p*h,r[5]=d-f*h,r[9]=-o*l,r[2]=f-d*h,r[6]=p+m*h,r[10]=a*l}else if(e.order==="YXZ"){let d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d+f*o,r[4]=p*o-m,r[8]=a*h,r[1]=a*c,r[5]=a*u,r[9]=-o,r[2]=m*o-p,r[6]=f+d*o,r[10]=a*l}else if(e.order==="ZXY"){let d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d-f*o,r[4]=-a*c,r[8]=p+m*o,r[1]=m+p*o,r[5]=a*u,r[9]=f-d*o,r[2]=-a*h,r[6]=o,r[10]=a*l}else if(e.order==="ZYX"){let d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=p*h-m,r[8]=d*h+f,r[1]=l*c,r[5]=f*h+d,r[9]=m*h-p,r[2]=-h,r[6]=o*l,r[10]=a*l}else if(e.order==="YZX"){let d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=f-d*c,r[8]=p*c+m,r[1]=c,r[5]=a*u,r[9]=-o*u,r[2]=-h*u,r[6]=m*c+p,r[10]=d-f*c}else if(e.order==="XZY"){let d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=-c,r[8]=h*u,r[1]=d*c+f,r[5]=a*u,r[9]=m*c-p,r[2]=p*c-m,r[6]=o*u,r[10]=f*c+d}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Tee,e,wee)}lookAt(e,r,i){let s=this.elements;return ss.subVectors(e,r),ss.lengthSq()===0&&(ss.z=1),ss.normalize(),uo.crossVectors(i,ss),uo.lengthSq()===0&&(Math.abs(i.z)===1?ss.x+=1e-4:ss.z+=1e-4,ss.normalize(),uo.crossVectors(i,ss)),uo.normalize(),lf.crossVectors(ss,uo),s[0]=uo.x,s[4]=lf.x,s[8]=ss.x,s[1]=uo.y,s[5]=lf.y,s[9]=ss.y,s[2]=uo.z,s[6]=lf.z,s[10]=ss.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],u=i[1],c=i[5],d=i[9],m=i[13],p=i[2],f=i[6],g=i[10],y=i[14],T=i[3],S=i[7],w=i[11],_=i[15],M=s[0],E=s[4],A=s[8],U=s[12],Q=s[1],J=s[5],re=s[9],ie=s[13],se=s[2],ve=s[6],me=s[10],Me=s[14],ye=s[3],Te=s[7],ge=s[11],be=s[15];return n[0]=a*M+o*Q+l*se+h*ye,n[4]=a*E+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*U+o*ie+l*Me+h*be,n[1]=u*M+c*Q+d*se+m*ye,n[5]=u*E+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*U+c*ie+d*Me+m*be,n[2]=p*M+f*Q+g*se+y*ye,n[6]=p*E+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*U+f*ie+g*Me+y*be,n[3]=T*M+S*Q+w*se+_*ye,n[7]=T*E+S*J+w*ve+_*Te,n[11]=T*A+S*re+w*me+_*ge,n[15]=T*U+S*ie+w*Me+_*be,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[4]*=e,r[8]*=e,r[12]*=e,r[1]*=e,r[5]*=e,r[9]*=e,r[13]*=e,r[2]*=e,r[6]*=e,r[10]*=e,r[14]*=e,r[3]*=e,r[7]*=e,r[11]*=e,r[15]*=e,this}determinant(){let e=this.elements,r=e[0],i=e[4],s=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],u=e[2],c=e[6],d=e[10],m=e[14],p=e[3],f=e[7],g=e[11],y=e[15];return p*(+n*l*c-s*h*c-n*o*d+i*h*d+s*o*m-i*l*m)+f*(+r*l*m-r*h*d+n*a*d-s*a*m+s*h*u-n*l*u)+g*(+r*h*c-r*o*m-n*a*c+i*a*m+n*o*u-i*h*u)+y*(-s*o*u-r*l*c+r*o*d+s*a*c-i*a*d+i*l*u)}transpose(){let e=this.elements,r;return r=e[1],e[1]=e[4],e[4]=r,r=e[2],e[2]=e[8],e[8]=r,r=e[6],e[6]=e[9],e[9]=r,r=e[3],e[3]=e[12],e[12]=r,r=e[7],e[7]=e[13],e[13]=r,r=e[11],e[11]=e[14],e[14]=r,this}setPosition(e,r,i){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=r,s[14]=i),this}invert(){let e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],m=e[11],p=e[12],f=e[13],g=e[14],y=e[15],T=c*g*h-f*d*h+f*l*m-o*g*m-c*l*y+o*d*y,S=p*d*h-u*g*h-p*l*m+a*g*m+u*l*y-a*d*y,w=u*f*h-p*c*h+p*o*m-a*f*m-u*o*y+a*c*y,_=p*c*l-u*f*l-p*o*d+a*f*d+u*o*g-a*c*g,M=r*T+i*S+s*w+n*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/M;return e[0]=T*E,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*E,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*E,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*E,e[4]=S*E,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*E,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*E,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*E,e[8]=w*E,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*E,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*E,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*E,e[12]=_*E,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*E,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*E,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*E,this}scale(e){let r=this.elements,i=e.x,s=e.y,n=e.z;return r[0]*=i,r[4]*=s,r[8]*=n,r[1]*=i,r[5]*=s,r[9]*=n,r[2]*=i,r[6]*=s,r[10]*=n,r[3]*=i,r[7]*=s,r[11]*=n,this}getMaxScaleOnAxis(){let e=this.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(r,i,s))}makeTranslation(e,r,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,r,0,0,1,i,0,0,0,1),this}makeRotationX(e){let r=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,r,-i,0,0,i,r,0,0,0,0,1),this}makeRotationY(e){let r=Math.cos(e),i=Math.sin(e);return this.set(r,0,i,0,0,1,0,0,-i,0,r,0,0,0,0,1),this}makeRotationZ(e){let r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,0,i,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,r){let i=Math.cos(r),s=Math.sin(r),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,u=n*o;return this.set(h*a+i,h*o-s*l,h*l+s*o,0,h*o+s*l,u*o+i,u*l-s*a,0,h*l-s*o,u*l+s*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,r,i){return this.set(e,0,0,0,0,r,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,r,i,s,n,a){return this.set(1,i,n,0,e,1,a,0,r,s,1,0,0,0,0,1),this}compose(e,r,i){let s=this.elements,n=r._x,a=r._y,o=r._z,l=r._w,h=n+n,u=a+a,c=o+o,d=n*h,m=n*u,p=n*c,f=a*u,g=a*c,y=o*c,T=l*h,S=l*u,w=l*c,_=i.x,M=i.y,E=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-S)*_,s[3]=0,s[4]=(m-w)*M,s[5]=(1-(d+y))*M,s[6]=(g+T)*M,s[7]=0,s[8]=(p+S)*E,s[9]=(g-T)*E,s[10]=(1-(d+f))*E,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,r,i){let s=this.elements,n=Eh.set(s[0],s[1],s[2]).length(),a=Eh.set(s[4],s[5],s[6]).length(),o=Eh.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),e.x=s[12],e.y=s[13],e.z=s[14],nn.copy(this);let h=1/n,u=1/a,c=1/o;return nn.elements[0]*=h,nn.elements[1]*=h,nn.elements[2]*=h,nn.elements[4]*=u,nn.elements[5]*=u,nn.elements[6]*=u,nn.elements[8]*=c,nn.elements[9]*=c,nn.elements[10]*=c,r.setFromRotationMatrix(nn),i.x=n,i.y=a,i.z=o,this}makePerspective(e,r,i,s,n,a,o=Tl){let l=this.elements,h=2*n/(r-e),u=2*n/(i-s),c=(r+e)/(r-e),d=(i+s)/(i-s),m,p;if(o===Tl)m=-(a+n)/(a-n),p=-2*a*n/(a-n);else if(o===Wb)m=-a/(a-n),p=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,r,i,s,n,a,o=Tl){let l=this.elements,h=1/(r-e),u=1/(i-s),c=1/(a-n),d=(r+e)*h,m=(i+s)*u,p,f;if(o===Tl)p=(a+n)*c,f=-2*c;else if(o===Wb)p=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=f,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let r=this.elements,i=e.elements;for(let s=0;s<16;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<16;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){let i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e[r+9]=i[9],e[r+10]=i[10],e[r+11]=i[11],e[r+12]=i[12],e[r+13]=i[13],e[r+14]=i[14],e[r+15]=i[15],e}};const Eh=new Tn,nn=new t5,Tee=new Tn(0,0,0),wee=new Tn(1,1,1),uo=new Tn,lf=new Tn,ss=new Tn;var r5=class i5{constructor(e=0,r=0){i5.prototype.isVector2=!0,this.x=e,this.y=r}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,r){return this.x=e,this.y=r,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let r=this.x,i=this.y,s=e.elements;return this.x=s[0]*r+s[3]*i+s[6],this.y=s[1]*r+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,r){return this.x=xt(this.x,e.x,r.x),this.y=xt(this.y,e.y,r.y),this}clampScalar(e,r){return this.x=xt(this.x,e,r),this.y=xt(this.y,e,r),this}clampLength(e,r){let i=this.length();return this.divideScalar(i||1).multiplyScalar(xt(i,e,r))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let i=this.dot(e)/r;return Math.acos(xt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,i=this.y-e.y;return r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this}rotateAround(e,r){let i=Math.cos(r),s=Math.sin(r),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*s+e.x,this.y=n*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},See=class s5{constructor(e=0,r=0,i=0,s=1){s5.prototype.isVector4=!0,this.x=e,this.y=r,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,r,i,s){return this.x=e,this.y=r,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this.w=e.w+r.w,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this.w+=e.w*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this.w=e.w-r.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let r=this.x,i=this.y,s=this.z,n=this.w,a=e.elements;return this.x=a[0]*r+a[4]*i+a[8]*s+a[12]*n,this.y=a[1]*r+a[5]*i+a[9]*s+a[13]*n,this.z=a[2]*r+a[6]*i+a[10]*s+a[14]*n,this.w=a[3]*r+a[7]*i+a[11]*s+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let r=Math.sqrt(1-e.w*e.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/r,this.y=e.y/r,this.z=e.z/r),this}setAxisAngleFromRotationMatrix(e){let r,i,s,n,a=.01,o=.1,l=e.elements,h=l[0],u=l[4],c=l[8],d=l[1],m=l[5],p=l[9],f=l[2],g=l[6],y=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(p-g)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(p+g)<o&&Math.abs(h+m+y-3)<o)return this.set(1,0,0,0),this;r=Math.PI;let S=(h+1)/2,w=(m+1)/2,_=(y+1)/2,M=(u+d)/4,E=(c+f)/4,A=(p+g)/4;return S>w&&S>_?S<a?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(S),s=M/i,n=E/i):w>_?w<a?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=M/s,n=A/s):_<a?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=E/n,s=A/n),this.set(i,s,n,r),this}let T=Math.sqrt((g-p)*(g-p)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(T)<.001&&(T=1),this.x=(g-p)/T,this.y=(c-f)/T,this.z=(d-u)/T,this.w=Math.acos((h+m+y-1)/2),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this.w=r[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,r){return this.x=xt(this.x,e.x,r.x),this.y=xt(this.y,e.y,r.y),this.z=xt(this.z,e.z,r.z),this.w=xt(this.w,e.w,r.w),this}clampScalar(e,r){return this.x=xt(this.x,e,r),this.y=xt(this.y,e,r),this.z=xt(this.z,e,r),this.w=xt(this.w,e,r),this}clampLength(e,r){let i=this.length();return this.divideScalar(i||1).multiplyScalar(xt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this.w+=(e.w-this.w)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this.w=e.w+(r.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this.w=e[r+3],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e[r+3]=this.w,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this.w=e.getW(r),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}};function qb(t,e=0){let r=3735928559^e,i=1103547991^e;if(t instanceof Array)for(let s=0,n;s<t.length;s++)n=t[s],r=Math.imul(r^n,2654435761),i=Math.imul(i^n,1597334677);else for(let s=0,n;s<t.length;s++)n=t.charCodeAt(s),r=Math.imul(r^n,2654435761),i=Math.imul(i^n,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&i)+(r>>>0)}const n5=(...t)=>qb(t);function Mee(t,e=!1){let r=[];t.isNode===!0&&(r.push(t.id),t=t.getSelf());for(let{property:i,childNode:s}of Xb(t))r.push(qb(i.slice(0,-4)),s.getCacheKey(e));return qb(r)}function*Xb(t,e=!1){for(let r in t){if(r.startsWith("_")===!0)continue;let i=t[r];if(Array.isArray(i)===!0)for(let s=0;s<i.length;s++){let n=i[s];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:s,childNode:n})}else if(i&&i.isNode===!0)yield{property:r,childNode:i};else if(typeof i=="object")for(let s in i){let n=i[s];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:s,childNode:n})}}}function Yb(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function a5(t,...e){let r=t?t.slice(-4):void 0;return e.length===1&&(r==="vec2"?e=[e[0],e[0]]:r==="vec3"?e=[e[0],e[0],e[0]]:r==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new lT(...e):r==="vec2"?new r5(...e):r==="vec3"?new Tn(...e):r==="vec4"?new See(...e):r==="mat2"?new bee(...e):r==="mat3"?new Vm(...e):r==="mat4"?new t5(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?Nee(e[0]):null}function _ee(t){let e="",r=new Uint8Array(t);for(let i=0;i<r.length;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function Nee(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer}var Eee=class{addEventListener(e,r){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(r)===-1&&i[e].push(r)}hasEventListener(e,r){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(r)!==-1}removeEventListener(e,r){let i=this._listeners;if(i===void 0)return;let s=i[e];if(s!==void 0){let n=s.indexOf(r);n!==-1&&s.splice(n,1)}}dispatchEvent(e){let r=this._listeners;if(r===void 0)return;let i=r[e.type];if(i!==void 0){e.target=this;let s=i.slice(0);for(let n=0,a=s.length;n<a;n++)s[n].call(this,e);e.target=null}}};const Aee={analyze:"setup",generate:"analyze"};let Cee=0;var Ree=class extends Eee{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=po.NONE,this.updateBeforeType=po.NONE,this.updateAfterType=po.NONE,this.uuid=yee.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Cee++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,r){return this.updateType=r,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,po.FRAME)}onRenderUpdate(e){return this.onUpdate(e,po.RENDER)}onObjectUpdate(e){return this.onUpdate(e,po.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of Xb(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(let r of this.getChildren())r.traverse(e)}getCacheKey(e=!1){return e||(e=this.version!==this._cacheKeyVersion),(e===!0||this._cacheKey===null)&&(this._cacheKey=n5(Mee(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let r=this.getNodeType(e);return e.getElementType(r)}getMemberType(){return"void"}getNodeType(e){let r=e.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(e):this.nodeType}getShared(e){let r=this.getHash(e);return e.getNodeFromHash(r)||this}setup(e){let r=e.getNodeProperties(this),i=0;for(let s of this.getChildren())r["node"+i++]=s;return r.outputNode||null}analyze(e,r=null){let i=e.increaseUsage(this);if(this.parents===!0){let s=e.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[e.shaderStage]=s.stages[e.shaderStage]||[],s.stages[e.shaderStage].push(r)}if(i===1){let s=e.getNodeProperties(this);for(let n of Object.values(s))n&&n.isNode===!0&&n.build(e,this)}}generate(e,r){let{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,r)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,r=null){let i=this.getShared(e);if(this!==i)return i.build(e,r);let s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;let n=Aee[e.buildStage];if(n&&s.buildStages[n]!==!0){let l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o==="setup"){this.updateReference(e);let l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(let h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){let u=e.getNodeProperties(h);u.parents=u.parents||[],u.parents.push(this)}h.build(e)}}a=l.outputNode}else if(o==="analyze")this.analyze(e,r);else if(o==="generate")if(this.generate.length===1){let h=this.getNodeType(e),u=e.getDataFromNode(this);a=u.snippet,a===void 0?u.generated===void 0?(u.generated=!0,a=this.generate(e)||"",u.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a=""):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,h,r)}else a=this.generate(e,r)||"";return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Xb(this)}serialize(e){let r=this.getSerializeChildren(),i={};for(let{property:s,index:n,childNode:a}of r)n===void 0?i[s]=a.toJSON(e.meta).uuid:(i[s]===void 0&&(i[s]=Number.isInteger(n)?[]:{}),i[s][n]=a.toJSON(e.meta).uuid);Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){let r=e.meta.nodes;for(let i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){let s=[];for(let n of e.inputNodes[i])s.push(r[n]);this[i]=s}else if(typeof e.inputNodes[i]=="object"){let s={};for(let n in e.inputNodes[i]){let a=e.inputNodes[i][n];s[n]=r[a]}this[i]=s}else{let s=e.inputNodes[i];this[i]=r[s]}}}toJSON(e){let{uuid:r,type:i}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[r];n===void 0&&(n={uuid:r,type:i,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){let l=[];for(let h in o){let u=o[h];delete u.metadata,l.push(u)}return l}if(s){let o=a(e.textures),l=a(e.images),h=a(e.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}},Cr=Ree,Pee=class extends Cr{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,r){if(e.getBuildStage()==="generate"){let s=e.getVectorType(this.getNodeType(e,r)),n=e.getDataFromNode(this);if(n.propertyName!==void 0)return e.format(n.propertyName,s,r);if(s!=="void"&&r!=="void"&&this.hasDependencies(e)){let a=super.build(e,s),o=e.getVarFromNode(this,null,s),l=e.getPropertyName(o);return e.addLineFlowCode(`${l} = ${a}`,this),n.snippet=a,n.propertyName=l,e.format(n.propertyName,s,r)}}return super.build(e,r)}},Ts=Pee,Iee=class extends Cr{static get type(){return"ArrayElementNode"}constructor(e,r){super(),this.node=e,this.indexNode=r,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let r=this.indexNode.getNodeType(e),i=this.node.build(e),s=this.indexNode.build(e,!e.isVector(r)&&e.isInteger(r)?r:"uint");return`${i}[ ${s} ]`}},uT=Iee,Vee=class extends Cr{static get type(){return"ConvertNode"}constructor(e,r){super(),this.node=e,this.convertTo=r}getNodeType(e){let r=this.node.getNodeType(e),i=null;for(let s of this.convertTo.split("|"))(i===null||e.getTypeLength(r)===e.getTypeLength(s))&&(i=s);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,r){let i=this.node,s=this.getNodeType(e),n=i.build(e,s);return e.format(n,s,r)}},o5=Vee,Oee=class extends Ts{static get type(){return"JoinNode"}constructor(e=[],r=null){super(r),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((r,i)=>r+e.getTypeLength(i.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,r){let i=this.getNodeType(e),s=e.getTypeLength(i),n=this.nodes,a=e.getComponentType(i),o=[],l=0;for(let u of n){if(l>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${i}()' type.`);break}let c=u.getNodeType(e),d=e.getTypeLength(c),m;l+d>s&&(console.error(`THREE.TSL: Length of '${i}()' data exceeds maximum length of output type.`),d=s-l,c=e.getTypeFromLength(d)),l+=d,m=u.build(e,c);let p=e.getComponentType(c);p!==a&&(m=e.format(m,p,a)),o.push(m)}let h=`${e.getType(i)}( ${o.join(", ")} )`;return e.format(h,i,r)}},Lee=Oee;const Fee=Im.join("");var zee=class extends Cr{static get type(){return"SplitNode"}constructor(e,r="x"){super(),this.node=e,this.components=r,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let r of this.components)e=Math.max(Im.indexOf(r)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,r){let i=this.node,s=e.getTypeLength(i.getNodeType(e)),n=null;if(s>1){let a=null;this.getVectorLength()>=s&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let l=i.build(e,a);n=this.components.length===s&&this.components===Fee.slice(0,this.components.length)?e.format(l,a,r):e.format(`${l}.${this.components}`,this.getNodeType(e),r)}else n=i.build(e,r);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},k_=zee,Bee=class extends Ts{static get type(){return"SetNode"}constructor(t,e,r){super(),this.sourceNode=t,this.components=e,this.targetNode=r}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:r,targetNode:i}=this,s=this.getNodeType(t),n=t.getComponentType(i.getNodeType(t)),a=t.getTypeFromLength(r.length,n),o=i.build(t,a),l=e.build(t,s),h=t.getTypeLength(s),u=[];for(let c=0;c<h;c++){let d=Im[c];d===r[0]?(u.push(o),c+=r.length-1):u.push(l+"."+d)}return`${t.getType(s)}( ${u.join(", ")} )`}},kee=Bee,Uee=class extends Ts{static get type(){return"FlipNode"}constructor(e,r){super(),this.sourceNode=e,this.components=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:r,sourceNode:i}=this,s=this.getNodeType(e),n=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+n,this);let l=e.getTypeLength(s),h=[],u=0;for(let c=0;c<l;c++){let d=Im[c];d===r[u]?(h.push("1.0 - "+(o+"."+d)),u++):h.push(o+"."+d)}return`${e.getType(s)}( ${h.join(", ")} )`}},Dee=Uee,$ee=class extends Cr{static get type(){return"InputNode"}constructor(e,r=null){super(r),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Yb(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Yb(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=_ee(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?a5(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}},hT=$ee;const U_=/float|u?int/;var Gee=class extends hT{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let r=this.getNodeType(t);return U_.test(r)&&U_.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),r,e)}},Wa=Gee,jee=class extends Cr{static get type(){return"MemberNode"}constructor(e,r){super(),this.node=e,this.property=r,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}},Wee=jee;const Wh=new Map;function H(t,e){if(Wh.has(t)){console.warn(`THREE.TSL: Redefinition of method chaining '${t}'.`);return}if(typeof e!="function")throw Error(`THREE.TSL: Node element ${t} is not a function`);Wh.set(t,e)}const l5=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),D_=t=>l5(t).split("").sort().join(""),u5={setup(t,e){let r=e.shift();return t(my(r),...e)},get(t,e,r){if(typeof e=="string"&&t[e]===void 0){if(t.isStackNode!==!0&&e==="assign")return(...i)=>(null.assign(r,...i),r);if(Wh.has(e)){let i=Wh.get(e);return t.isStackNode?(...s)=>r.add(i(...s)):(...s)=>i(r,...s)}else{if(e==="self")return t;if(e.endsWith("Assign")&&Wh.has(e.slice(0,e.length-6))){let i=Wh.get(e.slice(0,e.length-6));return t.isStackNode?(...s)=>r.assign(s[0],i(...s)):(...s)=>r.assign(i(r,...s))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=l5(e),Re(new k_(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D_(e.slice(3).toLowerCase()),i=>Re(new kee(t,e,Re(i)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D_(e.slice(4).toLowerCase()),()=>Re(new Dee(Re(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Re(new k_(t,e));if(/^\d+$/.test(e)===!0)return Re(new uT(r,new Wa(Number(e),"uint")));if(/^get$/.test(e)===!0)return i=>Re(new Wee(r,i))}}}return Reflect.get(t,e,r)},set(t,e,r,i){return typeof e=="string"&&t[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(r),!0):Reflect.set(t,e,r,i)}},xx=new WeakMap,$_=new WeakMap,Hee=function(t,e=null){let r=Yb(t);if(r==="node"){let i=xx.get(t);return i===void 0&&(i=new Proxy(t,u5),xx.set(t,i),xx.set(i,i)),i}else{if(e===null&&(r==="float"||r==="boolean")||r&&r!=="shader"&&r!=="string")return Re(Zb(t,e));if(r==="shader")return Xs(t)}return t},qee=function(t,e=null){for(let r in t)t[r]=Re(t[r],e);return t},Xee=function(t,e=null){let r=t.length;for(let i=0;i<r;i++)t[i]=Re(t[i],e);return t},Yee=function(t,e=null,r=null,i=null){let s=u=>Re(i===null?u:Object.assign(u,i)),n,a=e,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:t.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return e===null?n=(...u)=>s(new t(...kf(h(u)))):r===null?n=(...u)=>s(new t(e,...kf(h(u)))):(r=Re(r),n=(...u)=>s(new t(e,...kf(h(u)),r))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var Zee=class extends Cr{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,inputNodes:r}=this,i=t.getNodeProperties(e),s=e.namespace&&e.namespace===t.namespace?t.getNamespace("once"):"once";if(i[s])return i[s];let n=null;if(e.layout){let a=$_.get(t.constructor);a===void 0&&(a=new WeakMap,$_.set(t.constructor,a));let o=a.get(e);o===void 0&&(o=Re(t.buildFunctionNode(e)),a.set(e,o)),t.addInclude(o),n=Re(o.call(r))}else{let a=e.jsFunc,o=r!==null||a.length>1?a(r||[],t):a(t);n=Re(o)}return e.once&&(i[s]=n),n}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),r=t.getOutputNamespace();return e[r]=e[r]||this.setupOutput(t),e[r]}build(t,e=null){let r=null,i=t.getBuildStage(),s=t.getNodeProperties(this),n=t.getOutputNamespace(),a=this.getOutputNode(t);if(i==="setup"){let o=t.getNamespace("initialized");s[o]!==!0&&(s[o]=!0,s[n]=this.getOutputNode(t),s[n].build(t)),r=s[n]}else i==="analyze"?a.build(t,e):i==="generate"&&(r=a.build(t,e)||"");return r}},Jee=class extends Cr{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(t){return this.layout=t,this}call(t=null){return my(t),Re(new Zee(this,t))}setup(){return this.call()}};const Kee=[!1,!0],Qee=[0,1,2,3],ete=[-1,-2],h5=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],cT=new Map;for(let t of Kee)cT.set(t,new Wa(t));const dT=new Map;for(let t of Qee)dT.set(t,new Wa(t,"uint"));const mT=new Map([...dT].map(t=>new Wa(t.value,"int")));for(let t of ete)mT.set(t,new Wa(t,"int"));const cy=new Map([...mT].map(t=>new Wa(t.value)));for(let t of h5)cy.set(t,new Wa(t));for(let t of h5)cy.set(-t,new Wa(-t));const dy={bool:cT,uint:dT,ints:mT,float:cy},G_=new Map([...cT,...cy]),Zb=(t,e)=>G_.has(t)?G_.get(t):t.isNode===!0?t:new Wa(t,e),tte=t=>{try{return t.getNodeType()}catch{return}},Rr=function(t,e=null){return(...r)=>{if((r.length===0||!["bool","float","int","uint"].includes(t)&&r.every(s=>typeof s!="object"))&&(r=[a5(t,...r)]),r.length===1&&e!==null&&e.has(r[0]))return Re(e.get(r[0]));if(r.length===1){let s=Zb(r[0],t);return tte(s)===t?Re(s):Re(new o5(s,t))}let i=r.map(s=>Zb(s));return Re(new Lee(i,t))}},rte=t=>t==null?null:t.nodeType||t.convertTo||(typeof t=="string"?t:null);function ite(t,e){return new Proxy(new Jee(t,e),u5)}const Re=(t,e=null)=>Hee(t,e),my=(t,e=null)=>new qee(t,e),kf=(t,e=null)=>new Xee(t,e),de=(...t)=>new Yee(...t);let ste=0;const Xs=(t,e=null)=>{let r=null;e!==null&&(typeof e=="object"?r=e.return:(typeof e=="string"?r=e:console.error("THREE.TSL: Invalid layout type."),e=null));let i=new ite(t,r),s=(...n)=>{let a;my(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=i.call(a);return r==="void"&&l.toStack(),l};if(s.shaderNode=i,s.id=i.id,s.getNodeType=(...n)=>i.getNodeType(...n),s.getCacheKey=(...n)=>i.getCacheKey(...n),s.setLayout=n=>(i.setLayout(n),s),s.once=(n=null)=>(i.once=!0,i.namespace=n,s),e!==null){if(typeof e.inputs!="object"){let n={name:"fn"+ste++,type:r,inputs:[]};for(let a in e)a!=="return"&&n.inputs.push({name:a,type:e[a]});e=n}s.setLayout(e)}return s};function nte(t){return t}H("toStack",nte);const ate=new Rr("color"),za=new Rr("float",dy.float),sm=new Rr("int",dy.ints),ote=new Rr("uint",dy.uint),lte=new Rr("bool",dy.bool),c5=new Rr("vec2"),ute=new Rr("ivec2"),hte=new Rr("uvec2"),cte=new Rr("bvec2"),Tc=new Rr("vec3"),dte=new Rr("ivec3"),mte=new Rr("uvec3"),pte=new Rr("bvec3"),ql=new Rr("vec4"),fte=new Rr("ivec4"),gte=new Rr("uvec4"),yte=new Rr("bvec4"),xte=new Rr("mat2"),d5=new Rr("mat3"),bte=new Rr("mat4");H("toColor",ate),H("toFloat",za),H("toInt",sm),H("toUint",ote),H("toBool",lte),H("toVec2",c5),H("toIVec2",ute),H("toUVec2",hte),H("toBVec2",cte),H("toVec3",Tc),H("toIVec3",dte),H("toUVec3",mte),H("toBVec3",pte),H("toVec4",ql),H("toIVec4",fte),H("toUVec4",gte),H("toBVec4",yte),H("toMat2",xte),H("toMat3",d5),H("toMat4",bte);const vte=de(uT).setParameterLength(2),Tte=(t,e)=>Re(new o5(Re(t),e));H("element",vte),H("convert",Tte),H("append",t=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),t));const wte={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var yr=class Jb extends Ts{static get type(){return"OperatorNode"}constructor(e,r,i,...s){if(super(),s.length>0){let n=new Jb(e,r,i);for(let a=0;a<s.length-1;a++)n=new Jb(e,n,s[a]);r=n,i=s[s.length-1]}this.op=e,this.aNode=r,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(e,r){return e.getMethod(wte[this.op],r)}getNodeType(e){let r=this.op,i=this.aNode,s=this.bNode,n=i.getNodeType(e),a=s?s.getNodeType(e):null;if(n==="void"||a==="void")return"void";if(r==="%")return n;if(r==="~"||r==="&"||r==="|"||r==="^"||r===">>"||r==="<<")return e.getIntegerType(n);if(r==="!"||r==="&&"||r==="||"||r==="^^")return"bool";if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){let o=Math.max(e.getTypeLength(n),e.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(e.isMatrix(n)){if(a==="float")return n;if(e.isVector(a))return e.getVectorFromMatrix(n);if(e.isMatrix(a))return n}else if(e.isMatrix(a)){if(n==="float")return a;if(e.isVector(n))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(n)?a:n}}generate(e,r){let i=this.op,{aNode:s,bNode:n}=this,a=this.getNodeType(e),o=null,l=null;a==="void"?o=l=a:(o=s.getNodeType(e),l=n?n.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):i==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):o=e.isMatrix(l)?o==="float"?"float":e.isVector(o)?e.getVectorFromMatrix(l):l=a:l=a);let h=s.build(e,o),u=n?n.build(e,l):null,c=e.getFunctionOperator(i);if(r!=="void"){let d=e.renderer.coordinateSystem===Tl;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return d&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,r)}( ${h}, ${u} )`,a,r):e.format(`( ${h} ${i} ${u} )`,a,r);if(i==="%")return e.isInteger(l)?e.format(`( ${h} % ${u} )`,a,r):e.format(`${this.getOperatorMethod(e,a)}( ${h}, ${u} )`,a,r);if(i==="!"||i==="~")return e.format(`(${i}${h})`,o,r);if(c)return e.format(`${c}( ${h}, ${u} )`,a,r);if(e.isMatrix(o)&&l==="float")return e.format(`( ${u} ${i} ${h} )`,a,r);if(o==="float"&&e.isMatrix(l))return e.format(`${h} ${i} ${u}`,a,r);{let m=`( ${h} ${i} ${u} )`;return!d&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(m=`all${m}`),e.format(m,a,r)}}else if(o!=="void")return c?e.format(`${c}( ${h}, ${u} )`,a,r):e.isMatrix(o)&&l==="float"?e.format(`${u} ${i} ${h}`,a,r):e.format(`${h} ${i} ${u}`,a,r)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const m5=de(yr,"+").setParameterLength(2,1/0).setName("add"),Kb=de(yr,"-").setParameterLength(2,1/0).setName("sub"),pT=de(yr,"*").setParameterLength(2,1/0).setName("mul"),p5=de(yr,"/").setParameterLength(2,1/0).setName("div"),py=de(yr,"%").setParameterLength(2).setName("mod"),f5=de(yr,"==").setParameterLength(2).setName("equal"),Ste=de(yr,"!=").setParameterLength(2).setName("notEqual"),Mte=de(yr,"<").setParameterLength(2).setName("lessThan"),_te=de(yr,">").setParameterLength(2).setName("greaterThan"),Nte=de(yr,"<=").setParameterLength(2).setName("lessThanEqual"),Ete=de(yr,">=").setParameterLength(2).setName("greaterThanEqual"),Ate=de(yr,"&&").setParameterLength(2,1/0).setName("and"),Cte=de(yr,"||").setParameterLength(2,1/0).setName("or"),Rte=de(yr,"!").setParameterLength(1).setName("not"),Pte=de(yr,"^^").setParameterLength(2).setName("xor"),Ite=de(yr,"&").setParameterLength(2).setName("bitAnd"),Vte=de(yr,"~").setParameterLength(2).setName("bitNot"),Ote=de(yr,"|").setParameterLength(2).setName("bitOr"),Lte=de(yr,"^").setParameterLength(2).setName("bitXor"),Fte=de(yr,"<<").setParameterLength(2).setName("shiftLeft"),zte=de(yr,">>").setParameterLength(2).setName("shiftRight"),Bte=Xs(([t])=>(t.addAssign(1),t)),kte=Xs(([t])=>(t.subAssign(1),t)),Ute=Xs(([t])=>{let e=sm(t).toConst();return t.addAssign(1),e}),Dte=Xs(([t])=>{let e=sm(t).toConst();return t.subAssign(1),e});H("add",m5),H("sub",Kb),H("mul",pT),H("div",p5),H("mod",py),H("equal",f5),H("notEqual",Ste),H("lessThan",Mte),H("greaterThan",_te),H("lessThanEqual",Nte),H("greaterThanEqual",Ete),H("and",Ate),H("or",Cte),H("not",Rte),H("xor",Pte),H("bitAnd",Ite),H("bitNot",Vte),H("bitOr",Ote),H("bitXor",Lte),H("shiftLeft",Fte),H("shiftRight",zte),H("incrementBefore",Bte),H("decrementBefore",kte),H("increment",Ute),H("decrement",Dte);const $te=(t,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),py(t,e)),Gte=(t,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),py(sm(t),sm(e)));H("remainder",$te),H("modInt",Gte);var D=class zt extends Ts{static get type(){return"MathNode"}constructor(e,r,i=null,s=null){if(super(),(e===zt.MAX||e===zt.MIN)&&arguments.length>3){let n=new zt(e,r,i);for(let a=2;a<arguments.length-1;a++)n=new zt(e,n,arguments[a]);r=n,i=arguments[arguments.length-1],s=null}this.method=e,this.aNode=r,this.bNode=i,this.cNode=s,this.isMathNode=!0}getInputType(e){let r=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,s=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(s)?0:e.getTypeLength(s);return n>a&&n>o?r:a>o?i:o>n?s:r}getNodeType(e){let r=this.method;return r===zt.LENGTH||r===zt.DISTANCE||r===zt.DOT?"float":r===zt.CROSS?"vec3":r===zt.ALL||r===zt.ANY?"bool":r===zt.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:r,bNode:i,method:s}=this,n=null;if(s===zt.ONE_MINUS)n=Kb(1,r);else if(s===zt.RECIPROCAL)n=p5(1,r);else if(s===zt.DIFFERENCE)n=fT(Kb(r,i));else if(s===zt.TRANSFORM_DIRECTION){let a=r,o=i;e.isMatrix(a.getNodeType(e))?o=ql(Tc(o),0):a=ql(Tc(a),0);let l=pT(a,o).xyz;n=g5(l)}return n===null?super.setup(e):n}generate(e,r){if(e.getNodeProperties(this).outputNode)return super.generate(e,r);let s=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,h=this.cNode,u=e.renderer.coordinateSystem;if(s===zt.NEGATE)return e.format("( - "+o.build(e,a)+" )",n,r);{let c=[];return s===zt.CROSS?c.push(o.build(e,n),l.build(e,n)):u===Tl&&s===zt.STEP?c.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===Tl&&(s===zt.MIN||s===zt.MAX)?c.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):s===zt.REFRACT?c.push(o.build(e,a),l.build(e,a),h.build(e,"float")):s===zt.MIX?c.push(o.build(e,a),l.build(e,a),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":a)):(u===Wb&&s===zt.ATAN&&l!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===zt.DFDX||s===zt.DFDY)&&(console.warn(`THREE.TSL: '${s}' is not supported in the ${e.shaderStage} stage.`),s="/*"+s+"*/"),c.push(o.build(e,a)),l!==null&&c.push(l.build(e,a)),h!==null&&c.push(h.build(e,a))),e.format(`${e.getMethod(s,n)}( ${c.join(", ")} )`,n,r)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};D.ALL="all",D.ANY="any",D.RADIANS="radians",D.DEGREES="degrees",D.EXP="exp",D.EXP2="exp2",D.LOG="log",D.LOG2="log2",D.SQRT="sqrt",D.INVERSE_SQRT="inversesqrt",D.FLOOR="floor",D.CEIL="ceil",D.NORMALIZE="normalize",D.FRACT="fract",D.SIN="sin",D.COS="cos",D.TAN="tan",D.ASIN="asin",D.ACOS="acos",D.ATAN="atan",D.ABS="abs",D.SIGN="sign",D.LENGTH="length",D.NEGATE="negate",D.ONE_MINUS="oneMinus",D.DFDX="dFdx",D.DFDY="dFdy",D.ROUND="round",D.RECIPROCAL="reciprocal",D.TRUNC="trunc",D.FWIDTH="fwidth",D.TRANSPOSE="transpose",D.BITCAST="bitcast",D.EQUALS="equals",D.MIN="min",D.MAX="max",D.STEP="step",D.REFLECT="reflect",D.DISTANCE="distance",D.DIFFERENCE="difference",D.DOT="dot",D.CROSS="cross",D.POW="pow",D.TRANSFORM_DIRECTION="transformDirection",D.MIX="mix",D.CLAMP="clamp",D.REFRACT="refract",D.SMOOTHSTEP="smoothstep",D.FACEFORWARD="faceforward";const jte=za(Math.PI),Wte=de(D,D.ALL).setParameterLength(1),Hte=de(D,D.ANY).setParameterLength(1),qte=de(D,D.RADIANS).setParameterLength(1),Xte=de(D,D.DEGREES).setParameterLength(1),Yte=de(D,D.EXP).setParameterLength(1),Zte=de(D,D.EXP2).setParameterLength(1),Jte=de(D,D.LOG).setParameterLength(1),Kte=de(D,D.LOG2).setParameterLength(1),Qte=de(D,D.SQRT).setParameterLength(1),ere=de(D,D.INVERSE_SQRT).setParameterLength(1),tre=de(D,D.FLOOR).setParameterLength(1),rre=de(D,D.CEIL).setParameterLength(1),g5=de(D,D.NORMALIZE).setParameterLength(1),y5=de(D,D.FRACT).setParameterLength(1),x5=de(D,D.SIN).setParameterLength(1),ire=de(D,D.COS).setParameterLength(1),sre=de(D,D.TAN).setParameterLength(1),nre=de(D,D.ASIN).setParameterLength(1),are=de(D,D.ACOS).setParameterLength(1),b5=de(D,D.ATAN).setParameterLength(1,2),fT=de(D,D.ABS).setParameterLength(1),v5=de(D,D.SIGN).setParameterLength(1),ore=de(D,D.LENGTH).setParameterLength(1),lre=de(D,D.NEGATE).setParameterLength(1),ure=de(D,D.ONE_MINUS).setParameterLength(1),hre=de(D,D.DFDX).setParameterLength(1),cre=de(D,D.DFDY).setParameterLength(1),dre=de(D,D.ROUND).setParameterLength(1),mre=de(D,D.RECIPROCAL).setParameterLength(1),pre=de(D,D.TRUNC).setParameterLength(1),fre=de(D,D.FWIDTH).setParameterLength(1),gre=de(D,D.TRANSPOSE).setParameterLength(1),yre=(t,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),f5(t,e)),xre=de(D,D.MIN).setParameterLength(2,1/0),bre=de(D,D.MAX).setParameterLength(2,1/0),vre=de(D,D.STEP).setParameterLength(2),Tre=de(D,D.REFLECT).setParameterLength(2),wre=de(D,D.DISTANCE).setParameterLength(2),Sre=de(D,D.DIFFERENCE).setParameterLength(2),Om=de(D,D.DOT).setParameterLength(2),Mre=de(D,D.CROSS).setParameterLength(2),T5=de(D,D.POW).setParameterLength(2),_re=de(D,D.POW,2).setParameterLength(1),Nre=de(D,D.POW,3).setParameterLength(1),Ere=de(D,D.POW,4).setParameterLength(1),Are=de(D,D.TRANSFORM_DIRECTION).setParameterLength(2),Cre=t=>pT(v5(t),T5(fT(t),1/3)),Rre=t=>Om(t,t),fy=de(D,D.MIX).setParameterLength(3),w5=(t,e=0,r=1)=>Re(new D(D.CLAMP,Re(t),Re(e),Re(r))),Pre=t=>w5(t),Ire=de(D,D.REFRACT).setParameterLength(3),Vre=de(D,D.SMOOTHSTEP).setParameterLength(3),Ore=de(D,D.FACEFORWARD).setParameterLength(3),Lre=Xs(([t])=>{let e=Om(t.xy,c5(12.9898,78.233)),r=py(e,jte);return y5(x5(r).mul(43758.5453))}),Fre=(t,e,r)=>fy(e,r,t),zre=(t,e,r)=>Vre(e,r,t),Bre=(t,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),b5(t,e));H("all",Wte),H("any",Hte),H("equals",yre),H("radians",qte),H("degrees",Xte),H("exp",Yte),H("exp2",Zte),H("log",Jte),H("log2",Kte),H("sqrt",Qte),H("inverseSqrt",ere),H("floor",tre),H("ceil",rre),H("normalize",g5),H("fract",y5),H("sin",x5),H("cos",ire),H("tan",sre),H("asin",nre),H("acos",are),H("atan",b5),H("abs",fT),H("sign",v5),H("length",ore),H("lengthSq",Rre),H("negate",lre),H("oneMinus",ure),H("dFdx",hre),H("dFdy",cre),H("round",dre),H("reciprocal",mre),H("trunc",pre),H("fwidth",fre),H("atan2",Bre),H("min",xre),H("max",bre),H("step",vre),H("reflect",Tre),H("distance",wre),H("dot",Om),H("cross",Mre),H("pow",T5),H("pow2",_re),H("pow3",Nre),H("pow4",Ere),H("transformDirection",Are),H("mix",Fre),H("clamp",w5),H("refract",Ire),H("smoothstep",zre),H("faceForward",Ore),H("difference",Sre),H("saturate",Pre),H("cbrt",Cre),H("transpose",gre),H("rand",Lre);var j_=class extends Ts{static get type(){return"ArrayNode"}constructor(t,e,r=null){super(t),this.count=e,this.values=r,this.isArrayNode=!0}getNodeType(t){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(t)),this.nodeType}getElementType(t){return this.getNodeType(t)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}};const kre=(...t)=>{let e;if(t.length===1){let r=t[0];e=new j_(null,r.length,r)}else{let r=t[0],i=t[1];e=new j_(r,i)}return Re(e)};H("toArray",(t,e)=>kre(Array(e).fill(t)));var S5=class extends Cr{static get type(){return"UniformGroupNode"}constructor(t,e=!1,r=1){super("string"),this.name=t,this.shared=e,this.order=r,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}};const Ure=t=>new S5(t),Dre=(t,e=0)=>new S5(t,!0,e),$re=Dre("render"),Gre=Ure("object");var jre=class extends hT{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=Gre}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){let r=this.getSelf();return t=t.bind(r),super.onUpdate(i=>{let s=t(i,r);s!==void 0&&(this.value=s)},e)}generate(t,e){let r=this.getNodeType(t),i=this.getUniformHash(t),s=t.getNodeFromHash(i);s===void 0&&(t.setHashNode(this,i),s=this);let n=s.getInputType(t),a=t.getUniformFromNode(s,n,t.shaderStage,this.name||t.context.label),o=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(o,r,e)}};const Wre=(t,e)=>{let r=rte(e||t),i=t;return Re(new jre(i,r))};var Hre=class extends Cr{static get type(){return"PropertyNode"}constructor(t,e=null,r=!1){super(t),this.name=e,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}};const qre=(t,e)=>Re(new Hre(t,e));var Xre=class extends Ts{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e==="void"?"void":this.targetNode.getNodeType(t)}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let r=t.getTypeLength(e.node.getNodeType(t));return Im.join("").slice(0,r)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:r}=this,i=t.getNodeProperties(this);i.sourceNode=r,i.targetNode=e.context({assign:!0})}generate(t,e){let{targetNode:r,sourceNode:i}=t.getNodeProperties(this),s=this.needsSplitAssign(t),n=r.getNodeType(t),a=r.build(t),o=i.build(t,n),l=i.getNodeType(t),h=t.getDataFromNode(this),u;if(h.initialized===!0)e!=="void"&&(u=a);else if(s){let c=t.getVarFromNode(this,null,n),d=t.getPropertyName(c);t.addLineFlowCode(`${d} = ${o}`,this);let m=r.node,p=m.node.context({assign:!0}),f=p.build(t);for(let g=0;g<m.components.length;g++){let y=m.components[g];t.addLineFlowCode(`${f}.${y} = ${d}[ ${g} ]`,this)}e!=="void"&&(u=a)}else u=`${a} = ${o}`,(e==="void"||l==="void")&&(t.addLineFlowCode(u,this),e!=="void"&&(u=a));return h.initialized=!0,t.format(u,n,e)}};const Yre=de(Xre).setParameterLength(2);H("assign",Yre);var Zre=class extends Ts{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){let e=[],r=this.functionNode,i=r.getInputs(t),s=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(t):o.build(t,h),c};if(Array.isArray(s)){if(s.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length<i.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<i.length;)s.push(za(0));for(let o=0;o<s.length;o++)e.push(n(s[o],i[o]))}else for(let o of i){let l=s[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),e.push(n(za(0),o))):e.push(n(l,o))}return`${r.build(t,"property")}( ${e.join(", ")} )`}};const Jre=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?kf(e):my(e[0]),Re(new Zre(Re(t),e)));H("call",Jre);var Kre=class extends Cr{static get type(){return"ConditionalNode"}constructor(t,e,r=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=r}getNodeType(t){let{ifNode:e,elseNode:r}=t.getNodeProperties(this);if(e===void 0)return this.setup(t),this.getNodeType(t);let i=e.getNodeType(t);if(r!==null){let s=r.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(i))return s}return i}setup(t){let e=this.condNode.cache(),r=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,s=t.context.nodeBlock;t.getDataFromNode(r).parentNodeBlock=s,i!==null&&(t.getDataFromNode(i).parentNodeBlock=s);let n=t.getNodeProperties(this);n.condNode=e,n.ifNode=r.context({nodeBlock:r}),n.elseNode=i?i.context({nodeBlock:i}):null}generate(t,e){let r=this.getNodeType(t),i=t.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",h=l?qre(r).build(t):"";i.nodeProperty=h;let u=s.build(t,"bool");t.addFlowCode(`
437
+ */const r3="177",TJ=0,Ff=3,Pb=0,oy=1,wJ=0,Ib=1,nM=100,aM=204,oM=205,lM=3,SJ=0,Vb=0,Gv=300,ag=301,Ob=302,MJ=306,uM=1e3,bd=1001,hM=1002,$s=1003,ps=1006,i3=1008,_J=1008,s3=1009,NJ=1013,n3=1014,gc=1015,wo=1016,jv=1023,cM=1026,EJ=1027,So=1030,dM=0,AJ=1,og="",Ps="srgb",lg="srgb-linear",mM="linear",Ld="srgb",dh=7680,pM=519,CJ=513,ug=35044,vd=35048,va=2e3,Ru=2001;class Du{addEventListener(e,r){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(r)===-1&&i[e].push(r)}hasEventListener(e,r){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(r)!==-1}removeEventListener(e,r){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const n=s.indexOf(r);n!==-1&&s.splice(n,1)}}dispatchEvent(e){const r=this._listeners;if(r===void 0)return;const i=r[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let n=0,a=s.length;n<a;n++)s[n].call(this,e);e.target=null}}}const di=["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"];let fM=1234567;const Fd=Math.PI/180,hg=180/Math.PI;function Ca(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(di[t&255]+di[t>>8&255]+di[t>>16&255]+di[t>>24&255]+"-"+di[e&255]+di[e>>8&255]+"-"+di[e>>16&15|64]+di[e>>24&255]+"-"+di[r&63|128]+di[r>>8&255]+"-"+di[r>>16&255]+di[r>>24&255]+di[i&255]+di[i>>8&255]+di[i>>16&255]+di[i>>24&255]).toLowerCase()}function tt(t,e,r){return Math.max(e,Math.min(r,t))}function Wv(t,e){return(t%e+e)%e}function RJ(t,e,r,i,s){return i+(t-e)*(s-i)/(r-e)}function PJ(t,e,r){return t!==e?(r-t)/(e-t):0}function zd(t,e,r){return(1-r)*t+r*e}function IJ(t,e,r,i){return zd(t,e,1-Math.exp(-r*i))}function VJ(t,e=1){return e-Math.abs(Wv(t,e*2)-e)}function OJ(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*(3-2*t))}function LJ(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*t*(t*(t*6-15)+10))}function FJ(t,e){return t+Math.floor(Math.random()*(e-t+1))}function zJ(t,e){return t+Math.random()*(e-t)}function BJ(t){return t*(.5-Math.random())}function kJ(t){t!==void 0&&(fM=t);let e=fM+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function UJ(t){return t*Fd}function DJ(t){return t*hg}function $J(t){return(t&t-1)===0&&t!==0}function GJ(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function jJ(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function WJ(t,e,r,i,s){const n=Math.cos,a=Math.sin,o=n(r/2),l=a(r/2),h=n((e+i)/2),u=a((e+i)/2),c=n((e-i)/2),d=a((e-i)/2),m=n((i-e)/2),p=a((i-e)/2);switch(s){case"XYX":t.set(o*u,l*c,l*d,o*h);break;case"YZY":t.set(l*d,o*u,l*c,o*h);break;case"ZXZ":t.set(l*c,l*d,o*u,o*h);break;case"XZX":t.set(o*u,l*p,l*m,o*h);break;case"YXY":t.set(l*m,o*u,l*p,o*h);break;case"ZYZ":t.set(l*p,l*m,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function un(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function St(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const a3={DEG2RAD:Fd,RAD2DEG:hg,generateUUID:Ca,clamp:tt,euclideanModulo:Wv,mapLinear:RJ,inverseLerp:PJ,lerp:zd,damp:IJ,pingpong:VJ,smoothstep:OJ,smootherstep:LJ,randInt:FJ,randFloat:zJ,randFloatSpread:BJ,seededRandom:kJ,degToRad:UJ,radToDeg:DJ,isPowerOfTwo:$J,ceilPowerOfTwo:GJ,floorPowerOfTwo:jJ,setQuaternionFromProperEuler:WJ,normalize:St,denormalize:un};class Jt{constructor(e=0,r=0){Jt.prototype.isVector2=!0,this.x=e,this.y=r}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,r){return this.x=e,this.y=r,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const r=this.x,i=this.y,s=e.elements;return this.x=s[0]*r+s[3]*i+s[6],this.y=s[1]*r+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,r){return this.x=tt(this.x,e.x,r.x),this.y=tt(this.y,e.y,r.y),this}clampScalar(e,r){return this.x=tt(this.x,e,r),this.y=tt(this.y,e,r),this}clampLength(e,r){const i=this.length();return this.divideScalar(i||1).multiplyScalar(tt(i,e,r))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;const i=this.dot(e)/r;return Math.acos(tt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const r=this.x-e.x,i=this.y-e.y;return r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this}rotateAround(e,r){const i=Math.cos(r),s=Math.sin(r),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*s+e.x,this.y=n*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class _m{constructor(e=0,r=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=r,this._z=i,this._w=s}static slerpFlat(e,r,i,s,n,a,o){let l=i[s+0],h=i[s+1],u=i[s+2],c=i[s+3];const d=n[a+0],m=n[a+1],p=n[a+2],f=n[a+3];if(o===0){e[r+0]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c;return}if(o===1){e[r+0]=d,e[r+1]=m,e[r+2]=p,e[r+3]=f;return}if(c!==f||l!==d||h!==m||u!==p){let g=1-o;const y=l*d+h*m+u*p+c*f,T=y>=0?1:-1,S=1-y*y;if(S>Number.EPSILON){const _=Math.sqrt(S),M=Math.atan2(_,y*T);g=Math.sin(g*M)/_,o=Math.sin(o*M)/_}const w=o*T;if(l=l*g+d*w,h=h*g+m*w,u=u*g+p*w,c=c*g+f*w,g===1-o){const _=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=_,h*=_,u*=_,c*=_}}e[r]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c}static multiplyQuaternionsFlat(e,r,i,s,n,a){const o=i[s],l=i[s+1],h=i[s+2],u=i[s+3],c=n[a],d=n[a+1],m=n[a+2],p=n[a+3];return e[r]=o*p+u*c+l*m-h*d,e[r+1]=l*p+u*d+h*c-o*m,e[r+2]=h*p+u*m+o*d-l*c,e[r+3]=u*p-o*c-l*d-h*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,r,i,s){return this._x=e,this._y=r,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,r=!0){const i=e._x,s=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,h=o(i/2),u=o(s/2),c=o(n/2),d=l(i/2),m=l(s/2),p=l(n/2);switch(a){case"XYZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"YXZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"ZXY":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"ZYX":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"YZX":this._x=d*u*c+h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c-d*m*p;break;case"XZY":this._x=d*u*c-h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c+d*m*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,r){const i=r/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const r=e.elements,i=r[0],s=r[4],n=r[8],a=r[1],o=r[5],l=r[9],h=r[2],u=r[6],c=r[10],d=i+o+c;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-l)*m,this._y=(n-h)*m,this._z=(a-s)*m}else if(i>o&&i>c){const m=2*Math.sqrt(1+i-o-c);this._w=(u-l)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(n+h)/m}else if(o>c){const m=2*Math.sqrt(1+o-i-c);this._w=(n-h)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+c-i-o);this._w=(a-s)/m,this._x=(n+h)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,r){let i=e.dot(r)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*r.z-e.z*r.y,this._y=e.z*r.x-e.x*r.z,this._z=e.x*r.y-e.y*r.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(tt(this.dot(e),-1,1)))}rotateTowards(e,r){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,r/i);return this.slerp(e,s),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,r){const i=e._x,s=e._y,n=e._z,a=e._w,o=r._x,l=r._y,h=r._z,u=r._w;return this._x=i*u+a*o+s*h-n*l,this._y=s*u+a*l+n*o-i*h,this._z=n*u+a*h+i*l-s*o,this._w=a*u-i*o-s*l-n*h,this._onChangeCallback(),this}slerp(e,r){if(r===0)return this;if(r===1)return this.copy(e);const i=this._x,s=this._y,n=this._z,a=this._w;let o=a*e._w+i*e._x+s*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=s,this._z=n,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-r;return this._w=m*a+r*this._w,this._x=m*i+r*this._x,this._y=m*s+r*this._y,this._z=m*n+r*this._z,this.normalize(),this}const h=Math.sqrt(l),u=Math.atan2(h,o),c=Math.sin((1-r)*u)/h,d=Math.sin(r*u)/h;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=s*c+this._y*d,this._z=n*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,r,i){return this.copy(e).slerp(r,i)}random(){const e=2*Math.PI*Math.random(),r=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),n*Math.sin(r),n*Math.cos(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,r=0){return this._x=e[r],this._y=e[r+1],this._z=e[r+2],this._w=e[r+3],this._onChangeCallback(),this}toArray(e=[],r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,e}fromBufferAttribute(e,r){return this._x=e.getX(r),this._y=e.getY(r),this._z=e.getZ(r),this._w=e.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ${constructor(e=0,r=0,i=0){$.prototype.isVector3=!0,this.x=e,this.y=r,this.z=i}set(e,r,i){return i===void 0&&(i=this.z),this.x=e,this.y=r,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,r){return this.x=e.x*r.x,this.y=e.y*r.y,this.z=e.z*r.z,this}applyEuler(e){return this.applyQuaternion(gM.setFromEuler(e))}applyAxisAngle(e,r){return this.applyQuaternion(gM.setFromAxisAngle(e,r))}applyMatrix3(e){const r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[3]*i+n[6]*s,this.y=n[1]*r+n[4]*i+n[7]*s,this.z=n[2]*r+n[5]*i+n[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const r=this.x,i=this.y,s=this.z,n=e.elements,a=1/(n[3]*r+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*r+n[4]*i+n[8]*s+n[12])*a,this.y=(n[1]*r+n[5]*i+n[9]*s+n[13])*a,this.z=(n[2]*r+n[6]*i+n[10]*s+n[14])*a,this}applyQuaternion(e){const r=this.x,i=this.y,s=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*s-o*i),u=2*(o*r-n*s),c=2*(n*i-a*r);return this.x=r+l*h+a*c-o*u,this.y=i+l*u+o*h-n*c,this.z=s+l*c+n*u-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[4]*i+n[8]*s,this.y=n[1]*r+n[5]*i+n[9]*s,this.z=n[2]*r+n[6]*i+n[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,r){return this.x=tt(this.x,e.x,r.x),this.y=tt(this.y,e.y,r.y),this.z=tt(this.z,e.z,r.z),this}clampScalar(e,r){return this.x=tt(this.x,e,r),this.y=tt(this.y,e,r),this.z=tt(this.z,e,r),this}clampLength(e,r){const i=this.length();return this.divideScalar(i||1).multiplyScalar(tt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,r){const i=e.x,s=e.y,n=e.z,a=r.x,o=r.y,l=r.z;return this.x=s*l-n*o,this.y=n*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const r=e.lengthSq();if(r===0)return this.set(0,0,0);const i=e.dot(this)/r;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return k0.copy(this).projectOnVector(e),this.sub(k0)}reflect(e){return this.sub(k0.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;const i=this.dot(e)/r;return Math.acos(tt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const r=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return r*r+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,r,i){const s=Math.sin(r)*e;return this.x=s*Math.sin(i),this.y=Math.cos(r)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,r,i){return this.x=e*Math.sin(r),this.y=i,this.z=e*Math.cos(r),this}setFromMatrixPosition(e){const r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(e){const r=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=r,this.y=i,this.z=s,this}setFromMatrixColumn(e,r){return this.fromArray(e.elements,r*4)}setFromMatrix3Column(e,r){return this.fromArray(e.elements,r*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,r=Math.random()*2-1,i=Math.sqrt(1-r*r);return this.x=i*Math.cos(e),this.y=r,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const k0=new $,gM=new _m;class qs{constructor(e,r,i,s,n,a,o,l,h){qs.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h)}set(e,r,i,s,n,a,o,l,h){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=r,u[4]=n,u[5]=l,u[6]=i,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],this}extractBasis(e,r,i){return e.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const r=e.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){const i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],u=i[4],c=i[7],d=i[2],m=i[5],p=i[8],f=s[0],g=s[3],y=s[6],T=s[1],S=s[4],w=s[7],_=s[2],M=s[5],E=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*S+l*M,n[6]=a*y+o*w+l*E,n[1]=h*f+u*T+c*_,n[4]=h*g+u*S+c*M,n[7]=h*y+u*w+c*E,n[2]=d*f+m*T+p*_,n[5]=d*g+m*S+p*M,n[8]=d*y+m*w+p*E,this}multiplyScalar(e){const r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=e,r[4]*=e,r[7]*=e,r[2]*=e,r[5]*=e,r[8]*=e,this}determinant(){const e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8];return r*a*u-r*o*h-i*n*u+i*o*l+s*n*h-s*a*l}invert(){const e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=u*a-o*h,d=o*l-u*n,m=h*n-a*l,p=r*c+i*d+s*m;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=c*f,e[1]=(s*h-u*i)*f,e[2]=(o*i-s*a)*f,e[3]=d*f,e[4]=(u*r-s*l)*f,e[5]=(s*n-o*r)*f,e[6]=m*f,e[7]=(i*l-h*r)*f,e[8]=(a*r-i*n)*f,this}transpose(){let e;const r=this.elements;return e=r[1],r[1]=r[3],r[3]=e,e=r[2],r[2]=r[6],r[6]=e,e=r[5],r[5]=r[7],r[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const r=this.elements;return e[0]=r[0],e[1]=r[3],e[2]=r[6],e[3]=r[1],e[4]=r[4],e[5]=r[7],e[6]=r[2],e[7]=r[5],e[8]=r[8],this}setUvTransform(e,r,i,s,n,a,o){const l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-s*h,s*l,-s*(-h*a+l*o)+o+r,0,0,1),this}scale(e,r){return this.premultiply(U0.makeScale(e,r)),this}rotate(e){return this.premultiply(U0.makeRotation(-e)),this}translate(e,r){return this.premultiply(U0.makeTranslation(e,r)),this}makeTranslation(e,r){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,r,0,0,1),this}makeRotation(e){const r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,i,r,0,0,0,1),this}makeScale(e,r){return this.set(e,0,0,0,r,0,0,0,1),this}equals(e){const r=this.elements,i=e.elements;for(let s=0;s<9;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<9;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){const i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const U0=new qs;function HJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Lb(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const yM={};function xM(t){t in yM||(yM[t]=!0,console.warn(t))}const bM=new qs().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),vM=new qs().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function qJ(){const t={enabled:!0,workingColorSpace:lg,spaces:{},convert:function(s,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Ld&&(s.r=Ra(s.r),s.g=Ra(s.g),s.b=Ra(s.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ld&&(s.r=tc(s.r),s.g=tc(s.g),s.b=tc(s.b))),s},workingToColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},colorSpaceToWorking:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===og?mM:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,a){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,n){return xM("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(s,n)},toWorkingColorSpace:function(s,n){return xM("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(s,n)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[lg]:{primaries:e,whitePoint:i,transfer:mM,toXYZ:bM,fromXYZ:vM,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:Ps},outputColorSpaceConfig:{drawingBufferColorSpace:Ps}},[Ps]:{primaries:e,whitePoint:i,transfer:Ld,toXYZ:bM,fromXYZ:vM,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:Ps}}}),t}const or=qJ();function Ra(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function tc(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let mh;class XJ{static getDataURL(e,r="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{mh===void 0&&(mh=Lb("canvas")),mh.width=e.width,mh.height=e.height;const s=mh.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=mh}return i.toDataURL(r)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const r=Lb("canvas");r.width=e.width,r.height=e.height;const i=r.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),n=s.data;for(let a=0;a<n.length;a++)n[a]=Ra(n[a]/255)*255;return i.putImageData(s,0,0),r}else if(e.data){const r=e.data.slice(0);for(let i=0;i<r.length;i++)r instanceof Uint8Array||r instanceof Uint8ClampedArray?r[i]=Math.floor(Ra(r[i]/255)*255):r[i]=Ra(r[i]);return{data:r,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let YJ=0;class Hv{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:YJ++}),this.uuid=Ca(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const r=this.data;return r instanceof HTMLVideoElement?e.set(r.videoWidth,r.videoHeight):r!==null?e.set(r.width,r.height,r.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const r=e===void 0||typeof e=="string";if(!r&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?n.push(D0(s[a].image)):n.push(D0(s[a]))}else n=D0(s);i.url=n}return r||(e.images[this.uuid]=i),i}}function D0(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?XJ.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ZJ=0;const $0=new $;class vi extends Du{constructor(e=vi.DEFAULT_IMAGE,r=vi.DEFAULT_MAPPING,i=bd,s=bd,n=ps,a=i3,o=jv,l=s3,h=vi.DEFAULT_ANISOTROPY,u=og){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ZJ++}),this.uuid=Ca(),this.name="",this.source=new Hv(e),this.mipmaps=[],this.mapping=r,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=n,this.minFilter=a,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Jt(0,0),this.repeat=new Jt(1,1),this.center=new Jt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qs,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize($0).x}get height(){return this.source.getSize($0).y}get depth(){return this.source.getSize($0).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,r){this.updateRanges.push({start:e,count:r})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const r in e){const i=e[r];if(i===void 0){console.warn(`THREE.Texture.setValues(): parameter '${r}' has value of undefined.`);continue}const s=this[r];if(s===void 0){console.warn(`THREE.Texture.setValues(): property '${r}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[r]=i}}toJSON(e){const r=e===void 0||typeof e=="string";if(!r&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(i.userData=this.userData),r||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case uM:e.x=e.x-Math.floor(e.x);break;case bd:e.x=e.x<0?0:1;break;case hM:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case uM:e.y=e.y-Math.floor(e.y);break;case bd:e.y=e.y<0?0:1;break;case hM:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}vi.DEFAULT_IMAGE=null;vi.DEFAULT_MAPPING=Gv;vi.DEFAULT_ANISOTROPY=1;class Si{constructor(e=0,r=0,i=0,s=1){Si.prototype.isVector4=!0,this.x=e,this.y=r,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,r,i,s){return this.x=e,this.y=r,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this.w=e.w+r.w,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this.w+=e.w*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this.w=e.w-r.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const r=this.x,i=this.y,s=this.z,n=this.w,a=e.elements;return this.x=a[0]*r+a[4]*i+a[8]*s+a[12]*n,this.y=a[1]*r+a[5]*i+a[9]*s+a[13]*n,this.z=a[2]*r+a[6]*i+a[10]*s+a[14]*n,this.w=a[3]*r+a[7]*i+a[11]*s+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const r=Math.sqrt(1-e.w*e.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/r,this.y=e.y/r,this.z=e.z/r),this}setAxisAngleFromRotationMatrix(e){let r,i,s,n;const l=e.elements,h=l[0],u=l[4],c=l[8],d=l[1],m=l[5],p=l[9],f=l[2],g=l[6],y=l[10];if(Math.abs(u-d)<.01&&Math.abs(c-f)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+d)<.1&&Math.abs(c+f)<.1&&Math.abs(p+g)<.1&&Math.abs(h+m+y-3)<.1)return this.set(1,0,0,0),this;r=Math.PI;const S=(h+1)/2,w=(m+1)/2,_=(y+1)/2,M=(u+d)/4,E=(c+f)/4,A=(p+g)/4;return S>w&&S>_?S<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(S),s=M/i,n=E/i):w>_?w<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=M/s,n=A/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=E/n,s=A/n),this.set(i,s,n,r),this}let T=Math.sqrt((g-p)*(g-p)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(T)<.001&&(T=1),this.x=(g-p)/T,this.y=(c-f)/T,this.z=(d-u)/T,this.w=Math.acos((h+m+y-1)/2),this}setFromMatrixPosition(e){const r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this.w=r[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,r){return this.x=tt(this.x,e.x,r.x),this.y=tt(this.y,e.y,r.y),this.z=tt(this.z,e.z,r.z),this.w=tt(this.w,e.w,r.w),this}clampScalar(e,r){return this.x=tt(this.x,e,r),this.y=tt(this.y,e,r),this.z=tt(this.z,e,r),this.w=tt(this.w,e,r),this}clampLength(e,r){const i=this.length();return this.divideScalar(i||1).multiplyScalar(tt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this.w+=(e.w-this.w)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this.w=e.w+(r.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this.w=e[r+3],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e[r+3]=this.w,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this.w=e.getW(r),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 Nm extends Du{constructor(e=1,r=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ps,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=r,this.depth=i.depth,this.scissor=new Si(0,0,e,r),this.scissorTest=!1,this.viewport=new Si(0,0,e,r);const s={width:e,height:r,depth:i.depth},n=new vi(s);this.textures=[];const a=i.count;for(let o=0;o<a;o++)this.textures[o]=n.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const r={minFilter:ps,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(r.mapping=e.mapping),e.wrapS!==void 0&&(r.wrapS=e.wrapS),e.wrapT!==void 0&&(r.wrapT=e.wrapT),e.wrapR!==void 0&&(r.wrapR=e.wrapR),e.magFilter!==void 0&&(r.magFilter=e.magFilter),e.minFilter!==void 0&&(r.minFilter=e.minFilter),e.format!==void 0&&(r.format=e.format),e.type!==void 0&&(r.type=e.type),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(r.colorSpace=e.colorSpace),e.flipY!==void 0&&(r.flipY=e.flipY),e.generateMipmaps!==void 0&&(r.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(r.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(r)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,r,i=1){if(this.width!==e||this.height!==r||this.depth!==i){this.width=e,this.height=r,this.depth=i;for(let s=0,n=this.textures.length;s<n;s++)this.textures[s].image.width=e,this.textures[s].image.height=r,this.textures[s].image.depth=i,this.textures[s].isArrayTexture=this.textures[s].image.depth>1;this.dispose()}this.viewport.set(0,0,e,r),this.scissor.set(0,0,e,r)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let r=0,i=e.textures.length;r<i;r++){this.textures[r]=e.textures[r].clone(),this.textures[r].isRenderTargetTexture=!0,this.textures[r].renderTarget=this;const s=Object.assign({},e.textures[r].image);this.textures[r].source=new Hv(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class JJ extends vi{constructor(e=null,r=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:r,height:i,depth:s},this.magFilter=$s,this.minFilter=$s,this.wrapR=bd,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Em{constructor(e=new $(1/0,1/0,1/0),r=new $(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=r}set(e,r){return this.min.copy(e),this.max.copy(r),this}setFromArray(e){this.makeEmpty();for(let r=0,i=e.length;r<i;r+=3)this.expandByPoint(tn.fromArray(e,r));return this}setFromBufferAttribute(e){this.makeEmpty();for(let r=0,i=e.count;r<i;r++)this.expandByPoint(tn.fromBufferAttribute(e,r));return this}setFromPoints(e){this.makeEmpty();for(let r=0,i=e.length;r<i;r++)this.expandByPoint(e[r]);return this}setFromCenterAndSize(e,r){const i=tn.copy(r).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,r=!1){return this.makeEmpty(),this.expandByObject(e,r)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,r=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const n=i.getAttribute("position");if(r===!0&&n!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=n.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,tn):tn.fromBufferAttribute(n,a),tn.applyMatrix4(e.matrixWorld),this.expandByPoint(tn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Op.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Op.copy(i.boundingBox)),Op.applyMatrix4(e.matrixWorld),this.union(Op)}const s=e.children;for(let n=0,a=s.length;n<a;n++)this.expandByObject(s[n],r);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,r){return r.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,tn),tn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let r,i;return e.normal.x>0?(r=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(r=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(r+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(r+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(r+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(r+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),r<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(td),Lp.subVectors(this.max,td),ph.subVectors(e.a,td),fh.subVectors(e.b,td),gh.subVectors(e.c,td),ro.subVectors(fh,ph),io.subVectors(gh,fh),rl.subVectors(ph,gh);let r=[0,-ro.z,ro.y,0,-io.z,io.y,0,-rl.z,rl.y,ro.z,0,-ro.x,io.z,0,-io.x,rl.z,0,-rl.x,-ro.y,ro.x,0,-io.y,io.x,0,-rl.y,rl.x,0];return!G0(r,ph,fh,gh,Lp)||(r=[1,0,0,0,1,0,0,0,1],!G0(r,ph,fh,gh,Lp))?!1:(Fp.crossVectors(ro,io),r=[Fp.x,Fp.y,Fp.z],G0(r,ph,fh,gh,Lp))}clampPoint(e,r){return r.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,tn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(tn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ua[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ua[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ua[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ua[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ua[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ua[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ua[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ua[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ua),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const ua=[new $,new $,new $,new $,new $,new $,new $,new $],tn=new $,Op=new Em,ph=new $,fh=new $,gh=new $,ro=new $,io=new $,rl=new $,td=new $,Lp=new $,Fp=new $,il=new $;function G0(t,e,r,i,s){for(let n=0,a=t.length-3;n<=a;n+=3){il.fromArray(t,n);const o=s.x*Math.abs(il.x)+s.y*Math.abs(il.y)+s.z*Math.abs(il.z),l=e.dot(il),h=r.dot(il),u=i.dot(il);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}const KJ=new Em,rd=new $,j0=new $;class qv{constructor(e=new $,r=-1){this.isSphere=!0,this.center=e,this.radius=r}set(e,r){return this.center.copy(e),this.radius=r,this}setFromPoints(e,r){const i=this.center;r!==void 0?i.copy(r):KJ.setFromPoints(e).getCenter(i);let s=0;for(let n=0,a=e.length;n<a;n++)s=Math.max(s,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const r=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=r*r}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,r){const i=this.center.distanceToSquared(e);return r.copy(e),i>this.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;rd.subVectors(e,this.center);const r=rd.lengthSq();if(r>this.radius*this.radius){const i=Math.sqrt(r),s=(i-this.radius)*.5;this.center.addScaledVector(rd,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(j0.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rd.copy(e.center).add(j0)),this.expandByPoint(rd.copy(e.center).sub(j0))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const ha=new $,W0=new $,zp=new $,so=new $,H0=new $,Bp=new $,q0=new $;class QJ{constructor(e=new $,r=new $(0,0,-1)){this.origin=e,this.direction=r}set(e,r){return this.origin.copy(e),this.direction.copy(r),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,r){return r.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ha)),this}closestPointToPoint(e,r){r.subVectors(e,this.origin);const i=r.dot(this.direction);return i<0?r.copy(this.origin):r.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const r=ha.subVectors(e,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(e):(ha.copy(this.origin).addScaledVector(this.direction,r),ha.distanceToSquared(e))}distanceSqToSegment(e,r,i,s){W0.copy(e).add(r).multiplyScalar(.5),zp.copy(r).sub(e).normalize(),so.copy(this.origin).sub(W0);const n=e.distanceTo(r)*.5,a=-this.direction.dot(zp),o=so.dot(this.direction),l=-so.dot(zp),h=so.lengthSq(),u=Math.abs(1-a*a);let c,d,m,p;if(u>0)if(c=a*l-o,d=a*o-l,p=n*u,c>=0)if(d>=-p)if(d<=p){const f=1/u;c*=f,d*=f,m=c*(c+a*d+2*o)+d*(a*c+d+2*l)+h}else d=n,c=Math.max(0,-(a*d+o)),m=-c*c+d*(d+2*l)+h;else d=-n,c=Math.max(0,-(a*d+o)),m=-c*c+d*(d+2*l)+h;else d<=-p?(c=Math.max(0,-(-a*n+o)),d=c>0?-n:Math.min(Math.max(-n,-l),n),m=-c*c+d*(d+2*l)+h):d<=p?(c=0,d=Math.min(Math.max(-n,-l),n),m=d*(d+2*l)+h):(c=Math.max(0,-(a*n+o)),d=c>0?n:Math.min(Math.max(-n,-l),n),m=-c*c+d*(d+2*l)+h);else d=a>0?-n:n,c=Math.max(0,-(a*d+o)),m=-c*c+d*(d+2*l)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,c),s&&s.copy(W0).addScaledVector(zp,d),m}intersectSphere(e,r){ha.subVectors(e.center,this.origin);const i=ha.dot(this.direction),s=ha.dot(ha)-i*i,n=e.radius*e.radius;if(s>n)return null;const a=Math.sqrt(n-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,r):this.at(o,r)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const r=e.normal.dot(this.direction);if(r===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/r;return i>=0?i:null}intersectPlane(e,r){const i=this.distanceToPlane(e);return i===null?null:this.at(i,r)}intersectsPlane(e){const r=e.distanceToPoint(this.origin);return r===0||e.normal.dot(this.direction)*r<0}intersectBox(e,r){let i,s,n,a,o,l;const h=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,d=this.origin;return h>=0?(i=(e.min.x-d.x)*h,s=(e.max.x-d.x)*h):(i=(e.max.x-d.x)*h,s=(e.min.x-d.x)*h),u>=0?(n=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(n=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),i>a||n>s||((n>i||isNaN(i))&&(i=n),(a<s||isNaN(s))&&(s=a),c>=0?(o=(e.min.z-d.z)*c,l=(e.max.z-d.z)*c):(o=(e.max.z-d.z)*c,l=(e.min.z-d.z)*c),i>l||o>s)||((o>i||i!==i)&&(i=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(i>=0?i:s,r)}intersectsBox(e){return this.intersectBox(e,ha)!==null}intersectTriangle(e,r,i,s,n){H0.subVectors(r,e),Bp.subVectors(i,e),q0.crossVectors(H0,Bp);let a=this.direction.dot(q0),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;so.subVectors(this.origin,e);const l=o*this.direction.dot(Bp.crossVectors(so,Bp));if(l<0)return null;const h=o*this.direction.dot(H0.cross(so));if(h<0||l+h>a)return null;const u=-o*so.dot(q0);return u<0?null:this.at(u/a,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Rt{constructor(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){Rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g)}set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){const y=this.elements;return y[0]=e,y[4]=r,y[8]=i,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=u,y[10]=c,y[14]=d,y[3]=m,y[7]=p,y[11]=f,y[15]=g,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 Rt().fromArray(this.elements)}copy(e){const r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],this}copyPosition(e){const r=this.elements,i=e.elements;return r[12]=i[12],r[13]=i[13],r[14]=i[14],this}setFromMatrix3(e){const r=e.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(e,r,i){return e.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,r,i){return this.set(e.x,r.x,i.x,0,e.y,r.y,i.y,0,e.z,r.z,i.z,0,0,0,0,1),this}extractRotation(e){const r=this.elements,i=e.elements,s=1/yh.setFromMatrixColumn(e,0).length(),n=1/yh.setFromMatrixColumn(e,1).length(),a=1/yh.setFromMatrixColumn(e,2).length();return r[0]=i[0]*s,r[1]=i[1]*s,r[2]=i[2]*s,r[3]=0,r[4]=i[4]*n,r[5]=i[5]*n,r[6]=i[6]*n,r[7]=0,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(e){const r=this.elements,i=e.x,s=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(s),h=Math.sin(s),u=Math.cos(n),c=Math.sin(n);if(e.order==="XYZ"){const d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=-l*c,r[8]=h,r[1]=m+p*h,r[5]=d-f*h,r[9]=-o*l,r[2]=f-d*h,r[6]=p+m*h,r[10]=a*l}else if(e.order==="YXZ"){const d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d+f*o,r[4]=p*o-m,r[8]=a*h,r[1]=a*c,r[5]=a*u,r[9]=-o,r[2]=m*o-p,r[6]=f+d*o,r[10]=a*l}else if(e.order==="ZXY"){const d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d-f*o,r[4]=-a*c,r[8]=p+m*o,r[1]=m+p*o,r[5]=a*u,r[9]=f-d*o,r[2]=-a*h,r[6]=o,r[10]=a*l}else if(e.order==="ZYX"){const d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=p*h-m,r[8]=d*h+f,r[1]=l*c,r[5]=f*h+d,r[9]=m*h-p,r[2]=-h,r[6]=o*l,r[10]=a*l}else if(e.order==="YZX"){const d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=f-d*c,r[8]=p*c+m,r[1]=c,r[5]=a*u,r[9]=-o*u,r[2]=-h*u,r[6]=m*c+p,r[10]=d-f*c}else if(e.order==="XZY"){const d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=-c,r[8]=h*u,r[1]=d*c+f,r[5]=a*u,r[9]=m*c-p,r[2]=p*c-m,r[6]=o*u,r[10]=f*c+d}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(e){return this.compose(eK,e,tK)}lookAt(e,r,i){const s=this.elements;return rs.subVectors(e,r),rs.lengthSq()===0&&(rs.z=1),rs.normalize(),no.crossVectors(i,rs),no.lengthSq()===0&&(Math.abs(i.z)===1?rs.x+=1e-4:rs.z+=1e-4,rs.normalize(),no.crossVectors(i,rs)),no.normalize(),kp.crossVectors(rs,no),s[0]=no.x,s[4]=kp.x,s[8]=rs.x,s[1]=no.y,s[5]=kp.y,s[9]=rs.y,s[2]=no.z,s[6]=kp.z,s[10]=rs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){const i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],u=i[1],c=i[5],d=i[9],m=i[13],p=i[2],f=i[6],g=i[10],y=i[14],T=i[3],S=i[7],w=i[11],_=i[15],M=s[0],E=s[4],A=s[8],U=s[12],Q=s[1],J=s[5],re=s[9],ie=s[13],se=s[2],ve=s[6],me=s[10],Me=s[14],ye=s[3],Te=s[7],ge=s[11],be=s[15];return n[0]=a*M+o*Q+l*se+h*ye,n[4]=a*E+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*U+o*ie+l*Me+h*be,n[1]=u*M+c*Q+d*se+m*ye,n[5]=u*E+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*U+c*ie+d*Me+m*be,n[2]=p*M+f*Q+g*se+y*ye,n[6]=p*E+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*U+f*ie+g*Me+y*be,n[3]=T*M+S*Q+w*se+_*ye,n[7]=T*E+S*J+w*ve+_*Te,n[11]=T*A+S*re+w*me+_*ge,n[15]=T*U+S*ie+w*Me+_*be,this}multiplyScalar(e){const r=this.elements;return r[0]*=e,r[4]*=e,r[8]*=e,r[12]*=e,r[1]*=e,r[5]*=e,r[9]*=e,r[13]*=e,r[2]*=e,r[6]*=e,r[10]*=e,r[14]*=e,r[3]*=e,r[7]*=e,r[11]*=e,r[15]*=e,this}determinant(){const e=this.elements,r=e[0],i=e[4],s=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],u=e[2],c=e[6],d=e[10],m=e[14],p=e[3],f=e[7],g=e[11],y=e[15];return p*(+n*l*c-s*h*c-n*o*d+i*h*d+s*o*m-i*l*m)+f*(+r*l*m-r*h*d+n*a*d-s*a*m+s*h*u-n*l*u)+g*(+r*h*c-r*o*m-n*a*c+i*a*m+n*o*u-i*h*u)+y*(-s*o*u-r*l*c+r*o*d+s*a*c-i*a*d+i*l*u)}transpose(){const e=this.elements;let r;return r=e[1],e[1]=e[4],e[4]=r,r=e[2],e[2]=e[8],e[8]=r,r=e[6],e[6]=e[9],e[9]=r,r=e[3],e[3]=e[12],e[12]=r,r=e[7],e[7]=e[13],e[13]=r,r=e[11],e[11]=e[14],e[14]=r,this}setPosition(e,r,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=r,s[14]=i),this}invert(){const e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],m=e[11],p=e[12],f=e[13],g=e[14],y=e[15],T=c*g*h-f*d*h+f*l*m-o*g*m-c*l*y+o*d*y,S=p*d*h-u*g*h-p*l*m+a*g*m+u*l*y-a*d*y,w=u*f*h-p*c*h+p*o*m-a*f*m-u*o*y+a*c*y,_=p*c*l-u*f*l-p*o*d+a*f*d+u*o*g-a*c*g,M=r*T+i*S+s*w+n*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/M;return e[0]=T*E,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*E,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*E,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*E,e[4]=S*E,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*E,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*E,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*E,e[8]=w*E,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*E,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*E,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*E,e[12]=_*E,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*E,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*E,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*E,this}scale(e){const r=this.elements,i=e.x,s=e.y,n=e.z;return r[0]*=i,r[4]*=s,r[8]*=n,r[1]*=i,r[5]*=s,r[9]*=n,r[2]*=i,r[6]*=s,r[10]*=n,r[3]*=i,r[7]*=s,r[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(r,i,s))}makeTranslation(e,r,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,r,0,0,1,i,0,0,0,1),this}makeRotationX(e){const r=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,r,-i,0,0,i,r,0,0,0,0,1),this}makeRotationY(e){const r=Math.cos(e),i=Math.sin(e);return this.set(r,0,i,0,0,1,0,0,-i,0,r,0,0,0,0,1),this}makeRotationZ(e){const r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,0,i,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,r){const i=Math.cos(r),s=Math.sin(r),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,u=n*o;return this.set(h*a+i,h*o-s*l,h*l+s*o,0,h*o+s*l,u*o+i,u*l-s*a,0,h*l-s*o,u*l+s*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,r,i){return this.set(e,0,0,0,0,r,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,r,i,s,n,a){return this.set(1,i,n,0,e,1,a,0,r,s,1,0,0,0,0,1),this}compose(e,r,i){const s=this.elements,n=r._x,a=r._y,o=r._z,l=r._w,h=n+n,u=a+a,c=o+o,d=n*h,m=n*u,p=n*c,f=a*u,g=a*c,y=o*c,T=l*h,S=l*u,w=l*c,_=i.x,M=i.y,E=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-S)*_,s[3]=0,s[4]=(m-w)*M,s[5]=(1-(d+y))*M,s[6]=(g+T)*M,s[7]=0,s[8]=(p+S)*E,s[9]=(g-T)*E,s[10]=(1-(d+f))*E,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,r,i){const s=this.elements;let n=yh.set(s[0],s[1],s[2]).length();const a=yh.set(s[4],s[5],s[6]).length(),o=yh.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),e.x=s[12],e.y=s[13],e.z=s[14],rn.copy(this);const h=1/n,u=1/a,c=1/o;return rn.elements[0]*=h,rn.elements[1]*=h,rn.elements[2]*=h,rn.elements[4]*=u,rn.elements[5]*=u,rn.elements[6]*=u,rn.elements[8]*=c,rn.elements[9]*=c,rn.elements[10]*=c,r.setFromRotationMatrix(rn),i.x=n,i.y=a,i.z=o,this}makePerspective(e,r,i,s,n,a,o=va){const l=this.elements,h=2*n/(r-e),u=2*n/(i-s),c=(r+e)/(r-e),d=(i+s)/(i-s);let m,p;if(o===va)m=-(a+n)/(a-n),p=-2*a*n/(a-n);else if(o===Ru)m=-a/(a-n),p=-a*n/(a-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,r,i,s,n,a,o=va){const l=this.elements,h=1/(r-e),u=1/(i-s),c=1/(a-n),d=(r+e)*h,m=(i+s)*u;let p,f;if(o===va)p=(a+n)*c,f=-2*c;else if(o===Ru)p=n*c,f=-1*c;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=f,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const r=this.elements,i=e.elements;for(let s=0;s<16;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<16;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){const i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e[r+9]=i[9],e[r+10]=i[10],e[r+11]=i[11],e[r+12]=i[12],e[r+13]=i[13],e[r+14]=i[14],e[r+15]=i[15],e}}const yh=new $,rn=new Rt,eK=new $(0,0,0),tK=new $(1,1,1),no=new $,kp=new $,rs=new $,TM=new Rt,wM=new _m;class $u{constructor(e=0,r=0,i=0,s=$u.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=r,this._z=i,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,r,i,s=this._order){return this._x=e,this._y=r,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,r=this._order,i=!0){const s=e.elements,n=s[0],a=s[4],o=s[8],l=s[1],h=s[5],u=s[9],c=s[2],d=s[6],m=s[10];switch(r){case"XYZ":this._y=Math.asin(tt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-tt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(tt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-c,m),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-tt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(tt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-tt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+r)}return this._order=r,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,r,i){return TM.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TM,r,i)}setFromVector3(e,r=this._order){return this.set(e.x,e.y,e.z,r)}reorder(e){return wM.setFromEuler(this),this.setFromQuaternion(wM,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}$u.DEFAULT_ORDER="XYZ";class rK{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let iK=0;const SM=new $,xh=new _m,ca=new Rt,Up=new $,id=new $,sK=new $,nK=new _m,MM=new $(1,0,0),_M=new $(0,1,0),NM=new $(0,0,1),EM={type:"added"},aK={type:"removed"},bh={type:"childadded",child:null},X0={type:"childremoved",child:null};class yn extends Du{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:iK++}),this.uuid=Ca(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=yn.DEFAULT_UP.clone();const e=new $,r=new $u,i=new _m,s=new $(1,1,1);function n(){i.setFromEuler(r,!1)}function a(){r.setFromQuaternion(i,void 0,!1)}r._onChange(n),i._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:r},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Rt},normalMatrix:{value:new qs}}),this.matrix=new Rt,this.matrixWorld=new Rt,this.matrixAutoUpdate=yn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=yn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rK,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,r){this.quaternion.setFromAxisAngle(e,r)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,r){return xh.setFromAxisAngle(e,r),this.quaternion.multiply(xh),this}rotateOnWorldAxis(e,r){return xh.setFromAxisAngle(e,r),this.quaternion.premultiply(xh),this}rotateX(e){return this.rotateOnAxis(MM,e)}rotateY(e){return this.rotateOnAxis(_M,e)}rotateZ(e){return this.rotateOnAxis(NM,e)}translateOnAxis(e,r){return SM.copy(e).applyQuaternion(this.quaternion),this.position.add(SM.multiplyScalar(r)),this}translateX(e){return this.translateOnAxis(MM,e)}translateY(e){return this.translateOnAxis(_M,e)}translateZ(e){return this.translateOnAxis(NM,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ca.copy(this.matrixWorld).invert())}lookAt(e,r,i){e.isVector3?Up.copy(e):Up.set(e,r,i);const s=this.parent;this.updateWorldMatrix(!0,!1),id.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ca.lookAt(id,Up,this.up):ca.lookAt(Up,id,this.up),this.quaternion.setFromRotationMatrix(ca),s&&(ca.extractRotation(s.matrixWorld),xh.setFromRotationMatrix(ca),this.quaternion.premultiply(xh.invert()))}add(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(EM),bh.child=e,this.dispatchEvent(bh),bh.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const r=this.children.indexOf(e);return r!==-1&&(e.parent=null,this.children.splice(r,1),e.dispatchEvent(aK),X0.child=e,this.dispatchEvent(X0),X0.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ca.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ca.multiply(e.parent.matrixWorld)),e.applyMatrix4(ca),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(EM),bh.child=e,this.dispatchEvent(bh),bh.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,r){if(this[e]===r)return this;for(let i=0,s=this.children.length;i<s;i++){const a=this.children[i].getObjectByProperty(e,r);if(a!==void 0)return a}}getObjectsByProperty(e,r,i=[]){this[e]===r&&i.push(this);const s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].getObjectsByProperty(e,r,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(id,e,sK),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(id,nK,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const r=this.matrixWorld.elements;return e.set(r[8],r[9],r[10]).normalize()}raycast(){}traverse(e){e(this);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].traverseVisible(e)}traverseAncestors(e){const r=this.parent;r!==null&&(e(r),r.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const r=this.children;for(let i=0,s=r.length;i<s;i++)r[i].updateMatrixWorld(e)}updateWorldMatrix(e,r){const i=this.parent;if(e===!0&&i!==null&&i.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)),r===!0){const s=this.children;for(let n=0,a=s.length;n<a;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(e){const r=e===void 0||typeof e=="string",i={};r&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,u=l.length;h<u;h++){const c=l[h];n(e.shapes,c)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(n(e.materials,this.material[l]));s.material=o}else s.material=n(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(n(e.animations,l))}}if(r){const o=a(e.geometries),l=a(e.materials),h=a(e.textures),u=a(e.images),c=a(e.shapes),d=a(e.skeletons),m=a(e.animations),p=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),u.length>0&&(i.images=u),c.length>0&&(i.shapes=c),d.length>0&&(i.skeletons=d),m.length>0&&(i.animations=m),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const h in o){const u=o[h];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,r=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let i=0;i<e.children.length;i++){const s=e.children[i];this.add(s.clone())}return this}}yn.DEFAULT_UP=new $(0,1,0);yn.DEFAULT_MATRIX_AUTO_UPDATE=!0;yn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const sn=new $,da=new $,Y0=new $,ma=new $,vh=new $,Th=new $,AM=new $,Z0=new $,J0=new $,K0=new $,Q0=new Si,ex=new Si,tx=new Si;class hn{constructor(e=new $,r=new $,i=new $){this.a=e,this.b=r,this.c=i}static getNormal(e,r,i,s){s.subVectors(i,r),sn.subVectors(e,r),s.cross(sn);const n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(e,r,i,s,n){sn.subVectors(s,r),da.subVectors(i,r),Y0.subVectors(e,r);const a=sn.dot(sn),o=sn.dot(da),l=sn.dot(Y0),h=da.dot(da),u=da.dot(Y0),c=a*h-o*o;if(c===0)return n.set(0,0,0),null;const d=1/c,m=(h*l-o*u)*d,p=(a*u-o*l)*d;return n.set(1-m-p,p,m)}static containsPoint(e,r,i,s){return this.getBarycoord(e,r,i,s,ma)===null?!1:ma.x>=0&&ma.y>=0&&ma.x+ma.y<=1}static getInterpolation(e,r,i,s,n,a,o,l){return this.getBarycoord(e,r,i,s,ma)===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(n,ma.x),l.addScaledVector(a,ma.y),l.addScaledVector(o,ma.z),l)}static getInterpolatedAttribute(e,r,i,s,n,a){return Q0.setScalar(0),ex.setScalar(0),tx.setScalar(0),Q0.fromBufferAttribute(e,r),ex.fromBufferAttribute(e,i),tx.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Q0,n.x),a.addScaledVector(ex,n.y),a.addScaledVector(tx,n.z),a}static isFrontFacing(e,r,i,s){return sn.subVectors(i,r),da.subVectors(e,r),sn.cross(da).dot(s)<0}set(e,r,i){return this.a.copy(e),this.b.copy(r),this.c.copy(i),this}setFromPointsAndIndices(e,r,i,s){return this.a.copy(e[r]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,r,i,s){return this.a.fromBufferAttribute(e,r),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return sn.subVectors(this.c,this.b),da.subVectors(this.a,this.b),sn.cross(da).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return hn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,r){return hn.getBarycoord(e,this.a,this.b,this.c,r)}getInterpolation(e,r,i,s,n){return hn.getInterpolation(e,this.a,this.b,this.c,r,i,s,n)}containsPoint(e){return hn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return hn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,r){const i=this.a,s=this.b,n=this.c;let a,o;vh.subVectors(s,i),Th.subVectors(n,i),Z0.subVectors(e,i);const l=vh.dot(Z0),h=Th.dot(Z0);if(l<=0&&h<=0)return r.copy(i);J0.subVectors(e,s);const u=vh.dot(J0),c=Th.dot(J0);if(u>=0&&c<=u)return r.copy(s);const d=l*c-u*h;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),r.copy(i).addScaledVector(vh,a);K0.subVectors(e,n);const m=vh.dot(K0),p=Th.dot(K0);if(p>=0&&m<=p)return r.copy(n);const f=m*h-l*p;if(f<=0&&h>=0&&p<=0)return o=h/(h-p),r.copy(i).addScaledVector(Th,o);const g=u*p-m*c;if(g<=0&&c-u>=0&&m-p>=0)return AM.subVectors(n,s),o=(c-u)/(c-u+(m-p)),r.copy(s).addScaledVector(AM,o);const y=1/(g+f+d);return a=f*y,o=d*y,r.copy(i).addScaledVector(vh,a).addScaledVector(Th,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const o3={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},ao={h:0,s:0,l:0},Dp={h:0,s:0,l:0};function rx(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*6*(2/3-r):t}class ja{constructor(e,r,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,r,i)}set(e,r,i){if(r===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,r,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,r=Ps){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,or.colorSpaceToWorking(this,r),this}setRGB(e,r,i,s=or.workingColorSpace){return this.r=e,this.g=r,this.b=i,or.colorSpaceToWorking(this,s),this}setHSL(e,r,i,s=or.workingColorSpace){if(e=Wv(e,1),r=tt(r,0,1),i=tt(i,0,1),r===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+r):i+r-i*r,a=2*i-n;this.r=rx(a,n,e+1/3),this.g=rx(a,n,e),this.b=rx(a,n,e-1/3)}return or.colorSpaceToWorking(this,s),this}setStyle(e,r=Ps){function i(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,r);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,r);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=s[1],a=n.length;if(a===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,r);if(a===6)return this.setHex(parseInt(n,16),r);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,r);return this}setColorName(e,r=Ps){const i=o3[e.toLowerCase()];return i!==void 0?this.setHex(i,r):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ra(e.r),this.g=Ra(e.g),this.b=Ra(e.b),this}copyLinearToSRGB(e){return this.r=tc(e.r),this.g=tc(e.g),this.b=tc(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ps){return or.workingToColorSpace(mi.copy(this),e),Math.round(tt(mi.r*255,0,255))*65536+Math.round(tt(mi.g*255,0,255))*256+Math.round(tt(mi.b*255,0,255))}getHexString(e=Ps){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,r=or.workingColorSpace){or.workingToColorSpace(mi.copy(this),r);const i=mi.r,s=mi.g,n=mi.b,a=Math.max(i,s,n),o=Math.min(i,s,n);let l,h;const u=(o+a)/2;if(o===a)l=0,h=0;else{const c=a-o;switch(h=u<=.5?c/(a+o):c/(2-a-o),a){case i:l=(s-n)/c+(s<n?6:0);break;case s:l=(n-i)/c+2;break;case n:l=(i-s)/c+4;break}l/=6}return e.h=l,e.s=h,e.l=u,e}getRGB(e,r=or.workingColorSpace){return or.workingToColorSpace(mi.copy(this),r),e.r=mi.r,e.g=mi.g,e.b=mi.b,e}getStyle(e=Ps){or.workingToColorSpace(mi.copy(this),e);const r=mi.r,i=mi.g,s=mi.b;return e!==Ps?`color(${e} ${r.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(r*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,r,i){return this.getHSL(ao),this.setHSL(ao.h+e,ao.s+r,ao.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,r){return this.r=e.r+r.r,this.g=e.g+r.g,this.b=e.b+r.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,r){return this.r+=(e.r-this.r)*r,this.g+=(e.g-this.g)*r,this.b+=(e.b-this.b)*r,this}lerpColors(e,r,i){return this.r=e.r+(r.r-e.r)*i,this.g=e.g+(r.g-e.g)*i,this.b=e.b+(r.b-e.b)*i,this}lerpHSL(e,r){this.getHSL(ao),e.getHSL(Dp);const i=zd(ao.h,Dp.h,r),s=zd(ao.s,Dp.s,r),n=zd(ao.l,Dp.l,r);return this.setHSL(i,s,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const r=this.r,i=this.g,s=this.b,n=e.elements;return this.r=n[0]*r+n[3]*i+n[6]*s,this.g=n[1]*r+n[4]*i+n[7]*s,this.b=n[2]*r+n[5]*i+n[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,r=0){return this.r=e[r],this.g=e[r+1],this.b=e[r+2],this}toArray(e=[],r=0){return e[r]=this.r,e[r+1]=this.g,e[r+2]=this.b,e}fromBufferAttribute(e,r){return this.r=e.getX(r),this.g=e.getY(r),this.b=e.getZ(r),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const mi=new ja;ja.NAMES=o3;let oK=0;class Fb extends Du{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:oK++}),this.uuid=Ca(),this.name="",this.type="Material",this.blending=Ib,this.side=Pb,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=aM,this.blendDst=oM,this.blendEquation=nM,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ja(0,0,0),this.blendAlpha=0,this.depthFunc=lM,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pM,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=dh,this.stencilZFail=dh,this.stencilZPass=dh,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const r in e){const i=e[r];if(i===void 0){console.warn(`THREE.Material: parameter '${r}' has value of undefined.`);continue}const s=this[r];if(s===void 0){console.warn(`THREE.Material: '${r}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[r]=i}}toJSON(e){const r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ib&&(i.blending=this.blending),this.side!==Pb&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==aM&&(i.blendSrc=this.blendSrc),this.blendDst!==oM&&(i.blendDst=this.blendDst),this.blendEquation!==nM&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==lM&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==pM&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==dh&&(i.stencilFail=this.stencilFail),this.stencilZFail!==dh&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==dh&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const a=[];for(const o in n){const l=n[o];delete l.metadata,a.push(l)}return a}if(r){const n=s(e.textures),a=s(e.images);n.length>0&&(i.textures=n),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const r=e.clippingPlanes;let i=null;if(r!==null){const s=r.length;i=new Array(s);for(let n=0;n!==s;++n)i[n]=r[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class l3 extends Fb{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ja(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 $u,this.combine=SJ,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const wr=new $,$p=new Jt;let lK=0;class Bs{constructor(e,r,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lK++}),this.name="",this.array=e,this.itemSize=r,this.count=e!==void 0?e.length/r:0,this.normalized=i,this.usage=ug,this.updateRanges=[],this.gpuType=gc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,r){this.updateRanges.push({start:e,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,r,i){e*=this.itemSize,i*=r.itemSize;for(let s=0,n=this.itemSize;s<n;s++)this.array[e+s]=r.array[i+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let r=0,i=this.count;r<i;r++)$p.fromBufferAttribute(this,r),$p.applyMatrix3(e),this.setXY(r,$p.x,$p.y);else if(this.itemSize===3)for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.applyMatrix3(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}applyMatrix4(e){for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.applyMatrix4(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}applyNormalMatrix(e){for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.applyNormalMatrix(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}transformDirection(e){for(let r=0,i=this.count;r<i;r++)wr.fromBufferAttribute(this,r),wr.transformDirection(e),this.setXYZ(r,wr.x,wr.y,wr.z);return this}set(e,r=0){return this.array.set(e,r),this}getComponent(e,r){let i=this.array[e*this.itemSize+r];return this.normalized&&(i=un(i,this.array)),i}setComponent(e,r,i){return this.normalized&&(i=St(i,this.array)),this.array[e*this.itemSize+r]=i,this}getX(e){let r=this.array[e*this.itemSize];return this.normalized&&(r=un(r,this.array)),r}setX(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize]=r,this}getY(e){let r=this.array[e*this.itemSize+1];return this.normalized&&(r=un(r,this.array)),r}setY(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize+1]=r,this}getZ(e){let r=this.array[e*this.itemSize+2];return this.normalized&&(r=un(r,this.array)),r}setZ(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize+2]=r,this}getW(e){let r=this.array[e*this.itemSize+3];return this.normalized&&(r=un(r,this.array)),r}setW(e,r){return this.normalized&&(r=St(r,this.array)),this.array[e*this.itemSize+3]=r,this}setXY(e,r,i){return e*=this.itemSize,this.normalized&&(r=St(r,this.array),i=St(i,this.array)),this.array[e+0]=r,this.array[e+1]=i,this}setXYZ(e,r,i,s){return e*=this.itemSize,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array)),this.array[e+0]=r,this.array[e+1]=i,this.array[e+2]=s,this}setXYZW(e,r,i,s,n){return e*=this.itemSize,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array),n=St(n,this.array)),this.array[e+0]=r,this.array[e+1]=i,this.array[e+2]=s,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ug&&(e.usage=this.usage),e}}class uK extends Bs{constructor(e,r,i){super(new Uint16Array(e),r,i)}}class hK extends Bs{constructor(e,r,i){super(new Uint32Array(e),r,i)}}class rc extends Bs{constructor(e,r,i){super(new Float32Array(e),r,i)}}let cK=0;const Ms=new Rt,ix=new yn,wh=new $,is=new Em,sd=new Em,Zr=new $;class Cc extends Du{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cK++}),this.uuid=Ca(),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(e){return Array.isArray(e)?this.index=new(HJ(e)?hK:uK)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,r){return this.attributes[e]=r,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,r,i=0){this.groups.push({start:e,count:r,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,r){this.drawRange.start=e,this.drawRange.count=r}applyMatrix4(e){const r=this.attributes.position;r!==void 0&&(r.applyMatrix4(e),r.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new qs().getNormalMatrix(e);i.applyNormalMatrix(n),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ms.makeRotationFromQuaternion(e),this.applyMatrix4(Ms),this}rotateX(e){return Ms.makeRotationX(e),this.applyMatrix4(Ms),this}rotateY(e){return Ms.makeRotationY(e),this.applyMatrix4(Ms),this}rotateZ(e){return Ms.makeRotationZ(e),this.applyMatrix4(Ms),this}translate(e,r,i){return Ms.makeTranslation(e,r,i),this.applyMatrix4(Ms),this}scale(e,r,i){return Ms.makeScale(e,r,i),this.applyMatrix4(Ms),this}lookAt(e){return ix.lookAt(e),ix.updateMatrix(),this.applyMatrix4(ix.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wh).negate(),this.translate(wh.x,wh.y,wh.z),this}setFromPoints(e){const r=this.getAttribute("position");if(r===void 0){const i=[];for(let s=0,n=e.length;s<n;s++){const a=e[s];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new rc(i,3))}else{const i=Math.min(e.length,r.count);for(let s=0;s<i;s++){const n=e[s];r.setXYZ(s,n.x,n.y,n.z||0)}e.length>r.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),r.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Em);const e=this.attributes.position,r=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new $(-1/0,-1/0,-1/0),new $(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),r)for(let i=0,s=r.length;i<s;i++){const n=r[i];is.setFromBufferAttribute(n),this.morphTargetsRelative?(Zr.addVectors(this.boundingBox.min,is.min),this.boundingBox.expandByPoint(Zr),Zr.addVectors(this.boundingBox.max,is.max),this.boundingBox.expandByPoint(Zr)):(this.boundingBox.expandByPoint(is.min),this.boundingBox.expandByPoint(is.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 qv);const e=this.attributes.position,r=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new $,1/0);return}if(e){const i=this.boundingSphere.center;if(is.setFromBufferAttribute(e),r)for(let n=0,a=r.length;n<a;n++){const o=r[n];sd.setFromBufferAttribute(o),this.morphTargetsRelative?(Zr.addVectors(is.min,sd.min),is.expandByPoint(Zr),Zr.addVectors(is.max,sd.max),is.expandByPoint(Zr)):(is.expandByPoint(sd.min),is.expandByPoint(sd.max))}is.getCenter(i);let s=0;for(let n=0,a=e.count;n<a;n++)Zr.fromBufferAttribute(e,n),s=Math.max(s,i.distanceToSquared(Zr));if(r)for(let n=0,a=r.length;n<a;n++){const o=r[n],l=this.morphTargetsRelative;for(let h=0,u=o.count;h<u;h++)Zr.fromBufferAttribute(o,h),l&&(wh.fromBufferAttribute(e,h),Zr.add(wh)),s=Math.max(s,i.distanceToSquared(Zr))}this.boundingSphere.radius=Math.sqrt(s),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 e=this.index,r=this.attributes;if(e===null||r.position===void 0||r.normal===void 0||r.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=r.position,s=r.normal,n=r.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Bs(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let A=0;A<i.count;A++)o[A]=new $,l[A]=new $;const h=new $,u=new $,c=new $,d=new Jt,m=new Jt,p=new Jt,f=new $,g=new $;function y(A,U,Q){h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,U),c.fromBufferAttribute(i,Q),d.fromBufferAttribute(n,A),m.fromBufferAttribute(n,U),p.fromBufferAttribute(n,Q),u.sub(h),c.sub(h),m.sub(d),p.sub(d);const J=1/(m.x*p.y-p.x*m.y);isFinite(J)&&(f.copy(u).multiplyScalar(p.y).addScaledVector(c,-m.y).multiplyScalar(J),g.copy(c).multiplyScalar(m.x).addScaledVector(u,-p.x).multiplyScalar(J),o[A].add(f),o[U].add(f),o[Q].add(f),l[A].add(g),l[U].add(g),l[Q].add(g))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let A=0,U=T.length;A<U;++A){const Q=T[A],J=Q.start,re=Q.count;for(let ie=J,se=J+re;ie<se;ie+=3)y(e.getX(ie+0),e.getX(ie+1),e.getX(ie+2))}const S=new $,w=new $,_=new $,M=new $;function E(A){_.fromBufferAttribute(s,A),M.copy(_);const U=o[A];S.copy(U),S.sub(_.multiplyScalar(_.dot(U))).normalize(),w.crossVectors(M,U);const J=w.dot(l[A])<0?-1:1;a.setXYZW(A,S.x,S.y,S.z,J)}for(let A=0,U=T.length;A<U;++A){const Q=T[A],J=Q.start,re=Q.count;for(let ie=J,se=J+re;ie<se;ie+=3)E(e.getX(ie+0)),E(e.getX(ie+1)),E(e.getX(ie+2))}}computeVertexNormals(){const e=this.index,r=this.getAttribute("position");if(r!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Bs(new Float32Array(r.count*3),3),this.setAttribute("normal",i);else for(let d=0,m=i.count;d<m;d++)i.setXYZ(d,0,0,0);const s=new $,n=new $,a=new $,o=new $,l=new $,h=new $,u=new $,c=new $;if(e)for(let d=0,m=e.count;d<m;d+=3){const p=e.getX(d+0),f=e.getX(d+1),g=e.getX(d+2);s.fromBufferAttribute(r,p),n.fromBufferAttribute(r,f),a.fromBufferAttribute(r,g),u.subVectors(a,n),c.subVectors(s,n),u.cross(c),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,f),h.fromBufferAttribute(i,g),o.add(u),l.add(u),h.add(u),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(f,l.x,l.y,l.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let d=0,m=r.count;d<m;d+=3)s.fromBufferAttribute(r,d+0),n.fromBufferAttribute(r,d+1),a.fromBufferAttribute(r,d+2),u.subVectors(a,n),c.subVectors(s,n),u.cross(c),i.setXYZ(d+0,u.x,u.y,u.z),i.setXYZ(d+1,u.x,u.y,u.z),i.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let r=0,i=e.count;r<i;r++)Zr.fromBufferAttribute(e,r),Zr.normalize(),e.setXYZ(r,Zr.x,Zr.y,Zr.z)}toNonIndexed(){function e(o,l){const h=o.array,u=o.itemSize,c=o.normalized,d=new h.constructor(l.length*u);let m=0,p=0;for(let f=0,g=l.length;f<g;f++){o.isInterleavedBufferAttribute?m=l[f]*o.data.stride+o.offset:m=l[f]*u;for(let y=0;y<u;y++)d[p++]=h[m++]}return new Bs(d,u,c)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const r=new Cc,i=this.index.array,s=this.attributes;for(const o in s){const l=s[o],h=e(l,i);r.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const l=[],h=n[o];for(let u=0,c=h.length;u<c;u++){const d=h[u],m=e(d,i);l.push(m)}r.morphAttributes[o]=l}r.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const h=a[o];r.addGroup(h.start,h.count,h.materialIndex)}return r}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const r=this.index;r!==null&&(e.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const s={};let n=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],u=[];for(let c=0,d=h.length;c<d;c++){const m=h[c];u.push(m.toJSON(e.data))}u.length>0&&(s[l]=u,n=!0)}n&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const r={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const h in s){const u=s[h];this.setAttribute(h,u.clone(r))}const n=e.morphAttributes;for(const h in n){const u=[],c=n[h];for(let d=0,m=c.length;d<m;d++)u.push(c[d].clone(r));this.morphAttributes[h]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let h=0,u=a.length;h<u;h++){const c=a[h];this.addGroup(c.start,c.count,c.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const CM=new Rt,sl=new QJ,Gp=new qv,RM=new $,jp=new $,Wp=new $,Hp=new $,sx=new $,qp=new $,PM=new $,Xp=new $;class cg extends yn{constructor(e=new Cc,r=new l3){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=r,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,r){return super.copy(e,r),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const r=this.geometry.morphAttributes,i=Object.keys(r);if(i.length>0){const s=r[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,a=s.length;n<a;n++){const o=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}getVertexPosition(e,r){const i=this.geometry,s=i.attributes.position,n=i.morphAttributes.position,a=i.morphTargetsRelative;r.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(n&&o){qp.set(0,0,0);for(let l=0,h=n.length;l<h;l++){const u=o[l],c=n[l];u!==0&&(sx.fromBufferAttribute(c,e),a?qp.addScaledVector(sx,u):qp.addScaledVector(sx.sub(r),u))}r.add(qp)}return r}raycast(e,r){const i=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Gp.copy(i.boundingSphere),Gp.applyMatrix4(n),sl.copy(e.ray).recast(e.near),!(Gp.containsPoint(sl.origin)===!1&&(sl.intersectSphere(Gp,RM)===null||sl.origin.distanceToSquared(RM)>(e.far-e.near)**2))&&(CM.copy(n).invert(),sl.copy(e.ray).applyMatrix4(CM),!(i.boundingBox!==null&&sl.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,r,sl)))}_computeIntersections(e,r,i){let s;const n=this.geometry,a=this.material,o=n.index,l=n.attributes.position,h=n.attributes.uv,u=n.attributes.uv1,c=n.attributes.normal,d=n.groups,m=n.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,f=d.length;p<f;p++){const g=d[p],y=a[g.materialIndex],T=Math.max(g.start,m.start),S=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=S;w<_;w+=3){const M=o.getX(w),E=o.getX(w+1),A=o.getX(w+2);s=Yp(this,y,e,i,h,u,c,M,E,A),s&&(s.faceIndex=Math.floor(w/3),s.face.materialIndex=g.materialIndex,r.push(s))}}else{const p=Math.max(0,m.start),f=Math.min(o.count,m.start+m.count);for(let g=p,y=f;g<y;g+=3){const T=o.getX(g),S=o.getX(g+1),w=o.getX(g+2);s=Yp(this,a,e,i,h,u,c,T,S,w),s&&(s.faceIndex=Math.floor(g/3),r.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let p=0,f=d.length;p<f;p++){const g=d[p],y=a[g.materialIndex],T=Math.max(g.start,m.start),S=Math.min(l.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=S;w<_;w+=3){const M=w,E=w+1,A=w+2;s=Yp(this,y,e,i,h,u,c,M,E,A),s&&(s.faceIndex=Math.floor(w/3),s.face.materialIndex=g.materialIndex,r.push(s))}}else{const p=Math.max(0,m.start),f=Math.min(l.count,m.start+m.count);for(let g=p,y=f;g<y;g+=3){const T=g,S=g+1,w=g+2;s=Yp(this,a,e,i,h,u,c,T,S,w),s&&(s.faceIndex=Math.floor(g/3),r.push(s))}}}}function dK(t,e,r,i,s,n,a,o){let l;if(e.side===oy?l=i.intersectTriangle(a,n,s,!0,o):l=i.intersectTriangle(s,n,a,e.side===Pb,o),l===null)return null;Xp.copy(o),Xp.applyMatrix4(t.matrixWorld);const h=r.ray.origin.distanceTo(Xp);return h<r.near||h>r.far?null:{distance:h,point:Xp.clone(),object:t}}function Yp(t,e,r,i,s,n,a,o,l,h){t.getVertexPosition(o,jp),t.getVertexPosition(l,Wp),t.getVertexPosition(h,Hp);const u=dK(t,e,r,i,jp,Wp,Hp,PM);if(u){const c=new $;hn.getBarycoord(PM,jp,Wp,Hp,c),s&&(u.uv=hn.getInterpolatedAttribute(s,o,l,h,c,new Jt)),n&&(u.uv1=hn.getInterpolatedAttribute(n,o,l,h,c,new Jt)),a&&(u.normal=hn.getInterpolatedAttribute(a,o,l,h,c,new $),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c:h,normal:new $,materialIndex:0};hn.getNormal(jp,Wp,Hp,d.normal),u.face=d,u.barycoord=c}return u}class Xv extends Cc{constructor(e=1,r=1,i=1,s=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:r,depth:i,widthSegments:s,heightSegments:n,depthSegments:a};const o=this;s=Math.floor(s),n=Math.floor(n),a=Math.floor(a);const l=[],h=[],u=[],c=[];let d=0,m=0;p("z","y","x",-1,-1,i,r,e,a,n,0),p("z","y","x",1,-1,i,r,-e,a,n,1),p("x","z","y",1,1,e,i,r,s,a,2),p("x","z","y",1,-1,e,i,-r,s,a,3),p("x","y","z",1,-1,e,r,i,s,n,4),p("x","y","z",-1,-1,e,r,-i,s,n,5),this.setIndex(l),this.setAttribute("position",new rc(h,3)),this.setAttribute("normal",new rc(u,3)),this.setAttribute("uv",new rc(c,2));function p(f,g,y,T,S,w,_,M,E,A,U){const Q=w/E,J=_/A,re=w/2,ie=_/2,se=M/2,ve=E+1,me=A+1;let Me=0,ye=0;const Te=new $;for(let ge=0;ge<me;ge++){const be=ge*J-ie;for(let Je=0;Je<ve;Je++){const wt=Je*Q-re;Te[f]=wt*T,Te[g]=be*S,Te[y]=se,h.push(Te.x,Te.y,Te.z),Te[f]=0,Te[g]=0,Te[y]=M>0?1:-1,u.push(Te.x,Te.y,Te.z),c.push(Je/E),c.push(1-ge/A),Me+=1}}for(let ge=0;ge<A;ge++)for(let be=0;be<E;be++){const Je=d+be+ve*ge,wt=d+be+ve*(ge+1),Bt=d+(be+1)+ve*(ge+1),He=d+(be+1)+ve*ge;l.push(Je,wt,He),l.push(wt,Bt,He),ye+=6}o.addGroup(m,ye,U),m+=ye,d+=Me}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class u3 extends yn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=va}copy(e,r){return super.copy(e,r),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const oo=new $,IM=new Jt,VM=new Jt;class mK extends u3{constructor(e=50,r=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=r,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,r){return super.copy(e,r),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const r=.5*this.getFilmHeight()/e;this.fov=hg*2*Math.atan(r),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Fd*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return hg*2*Math.atan(Math.tan(Fd*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,r,i){oo.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(oo.x,oo.y).multiplyScalar(-e/oo.z),oo.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(oo.x,oo.y).multiplyScalar(-e/oo.z)}getViewSize(e,r){return this.getViewBounds(e,IM,VM),r.subVectors(VM,IM)}setViewOffset(e,r,i,s,n,a){this.aspect=e/r,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=r,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let r=e*Math.tan(Fd*.5*this.fov)/this.zoom,i=2*r,s=this.aspect*i,n=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,h=a.fullHeight;n+=a.offsetX*s/l,r-=a.offsetY*i/h,s*=a.width/l,i*=a.height/h}const o=this.filmOffset;o!==0&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+s,r,r-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const r=super.toJSON(e);return r.object.fov=this.fov,r.object.zoom=this.zoom,r.object.near=this.near,r.object.far=this.far,r.object.focus=this.focus,r.object.aspect=this.aspect,this.view!==null&&(r.object.view=Object.assign({},this.view)),r.object.filmGauge=this.filmGauge,r.object.filmOffset=this.filmOffset,r}}class pK extends vi{constructor(e=[],r=ag,i,s,n,a,o,l,h,u){super(e,r,i,s,n,a,o,l,h,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class h3{constructor(e,r){this.isInterleavedBuffer=!0,this.array=e,this.stride=r,this.count=e!==void 0?e.length/r:0,this.usage=ug,this.updateRanges=[],this.version=0,this.uuid=Ca()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,r){this.updateRanges.push({start:e,count:r})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,r,i){e*=this.stride,i*=r.stride;for(let s=0,n=this.stride;s<n;s++)this.array[e+s]=r.array[i+s];return this}set(e,r=0){return this.array.set(e,r),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const r=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(r,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ca()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ai=new $;class Yv{constructor(e,r,i,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=r,this.offset=i,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let r=0,i=this.data.count;r<i;r++)Ai.fromBufferAttribute(this,r),Ai.applyMatrix4(e),this.setXYZ(r,Ai.x,Ai.y,Ai.z);return this}applyNormalMatrix(e){for(let r=0,i=this.count;r<i;r++)Ai.fromBufferAttribute(this,r),Ai.applyNormalMatrix(e),this.setXYZ(r,Ai.x,Ai.y,Ai.z);return this}transformDirection(e){for(let r=0,i=this.count;r<i;r++)Ai.fromBufferAttribute(this,r),Ai.transformDirection(e),this.setXYZ(r,Ai.x,Ai.y,Ai.z);return this}getComponent(e,r){let i=this.array[e*this.data.stride+this.offset+r];return this.normalized&&(i=un(i,this.array)),i}setComponent(e,r,i){return this.normalized&&(i=St(i,this.array)),this.data.array[e*this.data.stride+this.offset+r]=i,this}setX(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset]=r,this}setY(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset+1]=r,this}setZ(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset+2]=r,this}setW(e,r){return this.normalized&&(r=St(r,this.array)),this.data.array[e*this.data.stride+this.offset+3]=r,this}getX(e){let r=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(r=un(r,this.array)),r}getY(e){let r=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(r=un(r,this.array)),r}getZ(e){let r=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(r=un(r,this.array)),r}getW(e){let r=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(r=un(r,this.array)),r}setXY(e,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(r=St(r,this.array),i=St(i,this.array)),this.data.array[e+0]=r,this.data.array[e+1]=i,this}setXYZ(e,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array)),this.data.array[e+0]=r,this.data.array[e+1]=i,this.data.array[e+2]=s,this}setXYZW(e,r,i,s,n){return e=e*this.data.stride+this.offset,this.normalized&&(r=St(r,this.array),i=St(i,this.array),s=St(s,this.array),n=St(n,this.array)),this.data.array[e+0]=r,this.data.array[e+1]=i,this.data.array[e+2]=s,this.data.array[e+3]=n,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const r=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)r.push(this.data.array[s+n])}return new Bs(new this.array.constructor(r),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Yv(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const r=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)r.push(this.data.array[s+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:r,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class em extends vi{constructor(e=null,r=1,i=1,s,n,a,o,l,h=$s,u=$s,c,d){super(null,a,o,l,h,u,s,n,c,d),this.isDataTexture=!0,this.image={data:e,width:r,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ic extends Bs{constructor(e,r,i,s=1){super(e,r,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const nx=new $,fK=new $,gK=new qs;class yK{constructor(e=new $(1,0,0),r=0){this.isPlane=!0,this.normal=e,this.constant=r}set(e,r){return this.normal.copy(e),this.constant=r,this}setComponents(e,r,i,s){return this.normal.set(e,r,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,r){return this.normal.copy(e),this.constant=-r.dot(this.normal),this}setFromCoplanarPoints(e,r,i){const s=nx.subVectors(i,r).cross(fK.subVectors(e,r)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,r){return r.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,r){const i=e.delta(nx),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(e.start)===0?r.copy(e.start):null;const n=-(e.start.dot(this.normal)+this.constant)/s;return n<0||n>1?null:r.copy(e.start).addScaledVector(i,n)}intersectsLine(e){const r=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return r<0&&i>0||i<0&&r>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,r){const i=r||gK.getNormalMatrix(e),s=this.coplanarPoint(nx).applyMatrix4(e),n=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(n),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}class c3 extends vi{constructor(e,r){super({width:e,height:r}),this.isFramebufferTexture=!0,this.magFilter=$s,this.minFilter=$s,this.generateMipmaps=!1,this.needsUpdate=!0}}class Am extends vi{constructor(e,r,i=n3,s,n,a,o=$s,l=$s,h,u=cM,c=1){if(u!==cM&&u!==EJ)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:r,depth:c};super(d,s,n,a,o,l,u,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Hv(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const r=super.toJSON(e);return this.compareFunction!==null&&(r.compareFunction=this.compareFunction),r}}const OM={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class xK{constructor(e,r,i){const s=this;let n=!1,a=0,o=0,l;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=r,this.onError=i,this.itemStart=function(u){o++,n===!1&&s.onStart!==void 0&&s.onStart(u,a,o),n=!0},this.itemEnd=function(u){a++,s.onProgress!==void 0&&s.onProgress(u,a,o),a===o&&(n=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(u){s.onError!==void 0&&s.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,c){return h.push(u,c),this},this.removeHandler=function(u){const c=h.indexOf(u);return c!==-1&&h.splice(c,2),this},this.getHandler=function(u){for(let c=0,d=h.length;c<d;c+=2){const m=h[c],p=h[c+1];if(m.global&&(m.lastIndex=0),m.test(u))return p}return null}}}const bK=new xK;class Zv{constructor(e){this.manager=e!==void 0?e:bK,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,r){const i=this;return new Promise(function(s,n){i.load(e,s,r,n)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Zv.DEFAULT_MATERIAL_NAME="__DEFAULT";class vK extends Zv{constructor(e){super(e)}load(e,r,i,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=OM.get(e);if(a!==void 0)return n.manager.itemStart(e),setTimeout(function(){r&&r(a),n.manager.itemEnd(e)},0),a;const o=Lb("img");function l(){u(),OM.add(e,this),r&&r(this),n.manager.itemEnd(e)}function h(c){u(),s&&s(c),n.manager.itemError(e),n.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),n.manager.itemStart(e),o.src=e,o}}class TK extends Zv{constructor(e){super(e)}load(e,r,i,s){const n=new vi,a=new vK(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){n.image=o,n.needsUpdate=!0,r!==void 0&&r(n)},i,s),n}}class d3 extends u3{constructor(e=-1,r=1,i=1,s=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=r,this.top=i,this.bottom=s,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(e,r){return super.copy(e,r),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,r,i,s,n,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=r,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),r=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let n=i-e,a=i+e,o=s+r,l=s-r;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,a=n+h*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(n,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const r=super.toJSON(e);return r.object.zoom=this.zoom,r.object.left=this.left,r.object.right=this.right,r.object.top=this.top,r.object.bottom=this.bottom,r.object.near=this.near,r.object.far=this.far,this.view!==null&&(r.object.view=Object.assign({},this.view)),r}}class wK extends h3{constructor(e,r,i=1){super(e,r),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const r=super.clone(e);return r.meshPerAttribute=this.meshPerAttribute,r}toJSON(e){const r=super.toJSON(e);return r.isInstancedInterleavedBuffer=!0,r.meshPerAttribute=this.meshPerAttribute,r}}class Jv{constructor(e,r,i,s){Jv.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,r,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,r=0){for(let i=0;i<4;i++)this.elements[i]=e[i+r];return this}set(e,r,i,s){const n=this.elements;return n[0]=e,n[2]=r,n[1]=i,n[3]=s,this}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:r3}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=r3);const El={name:"Ascii",category:"Effects",requiresRTT:!0,props:{characters:{default:"@%#*+=-:.",description:"Characters to use for ASCII effect (light to dark)",ui:{type:"text",label:"Characters"}},cellSize:{default:30,description:"Size of each ASCII character cell in pixels",ui:{type:"range",min:8,max:100,step:1,label:"Cell Size"}},fontFamily:{default:"jetbrains mono",description:"Font family for characters",ui:{type:"select",options:[{label:"JetBrains Mono",value:"jetbrains mono"},{label:"Courier New",value:"courier new"},{label:"Monaco",value:"monaco"},{label:"Consolas",value:"consolas"}],label:"Font Family"}},spacing:{default:1,description:"Character padding within each cell (1.0 = no padding, 0.5 = 50% padding)",ui:{type:"range",min:.1,max:1,step:.05,label:"Spacing"}}},fragmentNode:({uniforms:t,childNode:e,onCleanup:r,onBeforeRender:i,dimensions:s})=>{let{vec2:n,vec3:a,vec4:o,floor:l,fract:h,dot:u,ceil:c,sqrt:d,screenUV:m,convertToTexture:p,texture:f}=Ve;if(!e)return o(0,0,0,0);let g=Math.round(s.width),y=Math.round(s.height),T=p(e,g,y),S=1024,w=(Mi,ri,_i)=>{let Ni=Mi.length,ws=Math.max(2,Math.ceil(Math.sqrt(Ni))),ta=Math.max(12,ri*.8),Vr=document.createElement("canvas");Vr.width=S,Vr.height=S;let zi=Vr.getContext("2d");zi.fillStyle="#000000",zi.fillRect(0,0,Vr.width,Vr.height),zi.fillStyle="#ffffff",zi.font=`${ta}px ${_i}`,zi.textAlign="center",zi.textBaseline="middle";let ii=Math.max(32,ri*2),he=Math.floor(S/ii)*ii,oe=Math.min(ii,he/ws);for(let ut=0;ut<Ni;ut++){let ht=Mi[ut],Pt=Math.floor(ut/ws),Lt=ut%ws,ar=Lt*oe+oe/2,yt=Pt*oe+oe/2;zi.fillText(ht,ar,yt)}let xe=zi.getImageData(0,0,Vr.width,Vr.height),ce=new Uint8Array(xe.data),qe=ws*oe/S;return{data:ce,width:S,height:S,atlasSize:ws,cellSize:ri,charCount:Ni,characters:Mi,fontFamily:_i,uvScale:qe}},_=w(t.characters.uniform.value,t.cellSize.uniform.value,t.fontFamily.uniform.value);_=w(t.characters.uniform.value,t.cellSize.uniform.value,t.fontFamily.uniform.value);let M=new em(_.data,S,S,jv,s3);M.minFilter=$s,M.magFilter=$s,M.generateMipmaps=!1,M.needsUpdate=!0;let E=f(M),A=t.characters.uniform.value,U=t.cellSize.uniform.value,Q=t.fontFamily.uniform.value,J=0;i(()=>{let Mi=Date.now();if(Mi-J<16)return;let ri=t.characters.uniform.value,_i=t.cellSize.uniform.value,Ni=t.fontFamily.uniform.value;(ri!==A||_i!==U||Ni!==Q)&&(console.log(`Updating atlas texture: cellSize ${U} → ${_i}`),J=Mi,_=w(ri,_i,Ni),M.image.data=_.data,M.needsUpdate=!0,re.value=_.charCount,ie.value=_.cellSize,se.value=_.uvScale,A=ri,U=_i,Q=Ni)}),r(()=>{M.dispose()});let re=Od(_.charCount),ie=Od(_.cellSize),se=Od(_.uvScale),ve=ie.mul(1.5),me=n(g,y).div(ve),Me=m.mul(me),ye=l(Me),Te=h(Me),ge=t.spacing.uniform,be=Te.mul(ge),Je=Eb(1).sub(ge).mul(.5),wt=be.add(Je),Bt=ye.add(n(.5)).div(me),He=T.sample(Bt),Wr=u(He.rgb,a(.299,.587,.114)),Hr=re,Qt=Wr.mul(.8).add(.1),Ot=Qt.mul(Hr),br=l(Ot.min(Hr.sub(1e-4))),vr=c(d(Hr)),qr=br.mod(vr),Wt=l(br.div(vr)),Ir=Eb(1).div(vr).mul(se),ui=n(qr,Wt).mul(Ir).add(wt.mul(Ir)),Zi=E.sample(ui);return o(Zi.rgb.mul(He.rgb),He.a)}};function qt(t,e){let r=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(e[0])||(e=e.map(a=>[a]));let i=e[0].length,s=e[0].map((a,o)=>e.map(l=>l[o])),n=t.map(a=>s.map(o=>{let l=0;if(!Array.isArray(a)){for(let h of o)l+=a*h;return l}for(let h=0;h<a.length;h++)l+=a[h]*(o[h]||0);return l}));return r===1&&(n=n[0]),i===1?n.map(a=>a[0]):n}function Cm(t){return Co(t)==="string"}function Co(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function dg(t,{precision:e,unit:r}){return Vo(t)?"none":m3(t,e)+(r??"")}function Vo(t){return Number.isNaN(t)||t instanceof Number&&t?.none}function Er(t){return Vo(t)?0:t}function m3(t,e){if(t===0)return 0;let r=~~t,i=0;r&&e&&(i=~~Math.log10(Math.abs(r))+1);let s=10**(e-i);return Math.floor(t*s+.5)/s}const SK={deg:1,grad:.9,rad:180/Math.PI,turn:360};function p3(t){if(!t)return;t=t.trim();let e=/^([a-z]+)\((.+?)\)$/i,r=/^-?[\d.]+$/,i=/%|deg|g?rad|turn$/,s=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,n=t.match(e);if(n){let a=[];return n[2].replace(s,(o,l)=>{let h=l.match(i),u=l;if(h){let c=h[0],d=u.slice(0,-c.length);c==="%"?(u=new Number(d/100),u.type="<percentage>"):(u=new Number(d*SK[c]),u.type="<angle>",u.unit=c)}else r.test(u)?(u=new Number(u),u.type="<number>"):u==="none"&&(u=new Number(NaN),u.none=!0);o.startsWith("/")&&(u=u instanceof Number?u:new Number(u),u.alpha=!0),typeof u=="object"&&u instanceof Number&&(u.raw=l),a.push(u)}),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:a}}}function f3(t){return t[t.length-1]}function tm(t,e,r){return isNaN(t)?e:isNaN(e)?t:t+(e-t)*r}function g3(t,e,r){return(r-t)/(e-t)}function Kv(t,e,r){return tm(e[0],e[1],g3(t[0],t[1],r))}function y3(t){return t.map(e=>e.split("|").map(r=>{r=r.trim();let i=r.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(i){let s=new String(i[1]);return s.range=[+i[2],+i[3]],s}return r}))}function x3(t,e,r){return Math.max(Math.min(r,e),t)}function ly(t,e){return Math.sign(t)===Math.sign(e)?t:-t}function Cn(t,e){return ly(Math.abs(t)**e,t)}function Qv(t,e){return e===0?0:t/e}function b3(t,e,r=0,i=t.length){for(;r<i;){let s=r+i>>1;t[s]<e?r=s+1:i=s}return r}var MK=Object.freeze({__proto__:null,bisectLeft:b3,clamp:x3,copySign:ly,interpolate:tm,interpolateInv:g3,isNone:Vo,isString:Cm,last:f3,mapRange:Kv,multiplyMatrices:qt,parseCoordGrammar:y3,parseFunction:p3,serializeNumber:dg,skipNone:Er,spow:Cn,toPrecision:m3,type:Co,zdiv:Qv}),_K=class{add(e,r,i){if(typeof arguments[0]!="string"){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(s){this[s]=this[s]||[],r&&this[s][i?"unshift":"push"](r)},this)}run(e,r){this[e]=this[e]||[],this[e].forEach(function(i){i.call(r&&r.context?r.context:r,r)})}};const Oo=new _K;var vs={gamut_mapping:"css",precision:5,deltaE:"76",verbose:globalThis?.process?.env?.NODE_ENV?.toLowerCase()!=="test",warn:function(t){this.verbose&&globalThis?.console?.warn?.(t)}};const Oi={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function zb(t){return Array.isArray(t)?t:Oi[t]}function mg(t,e,r,i={}){if(t=zb(t),e=zb(e),!t||!e)throw TypeError(`Missing white point to convert ${t?"":"from"}${!t&&!e?"/":""}${e?"":"to"}`);if(t===e)return r;let s={W1:t,W2:e,XYZ:r,options:i};if(Oo.run("chromatic-adaptation-start",s),s.M||(s.W1===Oi.D65&&s.W2===Oi.D50?s.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:s.W1===Oi.D50&&s.W2===Oi.D65&&(s.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),Oo.run("chromatic-adaptation-end",s),s.M)return qt(s.M,s.XYZ);throw TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const NK=new Set(["<number>","<percentage>","<angle>"]);function LM(t,e,r,i){return Object.entries(t.coords).map(([n,a],o)=>{let l=e.coordGrammar[o],h=i[o],u=h?.type,c;if(c=h.none?l.find(p=>NK.has(p)):l.find(p=>p==u),!c){let p=a.name||n;throw TypeError(`${u??h.raw} not allowed for ${p} in ${r}()`)}let d=c.range;u==="<percentage>"&&(d||(d=[0,1]));let m=a.range||a.refRange;return d&&m&&(i[o]=Kv(d,m,i[o])),c})}function v3(t,{meta:e}={}){let r={str:String(t)?.trim()};if(Oo.run("parse-start",r),r.color)return r.color;if(r.parsed=p3(r.str),r.parsed){let i=r.parsed.name;if(i==="color"){let s=r.parsed.args.shift(),n=s.startsWith("--")?s.substring(2):`--${s}`,a=[s,n],o=r.parsed.rawArgs.indexOf("/")>0?r.parsed.args.pop():1;for(let u of Ce.all){let c=u.getFormat("color");if(c&&(a.includes(c.id)||c.ids?.filter(d=>a.includes(d)).length)){let d=Object.keys(u.coords).map((p,f)=>r.parsed.args[f]||0),m;return c.coordGrammar&&(m=LM(u,c,"color",d)),e&&Object.assign(e,{formatId:"color",types:m}),c.id.startsWith("--")&&!s.startsWith("--")&&vs.warn(`${u.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${c.id}) instead of color(${s}).`),s.startsWith("--")&&!c.id.startsWith("--")&&vs.warn(`${u.name} is a standard space and supported in the CSS spec. Use color(${c.id}) instead of prefixed color(${s}).`),{spaceId:u.id,coords:d,alpha:o}}}let l="",h=s in Ce.registry?s:n;if(h in Ce.registry){let u=Ce.registry[h].formats?.color?.id;u&&(l=`Did you mean color(${u})?`)}throw TypeError(`Cannot parse color(${s}). `+(l||"Missing a plugin?"))}else for(let s of Ce.all){let n=s.getFormat(i);if(n&&n.type==="function"){let a=1;(n.lastAlpha||f3(r.parsed.args).alpha)&&(a=r.parsed.args.pop());let o=r.parsed.args,l;return n.coordGrammar&&(l=LM(s,n,i,o)),e&&Object.assign(e,{formatId:n.name,types:l}),{spaceId:s.id,coords:o,alpha:a}}}}else for(let i of Ce.all)for(let s in i.formats){let n=i.formats[s];if(n.type!=="custom"||n.test&&!n.test(r.str))continue;let a=n.parse(r.str);if(a)return a.alpha??(a.alpha=1),e&&(e.formatId=s),a}throw TypeError(`Could not parse ${t} as a color. Missing a plugin?`)}function We(t){if(Array.isArray(t))return t.map(We);if(!t)throw TypeError("Empty color reference");Cm(t)&&(t=v3(t));let e=t.space||t.spaceId;return e instanceof Ce||(t.space=Ce.get(e)),t.alpha===void 0&&(t.alpha=1),t}var ni,Ce=(ni=class{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?ni.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let r=e.coords??this.base.coords;for(let s in r)"name"in r[s]||(r[s].name=s);this.coords=r;let i=e.white??this.base.white??"D65";for(let s in this.white=zb(i),this.formats=e.formats??{},this.formats){let n=this.formats[s];n.type||(n.type="function"),n.name||(n.name=s)}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace=e.gamutSpace==="self"?this:ni.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(s,n)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:EK(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),Oo.run("colorspace-init-end",this)}inGamut(e,{epsilon:r=75e-6}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:r});let i=Object.values(this.coords);return e.every((s,n)=>{let a=i[n];if(a.type!=="angle"&&a.range){if(Number.isNaN(s))return!0;let[o,l]=a.range;return(o===void 0||s>=o-r)&&(l===void 0||s<=l+r)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!("range"in e))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type==="angle")return!0;return!1}getFormat(e){if(typeof e=="object")return e=FM(e,this),e;let r;return r=e==="default"?Object.values(this.formats)[0]:this.formats[e],r?(r=FM(r,this),r):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(e,r){if(arguments.length===1){let o=We(e);[e,r]=[o.space,o.coords]}if(e=ni.get(e),this.equals(e))return r;r=r.map(o=>Number.isNaN(o)?0:o);let i=this.path,s=e.path,n,a;for(let o=0;o<i.length&&i[o].equals(s[o]);o++)n=i[o],a=o;if(!n)throw Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let o=i.length-1;o>a;o--)r=i[o].toBase(r);for(let o=a+1;o<s.length;o++)r=s[o].fromBase(r);return r}from(e,r){if(arguments.length===1){let i=We(e);[e,r]=[i.space,i.coords]}return e=ni.get(e),e.to(this,r)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let r in this.coords){let i=this.coords[r],s=i.range||i.refRange;e.push(s?.min??0)}return e}static get all(){return[...new Set(Object.values(ni.registry))]}static register(e,r){if(arguments.length===1&&(r=arguments[0],e=r.id),r=this.get(r),this.registry[e]&&this.registry[e]!==r)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=r,arguments.length===1&&r.aliases)for(let i of r.aliases)this.register(i,r);return r}static get(e,...r){if(!e||e instanceof ni)return e;if(Co(e)==="string"){let s=ni.registry[e.toLowerCase()];if(!s)throw TypeError(`No color space found with id = "${e}"`);return s}if(r.length)return ni.get(...r);throw TypeError(`${e} is not a valid color space`)}static resolveCoord(e,r){let i=Co(e),s,n;if(i==="string"?e.includes(".")?[s,n]=e.split("."):[s,n]=[,e]:Array.isArray(e)?[s,n]=e:(s=e.space,n=e.coordId),s=ni.get(s),s||(s=r),!s)throw TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(i=Co(n),i==="number"||i==="string"&&n>=0){let l=Object.entries(s.coords)[n];if(l)return{space:s,id:l[0],index:n,...l[1]}}s=ni.get(s);let a=n.toLowerCase(),o=0;for(let l in s.coords){let h=s.coords[l];if(l.toLowerCase()===a||h.name?.toLowerCase()===a)return{space:s,id:l,index:o,...h};o++}throw TypeError(`No "${n}" coordinate found in ${s.name}. Its coordinates are: ${Object.keys(s.coords).join(", ")}`)}},Iy(ni,"registry",{}),Iy(ni,"DEFAULT_FORMAT",{type:"functions",name:"color"}),ni);function EK(t){let e=[t];for(let r=t;r=r.base;)e.push(r);return e}function FM(t,{coords:e}={}){if(t.coords&&!t.coordGrammar){t.type||(t.type="function"),t.name||(t.name="color"),t.coordGrammar=y3(t.coords);let r=Object.entries(e).map(([i,s],n)=>{let a=t.coordGrammar[n][0],o=s.range||s.refRange,l=a.range,h="";return a=="<percentage>"?(l=[0,100],h="%"):a=="<angle>"&&(h="deg"),{fromRange:o,toRange:l,suffix:h}});t.serializeCoords=(i,s)=>i.map((n,a)=>{let{fromRange:o,toRange:l,suffix:h}=r[a];return o&&l&&(n=Kv(o,l,n)),n=dg(n,{precision:s,unit:h}),n})}return t}var ai=new Ce({id:"xyz-d65",name:"XYZ D65",coords:{x:{name:"X"},y:{name:"Y"},z:{name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]}),Yi=class extends Ce{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=ai),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??(e.toBase=r=>{let i=qt(e.toXYZ_M,r);return this.white!==this.base.white&&(i=mg(this.white,this.base.white,i)),i}),e.fromBase??(e.fromBase=r=>(r=mg(this.base.white,this.white,r),qt(e.fromXYZ_M,r)))),e.referred??(e.referred="display"),super(e)}};function Rm(t,e){return t=We(t),!e||t.space.equals(e)?t.coords.slice():(e=Ce.get(e),e.from(t))}function fs(t,e){t=We(t);let{space:r,index:i}=Ce.resolveCoord(e,t.space);return Rm(t,r)[i]}function eT(t,e,r){return t=We(t),e=Ce.get(e),t.coords=e.to(t.space,r),t}eT.returns="color";function Fa(t,e,r){if(t=We(t),arguments.length===2&&Co(arguments[1])==="object"){let i=arguments[1];for(let s in i)Fa(t,s,i[s])}else{typeof r=="function"&&(r=r(fs(t,e)));let{space:i,index:s}=Ce.resolveCoord(e,t.space),n=Rm(t,i);n[s]=r,eT(t,i,n)}return t}Fa.returns="color";var tT=new Ce({id:"xyz-d50",name:"XYZ D50",white:"D50",base:ai,fromBase:t=>mg(ai.white,"D50",t),toBase:t=>mg("D50",ai.white,t)});const zM=24/116,Zp=24389/27;let ax=Oi.D50;var gs=new Ce({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:ax,base:tT,fromBase(t){let e=t.map((i,s)=>i/ax[s]),r=e.map(i=>i>.008856451679035631?Math.cbrt(i):(Zp*i+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>zM?e[0]**3:(116*e[0]-16)/Zp,t[0]>8?((t[0]+16)/116)**3:t[0]/Zp,e[2]>zM?e[2]**3:(116*e[2]-16)/Zp].map((i,s)=>i*ax[s])},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Kn(t){return(t%360+360)%360}function AK(t,e){if(t==="raw")return e;let[r,i]=e.map(Kn),s=i-r;return t==="increasing"?s<0&&(i+=360):t==="decreasing"?s>0&&(r+=360):t==="longer"?-180<s&&s<180&&(s>0?r+=360:i+=360):t==="shorter"&&(s>180?r+=360:s<-180&&(i+=360)),[r,i]}var rm=new Ce({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:gs,fromBase(t){let[e,r,i]=t,s,n=.02;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){let[e,r,i]=t;return r<0&&(r=0),isNaN(i)&&(i=0),[e,r*Math.cos(i*Math.PI/180),r*Math.sin(i*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const BM=25**7,pg=Math.PI,kM=180/pg,Sh=pg/180;function UM(t){let e=t*t;return e*e*e*t}function T3(t,e,{kL:r=1,kC:i=1,kH:s=1}={}){[t,e]=We([t,e]);let[n,a,o]=gs.from(t),l=rm.from(gs,[n,a,o])[1],[h,u,c]=gs.from(e),d=rm.from(gs,[h,u,c])[1];l<0&&(l=0),d<0&&(d=0);let m=(l+d)/2,p=UM(m),f=.5*(1-Math.sqrt(p/(p+BM))),g=(1+f)*a,y=(1+f)*u,T=Math.sqrt(g**2+o**2),S=Math.sqrt(y**2+c**2),w=g===0&&o===0?0:Math.atan2(o,g),_=y===0&&c===0?0:Math.atan2(c,y);w<0&&(w+=2*pg),_<0&&(_+=2*pg),w*=kM,_*=kM;let M=h-n,E=S-T,A=_-w,U=w+_,Q=Math.abs(A),J;T*S===0?J=0:Q<=180?J=A:A>180?J=A-360:A<-180?J=A+360:vs.warn("the unthinkable has happened");let re=2*Math.sqrt(S*T)*Math.sin(J*Sh/2),ie=(n+h)/2,se=(T+S)/2,ve=UM(se),me;me=T*S===0?U:Q<=180?U/2:U<360?(U+360)/2:(U-360)/2;let Me=(ie-50)**2,ye=1+.015*Me/Math.sqrt(20+Me),Te=1+.045*se,ge=1;ge-=.17*Math.cos((me-30)*Sh),ge+=.24*Math.cos(2*me*Sh),ge+=.32*Math.cos((3*me+6)*Sh),ge-=.2*Math.cos((4*me-63)*Sh);let be=1+.015*se*ge,Je=30*Math.exp(-1*((me-275)/25)**2),wt=2*Math.sqrt(ve/(ve+BM)),Bt=-1*Math.sin(2*Je*Sh)*wt,He=(M/(r*ye))**2;return He+=(E/(i*Te))**2,He+=(re/(s*be))**2,He+=Bt*(E/(i*Te))*(re/(s*be)),Math.sqrt(He)}const CK=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],RK=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],PK=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],IK=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var yc=new Ce({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:ai,fromBase(t){let e=qt(CK,t),r=e.map(i=>Math.cbrt(i));return qt(PK,r)},toBase(t){let e=qt(IK,t),r=e.map(i=>i**3);return qt(RK,r)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function Bb(t,e){[t,e]=We([t,e]);let[r,i,s]=yc.from(t),[n,a,o]=yc.from(e),l=r-n,h=i-a,u=s-o;return Math.sqrt(l**2+h**2+u**2)}function Al(t,e,{epsilon:r=75e-6}={}){t=We(t),e||(e=t.space),e=Ce.get(e);let i=t.coords;return e!==t.space&&(i=e.from(t)),e.inGamut(i,{epsilon:r})}function xc(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}function w3(t,e,r="lab"){r=Ce.get(r);let i=r.from(t),s=r.from(e);return Math.sqrt(i.reduce((n,a,o)=>{let l=s[o];return isNaN(a)||isNaN(l)?n:n+(l-a)**2},0))}function VK(t,e){return w3(t,e,"lab")}const OK=Math.PI,DM=OK/180;function LK(t,e,{l:r=2,c:i=1}={}){[t,e]=We([t,e]);let[s,n,a]=gs.from(t),[,o,l]=rm.from(gs,[s,n,a]),[h,u,c]=gs.from(e),d=rm.from(gs,[h,u,c])[1];o<0&&(o=0),d<0&&(d=0);let m=s-h,p=o-d,f=n-u,g=a-c,y=f**2+g**2-p**2,T=.511;s>=16&&(T=.040975*s/(1+.01765*s));let S=.0638*o/(1+.0131*o)+.638,w;Number.isNaN(l)&&(l=0),w=l>=164&&l<=345?.56+Math.abs(.2*Math.cos((l+168)*DM)):.36+Math.abs(.4*Math.cos((l+35)*DM));let _=o**4,M=Math.sqrt(_/(_+1900)),E=S*(M*w+1-M),A=(m/(r*T))**2;return A+=(p/(i*S))**2,A+=y/E**2,Math.sqrt(A)}var rT=new Ce({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:ai,fromBase(t){return t.map(e=>Math.max(e*203,0))},toBase(t){return t.map(e=>Math.max(e/203,0))}});const Jp=1.15,Kp=.66,$M=2610/2**14,FK=2**14/2610,GM=3424/2**12,jM=2413/2**7,WM=2392/2**7,HM=2**5/(1.7*2523),Qp=-.56,ox=16295499532821565e-27,zK=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],BK=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],kK=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],UK=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var S3=new Ce({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:rT,fromBase(t){let[e,r,i]=t,s=Jp*e-(Jp-1)*i,n=Kp*r-(Kp-1)*e,a=qt(zK,[s,n,i]),o=a.map(function(d){let m=GM+jM*(d/1e4)**$M,p=1+WM*(d/1e4)**$M;return(m/p)**134.03437499999998}),[l,h,u]=qt(kK,o);return[(1+Qp)*l/(1+Qp*l)-ox,h,u]},toBase(t){let[e,r,i]=t,s=(e+ox)/(1+Qp-Qp*(e+ox)),n=qt(UK,[s,r,i]),a=n.map(function(d){let m=GM-d**HM,p=WM*d**HM-jM;return 1e4*(m/p)**FK}),[o,l,h]=qt(BK,a),u=(o+(Jp-1)*h)/Jp,c=(l+(Kp-1)*u)/Kp;return[u,c,h]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),kb=new Ce({id:"jzczhz",name:"JzCzHz",coords:{jz:{refRange:[0,1],name:"Jz"},cz:{refRange:[0,1],name:"Chroma"},hz:{refRange:[0,360],type:"angle",name:"Hue"}},base:S3,fromBase(t){let[e,r,i]=t,s,n=2e-4;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){return[t[0],t[1]*Math.cos(t[2]*Math.PI/180),t[1]*Math.sin(t[2]*Math.PI/180)]}});function DK(t,e){[t,e]=We([t,e]);let[r,i,s]=kb.from(t),[n,a,o]=kb.from(e),l=r-n,h=i-a;Number.isNaN(s)&&Number.isNaN(o)?(s=0,o=0):Number.isNaN(s)?s=o:Number.isNaN(o)&&(o=s);let u=s-o,c=2*Math.sqrt(i*a)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(l**2+h**2+c**2)}const M3=3424/4096,_3=2413/128,N3=2392/128,qM=2610/16384,XM=32/2523,$K=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],GK=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],jK=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],WK=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var Ub=new Ce({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:rT,fromBase(t){let e=qt($K,t);return HK(e)},toBase(t){let e=qK(t);return qt(WK,e)}});function HK(t){let e=t.map(function(r){let i=M3+_3*(r/1e4)**qM,s=1+N3*(r/1e4)**qM;return(i/s)**78.84375});return qt(GK,e)}function qK(t){return qt(jK,t).map(function(i){let s=Math.max(i**XM-M3,0),n=_3-N3*i**XM;return 1e4*(s/n)**6.277394636015326})}function XK(t,e){[t,e]=We([t,e]);let[r,i,s]=Ub.from(t),[n,a,o]=Ub.from(e);return 720*Math.sqrt((r-n)**2+.25*(i-a)**2+(s-o)**2)}const YK=Oi.D65,E3=.42,YM=1/E3,lx=2*Math.PI,A3=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],ZK=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],JK=[[460,451,288],[460,-891,-261],[460,-220,-6300]],KK={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},fl={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},QK=180/Math.PI,ZM=Math.PI/180;function C3(t,e){return t.map(i=>{let s=Cn(e*Math.abs(i)*.01,E3);return 400*ly(s,i)/(s+27.13)})}function eQ(t,e){let r=100/e*27.13**YM;return t.map(i=>{let s=Math.abs(i);return ly(r*Cn(s/(400-s),YM),i)})}function tQ(t){let e=Kn(t);e<=fl.h[0]&&(e+=360);let r=b3(fl.h,e)-1,[i,s]=fl.h.slice(r,r+2),[n,a]=fl.e.slice(r,r+2),o=fl.H[r],l=(e-i)/n;return o+100*l/(l+(s-e)/a)}function rQ(t){let e=(t%400+400)%400,r=Math.floor(.01*e);e%=100;let[i,s]=fl.h.slice(r,r+2),[n,a]=fl.e.slice(r,r+2);return Kn((e*(a*i-n*s)-100*i*a)/(e*(a-n)-100*a))}function R3(t,e,r,i,s){let n={};n.discounting=s,n.refWhite=t,n.surround=i;let a=t.map(f=>f*100);n.la=e,n.yb=r;let o=a[1],l=qt(A3,a);i=KK[n.surround];let h=i[0];n.c=i[1],n.nc=i[2];let u=1/(5*n.la+1),c=u**4;n.fl=c*n.la+.1*(1-c)*(1-c)*Math.cbrt(5*n.la),n.flRoot=n.fl**.25,n.n=n.yb/o,n.z=1.48+Math.sqrt(n.n),n.nbb=.725*n.n**-.2,n.ncb=n.nbb;let d=Math.max(Math.min(h*(1-1/3.6*Math.exp((-n.la-42)/92)),1),0);n.dRgb=l.map(f=>tm(1,o/f,d)),n.dRgbInv=n.dRgb.map(f=>1/f);let m=l.map((f,g)=>f*n.dRgb[g]),p=C3(m,n.fl);return n.aW=n.nbb*(2*p[0]+p[1]+.05*p[2]),n}const JM=R3(YK,64/Math.PI*.2,20,"average",!1);function Db(t,e){if(!(t.J!==void 0^t.Q!==void 0))throw Error("Conversion requires one and only one: 'J' or 'Q'");if(!(t.C!==void 0^t.M!==void 0^t.s!==void 0))throw Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(t.h!==void 0^t.H!==void 0))throw Error("Conversion requires one and only one: 'h' or 'H'");if(t.J===0||t.Q===0)return[0,0,0];let r=0;r=t.h===void 0?rQ(t.H)*ZM:Kn(t.h)*ZM;let i=Math.cos(r),s=Math.sin(r),n=0;t.J===void 0?t.Q!==void 0&&(n=.25*e.c*t.Q/((e.aW+4)*e.flRoot)):n=Cn(t.J,1/2)*.1;let a=0;t.C===void 0?t.M===void 0?t.s!==void 0&&(a=4e-4*t.s**2*(e.aW+4)/e.c):a=t.M/e.flRoot/n:a=t.C/n;let o=Cn(a*(1.64-.29**e.n)**-.73,10/9),l=.25*(Math.cos(r+2)+3.8),h=e.aW*Cn(n,2/e.c/e.z),u=5e4/13*e.nc*e.ncb*l,c=h/e.nbb,d=23*(c+.305)*Qv(o,23*u+o*(11*i+108*s)),m=d*i,p=d*s,f=eQ(qt(JK,[c,m,p]).map(g=>g*1/1403),e.fl);return qt(ZK,f.map((g,y)=>g*e.dRgbInv[y])).map(g=>g/100)}function P3(t,e){let r=t.map(S=>S*100),i=C3(qt(A3,r).map((S,w)=>S*e.dRgb[w]),e.fl),s=i[0]+(-12*i[1]+i[2])/11,n=(i[0]+i[1]-2*i[2])/9,a=(Math.atan2(n,s)%lx+lx)%lx,o=.25*(Math.cos(a+2)+3.8),l=5e4/13*e.nc*e.ncb*Qv(o*Math.sqrt(s**2+n**2),i[0]+i[1]+1.05*i[2]+.305),h=Cn(l,.9)*(1.64-.29**e.n)**.73,u=e.nbb*(2*i[0]+i[1]+.05*i[2]),c=Cn(u/e.aW,.5*e.c*e.z),d=100*Cn(c,2),m=4/e.c*c*(e.aW+4)*e.flRoot,p=h*c,f=p*e.flRoot,g=Kn(a*QK),y=tQ(g),T=50*Cn(e.c*h/(e.aW+4),1/2);return{J:d,C:p,h:g,s:T,Q:m,M:f,H:y}}var iQ=new Ce({id:"cam16-jmh",cssId:"--cam16-jmh",name:"CAM16-JMh",coords:{j:{refRange:[0,100],name:"J"},m:{refRange:[0,105],name:"Colorfulness"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:ai,fromBase(t){let e=P3(t,JM);return[e.J,e.M,e.h]},toBase(t){return Db({J:t[0],M:t[1],h:t[2]},JM)}});const sQ=Oi.D65,I3=24389/27;function nQ(t){return 116*(t>.008856451679035631?Math.cbrt(t):(I3*t+16)/116)-16}function $b(t){return t>8?((t+16)/116)**3:t/I3}function aQ(t,e){let[r,i,s]=t,n=[],a=0;if(s===0)return[0,0,0];let o=$b(s);a=s>0?.00379058511492914*s**2+.608983189401032*s+.9155088574762233:9514440756550361e-21*s**2+.08693057439788597*s-21.928975842194614;let l=0,h=1/0;for(;l<=15;){n=Db({J:a,C:i,h:r},e);let u=Math.abs(n[1]-o);if(u<h){if(u<=2e-12)return n;h=u}a-=(n[1]-o)*a/(2*n[1]),l+=1}return Db({J:a,C:i,h:r},e)}function oQ(t,e){let r=nQ(t[1]);if(r===0)return[0,0,0];let i=P3(t,iT);return[Kn(i.h),i.C,r]}const iT=R3(sQ,200/Math.PI*$b(50),$b(50)*100,"average",!1);var im=new Ce({id:"hct",name:"HCT",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},c:{refRange:[0,145],name:"Colorfulness"},t:{refRange:[0,100],name:"Tone"}},base:ai,fromBase(t){return oQ(t)},toBase(t){return aQ(t,iT)},formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const lQ=Math.PI/180,KM=[1,.007,.0228];function QM(t){t[1]<0&&(t=im.fromBase(im.toBase(t)));let e=Math.log(Math.max(1+KM[2]*t[1]*iT.flRoot,1))/KM[2],r=t[0]*lQ,i=e*Math.cos(r),s=e*Math.sin(r);return[t[2],i,s]}function uQ(t,e){[t,e]=We([t,e]);let[r,i,s]=QM(im.from(t)),[n,a,o]=QM(im.from(e));return Math.sqrt((r-n)**2+(i-a)**2+(s-o)**2)}var bc={deltaE76:VK,deltaECMC:LK,deltaE2000:T3,deltaEJz:DK,deltaEITP:XK,deltaEOK:Bb,deltaEHCT:uQ};function hQ(t){let e=t?Math.floor(Math.log10(Math.abs(t))):0;return Math.max(parseFloat(`1e${e-2}`),1e-6)}const e_={hct:{method:"hct.c",jnd:2,deltaEMethod:"hct",blackWhiteClamp:{}},"hct-tonal":{method:"hct.c",jnd:0,deltaEMethod:"hct",blackWhiteClamp:{channel:"hct.t",min:0,max:100}}};function Lo(t,{method:e=vs.gamut_mapping,space:r=void 0,deltaEMethod:i="",jnd:s=2,blackWhiteClamp:n={}}={}){if(t=We(t),Cm(arguments[1])?r=arguments[1]:r||(r=t.space),r=Ce.get(r),Al(t,r,{epsilon:0}))return t;let a;if(e==="css")a=cQ(t,{space:r});else{if(e!=="clip"&&!Al(t,r)){Object.prototype.hasOwnProperty.call(e_,e)&&({method:e,jnd:s,deltaEMethod:i,blackWhiteClamp:n}=e_[e]);let o=T3;if(i!==""){for(let h in bc)if("deltae"+i.toLowerCase()===h.toLowerCase()){o=bc[h];break}}let l=Lo(Ht(t,r),{method:"clip",space:r});if(o(t,l)>s){if(Object.keys(n).length===3){let T=Ce.resolveCoord(n.channel),S=fs(Ht(t,T.space),T.id);if(Vo(S)&&(S=0),S>=n.max)return Ht({space:"xyz-d65",coords:Oi.D65},t.space);if(S<=n.min)return Ht({space:"xyz-d65",coords:[0,0,0]},t.space)}let h=Ce.resolveCoord(e),u=h.space,c=h.id,d=Ht(t,u);d.coords.forEach((T,S)=>{Vo(T)&&(d.coords[S]=0)});let m=h.range||h.refRange,p=m[0],f=hQ(s),g=p,y=fs(d,c);for(;y-g>f;){let T=xc(d);T=Lo(T,{space:r,method:"clip"}),o(d,T)-s<f?g=fs(d,c):y=fs(d,c),Fa(d,c,(g+y)/2)}a=Ht(d,r)}else a=l}else a=Ht(t,r);if(e==="clip"||!Al(a,r,{epsilon:0})){let o=Object.values(r.coords).map(l=>l.range||[]);a.coords=a.coords.map((l,h)=>{let[u,c]=o[h];return u!==void 0&&(l=Math.max(u,l)),c!==void 0&&(l=Math.min(l,c)),l})}}return r!==t.space&&(a=Ht(a,t.space)),t.coords=a.coords,t}Lo.returns="color";const t_={WHITE:{space:yc,coords:[1,0,0]},BLACK:{space:yc,coords:[0,0,0]}};function cQ(t,{space:e}={}){let r=.02,i=1e-4;t=We(t),e||(e=t.space),e=Ce.get(e);let s=Ce.get("oklch");if(e.isUnbounded)return Ht(t,e);let n=Ht(t,s),a=n.coords[0];if(a>=1){let p=Ht(t_.WHITE,e);return p.alpha=t.alpha,Ht(p,e)}if(a<=0){let p=Ht(t_.BLACK,e);return p.alpha=t.alpha,Ht(p,e)}if(Al(n,e,{epsilon:0}))return Ht(n,e);function o(p){let f=Ht(p,e),g=Object.values(e.coords);return f.coords=f.coords.map((y,T)=>{if("range"in g[T]){let[S,w]=g[T].range;return x3(S,y,w)}return y}),f}let l=0,h=n.coords[1],u=!0,c=xc(n),d=o(c),m=Bb(d,c);if(m<r)return d;for(;h-l>i;){let p=(l+h)/2;if(c.coords[1]=p,u&&Al(c,e,{epsilon:0}))l=p;else if(d=o(c),m=Bb(d,c),m<r){if(r-m<i)break;u=!1,l=p}else h=p}return d}function Ht(t,e,{inGamut:r}={}){t=We(t),e=Ce.get(e);let i=e.from(t),s={space:e,coords:i,alpha:t.alpha};return r&&(s=Lo(s,r===!0?void 0:r)),s}Ht.returns="color";function Bd(t,{precision:e=vs.precision,format:r="default",inGamut:i=!0,...s}={}){let n;t=We(t);let a=r;r=t.space.getFormat(r)??t.space.getFormat("default")??Ce.DEFAULT_FORMAT;let o=t.coords.slice();if(i||(i=r.toGamut),i&&!Al(t)&&(o=Lo(xc(t),i===!0?void 0:i).coords),r.type==="custom")if(s.precision=e,r.serialize)n=r.serialize(o,t.alpha,s);else throw TypeError(`format ${a} can only be used to parse colors, not for serialization`);else{let l=r.name||"color";r.serializeCoords?o=r.serializeCoords(o,e):e!==null&&(o=o.map(d=>dg(d,{precision:e})));let h=[...o];if(l==="color"){let d=r.id||r.ids?.[0]||t.space.id;h.unshift(d)}let u=t.alpha;e!==null&&(u=dg(u,{precision:e}));let c=t.alpha>=1||r.noAlpha?"":`${r.commas?",":" /"} ${u}`;n=`${l}(${h.join(r.commas?", ":" ")}${c})`}return n}const dQ=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],mQ=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var uy=new Yi({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:dQ,fromXYZ_M:mQ});const ef=1.09929682680944,r_=.018053968510807;var V3=new Yi({id:"rec2020",name:"REC.2020",base:uy,toBase(t){return t.map(function(e){return e<r_*4.5?e/4.5:((e+ef-1)/ef)**(1/.45)})},fromBase(t){return t.map(function(e){return e>=r_?ef*e**.45-(ef-1):4.5*e})}});const pQ=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fQ=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var O3=new Yi({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:pQ,fromXYZ_M:fQ});const gQ=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],Br=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var L3=new Yi({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:gQ,fromXYZ_M:Br}),i_={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let s_=[,,,].fill("<percentage> | <number>[0, 255]"),n_=[,,,].fill("<number>[0, 255]");var vc=new Yi({id:"srgb",name:"sRGB",base:L3,fromBase:t=>t.map(e=>{let r=e<0?-1:1,i=e*r;return i>.0031308?r*(1.055*i**(1/2.4)-.055):12.92*e}),toBase:t=>t.map(e=>{let r=e<0?-1:1,i=e*r;return i<=.04045?e/12.92:r*((i+.055)/1.055)**2.4}),formats:{rgb:{coords:s_},rgb_number:{name:"rgb",commas:!0,coords:n_,noAlpha:!0},color:{},rgba:{coords:s_,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:n_},hex:{type:"custom",toGamut:!0,test:t=>/^#([a-f0-9]{3,4}){1,2}$/i.test(t),parse(t){t.length<=5&&(t=t.replace(/[a-f0-9]/gi,"$&$&"));let e=[];return t.replace(/[a-f0-9]{2}/gi,r=>{e.push(parseInt(r,16)/255)}),{spaceId:"srgb",coords:e.slice(0,3),alpha:e.slice(3)[0]}},serialize:(t,e,{collapse:r=!0}={})=>{e<1&&t.push(e),t=t.map(n=>Math.round(n*255));let i=r&&t.every(n=>n%17==0);return"#"+t.map(n=>i?(n/17).toString(16):n.toString(16).padStart(2,"0")).join("")}},keyword:{type:"custom",test:t=>/^[a-z]+$/i.test(t),parse(t){t=t.toLowerCase();let e={spaceId:"srgb",coords:null,alpha:1};if(t==="transparent"?(e.coords=i_.black,e.alpha=0):e.coords=i_[t],e.coords)return e}}}}),F3=new Yi({id:"p3",cssId:"display-p3",name:"P3",base:O3,fromBase:vc.fromBase,toBase:vc.toBase});vs.display_space=vc;let yQ;if(typeof CSS<"u"&&CSS.supports)for(let t of[gs,V3,F3]){let e=t.getMinCoords(),r={space:t,coords:e,alpha:1},i=Bd(r);if(CSS.supports("color",i)){vs.display_space=t;break}}function xQ(t,{space:e=vs.display_space,...r}={}){let i=Bd(t,r);if(typeof CSS>"u"||CSS.supports("color",i)||!vs.display_space)i=new String(i),i.color=t;else{let s=t;if((t.coords.some(Vo)||Vo(t.alpha))&&!(yQ??(yQ=CSS.supports("color","hsl(none 50% 50%)")))&&(s=xc(t),s.coords=s.coords.map(Er),s.alpha=Er(s.alpha),i=Bd(s,r),CSS.supports("color",i)))return i=new String(i),i.color=s,i;s=Ht(s,e),i=new String(Bd(s,r)),i.color=s}return i}function bQ(t,e){return t=We(t),e=We(e),t.space===e.space&&t.alpha===e.alpha&&t.coords.every((r,i)=>r===e.coords[i])}function Fo(t){return fs(t,[ai,"y"])}function z3(t,e){Fa(t,[ai,"y"],e)}function vQ(t){Object.defineProperty(t.prototype,"luminance",{get(){return Fo(this)},set(e){z3(this,e)}})}var TQ=Object.freeze({__proto__:null,getLuminance:Fo,register:vQ,setLuminance:z3});function wQ(t,e){t=We(t),e=We(e);let r=Math.max(Fo(t),0),i=Math.max(Fo(e),0);return i>r&&([r,i]=[i,r]),(r+.05)/(i+.05)}const a_=.022,o_=.027;function l_(t){return t>=a_?t:t+(a_-t)**1.414}function Mh(t){let e=t<0?-1:1,r=Math.abs(t);return e*r**2.4}function SQ(t,e){e=We(e),t=We(t);let r,i,s,n,a,o;e=Ht(e,"srgb"),[n,a,o]=e.coords;let l=Mh(n)*.2126729+Mh(a)*.7151522+Mh(o)*.072175;t=Ht(t,"srgb"),[n,a,o]=t.coords;let h=Mh(n)*.2126729+Mh(a)*.7151522+Mh(o)*.072175,u=l_(l),c=l_(h),d=c>u;return Math.abs(c-u)<5e-4?i=0:d?(r=c**.56-u**.57,i=r*1.14):(r=c**.65-u**.62,i=r*1.14),s=Math.abs(i)<.1?0:i>0?i-o_:i+o_,s*100}function MQ(t,e){t=We(t),e=We(e);let r=Math.max(Fo(t),0),i=Math.max(Fo(e),0);i>r&&([r,i]=[i,r]);let s=r+i;return s===0?0:(r-i)/s}function _Q(t,e){t=We(t),e=We(e);let r=Math.max(Fo(t),0),i=Math.max(Fo(e),0);return i>r&&([r,i]=[i,r]),i===0?5e4:(r-i)/i}function NQ(t,e){t=We(t),e=We(e);let r=fs(t,[gs,"l"]),i=fs(e,[gs,"l"]);return Math.abs(r-i)}const u_=24/116,tf=24389/27;let ux=Oi.D65;var Gb=new Ce({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:ux,base:ai,fromBase(t){let e=t.map((i,s)=>i/ux[s]),r=e.map(i=>i>.008856451679035631?Math.cbrt(i):(tf*i+16)/116);return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(t){let e=[];return e[1]=(t[0]+16)/116,e[0]=t[1]/500+e[1],e[2]=e[1]-t[2]/200,[e[0]>u_?e[0]**3:(116*e[0]-16)/tf,t[0]>8?((t[0]+16)/116)**3:t[0]/tf,e[2]>u_?e[2]**3:(116*e[2]-16)/tf].map((i,s)=>i*ux[s])},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const EQ=5**.5*.5+.5;function AQ(t,e){t=We(t),e=We(e);let r=fs(t,[Gb,"l"]),i=fs(e,[Gb,"l"]),s=Math.abs(r**1.618033988749895-i**1.618033988749895),n=s**(1/EQ)*Math.SQRT2-40;return n<7.5?0:n}var zf=Object.freeze({__proto__:null,contrastAPCA:SQ,contrastDeltaPhi:AQ,contrastLstar:NQ,contrastMichelson:MQ,contrastWCAG21:wQ,contrastWeber:_Q});function CQ(t,e,r={}){Cm(r)&&(r={algorithm:r});let{algorithm:i,...s}=r;if(!i){let n=Object.keys(zf).map(a=>a.replace(/^contrast/,"")).join(", ");throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${n}`)}for(let n in t=We(t),e=We(e),zf)if("contrast"+i.toLowerCase()===n.toLowerCase())return zf[n](t,e,s);throw TypeError(`Unknown contrast algorithm: ${i}`)}function hy(t){let[e,r,i]=Rm(t,ai),s=e+15*r+3*i;return[4*e/s,9*r/s]}function B3(t){let[e,r,i]=Rm(t,ai),s=e+r+i;return[e/s,r/s]}function RQ(t){Object.defineProperty(t.prototype,"uv",{get(){return hy(this)}}),Object.defineProperty(t.prototype,"xy",{get(){return B3(this)}})}var PQ=Object.freeze({__proto__:null,register:RQ,uv:hy,xy:B3});function Td(t,e,r={}){Cm(r)&&(r={method:r});let{method:i=vs.deltaE,...s}=r;for(let n in bc)if("deltae"+i.toLowerCase()===n.toLowerCase())return bc[n](t,e,s);throw TypeError(`Unknown deltaE method: ${i}`)}function IQ(t,e=.25){let r=Ce.get("oklch","lch");return Fa(t,[r,"l"],s=>s*(1+e))}function VQ(t,e=.25){let r=Ce.get("oklch","lch");return Fa(t,[r,"l"],s=>s*(1-e))}var OQ=Object.freeze({__proto__:null,darken:VQ,lighten:IQ});function k3(t,e,r=.5,i={}){return[t,e]=[We(t),We(e)],Co(r)==="object"&&([r,i]=[.5,r]),Pm(t,e,i)(r)}function U3(t,e,r={}){let i;sT(t)&&([i,r]=[t,e],[t,e]=i.rangeArgs.colors);let{maxDeltaE:s,deltaEMethod:n,steps:a=2,maxSteps:o=1e3,...l}=r;i||([t,e]=[We(t),We(e)],i=Pm(t,e,l));let h=Td(t,e),u=s>0?Math.max(a,Math.ceil(h/s)+1):a,c=[];if(o!==void 0&&(u=Math.min(u,o)),u===1)c=[{p:.5,color:i(.5)}];else{let d=1/(u-1);c=Array.from({length:u},(m,p)=>{let f=p*d;return{p:f,color:i(f)}})}if(s>0){let d=c.reduce((m,p,f)=>{if(f===0)return 0;let g=Td(p.color,c[f-1].color,n);return Math.max(m,g)},0);for(;d>s;){d=0;for(let m=1;m<c.length&&c.length<o;m++){let p=c[m-1],f=c[m],g=(f.p+p.p)/2,y=i(g);d=Math.max(d,Td(y,p.color),Td(y,f.color)),c.splice(m,0,{p:g,color:i(g)}),m++}}}return c=c.map(d=>d.color),c}function Pm(t,e,r={}){if(sT(t)){let[l,h]=[t,e];return Pm(...l.rangeArgs.colors,{...l.rangeArgs.options,...h})}let{space:i,outputSpace:s,progression:n,premultiplied:a}=r;t=We(t),e=We(e),t=xc(t),e=xc(e);let o={colors:[t,e],options:r};if(i=i?Ce.get(i):Ce.registry[vs.interpolationSpace]||t.space,s=s?Ce.get(s):i,t=Ht(t,i),e=Ht(e,i),t=Lo(t),e=Lo(e),i.coords.h&&i.coords.h.type==="angle"){let l=r.hue=r.hue||"shorter",h=[i,"h"],[u,c]=[fs(t,h),fs(e,h)];isNaN(u)&&!isNaN(c)?u=c:isNaN(c)&&!isNaN(u)&&(c=u),[u,c]=AK(l,[u,c]),Fa(t,h,u),Fa(e,h,c)}return a&&(t.coords=t.coords.map(l=>l*t.alpha),e.coords=e.coords.map(l=>l*e.alpha)),Object.assign(l=>{l=n?n(l):l;let h=t.coords.map((d,m)=>{let p=e.coords[m];return tm(d,p,l)}),u=tm(t.alpha,e.alpha,l),c={space:i,coords:h,alpha:u};return a&&(c.coords=c.coords.map(d=>d/u)),s!==i&&(c=Ht(c,s)),c},{rangeArgs:o})}function sT(t){return Co(t)==="function"&&!!t.rangeArgs}vs.interpolationSpace="lab";function LQ(t){t.defineFunction("mix",k3,{returns:"color"}),t.defineFunction("range",Pm,{returns:"function<color>"}),t.defineFunction("steps",U3,{returns:"array<color>"})}var FQ=Object.freeze({__proto__:null,isRange:sT,mix:k3,range:Pm,register:LQ,steps:U3}),D3=new Ce({id:"hsl",name:"HSL",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:vc,fromBase:t=>{let e=Math.max(...t),r=Math.min(...t),[i,s,n]=t,[a,o,l]=[NaN,0,(r+e)/2],h=e-r;if(h!==0){switch(o=l===0||l===1?0:(e-l)/Math.min(l,1-l),e){case i:a=(s-n)/h+(s<n?6:0);break;case s:a=(n-i)/h+2;break;case n:a=(i-s)/h+4}a*=60}return o<0&&(a+=180,o=Math.abs(o)),a>=360&&(a-=360),[a,o*100,l*100]},toBase:t=>{let[e,r,i]=t;e%=360,e<0&&(e+=360),r/=100,i/=100;function s(n){let a=(n+e/30)%12,o=r*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(a-3,9-a,1))}return[s(0),s(8),s(4)]},formats:{hsl:{coords:["<number> | <angle>","<percentage>","<percentage>"]},hsla:{coords:["<number> | <angle>","<percentage>","<percentage>"],commas:!0,lastAlpha:!0}}}),$3=new Ce({id:"hsv",name:"HSV",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},v:{range:[0,100],name:"Value"}},base:D3,fromBase(t){let[e,r,i]=t;r/=100,i/=100;let s=i+r*Math.min(i,1-i);return[e,s===0?0:200*(1-i/s),100*s]},toBase(t){let[e,r,i]=t;r/=100,i/=100;let s=i*(1-r/2);return[e,s===0||s===1?0:(i-s)/Math.min(s,1-s)*100,s*100]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),zQ=new Ce({id:"hwb",name:"HWB",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},w:{range:[0,100],name:"Whiteness"},b:{range:[0,100],name:"Blackness"}},base:$3,fromBase(t){let[e,r,i]=t;return[e,i*(100-r)/100,100-i]},toBase(t){let[e,r,i]=t;r/=100,i/=100;let s=r+i;if(s>=1){let o=r/s;return[e,0,o*100]}let n=1-i,a=n===0?0:1-r/n;return[e,a*100,n*100]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const BQ=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],kQ=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var G3=new Yi({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:BQ,fromXYZ_M:kQ}),UQ=new Yi({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:G3,toBase:t=>t.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:t=>t.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const DQ=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],$Q=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var j3=new Yi({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:tT,toXYZ_M:DQ,fromXYZ_M:$Q}),GQ=new Yi({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:j3,toBase(t){return t.map(e=>e<.03125?e/16:e**1.8)},fromBase(t){return t.map(e=>e>=.001953125?e**(1/1.8):16*e)}}),jQ=new Ce({id:"oklch",name:"Oklch",coords:{l:{refRange:[0,1],name:"Lightness"},c:{refRange:[0,.4],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},white:"D65",base:yc,fromBase(t){let[e,r,i]=t,s,n=2e-4;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){let[e,r,i]=t,s,n;return isNaN(i)?(s=0,n=0):(s=r*Math.cos(i*Math.PI/180),n=r*Math.sin(i*Math.PI/180)),[e,s,n]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let W3=Oi.D65;const h_=24389/27,[c_,d_]=hy({space:ai,coords:W3});var H3=new Ce({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:W3,base:ai,fromBase(t){let e=[Er(t[0]),Er(t[1]),Er(t[2])],r=e[1],[i,s]=hy({space:ai,coords:e});if(!Number.isFinite(i)||!Number.isFinite(s))return[0,0,0];let n=r<=.008856451679035631?h_*r:116*Math.cbrt(r)-16;return[n,13*n*(i-c_),13*n*(s-d_)]},toBase(t){let[e,r,i]=t;if(e===0||Vo(e))return[0,0,0];r=Er(r),i=Er(i);let s=r/(13*e)+c_,n=i/(13*e)+d_,a=e<=8?e/h_:((e+16)/116)**3;return[a*(9*s/(4*n)),a,a*((12-3*s-20*n)/(4*n))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),nT=new Ce({id:"lchuv",name:"LChuv",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,220],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:H3,fromBase(t){let[e,r,i]=t,s,n=.02;return s=Math.abs(r)<n&&Math.abs(i)<n?NaN:Math.atan2(i,r)*180/Math.PI,[e,Math.sqrt(r**2+i**2),Kn(s)]},toBase(t){let[e,r,i]=t;return r<0&&(r=0),isNaN(i)&&(i=0),[e,r*Math.cos(i*Math.PI/180),r*Math.sin(i*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const m_=Br[0][0],p_=Br[0][1],hx=Br[0][2],f_=Br[1][0],g_=Br[1][1],cx=Br[1][2],y_=Br[2][0],x_=Br[2][1],dx=Br[2][2];function _h(t,e,r){let i=e/(Math.sin(r)-t*Math.cos(r));return i<0?1/0:i}function fg(t){let e=(t+16)**3/1560896,r=e>.008856451679035631?e:t/903.2962962962963,i=r*(284517*m_-94839*hx),s=r*(838422*hx+769860*p_+731718*m_),n=r*(632260*hx-126452*p_),a=r*(284517*f_-94839*cx),o=r*(838422*cx+769860*g_+731718*f_),l=r*(632260*cx-126452*g_),h=r*(284517*y_-94839*dx),u=r*(838422*dx+769860*x_+731718*y_),c=r*(632260*dx-126452*x_);return{r0s:i/n,r0i:s*t/n,r1s:i/(n+126452),r1i:(s-769860)*t/(n+126452),g0s:a/l,g0i:o*t/l,g1s:a/(l+126452),g1i:(o-769860)*t/(l+126452),b0s:h/c,b0i:u*t/c,b1s:h/(c+126452),b1i:(u-769860)*t/(c+126452)}}function b_(t,e){let r=e/360*Math.PI*2,i=_h(t.r0s,t.r0i,r),s=_h(t.r1s,t.r1i,r),n=_h(t.g0s,t.g0i,r),a=_h(t.g1s,t.g1i,r),o=_h(t.b0s,t.b0i,r),l=_h(t.b1s,t.b1i,r);return Math.min(i,s,n,a,o,l)}var WQ=new Ce({id:"hsluv",name:"HSLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:nT,gamutSpace:vc,fromBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(e>99.9999999)s=0,e=100;else if(e<1e-8)s=0,e=0;else{let n=fg(e),a=b_(n,i);s=r/a*100}return[i,s,e]},toBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(i>99.9999999)i=100,s=0;else if(i<1e-8)i=0,s=0;else{let n=fg(i);s=b_(n,e)/100*r}return[i,s,e]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});Br[0][0],Br[0][1],Br[0][2],Br[1][0],Br[1][1],Br[1][2],Br[2][0],Br[2][1],Br[2][2];function Nh(t,e){return Math.abs(e)/Math.sqrt(t**2+1)}function v_(t){let e=Nh(t.r0s,t.r0i),r=Nh(t.r1s,t.r1i),i=Nh(t.g0s,t.g0i),s=Nh(t.g1s,t.g1i),n=Nh(t.b0s,t.b0i),a=Nh(t.b1s,t.b1i);return Math.min(e,r,i,s,n,a)}var HQ=new Ce({id:"hpluv",name:"HPLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:nT,gamutSpace:"self",fromBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(e>99.9999999)s=0,e=100;else if(e<1e-8)s=0,e=0;else{let n=fg(e),a=v_(n);s=r/a*100}return[i,s,e]},toBase(t){let[e,r,i]=[Er(t[0]),Er(t[1]),Er(t[2])],s;if(i>99.9999999)i=100,s=0;else if(i<1e-8)i=0,s=0;else{let n=fg(i);s=v_(n)/100*r}return[i,s,e]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const T_=2610/2**14,qQ=2**14/2610,w_=2**5/2523,S_=3424/2**12,M_=2413/2**7,__=2392/2**7;var XQ=new Yi({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:uy,toBase(t){return t.map(function(e){return(Math.max(e**w_-S_,0)/(M_-__*e**w_))**qQ*1e4/203})},fromBase(t){return t.map(function(e){let r=Math.max(e*203/1e4,0),i=S_+M_*r**T_,s=1+__*r**T_;return(i/s)**78.84375})}});const N_=.17883277,E_=.28466892,A_=.55991073,mx=3.7743;var YQ=new Yi({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:uy,toBase(t){return t.map(function(e){return e<=.5?e**2/3*mx:(Math.exp((e-A_)/N_)+E_)/12*mx})},fromBase(t){return t.map(function(e){return e/=mx,e<=1/12?Math.sqrt(3*e):N_*Math.log(12*e-E_)+A_})}});const q3={};Oo.add("chromatic-adaptation-start",t=>{t.options.method&&(t.M=C_(t.W1,t.W2,t.options.method))}),Oo.add("chromatic-adaptation-end",t=>{t.M||(t.M=C_(t.W1,t.W2,t.options.method))});function rf({id:t,toCone_M:e,fromCone_M:r}){q3[t]=arguments[0]}function C_(t,e,r="Bradford"){let i=q3[r],[s,n,a]=qt(i.toCone_M,t),[o,l,h]=qt(i.toCone_M,e),u=[[o/s,0,0],[0,l/n,0],[0,0,h/a]],c=qt(u,i.toCone_M);return qt(i.fromCone_M,c)}rf({id:"von Kries",toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),rf({id:"Bradford",toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),rf({id:"CAT02",toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),rf({id:"CAT16",toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(Oi,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),Oi.ACES=[.32168/.33767,1,.34065/.33767];const ZQ=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],JQ=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var X3=new Yi({id:"acescg",cssId:"--acescg",name:"ACEScg",coords:{r:{range:[0,65504],name:"Red"},g:{range:[0,65504],name:"Green"},b:{range:[0,65504],name:"Blue"}},referred:"scene",white:Oi.ACES,toXYZ_M:ZQ,fromXYZ_M:JQ});const sf=2**-16,px=-.35828683,nf=(Math.log2(65504)+9.72)/17.52;var KQ=new Yi({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[px,nf],name:"Red"},g:{range:[px,nf],name:"Green"},b:{range:[px,nf],name:"Blue"}},referred:"scene",base:X3,toBase(t){return t.map(function(e){return e<=-.3013698630136986?(2**(e*17.52-9.72)-sf)*2:e<nf?2**(e*17.52-9.72):65504})},fromBase(t){return t.map(function(e){return e<=0?(Math.log2(sf)+9.72)/17.52:e<sf?(Math.log2(sf+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),R_=Object.freeze({__proto__:null,A98RGB:UQ,A98RGB_Linear:G3,ACEScc:KQ,ACEScg:X3,CAM16_JMh:iQ,HCT:im,HPLuv:HQ,HSL:D3,HSLuv:WQ,HSV:$3,HWB:zQ,ICTCP:Ub,JzCzHz:kb,Jzazbz:S3,LCH:rm,LCHuv:nT,Lab:gs,Lab_D65:Gb,Luv:H3,OKLCH:jQ,OKLab:yc,P3:F3,P3_Linear:O3,ProPhoto:GQ,ProPhoto_Linear:j3,REC_2020:V3,REC_2020_Linear:uy,REC_2100_HLG:YQ,REC_2100_PQ:XQ,XYZ_ABS_D65:rT,XYZ_D50:tT,XYZ_D65:ai,sRGB:vc,sRGB_Linear:L3}),as=class Bi{constructor(...e){let r;e.length===1&&(r=We(e[0]));let i,s,n;r?(i=r.space||r.spaceId,s=r.coords,n=r.alpha):[i,s,n]=e,Object.defineProperty(this,"space",{value:Ce.get(i),writable:!1,enumerable:!0,configurable:!0}),this.coords=s?s.slice():[0,0,0],this.alpha=n>1||n===void 0?1:n<0?0:n;for(let a=0;a<this.coords.length;a++)this.coords[a]==="NaN"&&(this.coords[a]=NaN);for(let a in this.space.coords)Object.defineProperty(this,a,{get:()=>this.get(a),set:o=>this.set(a,o)})}get spaceId(){return this.space.id}clone(){return new Bi(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...e){let r=xQ(this,...e);return r.color=new Bi(r.color),r}static get(e,...r){return e instanceof Bi?e:new Bi(e,...r)}static defineFunction(e,r,i=r){let{instance:s=!0,returns:n}=i,a=function(...o){let l=r(...o);if(n==="color")l=Bi.get(l);else if(n==="function<color>"){let h=l;l=function(...u){let c=h(...u);return Bi.get(c)},Object.assign(l,h)}else n==="array<color>"&&(l=l.map(h=>Bi.get(h)));return l};e in Bi||(Bi[e]=a),s&&(Bi.prototype[e]=function(...o){return a(this,...o)})}static defineFunctions(e){for(let r in e)Bi.defineFunction(r,e[r],e[r])}static extend(e){if(e.register)e.register(Bi);else for(let r in e)Bi.defineFunction(r,e[r])}};as.defineFunctions({get:fs,getAll:Rm,set:Fa,setAll:eT,to:Ht,equals:bQ,inGamut:Al,toGamut:Lo,distance:w3,toString:Bd}),Object.assign(as,{util:MK,hooks:Oo,WHITES:Oi,Space:Ce,spaces:Ce.registry,parse:v3,defaults:vs});for(let t of Object.keys(R_))Ce.register(R_[t]);for(let t in Ce.registry)jb(t,Ce.registry[t]);Oo.add("colorspace-init-end",t=>{jb(t.id,t),t.aliases?.forEach(e=>{jb(e,t)})});function jb(t,e){let r=t.replace(/-/g,"_");Object.defineProperty(as.prototype,r,{get(){let i=this.getAll(t);return typeof Proxy>"u"?i:new Proxy(i,{has:(s,n)=>{try{return Ce.resolveCoord([e,n]),!0}catch{}return Reflect.has(s,n)},get:(s,n,a)=>{if(n&&typeof n!="symbol"&&!(n in s)){let{index:o}=Ce.resolveCoord([e,n]);if(o>=0)return s[o]}return Reflect.get(s,n,a)},set:(s,n,a,o)=>{if(n&&typeof n!="symbol"&&!(n in s)||n>=0){let{index:l}=Ce.resolveCoord([e,n]);if(l>=0)return s[l]=a,this.setAll(t,s),!0}return Reflect.set(s,n,a,o)}})},set(i){this.setAll(t,i)},configurable:!0,enumerable:!0})}as.extend(bc),as.extend({deltaE:Td}),Object.assign(as,{deltaEMethods:bc}),as.extend(OQ),as.extend({contrast:CQ}),as.extend(PQ),as.extend(TQ),as.extend(FQ),as.extend(zf);const{vec2:QQ,vec4:eee}=Ve,Nt=t=>{let e=new as(t);return eee(...e.to("p3-linear").coords,e.alpha).value},Gu=t=>{let e=.5,r=.5,i=(s,n=!1)=>{if(typeof s=="number")return s;let a=s.toLowerCase().trim();if(n){if(a==="top")return 0;if(a==="bottom")return 1;if(a==="center")return .5}else{if(a==="left")return 0;if(a==="right")return 1;if(a==="center")return .5}return console.warn(`Invalid position value: ${s}. Defaulting to center.`),.5};if(typeof t=="string"){let s=t.toLowerCase().trim().split(/\s+/);s.includes("left")?e=0:s.includes("right")?e=1:(s.includes("center")||s.length===1&&(s[0]==="top"||s[0]==="bottom"))&&(e=.5),s.includes("top")?r=0:s.includes("bottom")?r=1:(s.includes("center")||s.length===1&&(s[0]==="left"||s[0]==="right"))&&(r=.5),s.length===1&&s[0]==="center"&&(e=.5,r=.5)}else typeof t=="object"&&t?(e=i(t.x,!1),r=i(t.y,!0)):console.warn(`Invalid position value provided: ${t}. Defaulting to center.`);return QQ(e,1-r).value},aT=t=>{if(typeof t=="number")return(t%360+360)%360;let e=t.toLowerCase().trim();switch(e){case"to right":return 0;case"to bottom":return 90;case"to left":return 180;case"to top":return 270;case"to bottom right":case"to right bottom":return 45;case"to bottom left":case"to left bottom":return 135;case"to top left":case"to left top":return 225;case"to top right":case"to right top":return 315;case"from left":return 0;case"from top":return 90;case"from right":return 180;case"from bottom":return 270;case"from top left":return 45;case"from top right":return 135;case"from bottom right":return 225;case"from bottom left":return 315;default:let r=e.match(/^(-?\d*\.?\d+)(deg|rad|turn)?$/);if(r){let[,i,s="deg"]=r,n=parseFloat(i);switch(s){case"deg":return(n%360+360)%360;case"rad":return(n*180/Math.PI%360+360)%360;case"turn":return(n*360%360+360)%360;default:return(n%360+360)%360}}return console.warn(`Invalid angle value: ${t}. Defaulting to 0 degrees.`),0}},Cl={name:"Blob",category:"Shapes & Masks",props:{colorA:{default:"#ff6b35",transform:Nt,description:"Primary color of the blob",ui:{type:"color",label:"Color A"}},colorB:{default:"#e91e63",transform:Nt,description:"Secondary color of the blob",ui:{type:"color",label:"Color B"}},colorC:{default:"#9c27b0",transform:Nt,description:"Tertiary color of the blob",ui:{type:"color",label:"Color C"}},size:{default:.5,description:"Size of the blob",ui:{type:"range",min:0,max:1,step:.01,label:"Size"}},conformity:{default:.5,description:"How organic and blobby the shape is (0 = circle, 1 = very blobby)",ui:{type:"range",min:0,max:1,step:.01,label:"Conformity"}},edgeWidth:{default:.1,description:"Width of edge transition (distance over which blob fades out)",ui:{type:"range",min:0,max:.5,step:.001,label:"Edge Width"}},edgeCurve:{default:.3,description:"Edge transition curve (< 1.0 = ease-in, 1.0 = linear, > 1.0 = ease-out)",ui:{type:"range",min:.1,max:3,step:.1,label:"Edge Curve"}},highlightIntensity:{default:.5,description:"Intensity of specular highlight effect",ui:{type:"range",min:0,max:1,step:.01,label:"Highlight Intensity"}},highlightLightX:{default:.4,description:"Light direction X component",ui:{type:"range",min:-1,max:1,step:.01,label:"Light X"}},highlightLightY:{default:-.4,description:"Light direction Y component",ui:{type:"range",min:-1,max:1,step:.01,label:"Light Y"}},highlightLightZ:{default:.2,description:"Light direction Z component",ui:{type:"range",min:-1,max:1,step:.01,label:"Light Z"}},highlightColor:{default:"#f4dfb5",transform:Nt,description:"Color of the specular highlight",ui:{type:"color",label:"Highlight Color"}},speed:{default:.5,description:"Animation speed",ui:{type:"range",min:0,max:2,step:.1,label:"Speed"}},seed:{default:1,description:"Animation seed offset for creating different animation states",ui:{type:"range",min:0,max:100,step:1,label:"Seed"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the blob",ui:{type:"position",label:"Center Position"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec3:r,vec4:i,float:s,screenUV:n,smoothstep:a,sin:o,length:l,timerLocal:h,viewportSize:u,mix:c,pow:d,max:m,normalize:p,dot:f,reflect:g}=Ve,y=h().mul(t.speed.uniform).add(t.seed.uniform),T=t.colorA.uniform,S=t.colorB.uniform,w=t.colorC.uniform,_=t.size.uniform,M=t.conformity.uniform,E=t.edgeWidth.uniform,A=t.edgeCurve.uniform,U=t.highlightIntensity.uniform,Q=t.highlightLightX.uniform,J=t.highlightLightY.uniform,re=t.highlightLightZ.uniform,ie=t.highlightColor.uniform,se=s(.5),ve=u.x.div(u.y),me=e(n.x.mul(ve),n.y),Me=e(t.center.uniform.x.mul(ve),t.center.uniform.y.oneMinus()),ye=me.sub(Me),Te=l(ye),ge=_,be=s(4),Je=o(ye.x.mul(be.mul(s(.8))).add(y.mul(s(.8)))).mul(o(ye.y.mul(be.mul(s(.7))).add(y.mul(s(.6))))).add(o(ye.x.mul(be.mul(s(1.2))).sub(ye.y.mul(be.mul(s(.9))).add(y.mul(s(.4)))))).mul(s(.15)).mul(M),wt=o(ye.x.mul(be.mul(s(1.4))).sub(y.mul(s(.5)))).mul(o(ye.y.mul(be.mul(s(1.1))).add(y.mul(s(.7))))).mul(s(.12)).mul(M).mul(a(s(.15),s(.25),se)),Bt=o(ye.x.mul(be.mul(s(1.8))).add(ye.y.mul(be.mul(s(1.6))).add(y.mul(s(.3))))).add(o(ye.x.mul(be.mul(s(.6))).sub(y.mul(s(.9))))).mul(s(.1)).mul(M).mul(a(s(.3),s(.4),se)),He=o(ye.x.mul(be.mul(s(2.2))).add(y.mul(s(.2)))).mul(o(ye.y.mul(be.mul(s(1.9))).sub(y.mul(s(.8))))).mul(s(.08)).mul(M).mul(a(s(.45),s(.55),se)),Wr=o(ye.x.mul(be.mul(s(2.8))).sub(ye.y.mul(be.mul(s(2.4))).add(y.mul(s(.6))))).mul(s(.06)).mul(M).mul(a(s(.6),s(.7),se)),Hr=o(ye.x.mul(be.mul(s(3.2))).add(y.mul(s(1.1)))).add(o(ye.y.mul(be.mul(s(3.5))).sub(y.mul(s(.4))))).mul(s(.04)).mul(M).mul(a(s(.75),s(.85),se)),Qt=Je.add(wt).add(Bt).add(He).add(Wr).add(Hr),Ot=ge.add(Qt),br=a(Ot.add(E),Ot.sub(E),Te),vr=d(br,A),qr=l(ye),Wt=Ot,Ir=a(s(0),Wt,qr),ui=s(1).sub(Ir.mul(s(.1))),Zi=p(r(ye.x.mul(Ir.add(s(.2))),ye.y.mul(Ir.add(s(.2))),ui)),Mi=p(r(Q,J,re)),ri=r(s(0),s(0),s(1)),_i=g(Mi.negate(),Zi),Ni=s(32),ws=m(s(0),f(_i,ri)),ta=d(ws,Ni),Vr=Ir.mul(s(.5)).add(s(.5)),zi=ta.mul(Vr),ii=zi.mul(U).mul(vr),he=ye.x.mul(s(3)),oe=ye.y.mul(s(3)),xe=o(he.add(y.mul(s(.4)))).mul(o(oe.add(y.mul(s(.3))))).add(o(he.mul(s(.7)).add(oe.mul(s(.8))).add(y.mul(s(.2))))).mul(s(.5)).add(s(.5)),ce=o(he.mul(s(1.3)).sub(y.mul(s(.5)))).mul(o(oe.mul(s(1.1)).add(y.mul(s(.6))))).add(o(he.mul(s(.5)).sub(oe.mul(s(.6)).sub(y.mul(s(.3)))))).mul(s(.5)).add(s(.5)),qe=o(he.mul(s(.8)).add(oe.mul(s(1.2)).add(y.mul(s(.1))))).mul(s(.3)).add(s(.5)),ut=a(s(.1),s(.9),xe),ht=a(s(.08),s(.99),ce.mul(qe)),Pt=c(T.rgb,S.rgb,ut),Lt=c(Pt,w.rgb,ht),ar=T.a.add(S.a).add(w.a).div(s(3)),yt=ie.rgb.mul(ii),st=Lt.add(yt);return i(st,ar.mul(vr))}},Rl={name:"Blur",category:"Effects",requiresRTT:!0,props:{intensity:{default:5,description:"Blur intensity (higher = more blur)",ui:{type:"range",min:0,max:20,step:.5,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,float:n,screenUV:a,convertToTexture:o,viewportSize:l}=Ve;if(!e)return s(0,0,0,0);let h=Math.round(r.width),u=Math.round(r.height),c=o(e,h,u),d=t.intensity.uniform.div(l.x.min(l.y)),m=[i(-1,-1),i(0,-1),i(1,-1),i(-1,0),i(0,0),i(1,0),i(-1,1),i(0,1),i(1,1)],p=[.0625,.125,.0625,.125,.25,.125,.0625,.125,.0625],f=s(0);for(let g=0;g<m.length;g++){let y=m[g].mul(d),T=a.add(y),S=n(p[g]),w=c.sample(T);f=f.add(w.mul(S))}return f}},Pl={name:"Bulge",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Il={name:"Checkerboard",category:"Shapes & Masks",props:{colorA:{default:"#cccccc",transform:Nt,description:"First color of the checkerboard pattern",ui:{type:"color",label:"Color A"}},colorB:{default:"#999999",transform:Nt,description:"Second color of the checkerboard pattern",ui:{type:"color",label:"Color B"}},cells:{default:8,description:"Number of cells along the shortest canvas edge (creates square cells)",ui:{type:"range",min:1,max:50,step:1,label:"Cells"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,floor:i,mod:s,screenUV:n,viewportSize:a}=Ve,o=a.x.div(a.y),l=e(n.x.mul(o),n.y.oneMinus()),h=t.cells.uniform,u=l.mul(h),c=i(u),d=s(c.x.add(c.y),2);return r(t.colorA.uniform,t.colorB.uniform,d)}},Vl={name:"ChromaFlow",category:"Gradients & Colors",props:{baseColor:{default:"#0066ff",transform:Nt,description:"Base liquid color",ui:{type:"color",label:"Base Color"}},upColor:{default:"#00ff00",transform:Nt,description:"Color for upward movement",ui:{type:"color",label:"Up Color"}},downColor:{default:"#ff0000",transform:Nt,description:"Color for downward movement",ui:{type:"color",label:"Down Color"}},leftColor:{default:"#0000ff",transform:Nt,description:"Color for leftward movement",ui:{type:"color",label:"Left Color"}},rightColor:{default:"#ffff00",transform:Nt,description:"Color for rightward movement",ui:{type:"color",label:"Right Color"}},intensity:{default:1,description:"Strength of the liquid effect",ui:{type:"range",min:.5,max:1.5,step:.1,label:"Intensity"}},duration:{default:3,description:"How long the liquid persists (higher = longer)",ui:{type:"range",min:0,max:10,step:.1,label:"Duration"}},radius:{default:2,description:"Radius of the liquid effect",ui:{type:"range",min:0,max:3,step:.01,label:"Radius"}},momentum:{default:30,description:"How much momentum colors retain in their flow direction",ui:{type:"range",min:10,max:60,step:1,label:"Momentum"}}},fragmentNode:({uniforms:t,onBeforeRender:e,onCleanup:r})=>{let{vec2:i,vec4:s,float:n,uniform:a,screenUV:o,texture:l,smoothstep:h,mix:u}=Ve,c=new Float32Array(16384*2),d=new Float32Array(16384*2),m=new em(c,128,128,So,gc);m.magFilter=ps,m.minFilter=ps,m.needsUpdate=!0;let p=new em(d,128,128,So,gc);p.magFilter=ps,p.minFilter=ps,p.needsUpdate=!0;let f=l(m),g=l(p),y=a(.5),T=a(.5),S=a(0),w=a(0),_=.5,M=.5,E=Date.now();e(({pointer:Vr})=>{let zi=Date.now(),ii=Math.min((zi-E)/1e3,.016);E=zi;let he=ii>0?(Vr.x-_)/ii:0,oe=ii>0?(Vr.y-M)/ii:0;S.value=S.value*.85+he*.15,w.value=w.value*.85+oe*.15,y.value=Vr.x,T.value=Vr.y;let xe=t.duration.uniform.value,ce=t.intensity.uniform.value,qe=t.radius.uniform.value*.05,ut=t.momentum.uniform.value,ht=new Float32Array(c),Pt=new Float32Array(d),Lt=1-ii/Math.max(xe/150*5,1);for(let ar=0;ar<16384*2;ar++)ht[ar]=c[ar]*Lt;for(let ar=0;ar<128;ar++)for(let yt=0;yt<128;yt++){let st=(ar*128+yt)*2,ct=1-ii/Math.max(xe/150*20,1);if(Pt[st]=d[st]*ct,Pt[st+1]=d[st+1]*ct,Math.abs(c[st])>.001||Math.abs(c[st+1])>.001){let Xr=ut*50*ii,Ji=yt-c[st]*Xr,Wo=ar-c[st+1]*Xr,ra=Math.floor(Ji),ia=Math.floor(Wo),Oc=ra+1,Ho=ia+1;if(ra>=0&&ia>=0&&Oc<128&&Ho<128){let qa=Ji-ra,qu=Wo-ia,fL=(ia*128+ra)*2,gL=(ia*128+Oc)*2,yL=(Ho*128+ra)*2,xL=(Ho*128+Oc)*2,bL=d[fL]*(1-qa)*(1-qu)+d[gL]*qa*(1-qu)+d[yL]*(1-qa)*qu+d[xL]*qa*qu;Pt[st]=bL*ct}}}for(let ar=0;ar<128;ar++)for(let yt=0;yt<128;yt++){let st=(ar*128+yt)*2,ct=(yt+.5)/128,Xr=(ar+.5)/128,Ji=ct-Vr.x,Wo=Xr-Vr.y,ra=Math.sqrt(Ji*Ji+Wo*Wo),ia=Math.sqrt(S.value*S.value+w.value*w.value),Oc=Math.min(ia*ia*20,1),Ho=qe*Oc;if(ra<Ho*2&&Math.abs(he)+Math.abs(oe)>.01){let qa=Math.exp(-ra*ra/(Ho*Ho));ht[st]+=S.value*qa*(ce*100)*ii*.01,ht[st+1]+=w.value*qa*(ce*100)*ii*.01;let qu=Math.min(ia*10,1);Pt[st]+=qa*(ce*100)*ii*.01*qu,Pt[st+1]=0}ht[st]=Math.max(-1,Math.min(1,ht[st])),ht[st+1]=Math.max(-1,Math.min(1,ht[st+1])),Pt[st]=Math.max(0,Math.min(1,Pt[st])),Pt[st+1]=0}c.set(ht),d.set(Pt),m.needsUpdate=!0,p.needsUpdate=!0,_=Vr.x,M=Vr.y}),r(()=>{m.dispose(),p.dispose()});let A=g.sample(o).x,U=i(n(1/128),n(1/128)),Q=g.sample(o.add(i(U.x,n(0)))).x,J=g.sample(o.add(i(n(0),U.y))).x,re=g.sample(o.add(i(U.x.negate(),n(0)))).x,ie=g.sample(o.add(i(n(0),U.y.negate()))).x,se=A.add(Q).add(J).add(re).add(ie).mul(n(.2)),ve=h(n(0),n(.1),se),me=i(n(1/128),n(1/128)),Me=f.sample(o).xy,ye=f.sample(o.add(i(me.x,n(0)))).xy,Te=f.sample(o.add(i(n(0),me.y))).xy,ge=f.sample(o.add(i(me.x.negate(),n(0)))).xy,be=f.sample(o.add(i(n(0),me.y.negate()))).xy,Je=Me.add(ye).add(Te).add(ge).add(be).mul(n(.2)),wt=t.baseColor.uniform,Bt=t.upColor.uniform,He=t.downColor.uniform,Wr=t.leftColor.uniform,Hr=t.rightColor.uniform,Qt=Je.x.mul(Je.x).add(Je.y.mul(Je.y)).sqrt(),Ot=h(n(.01),n(.1),Qt),br=Je.x.div(Qt.add(n(.001))),vr=Je.y.div(Qt.add(n(.001))),qr=h(n(0),n(.7),br.max(n(0))),Wt=h(n(0),n(.7),br.negate().max(n(0))),Ir=h(n(0),n(.7),vr.max(n(0))),ui=h(n(0),n(.7),vr.negate().max(n(0))),Zi=Wr.mul(Wt).add(Hr.mul(qr)),Mi=He.mul(ui).add(Bt.mul(Ir)),ri=Wt.add(qr),_i=Ir.add(ui),Ni=ri.add(_i).add(n(.001)),ws=Zi.mul(ri.div(Ni)).add(Mi.mul(_i.div(Ni))),ta=u(wt,ws,Ot);return s(ta.rgb.mul(ve),ta.a.mul(ve))}},Ol={name:"ChromaticAberration",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Ll={name:"Circle",category:"Shapes & Masks",props:{color:{default:"#ffffff",transform:Nt,description:"The color of the circle",ui:{type:"color",label:"Color"}},radius:{default:1,description:"The radius of the circle. A value of one (1) is sets the circle to fit the canvas.",ui:{type:"range",min:0,max:2,step:.01,label:"Radius"}},softness:{default:0,description:"Edge softness. Lower values like zero (0) are sharp, higher values like one (1) are softer.",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the circle",ui:{type:"position",label:"Center Position"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,length:i,smoothstep:s,screenUV:n,viewportSize:a}=Ve,o=a.x.div(a.y),l=e(n.x.mul(o),n.y),h=e(t.center.uniform.x.mul(o),t.center.uniform.y.oneMinus()),u=i(l.sub(h)),c=t.softness.uniform,d=t.radius.uniform.mul(.5),m=s(d,d.sub(c),u);return r(t.color.uniform.rgb,t.color.uniform.a.mul(m))}},Fl={name:"ColorMapping",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},zl={name:"CRTScreen",category:"Effects",requiresRTT:!0,props:{pixelSize:{default:128,description:"Size of individual TV pixels (lower = more pixels)",ui:{type:"range",min:8,max:128,step:1,label:"Pixel Size"}},colorShift:{default:1,description:"Chromatic aberration amount",ui:{type:"range",min:0,max:10,step:.1,label:"Color Shift"}},scanlineIntensity:{default:.3,description:"Strength of horizontal scanlines",ui:{type:"range",min:0,max:1,step:.01,label:"Scanline Intensity"}},scanlineFrequency:{default:200,description:"Number of scanlines across screen",ui:{type:"range",min:100,max:800,step:10,label:"Scanline Frequency"}},brightness:{default:1.1,description:"Screen brightness boost",ui:{type:"range",min:.5,max:2,step:.01,label:"Brightness"}},contrast:{default:1.2,description:"Screen contrast enhancement",ui:{type:"range",min:.5,max:2,step:.01,label:"Contrast"}},curvature:{default:.2,description:"CRT screen curvature effect",ui:{type:"range",min:0,max:.3,step:.01,label:"Curvature"}},scaleToFill:{default:0,description:"Automatically scale to eliminate curvature whitespace",ui:{type:"checkbox",label:"Scale to Fill"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec3:s,vec4:n,float:a,screenUV:o,sin:l,fract:h,smoothstep:u,mix:c,length:d,convertToTexture:m}=Ve;if(!e)return n(0,0,0,0);let p=Math.round(r.width),f=Math.round(r.height),g=m(e,p,f),y=t.pixelSize.uniform,T=t.colorShift.uniform,S=t.scanlineIntensity.uniform,w=t.scanlineFrequency.uniform,_=t.brightness.uniform,M=t.contrast.uniform,E=t.curvature.uniform,A=t.scaleToFill.uniform,U=A.greaterThan(a(.5)).select(a(1).add(E.mul(a(2))),a(1)),Q=o.sub(i(.5,.5)).div(U).add(i(.5,.5)),J=Q.sub(i(.5,.5)),re=d(J),ie=E.mul(re.mul(re)),se=Q.add(J.mul(ie)),ve=se.x.lessThan(a(0)).or(se.x.greaterThan(a(1))).or(se.y.lessThan(a(0))).or(se.y.greaterThan(a(1))),me=T.mul(a(.002)),Me=se.add(i(me,a(0))),ye=se,Te=se.sub(i(me,a(0))),ge=g.sample(Me).r,be=g.sample(ye).g,Je=g.sample(Te).b,wt=s(ge,be,Je),Bt=wt.sub(a(.5)).mul(M).add(a(.5)).mul(_),He=se.y.mul(w),Wr=l(He.mul(a(3.14159*2))),Hr=a(1).sub(S.mul(Wr.mul(a(.5)).add(a(.5)))),Qt=Bt.mul(Hr),Ot=y.mul(a(.5)),br=h(se.mul(Ot)),vr=l(br.x.mul(a(6.28318))).mul(a(.1)).add(a(.95)),qr=l(br.x.mul(a(6.28318)).add(a(2.09))).mul(a(.1)).add(a(.95)),Wt=l(br.x.mul(a(6.28318)).add(a(4.18))).mul(a(.1)).add(a(.95)),Ir=s(Qt.r.mul(vr),Qt.g.mul(qr),Qt.b.mul(Wt)),ui=d(J),Zi=u(a(.8),a(.3),ui),Mi=Ir.mul(Zi),ri=c(s(0,0,0),Mi,ve.select(a(0),a(1)));return n(ri,a(1))}},Bl={name:"Dither",category:"Effects",props:{pixelSize:{default:4,description:"Size of dithering pixels",ui:{type:"range",min:1,max:20,step:1,label:"Pixel Size"}},threshold:{default:.5,description:"Luminance threshold for dithering",ui:{type:"range",min:0,max:1,step:.01,label:"Threshold"}},colorA:{default:"transparent",transform:Nt,description:"Dark color for dithering",ui:{type:"color",label:"Dark Color"}},colorB:{default:"#ffffff",transform:Nt,description:"Light color for dithering",ui:{type:"color",label:"Light Color"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec2:r,vec3:i,vec4:s,floor:n,screenUV:a,viewportSize:o,dot:l,step:h,mix:u}=Ve;if(!e)return s(0);let c=e,d=l(c.rgb,i(.299,.587,.114)),m=d.mul(c.a),p=t.pixelSize.uniform,f=n(a.mul(o).div(p)),g=f.mod(r(4)),y=g.x,T=g.y,S=T.equal(0).select(y.equal(0).select(0/16,y.equal(1).select(8/16,y.equal(2).select(2/16,10/16))),T.equal(1).select(y.equal(0).select(12/16,y.equal(1).select(4/16,y.equal(2).select(14/16,6/16))),T.equal(2).select(y.equal(0).select(3/16,y.equal(1).select(11/16,y.equal(2).select(1/16,9/16))),y.equal(0).select(15/16,y.equal(1).select(7/16,y.equal(2).select(13/16,5/16)))))),w=t.threshold.uniform,_=h(S,m.add(w.sub(.5))),M=u(t.colorA.uniform.rgb,t.colorB.uniform.rgb,_),E=u(t.colorA.uniform.a,t.colorB.uniform.a,_);return s(M,E)}},kl={name:"DotGrid",category:"Shapes & Masks",props:{color:{default:"#ffffff",description:"The color of the dot",transform:Nt,ui:{type:"color",label:"Color"}},density:{default:100,description:"The number of dots on the longest canvas edge",ui:{type:"range",min:10,max:500,step:10,label:"Density"}},dotSize:{default:.3,description:"The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps",ui:{type:"range",min:0,max:1,step:.01,label:"Dot Size"}},twinkle:{default:0,description:"Intensity of the twinkle effect (0 = off, 1 = full twinkle)",ui:{type:"range",min:0,max:1,step:.01,label:"Twinkle"}}},fragmentNode:({uniforms:t})=>{let{screenUV:e,vec4:r,vec2:i,smoothstep:s,length:n,floor:a,float:o,viewportSize:l,time:h,sin:u,mix:c}=Ve,d=e,m=t.density.uniform,p=t.dotSize.uniform,f=t.color.uniform,g=t.twinkle.uniform,y=l,T=y.x.div(y.y),S=i(d.x.mul(T),d.y.oneMinus()),w=S.mul(m),_=w.sub(a(w)),M=n(_.sub(.5)),E=n(JR(S.mul(m))),A=o(1).sub(s(p.mul(.5),p.mul(.5).add(E.mul(.5)),M)),U=a(w),Q=U.x.mul(12.9898).add(U.y.mul(78.233)).sin().mul(43758.5453).fract(),J=h.mul(2).add(Q.mul(6.28318)),re=u(J).mul(.5).add(.5),ie=c(o(1),re,g),se=A.mul(ie);return r(f.rgb,se)}},Ul={name:"Duotone",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Dl={name:"Exposure",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},$l={name:"FilmGrain",category:"Effects",props:{strength:{default:.5,description:"Intensity of the film grain noise",ui:{type:"range",min:0,max:1,step:.01,label:"Strength"}},animated:{default:0,description:"Whether the noise should animate over time",ui:{type:"checkbox",label:"Animated"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec2:r,vec4:i,float:s,screenUV:n,sin:a,dot:o,fract:l,timerLocal:h}=Ve;if(!e)return console.error("You must pass a child component into the Film Noise shader."),i(0);let u=t.strength.uniform,c=t.animated.uniform,d=e||i(0,0,0,0),m=n,p=c.greaterThan(s(.5)).select(h(),s(0)),f=m.add(r(p.mul(s(.1)),p.mul(s(.13)))),g=o(f,r(s(12.9898),s(78.233)).mul(s(2))),y=l(a(g).mul(s(43758.5453))),T=y.mul(s(2)).sub(s(1)),S=T.mul(u.mul(s(.1))),w=d.rgb.add(S);return i(w,d.a)}},Gl={name:"GlassTiles",category:"Distortions",requiresRTT:!0,props:{intensity:{default:1,description:"The intensity of the glass tiles effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},tileCount:{default:100,description:"Number of tiles across the shortest dimension",ui:{type:"range",min:1,max:200,step:1,label:"Tile Count"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,floor:n,mul:a,div:o,sub:l,add:h,convertToTexture:u,screenUV:c,uniform:d}=Ve;if(!e)return console.error("You must pass a child component into the Glass Tiles shader."),s(0);let m=Math.round(r.width),p=Math.round(r.height),f=u(e,m,p),g=d(r.width/r.height),y=c,T=t.intensity.uniform,S=t.tileCount.uniform,w=i(g.greaterThanEqual(1).select(a(S,g),S),g.lessThan(1).select(o(S,g),S)),_=o(n(a(y,w)),w),M=l(y,_),E=i(.5,.5),A=a(T,.025),U=o(M,o(i(1),w)),Q=l(U,E),J=a(Q,A),re=h(M,J),ie=h(re,_);return s(f.sample(ie))}},jl={name:"Glitch",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Wl={name:"Glow",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Hl={name:"Godrays",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},af={VERTEX:"vertex"},po={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Im=["x","y","z","w"],pi="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".split(".");let P_=1234567;const Y3=Math.PI/180,Z3=180/Math.PI;function Bf(){let t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(pi[t&255]+pi[t>>8&255]+pi[t>>16&255]+pi[t>>24&255]+"-"+pi[e&255]+pi[e>>8&255]+"-"+pi[e>>16&15|64]+pi[e>>24&255]+"-"+pi[r&63|128]+pi[r>>8&255]+"-"+pi[r>>16&255]+pi[r>>24&255]+pi[i&255]+pi[i>>8&255]+pi[i>>16&255]+pi[i>>24&255]).toLowerCase()}function xt(t,e,r){return Math.max(e,Math.min(r,t))}function oT(t,e){return(t%e+e)%e}function tee(t,e,r,i,s){return i+(t-e)*(s-i)/(r-e)}function ree(t,e,r){return t===e?0:(r-t)/(e-t)}function kd(t,e,r){return(1-r)*t+r*e}function iee(t,e,r,i){return kd(t,e,1-Math.exp(-r*i))}function see(t,e=1){return e-Math.abs(oT(t,e*2)-e)}function nee(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*(3-2*t))}function aee(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e),t*t*t*(t*(t*6-15)+10))}function oee(t,e){return t+Math.floor(Math.random()*(e-t+1))}function lee(t,e){return t+Math.random()*(e-t)}function uee(t){return t*(.5-Math.random())}function hee(t){t!==void 0&&(P_=t);let e=P_+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function cee(t){return t*Y3}function dee(t){return t*Z3}function mee(t){return(t&t-1)==0&&t!==0}function pee(t){return 2**Math.ceil(Math.log(t)/Math.LN2)}function fee(t){return 2**Math.floor(Math.log(t)/Math.LN2)}function gee(t,e,r,i,s){let n=Math.cos,a=Math.sin,o=n(r/2),l=a(r/2),h=n((e+i)/2),u=a((e+i)/2),c=n((e-i)/2),d=a((e-i)/2),m=n((i-e)/2),p=a((i-e)/2);switch(s){case"XYX":t.set(o*u,l*c,l*d,o*h);break;case"YZY":t.set(l*d,o*u,l*c,o*h);break;case"ZXZ":t.set(l*c,l*d,o*u,o*h);break;case"XZX":t.set(o*u,l*p,l*m,o*h);break;case"YXY":t.set(l*m,o*u,l*p,o*h);break;case"ZYZ":t.set(l*p,l*m,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function cn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}function Mt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw Error("Invalid component type.")}}const yee={DEG2RAD:Y3,RAD2DEG:Z3,generateUUID:Bf,clamp:xt,euclideanModulo:oT,mapLinear:tee,inverseLerp:ree,lerp:kd,damp:iee,pingpong:see,smoothstep:nee,smootherstep:aee,randInt:oee,randFloat:lee,randFloatSpread:uee,seededRandom:hee,degToRad:cee,radToDeg:dee,isPowerOfTwo:mee,ceilPowerOfTwo:pee,floorPowerOfTwo:fee,setQuaternionFromProperEuler:gee,normalize:Mt,denormalize:cn},ln="srgb",I_="srgb-linear",V_="linear",Ud="srgb",gg=35044,Tl=2e3,Wb=2001;var Vm=class J3{constructor(e,r,i,s,n,a,o,l,h){J3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h)}set(e,r,i,s,n,a,o,l,h){let u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=r,u[4]=n,u[5]=l,u[6]=i,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],this}extractBasis(e,r,i){return e.setFromMatrix3Column(this,0),r.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let r=e.elements;return this.set(r[0],r[4],r[8],r[1],r[5],r[9],r[2],r[6],r[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[3],l=i[6],h=i[1],u=i[4],c=i[7],d=i[2],m=i[5],p=i[8],f=s[0],g=s[3],y=s[6],T=s[1],S=s[4],w=s[7],_=s[2],M=s[5],E=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*S+l*M,n[6]=a*y+o*w+l*E,n[1]=h*f+u*T+c*_,n[4]=h*g+u*S+c*M,n[7]=h*y+u*w+c*E,n[2]=d*f+m*T+p*_,n[5]=d*g+m*S+p*M,n[8]=d*y+m*w+p*E,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=e,r[4]*=e,r[7]*=e,r[2]*=e,r[5]*=e,r[8]*=e,this}determinant(){let e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8];return r*a*u-r*o*h-i*n*u+i*o*l+s*n*h-s*a*l}invert(){let e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=u*a-o*h,d=o*l-u*n,m=h*n-a*l,p=r*c+i*d+s*m;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(s*h-u*i)*f,e[2]=(o*i-s*a)*f,e[3]=d*f,e[4]=(u*r-s*l)*f,e[5]=(s*n-o*r)*f,e[6]=m*f,e[7]=(i*l-h*r)*f,e[8]=(a*r-i*n)*f,this}transpose(){let e,r=this.elements;return e=r[1],r[1]=r[3],r[3]=e,e=r[2],r[2]=r[6],r[6]=e,e=r[5],r[5]=r[7],r[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let r=this.elements;return e[0]=r[0],e[1]=r[3],e[2]=r[6],e[3]=r[1],e[4]=r[4],e[5]=r[7],e[6]=r[2],e[7]=r[5],e[8]=r[8],this}setUvTransform(e,r,i,s,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(i*l,i*h,-i*(l*a+h*o)+a+e,-s*h,s*l,-s*(-h*a+l*o)+o+r,0,0,1),this}scale(e,r){return this.premultiply(fx.makeScale(e,r)),this}rotate(e){return this.premultiply(fx.makeRotation(-e)),this}translate(e,r){return this.premultiply(fx.makeTranslation(e,r)),this}makeTranslation(e,r){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,r,0,0,1),this}makeRotation(e){let r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,i,r,0,0,0,1),this}makeScale(e,r){return this.set(e,0,0,0,r,0,0,0,1),this}equals(e){let r=this.elements,i=e.elements;for(let s=0;s<9;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<9;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){let i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const fx=new Vm,O_={};function L_(t){t in O_||(O_[t]=!0,console.warn(t))}const F_=new Vm().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),z_=new Vm().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xee(){let t={enabled:!0,workingColorSpace:I_,spaces:{},convert:function(s,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Ud&&(s.r=sc(s.r),s.g=sc(s.g),s.b=sc(s.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ud&&(s.r=nc(s.r),s.g=nc(s.g),s.b=nc(s.b))),s},workingToColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},colorSpaceToWorking:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===""?V_:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,a){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,n){return L_("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(s,n)},toWorkingColorSpace:function(s,n){return L_("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(s,n)}},e=[.64,.33,.3,.6,.15,.06],r=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[I_]:{primaries:e,whitePoint:i,transfer:V_,toXYZ:F_,fromXYZ:z_,luminanceCoefficients:r,workingColorSpaceConfig:{unpackColorSpace:ln},outputColorSpaceConfig:{drawingBufferColorSpace:ln}},[ln]:{primaries:e,whitePoint:i,transfer:Ud,toXYZ:F_,fromXYZ:z_,luminanceCoefficients:r,outputColorSpaceConfig:{drawingBufferColorSpace:ln}}}),t}const _r=xee();function sc(t){return t<.04045?t*.0773993808:(t*.9478672986+.0521327014)**2.4}function nc(t){return t<.0031308?t*12.92:1.055*t**.41666-.055}const K3={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},lo={h:0,s:0,l:0},of={h:0,s:0,l:0};function gx(t,e,r){return r<0&&(r+=1),r>1&&--r,r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*6*(2/3-r):t}var lT=class{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){let 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=ln){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,_r.colorSpaceToWorking(this,e),this}setRGB(t,e,r,i=_r.workingColorSpace){return this.r=t,this.g=e,this.b=r,_r.colorSpaceToWorking(this,i),this}setHSL(t,e,r,i=_r.workingColorSpace){if(t=oT(t,1),e=xt(e,0,1),r=xt(r,0,1),e===0)this.r=this.g=this.b=r;else{let s=r<=.5?r*(1+e):r+e-r*e,n=2*r-s;this.r=gx(n,s,t+1/3),this.g=gx(n,s,t),this.b=gx(n,s,t-1/3)}return _r.colorSpaceToWorking(this,i),this}setStyle(t,e=ln){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,n=i[1],a=i[2];switch(n){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)){let s=i[1],n=s.length;if(n===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(n===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=ln){let r=K3[t.toLowerCase()];return r===void 0?console.warn("THREE.Color: Unknown color "+t):this.setHex(r,e),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=sc(t.r),this.g=sc(t.g),this.b=sc(t.b),this}copyLinearToSRGB(t){return this.r=nc(t.r),this.g=nc(t.g),this.b=nc(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ln){return _r.workingToColorSpace(fi.copy(this),t),Math.round(xt(fi.r*255,0,255))*65536+Math.round(xt(fi.g*255,0,255))*256+Math.round(xt(fi.b*255,0,255))}getHexString(t=ln){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=_r.workingColorSpace){_r.workingToColorSpace(fi.copy(this),e);let r=fi.r,i=fi.g,s=fi.b,n=Math.max(r,i,s),a=Math.min(r,i,s),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case r:o=(i-s)/u+(i<s?6:0);break;case i:o=(s-r)/u+2;break;case s:o=(r-i)/u+4;break}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=_r.workingColorSpace){return _r.workingToColorSpace(fi.copy(this),e),t.r=fi.r,t.g=fi.g,t.b=fi.b,t}getStyle(t=ln){_r.workingToColorSpace(fi.copy(this),t);let e=fi.r,r=fi.g,i=fi.b;return t===ln?`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(i*255)})`:`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`}offsetHSL(t,e,r){return this.getHSL(lo),this.setHSL(lo.h+t,lo.s+e,lo.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(lo),t.getHSL(of);let r=kd(lo.h,of.h,e),i=kd(lo.s,of.s,e),s=kd(lo.l,of.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){let 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 fi=new lT;lT.NAMES=K3;var bee=class Q3{constructor(e,r,i,s){Q3.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,r,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,r=0){for(let i=0;i<4;i++)this.elements[i]=e[i+r];return this}set(e,r,i,s){let n=this.elements;return n[0]=e,n[2]=r,n[1]=i,n[3]=s,this}},vee=class{constructor(e=0,r=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=r,this._z=i,this._w=s}static slerpFlat(e,r,i,s,n,a,o){let l=i[s+0],h=i[s+1],u=i[s+2],c=i[s+3],d=n[a+0],m=n[a+1],p=n[a+2],f=n[a+3];if(o===0){e[r+0]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c;return}if(o===1){e[r+0]=d,e[r+1]=m,e[r+2]=p,e[r+3]=f;return}if(c!==f||l!==d||h!==m||u!==p){let g=1-o,y=l*d+h*m+u*p+c*f,T=y>=0?1:-1,S=1-y*y;if(S>2**-52){let _=Math.sqrt(S),M=Math.atan2(_,y*T);g=Math.sin(g*M)/_,o=Math.sin(o*M)/_}let w=o*T;if(l=l*g+d*w,h=h*g+m*w,u=u*g+p*w,c=c*g+f*w,g===1-o){let _=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=_,h*=_,u*=_,c*=_}}e[r]=l,e[r+1]=h,e[r+2]=u,e[r+3]=c}static multiplyQuaternionsFlat(e,r,i,s,n,a){let o=i[s],l=i[s+1],h=i[s+2],u=i[s+3],c=n[a],d=n[a+1],m=n[a+2],p=n[a+3];return e[r]=o*p+u*c+l*m-h*d,e[r+1]=l*p+u*d+h*c-o*m,e[r+2]=h*p+u*m+o*d-l*c,e[r+3]=u*p-o*c-l*d-h*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,r,i,s){return this._x=e,this._y=r,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,r=!0){let i=e._x,s=e._y,n=e._z,a=e._order,o=Math.cos,l=Math.sin,h=o(i/2),u=o(s/2),c=o(n/2),d=l(i/2),m=l(s/2),p=l(n/2);switch(a){case"XYZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"YXZ":this._x=d*u*c+h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"ZXY":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c-d*m*p;break;case"ZYX":this._x=d*u*c-h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c+d*m*p;break;case"YZX":this._x=d*u*c+h*m*p,this._y=h*m*c+d*u*p,this._z=h*u*p-d*m*c,this._w=h*u*c-d*m*p;break;case"XZY":this._x=d*u*c-h*m*p,this._y=h*m*c-d*u*p,this._z=h*u*p+d*m*c,this._w=h*u*c+d*m*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return r===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,r){let i=r/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let r=e.elements,i=r[0],s=r[4],n=r[8],a=r[1],o=r[5],l=r[9],h=r[2],u=r[6],c=r[10],d=i+o+c;if(d>0){let m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-l)*m,this._y=(n-h)*m,this._z=(a-s)*m}else if(i>o&&i>c){let m=2*Math.sqrt(1+i-o-c);this._w=(u-l)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(n+h)/m}else if(o>c){let m=2*Math.sqrt(1+o-i-c);this._w=(n-h)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(l+u)/m}else{let m=2*Math.sqrt(1+c-i-o);this._w=(a-s)/m,this._x=(n+h)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,r){let i=e.dot(r)+1;return i<2**-52?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*r.z-e.z*r.y,this._y=e.z*r.x-e.x*r.z,this._z=e.x*r.y-e.y*r.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(xt(this.dot(e),-1,1)))}rotateTowards(e,r){let i=this.angleTo(e);if(i===0)return this;let s=Math.min(1,r/i);return this.slerp(e,s),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,r){let i=e._x,s=e._y,n=e._z,a=e._w,o=r._x,l=r._y,h=r._z,u=r._w;return this._x=i*u+a*o+s*h-n*l,this._y=s*u+a*l+n*o-i*h,this._z=n*u+a*h+i*l-s*o,this._w=a*u-i*o-s*l-n*h,this._onChangeCallback(),this}slerp(e,r){if(r===0)return this;if(r===1)return this.copy(e);let i=this._x,s=this._y,n=this._z,a=this._w,o=a*e._w+i*e._x+s*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=s,this._z=n,this;let l=1-o*o;if(l<=2**-52){let m=1-r;return this._w=m*a+r*this._w,this._x=m*i+r*this._x,this._y=m*s+r*this._y,this._z=m*n+r*this._z,this.normalize(),this}let h=Math.sqrt(l),u=Math.atan2(h,o),c=Math.sin((1-r)*u)/h,d=Math.sin(r*u)/h;return this._w=a*c+this._w*d,this._x=i*c+this._x*d,this._y=s*c+this._y*d,this._z=n*c+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,r,i){return this.copy(e).slerp(r,i)}random(){let e=2*Math.PI*Math.random(),r=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),n*Math.sin(r),n*Math.cos(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,r=0){return this._x=e[r],this._y=e[r+1],this._z=e[r+2],this._w=e[r+3],this._onChangeCallback(),this}toArray(e=[],r=0){return e[r]=this._x,e[r+1]=this._y,e[r+2]=this._z,e[r+3]=this._w,e}fromBufferAttribute(e,r){return this._x=e.getX(r),this._y=e.getY(r),this._z=e.getZ(r),this._w=e.getW(r),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Tn=class e5{constructor(e=0,r=0,i=0){e5.prototype.isVector3=!0,this.x=e,this.y=r,this.z=i}set(e,r,i){return i===void 0&&(i=this.z),this.x=e,this.y=r,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,r){return this.x=e.x*r.x,this.y=e.y*r.y,this.z=e.z*r.z,this}applyEuler(e){return this.applyQuaternion(B_.setFromEuler(e))}applyAxisAngle(e,r){return this.applyQuaternion(B_.setFromAxisAngle(e,r))}applyMatrix3(e){let r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[3]*i+n[6]*s,this.y=n[1]*r+n[4]*i+n[7]*s,this.z=n[2]*r+n[5]*i+n[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let r=this.x,i=this.y,s=this.z,n=e.elements,a=1/(n[3]*r+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*r+n[4]*i+n[8]*s+n[12])*a,this.y=(n[1]*r+n[5]*i+n[9]*s+n[13])*a,this.z=(n[2]*r+n[6]*i+n[10]*s+n[14])*a,this}applyQuaternion(e){let r=this.x,i=this.y,s=this.z,n=e.x,a=e.y,o=e.z,l=e.w,h=2*(a*s-o*i),u=2*(o*r-n*s),c=2*(n*i-a*r);return this.x=r+l*h+a*c-o*u,this.y=i+l*u+o*h-n*c,this.z=s+l*c+n*u-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let r=this.x,i=this.y,s=this.z,n=e.elements;return this.x=n[0]*r+n[4]*i+n[8]*s,this.y=n[1]*r+n[5]*i+n[9]*s,this.z=n[2]*r+n[6]*i+n[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,r){return this.x=xt(this.x,e.x,r.x),this.y=xt(this.y,e.y,r.y),this.z=xt(this.z,e.z,r.z),this}clampScalar(e,r){return this.x=xt(this.x,e,r),this.y=xt(this.y,e,r),this.z=xt(this.z,e,r),this}clampLength(e,r){let i=this.length();return this.divideScalar(i||1).multiplyScalar(xt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,r){let i=e.x,s=e.y,n=e.z,a=r.x,o=r.y,l=r.z;return this.x=s*l-n*o,this.y=n*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){let r=e.lengthSq();if(r===0)return this.set(0,0,0);let i=e.dot(this)/r;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yx.copy(this).projectOnVector(e),this.sub(yx)}reflect(e){return this.sub(yx.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let i=this.dot(e)/r;return Math.acos(xt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return r*r+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,r,i){let s=Math.sin(r)*e;return this.x=s*Math.sin(i),this.y=Math.cos(r)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,r,i){return this.x=e*Math.sin(r),this.y=i,this.z=e*Math.cos(r),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this}setFromMatrixScale(e){let r=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=r,this.y=i,this.z=s,this}setFromMatrixColumn(e,r){return this.fromArray(e.elements,r*4)}setFromMatrix3Column(e,r){return this.fromArray(e.elements,r*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,r=Math.random()*2-1,i=Math.sqrt(1-r*r);return this.x=i*Math.cos(e),this.y=r,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const yx=new Tn,B_=new vee;var t5=class Hb{constructor(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){Hb.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g)}set(e,r,i,s,n,a,o,l,h,u,c,d,m,p,f,g){let y=this.elements;return y[0]=e,y[4]=r,y[8]=i,y[12]=s,y[1]=n,y[5]=a,y[9]=o,y[13]=l,y[2]=h,y[6]=u,y[10]=c,y[14]=d,y[3]=m,y[7]=p,y[11]=f,y[15]=g,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 Hb().fromArray(this.elements)}copy(e){let r=this.elements,i=e.elements;return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],this}copyPosition(e){let r=this.elements,i=e.elements;return r[12]=i[12],r[13]=i[13],r[14]=i[14],this}setFromMatrix3(e){let r=e.elements;return this.set(r[0],r[3],r[6],0,r[1],r[4],r[7],0,r[2],r[5],r[8],0,0,0,0,1),this}extractBasis(e,r,i){return e.setFromMatrixColumn(this,0),r.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,r,i){return this.set(e.x,r.x,i.x,0,e.y,r.y,i.y,0,e.z,r.z,i.z,0,0,0,0,1),this}extractRotation(e){let r=this.elements,i=e.elements,s=1/Eh.setFromMatrixColumn(e,0).length(),n=1/Eh.setFromMatrixColumn(e,1).length(),a=1/Eh.setFromMatrixColumn(e,2).length();return r[0]=i[0]*s,r[1]=i[1]*s,r[2]=i[2]*s,r[3]=0,r[4]=i[4]*n,r[5]=i[5]*n,r[6]=i[6]*n,r[7]=0,r[8]=i[8]*a,r[9]=i[9]*a,r[10]=i[10]*a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromEuler(e){let r=this.elements,i=e.x,s=e.y,n=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(s),h=Math.sin(s),u=Math.cos(n),c=Math.sin(n);if(e.order==="XYZ"){let d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=-l*c,r[8]=h,r[1]=m+p*h,r[5]=d-f*h,r[9]=-o*l,r[2]=f-d*h,r[6]=p+m*h,r[10]=a*l}else if(e.order==="YXZ"){let d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d+f*o,r[4]=p*o-m,r[8]=a*h,r[1]=a*c,r[5]=a*u,r[9]=-o,r[2]=m*o-p,r[6]=f+d*o,r[10]=a*l}else if(e.order==="ZXY"){let d=l*u,m=l*c,p=h*u,f=h*c;r[0]=d-f*o,r[4]=-a*c,r[8]=p+m*o,r[1]=m+p*o,r[5]=a*u,r[9]=f-d*o,r[2]=-a*h,r[6]=o,r[10]=a*l}else if(e.order==="ZYX"){let d=a*u,m=a*c,p=o*u,f=o*c;r[0]=l*u,r[4]=p*h-m,r[8]=d*h+f,r[1]=l*c,r[5]=f*h+d,r[9]=m*h-p,r[2]=-h,r[6]=o*l,r[10]=a*l}else if(e.order==="YZX"){let d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=f-d*c,r[8]=p*c+m,r[1]=c,r[5]=a*u,r[9]=-o*u,r[2]=-h*u,r[6]=m*c+p,r[10]=d-f*c}else if(e.order==="XZY"){let d=a*l,m=a*h,p=o*l,f=o*h;r[0]=l*u,r[4]=-c,r[8]=h*u,r[1]=d*c+f,r[5]=a*u,r[9]=m*c-p,r[2]=p*c-m,r[6]=o*u,r[10]=f*c+d}return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Tee,e,wee)}lookAt(e,r,i){let s=this.elements;return ss.subVectors(e,r),ss.lengthSq()===0&&(ss.z=1),ss.normalize(),uo.crossVectors(i,ss),uo.lengthSq()===0&&(Math.abs(i.z)===1?ss.x+=1e-4:ss.z+=1e-4,ss.normalize(),uo.crossVectors(i,ss)),uo.normalize(),lf.crossVectors(ss,uo),s[0]=uo.x,s[4]=lf.x,s[8]=ss.x,s[1]=uo.y,s[5]=lf.y,s[9]=ss.y,s[2]=uo.z,s[6]=lf.z,s[10]=ss.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,r){let i=e.elements,s=r.elements,n=this.elements,a=i[0],o=i[4],l=i[8],h=i[12],u=i[1],c=i[5],d=i[9],m=i[13],p=i[2],f=i[6],g=i[10],y=i[14],T=i[3],S=i[7],w=i[11],_=i[15],M=s[0],E=s[4],A=s[8],U=s[12],Q=s[1],J=s[5],re=s[9],ie=s[13],se=s[2],ve=s[6],me=s[10],Me=s[14],ye=s[3],Te=s[7],ge=s[11],be=s[15];return n[0]=a*M+o*Q+l*se+h*ye,n[4]=a*E+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*U+o*ie+l*Me+h*be,n[1]=u*M+c*Q+d*se+m*ye,n[5]=u*E+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*U+c*ie+d*Me+m*be,n[2]=p*M+f*Q+g*se+y*ye,n[6]=p*E+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*U+f*ie+g*Me+y*be,n[3]=T*M+S*Q+w*se+_*ye,n[7]=T*E+S*J+w*ve+_*Te,n[11]=T*A+S*re+w*me+_*ge,n[15]=T*U+S*ie+w*Me+_*be,this}multiplyScalar(e){let r=this.elements;return r[0]*=e,r[4]*=e,r[8]*=e,r[12]*=e,r[1]*=e,r[5]*=e,r[9]*=e,r[13]*=e,r[2]*=e,r[6]*=e,r[10]*=e,r[14]*=e,r[3]*=e,r[7]*=e,r[11]*=e,r[15]*=e,this}determinant(){let e=this.elements,r=e[0],i=e[4],s=e[8],n=e[12],a=e[1],o=e[5],l=e[9],h=e[13],u=e[2],c=e[6],d=e[10],m=e[14],p=e[3],f=e[7],g=e[11],y=e[15];return p*(+n*l*c-s*h*c-n*o*d+i*h*d+s*o*m-i*l*m)+f*(+r*l*m-r*h*d+n*a*d-s*a*m+s*h*u-n*l*u)+g*(+r*h*c-r*o*m-n*a*c+i*a*m+n*o*u-i*h*u)+y*(-s*o*u-r*l*c+r*o*d+s*a*c-i*a*d+i*l*u)}transpose(){let e=this.elements,r;return r=e[1],e[1]=e[4],e[4]=r,r=e[2],e[2]=e[8],e[8]=r,r=e[6],e[6]=e[9],e[9]=r,r=e[3],e[3]=e[12],e[12]=r,r=e[7],e[7]=e[13],e[13]=r,r=e[11],e[11]=e[14],e[14]=r,this}setPosition(e,r,i){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=r,s[14]=i),this}invert(){let e=this.elements,r=e[0],i=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],m=e[11],p=e[12],f=e[13],g=e[14],y=e[15],T=c*g*h-f*d*h+f*l*m-o*g*m-c*l*y+o*d*y,S=p*d*h-u*g*h-p*l*m+a*g*m+u*l*y-a*d*y,w=u*f*h-p*c*h+p*o*m-a*f*m-u*o*y+a*c*y,_=p*c*l-u*f*l-p*o*d+a*f*d+u*o*g-a*c*g,M=r*T+i*S+s*w+n*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/M;return e[0]=T*E,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*E,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*E,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*E,e[4]=S*E,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*E,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*E,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*E,e[8]=w*E,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*E,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*E,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*E,e[12]=_*E,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*E,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*E,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*E,this}scale(e){let r=this.elements,i=e.x,s=e.y,n=e.z;return r[0]*=i,r[4]*=s,r[8]*=n,r[1]*=i,r[5]*=s,r[9]*=n,r[2]*=i,r[6]*=s,r[10]*=n,r[3]*=i,r[7]*=s,r[11]*=n,this}getMaxScaleOnAxis(){let e=this.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(r,i,s))}makeTranslation(e,r,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,r,0,0,1,i,0,0,0,1),this}makeRotationX(e){let r=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,r,-i,0,0,i,r,0,0,0,0,1),this}makeRotationY(e){let r=Math.cos(e),i=Math.sin(e);return this.set(r,0,i,0,0,1,0,0,-i,0,r,0,0,0,0,1),this}makeRotationZ(e){let r=Math.cos(e),i=Math.sin(e);return this.set(r,-i,0,0,i,r,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,r){let i=Math.cos(r),s=Math.sin(r),n=1-i,a=e.x,o=e.y,l=e.z,h=n*a,u=n*o;return this.set(h*a+i,h*o-s*l,h*l+s*o,0,h*o+s*l,u*o+i,u*l-s*a,0,h*l-s*o,u*l+s*a,n*l*l+i,0,0,0,0,1),this}makeScale(e,r,i){return this.set(e,0,0,0,0,r,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,r,i,s,n,a){return this.set(1,i,n,0,e,1,a,0,r,s,1,0,0,0,0,1),this}compose(e,r,i){let s=this.elements,n=r._x,a=r._y,o=r._z,l=r._w,h=n+n,u=a+a,c=o+o,d=n*h,m=n*u,p=n*c,f=a*u,g=a*c,y=o*c,T=l*h,S=l*u,w=l*c,_=i.x,M=i.y,E=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-S)*_,s[3]=0,s[4]=(m-w)*M,s[5]=(1-(d+y))*M,s[6]=(g+T)*M,s[7]=0,s[8]=(p+S)*E,s[9]=(g-T)*E,s[10]=(1-(d+f))*E,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,r,i){let s=this.elements,n=Eh.set(s[0],s[1],s[2]).length(),a=Eh.set(s[4],s[5],s[6]).length(),o=Eh.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),e.x=s[12],e.y=s[13],e.z=s[14],nn.copy(this);let h=1/n,u=1/a,c=1/o;return nn.elements[0]*=h,nn.elements[1]*=h,nn.elements[2]*=h,nn.elements[4]*=u,nn.elements[5]*=u,nn.elements[6]*=u,nn.elements[8]*=c,nn.elements[9]*=c,nn.elements[10]*=c,r.setFromRotationMatrix(nn),i.x=n,i.y=a,i.z=o,this}makePerspective(e,r,i,s,n,a,o=Tl){let l=this.elements,h=2*n/(r-e),u=2*n/(i-s),c=(r+e)/(r-e),d=(i+s)/(i-s),m,p;if(o===Tl)m=-(a+n)/(a-n),p=-2*a*n/(a-n);else if(o===Wb)m=-a/(a-n),p=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=p,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,r,i,s,n,a,o=Tl){let l=this.elements,h=1/(r-e),u=1/(i-s),c=1/(a-n),d=(r+e)*h,m=(i+s)*u,p,f;if(o===Tl)p=(a+n)*c,f=-2*c;else if(o===Wb)p=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=f,l[14]=-p,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let r=this.elements,i=e.elements;for(let s=0;s<16;s++)if(r[s]!==i[s])return!1;return!0}fromArray(e,r=0){for(let i=0;i<16;i++)this.elements[i]=e[i+r];return this}toArray(e=[],r=0){let i=this.elements;return e[r]=i[0],e[r+1]=i[1],e[r+2]=i[2],e[r+3]=i[3],e[r+4]=i[4],e[r+5]=i[5],e[r+6]=i[6],e[r+7]=i[7],e[r+8]=i[8],e[r+9]=i[9],e[r+10]=i[10],e[r+11]=i[11],e[r+12]=i[12],e[r+13]=i[13],e[r+14]=i[14],e[r+15]=i[15],e}};const Eh=new Tn,nn=new t5,Tee=new Tn(0,0,0),wee=new Tn(1,1,1),uo=new Tn,lf=new Tn,ss=new Tn;var r5=class i5{constructor(e=0,r=0){i5.prototype.isVector2=!0,this.x=e,this.y=r}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,r){return this.x=e,this.y=r,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let r=this.x,i=this.y,s=e.elements;return this.x=s[0]*r+s[3]*i+s[6],this.y=s[1]*r+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,r){return this.x=xt(this.x,e.x,r.x),this.y=xt(this.y,e.y,r.y),this}clampScalar(e,r){return this.x=xt(this.x,e,r),this.y=xt(this.y,e,r),this}clampLength(e,r){let i=this.length();return this.divideScalar(i||1).multiplyScalar(xt(i,e,r))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){let r=Math.sqrt(this.lengthSq()*e.lengthSq());if(r===0)return Math.PI/2;let i=this.dot(e)/r;return Math.acos(xt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let r=this.x-e.x,i=this.y-e.y;return r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this}rotateAround(e,r){let i=Math.cos(r),s=Math.sin(r),n=this.x-e.x,a=this.y-e.y;return this.x=n*i-a*s+e.x,this.y=n*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},See=class s5{constructor(e=0,r=0,i=0,s=1){s5.prototype.isVector4=!0,this.x=e,this.y=r,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,r,i,s){return this.x=e,this.y=r,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,r){switch(e){case 0:this.x=r;break;case 1:this.y=r;break;case 2:this.z=r;break;case 3:this.w=r;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,r){return this.x=e.x+r.x,this.y=e.y+r.y,this.z=e.z+r.z,this.w=e.w+r.w,this}addScaledVector(e,r){return this.x+=e.x*r,this.y+=e.y*r,this.z+=e.z*r,this.w+=e.w*r,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,r){return this.x=e.x-r.x,this.y=e.y-r.y,this.z=e.z-r.z,this.w=e.w-r.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let r=this.x,i=this.y,s=this.z,n=this.w,a=e.elements;return this.x=a[0]*r+a[4]*i+a[8]*s+a[12]*n,this.y=a[1]*r+a[5]*i+a[9]*s+a[13]*n,this.z=a[2]*r+a[6]*i+a[10]*s+a[14]*n,this.w=a[3]*r+a[7]*i+a[11]*s+a[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let r=Math.sqrt(1-e.w*e.w);return r<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/r,this.y=e.y/r,this.z=e.z/r),this}setAxisAngleFromRotationMatrix(e){let r,i,s,n,a=.01,o=.1,l=e.elements,h=l[0],u=l[4],c=l[8],d=l[1],m=l[5],p=l[9],f=l[2],g=l[6],y=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(p-g)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(p+g)<o&&Math.abs(h+m+y-3)<o)return this.set(1,0,0,0),this;r=Math.PI;let S=(h+1)/2,w=(m+1)/2,_=(y+1)/2,M=(u+d)/4,E=(c+f)/4,A=(p+g)/4;return S>w&&S>_?S<a?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(S),s=M/i,n=E/i):w>_?w<a?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=M/s,n=A/s):_<a?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=E/n,s=A/n),this.set(i,s,n,r),this}let T=Math.sqrt((g-p)*(g-p)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(T)<.001&&(T=1),this.x=(g-p)/T,this.y=(c-f)/T,this.z=(d-u)/T,this.w=Math.acos((h+m+y-1)/2),this}setFromMatrixPosition(e){let r=e.elements;return this.x=r[12],this.y=r[13],this.z=r[14],this.w=r[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,r){return this.x=xt(this.x,e.x,r.x),this.y=xt(this.y,e.y,r.y),this.z=xt(this.z,e.z,r.z),this.w=xt(this.w,e.w,r.w),this}clampScalar(e,r){return this.x=xt(this.x,e,r),this.y=xt(this.y,e,r),this.z=xt(this.z,e,r),this.w=xt(this.w,e,r),this}clampLength(e,r){let i=this.length();return this.divideScalar(i||1).multiplyScalar(xt(i,e,r))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,r){return this.x+=(e.x-this.x)*r,this.y+=(e.y-this.y)*r,this.z+=(e.z-this.z)*r,this.w+=(e.w-this.w)*r,this}lerpVectors(e,r,i){return this.x=e.x+(r.x-e.x)*i,this.y=e.y+(r.y-e.y)*i,this.z=e.z+(r.z-e.z)*i,this.w=e.w+(r.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,r=0){return this.x=e[r],this.y=e[r+1],this.z=e[r+2],this.w=e[r+3],this}toArray(e=[],r=0){return e[r]=this.x,e[r+1]=this.y,e[r+2]=this.z,e[r+3]=this.w,e}fromBufferAttribute(e,r){return this.x=e.getX(r),this.y=e.getY(r),this.z=e.getZ(r),this.w=e.getW(r),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}};function qb(t,e=0){let r=3735928559^e,i=1103547991^e;if(t instanceof Array)for(let s=0,n;s<t.length;s++)n=t[s],r=Math.imul(r^n,2654435761),i=Math.imul(i^n,1597334677);else for(let s=0,n;s<t.length;s++)n=t.charCodeAt(s),r=Math.imul(r^n,2654435761),i=Math.imul(i^n,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&i)+(r>>>0)}const n5=(...t)=>qb(t);function Mee(t,e=!1){let r=[];t.isNode===!0&&(r.push(t.id),t=t.getSelf());for(let{property:i,childNode:s}of Xb(t))r.push(qb(i.slice(0,-4)),s.getCacheKey(e));return qb(r)}function*Xb(t,e=!1){for(let r in t){if(r.startsWith("_")===!0)continue;let i=t[r];if(Array.isArray(i)===!0)for(let s=0;s<i.length;s++){let n=i[s];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:s,childNode:n})}else if(i&&i.isNode===!0)yield{property:r,childNode:i};else if(typeof i=="object")for(let s in i){let n=i[s];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:s,childNode:n})}}}function Yb(t){if(t==null)return null;let e=typeof t;return t.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":t.isVector2===!0?"vec2":t.isVector3===!0?"vec3":t.isVector4===!0?"vec4":t.isMatrix2===!0?"mat2":t.isMatrix3===!0?"mat3":t.isMatrix4===!0?"mat4":t.isColor===!0?"color":t instanceof ArrayBuffer?"ArrayBuffer":null}function a5(t,...e){let r=t?t.slice(-4):void 0;return e.length===1&&(r==="vec2"?e=[e[0],e[0]]:r==="vec3"?e=[e[0],e[0],e[0]]:r==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),t==="color"?new lT(...e):r==="vec2"?new r5(...e):r==="vec3"?new Tn(...e):r==="vec4"?new See(...e):r==="mat2"?new bee(...e):r==="mat3"?new Vm(...e):r==="mat4"?new t5(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?Nee(e[0]):null}function _ee(t){let e="",r=new Uint8Array(t);for(let i=0;i<r.length;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function Nee(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer}var Eee=class{addEventListener(e,r){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(r)===-1&&i[e].push(r)}hasEventListener(e,r){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(r)!==-1}removeEventListener(e,r){let i=this._listeners;if(i===void 0)return;let s=i[e];if(s!==void 0){let n=s.indexOf(r);n!==-1&&s.splice(n,1)}}dispatchEvent(e){let r=this._listeners;if(r===void 0)return;let i=r[e.type];if(i!==void 0){e.target=this;let s=i.slice(0);for(let n=0,a=s.length;n<a;n++)s[n].call(this,e);e.target=null}}};const Aee={analyze:"setup",generate:"analyze"};let Cee=0;var Ree=class extends Eee{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=po.NONE,this.updateBeforeType=po.NONE,this.updateAfterType=po.NONE,this.uuid=yee.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Cee++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,r){return this.updateType=r,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,po.FRAME)}onRenderUpdate(e){return this.onUpdate(e,po.RENDER)}onObjectUpdate(e){return this.onUpdate(e,po.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of Xb(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(let r of this.getChildren())r.traverse(e)}getCacheKey(e=!1){return e||(e=this.version!==this._cacheKeyVersion),(e===!0||this._cacheKey===null)&&(this._cacheKey=n5(Mee(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let r=this.getNodeType(e);return e.getElementType(r)}getMemberType(){return"void"}getNodeType(e){let r=e.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(e):this.nodeType}getShared(e){let r=this.getHash(e);return e.getNodeFromHash(r)||this}setup(e){let r=e.getNodeProperties(this),i=0;for(let s of this.getChildren())r["node"+i++]=s;return r.outputNode||null}analyze(e,r=null){let i=e.increaseUsage(this);if(this.parents===!0){let s=e.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[e.shaderStage]=s.stages[e.shaderStage]||[],s.stages[e.shaderStage].push(r)}if(i===1){let s=e.getNodeProperties(this);for(let n of Object.values(s))n&&n.isNode===!0&&n.build(e,this)}}generate(e,r){let{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,r)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,r=null){let i=this.getShared(e);if(this!==i)return i.build(e,r);let s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;let n=Aee[e.buildStage];if(n&&s.buildStages[n]!==!0){let l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o==="setup"){this.updateReference(e);let l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(let h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){let u=e.getNodeProperties(h);u.parents=u.parents||[],u.parents.push(this)}h.build(e)}}a=l.outputNode}else if(o==="analyze")this.analyze(e,r);else if(o==="generate")if(this.generate.length===1){let h=this.getNodeType(e),u=e.getDataFromNode(this);a=u.snippet,a===void 0?u.generated===void 0?(u.generated=!0,a=this.generate(e)||"",u.snippet=a):(console.warn("THREE.Node: Recursion detected.",this),a=""):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,h,r)}else a=this.generate(e,r)||"";return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return Xb(this)}serialize(e){let r=this.getSerializeChildren(),i={};for(let{property:s,index:n,childNode:a}of r)n===void 0?i[s]=a.toJSON(e.meta).uuid:(i[s]===void 0&&(i[s]=Number.isInteger(n)?[]:{}),i[s][n]=a.toJSON(e.meta).uuid);Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){let r=e.meta.nodes;for(let i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){let s=[];for(let n of e.inputNodes[i])s.push(r[n]);this[i]=s}else if(typeof e.inputNodes[i]=="object"){let s={};for(let n in e.inputNodes[i]){let a=e.inputNodes[i][n];s[n]=r[a]}this[i]=s}else{let s=e.inputNodes[i];this[i]=r[s]}}}toJSON(e){let{uuid:r,type:i}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[r];n===void 0&&(n={uuid:r,type:i,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function a(o){let l=[];for(let h in o){let u=o[h];delete u.metadata,l.push(u)}return l}if(s){let o=a(e.textures),l=a(e.images),h=a(e.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),h.length>0&&(n.nodes=h)}return n}},Cr=Ree,Pee=class extends Cr{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,r){if(e.getBuildStage()==="generate"){let s=e.getVectorType(this.getNodeType(e,r)),n=e.getDataFromNode(this);if(n.propertyName!==void 0)return e.format(n.propertyName,s,r);if(s!=="void"&&r!=="void"&&this.hasDependencies(e)){let a=super.build(e,s),o=e.getVarFromNode(this,null,s),l=e.getPropertyName(o);return e.addLineFlowCode(`${l} = ${a}`,this),n.snippet=a,n.propertyName=l,e.format(n.propertyName,s,r)}}return super.build(e,r)}},Ts=Pee,Iee=class extends Cr{static get type(){return"ArrayElementNode"}constructor(e,r){super(),this.node=e,this.indexNode=r,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let r=this.indexNode.getNodeType(e),i=this.node.build(e),s=this.indexNode.build(e,!e.isVector(r)&&e.isInteger(r)?r:"uint");return`${i}[ ${s} ]`}},uT=Iee,Vee=class extends Cr{static get type(){return"ConvertNode"}constructor(e,r){super(),this.node=e,this.convertTo=r}getNodeType(e){let r=this.node.getNodeType(e),i=null;for(let s of this.convertTo.split("|"))(i===null||e.getTypeLength(r)===e.getTypeLength(s))&&(i=s);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,r){let i=this.node,s=this.getNodeType(e),n=i.build(e,s);return e.format(n,s,r)}},o5=Vee,Oee=class extends Ts{static get type(){return"JoinNode"}constructor(e=[],r=null){super(r),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((r,i)=>r+e.getTypeLength(i.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,r){let i=this.getNodeType(e),s=e.getTypeLength(i),n=this.nodes,a=e.getComponentType(i),o=[],l=0;for(let u of n){if(l>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${i}()' type.`);break}let c=u.getNodeType(e),d=e.getTypeLength(c),m;l+d>s&&(console.error(`THREE.TSL: Length of '${i}()' data exceeds maximum length of output type.`),d=s-l,c=e.getTypeFromLength(d)),l+=d,m=u.build(e,c);let p=e.getComponentType(c);p!==a&&(m=e.format(m,p,a)),o.push(m)}let h=`${e.getType(i)}( ${o.join(", ")} )`;return e.format(h,i,r)}},Lee=Oee;const Fee=Im.join("");var zee=class extends Cr{static get type(){return"SplitNode"}constructor(e,r="x"){super(),this.node=e,this.components=r,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let r of this.components)e=Math.max(Im.indexOf(r)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,r){let i=this.node,s=e.getTypeLength(i.getNodeType(e)),n=null;if(s>1){let a=null;this.getVectorLength()>=s&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let l=i.build(e,a);n=this.components.length===s&&this.components===Fee.slice(0,this.components.length)?e.format(l,a,r):e.format(`${l}.${this.components}`,this.getNodeType(e),r)}else n=i.build(e,r);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},k_=zee,Bee=class extends Ts{static get type(){return"SetNode"}constructor(t,e,r){super(),this.sourceNode=t,this.components=e,this.targetNode=r}getNodeType(t){return this.sourceNode.getNodeType(t)}generate(t){let{sourceNode:e,components:r,targetNode:i}=this,s=this.getNodeType(t),n=t.getComponentType(i.getNodeType(t)),a=t.getTypeFromLength(r.length,n),o=i.build(t,a),l=e.build(t,s),h=t.getTypeLength(s),u=[];for(let c=0;c<h;c++){let d=Im[c];d===r[0]?(u.push(o),c+=r.length-1):u.push(l+"."+d)}return`${t.getType(s)}( ${u.join(", ")} )`}},kee=Bee,Uee=class extends Ts{static get type(){return"FlipNode"}constructor(e,r){super(),this.sourceNode=e,this.components=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:r,sourceNode:i}=this,s=this.getNodeType(e),n=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+n,this);let l=e.getTypeLength(s),h=[],u=0;for(let c=0;c<l;c++){let d=Im[c];d===r[u]?(h.push("1.0 - "+(o+"."+d)),u++):h.push(o+"."+d)}return`${e.getType(s)}( ${h.join(", ")} )`}},Dee=Uee,$ee=class extends Cr{static get type(){return"InputNode"}constructor(e,r=null){super(r),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Yb(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Yb(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=_ee(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?a5(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}},hT=$ee;const U_=/float|u?int/;var Gee=class extends hT{static get type(){return"ConstNode"}constructor(t,e=null){super(t,e),this.isConstNode=!0}generateConst(t){return t.generateConst(this.getNodeType(t),this.value)}generate(t,e){let r=this.getNodeType(t);return U_.test(r)&&U_.test(e)?t.generateConst(e,this.value):t.format(this.generateConst(t),r,e)}},Wa=Gee,jee=class extends Cr{static get type(){return"MemberNode"}constructor(e,r){super(),this.node=e,this.property=r,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}},Wee=jee;const Wh=new Map;function H(t,e){if(Wh.has(t)){console.warn(`THREE.TSL: Redefinition of method chaining '${t}'.`);return}if(typeof e!="function")throw Error(`THREE.TSL: Node element ${t} is not a function`);Wh.set(t,e)}const l5=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),D_=t=>l5(t).split("").sort().join(""),u5={setup(t,e){let r=e.shift();return t(my(r),...e)},get(t,e,r){if(typeof e=="string"&&t[e]===void 0){if(t.isStackNode!==!0&&e==="assign")return(...i)=>(null.assign(r,...i),r);if(Wh.has(e)){let i=Wh.get(e);return t.isStackNode?(...s)=>r.add(i(...s)):(...s)=>i(r,...s)}else{if(e==="self")return t;if(e.endsWith("Assign")&&Wh.has(e.slice(0,e.length-6))){let i=Wh.get(e.slice(0,e.length-6));return t.isStackNode?(...s)=>r.assign(s[0],i(...s)):(...s)=>r.assign(i(r,...s))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=l5(e),Re(new k_(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D_(e.slice(3).toLowerCase()),i=>Re(new kee(t,e,Re(i)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D_(e.slice(4).toLowerCase()),()=>Re(new Dee(Re(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Re(new k_(t,e));if(/^\d+$/.test(e)===!0)return Re(new uT(r,new Wa(Number(e),"uint")));if(/^get$/.test(e)===!0)return i=>Re(new Wee(r,i))}}}return Reflect.get(t,e,r)},set(t,e,r,i){return typeof e=="string"&&t[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(r),!0):Reflect.set(t,e,r,i)}},xx=new WeakMap,$_=new WeakMap,Hee=function(t,e=null){let r=Yb(t);if(r==="node"){let i=xx.get(t);return i===void 0&&(i=new Proxy(t,u5),xx.set(t,i),xx.set(i,i)),i}else{if(e===null&&(r==="float"||r==="boolean")||r&&r!=="shader"&&r!=="string")return Re(Zb(t,e));if(r==="shader")return Xs(t)}return t},qee=function(t,e=null){for(let r in t)t[r]=Re(t[r],e);return t},Xee=function(t,e=null){let r=t.length;for(let i=0;i<r;i++)t[i]=Re(t[i],e);return t},Yee=function(t,e=null,r=null,i=null){let s=u=>Re(i===null?u:Object.assign(u,i)),n,a=e,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:t.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return e===null?n=(...u)=>s(new t(...kf(h(u)))):r===null?n=(...u)=>s(new t(e,...kf(h(u)))):(r=Re(r),n=(...u)=>s(new t(e,...kf(h(u)),r))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var Zee=class extends Cr{constructor(t,e){super(),this.shaderNode=t,this.inputNodes=e,this.isShaderCallNodeInternal=!0}getNodeType(t){return this.shaderNode.nodeType||this.getOutputNode(t).getNodeType(t)}getMemberType(t,e){return this.getOutputNode(t).getMemberType(t,e)}call(t){let{shaderNode:e,inputNodes:r}=this,i=t.getNodeProperties(e),s=e.namespace&&e.namespace===t.namespace?t.getNamespace("once"):"once";if(i[s])return i[s];let n=null;if(e.layout){let a=$_.get(t.constructor);a===void 0&&(a=new WeakMap,$_.set(t.constructor,a));let o=a.get(e);o===void 0&&(o=Re(t.buildFunctionNode(e)),a.set(e,o)),t.addInclude(o),n=Re(o.call(r))}else{let a=e.jsFunc,o=r!==null||a.length>1?a(r||[],t):a(t);n=Re(o)}return e.once&&(i[s]=n),n}setupOutput(t){return t.addStack(),t.stack.outputNode=this.call(t),t.removeStack()}getOutputNode(t){let e=t.getNodeProperties(this),r=t.getOutputNamespace();return e[r]=e[r]||this.setupOutput(t),e[r]}build(t,e=null){let r=null,i=t.getBuildStage(),s=t.getNodeProperties(this),n=t.getOutputNamespace(),a=this.getOutputNode(t);if(i==="setup"){let o=t.getNamespace("initialized");s[o]!==!0&&(s[o]=!0,s[n]=this.getOutputNode(t),s[n].build(t)),r=s[n]}else i==="analyze"?a.build(t,e):i==="generate"&&(r=a.build(t,e)||"");return r}},Jee=class extends Cr{constructor(t,e){super(e),this.jsFunc=t,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(t){return this.layout=t,this}call(t=null){return my(t),Re(new Zee(this,t))}setup(){return this.call()}};const Kee=[!1,!0],Qee=[0,1,2,3],ete=[-1,-2],h5=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],cT=new Map;for(let t of Kee)cT.set(t,new Wa(t));const dT=new Map;for(let t of Qee)dT.set(t,new Wa(t,"uint"));const mT=new Map([...dT].map(t=>new Wa(t.value,"int")));for(let t of ete)mT.set(t,new Wa(t,"int"));const cy=new Map([...mT].map(t=>new Wa(t.value)));for(let t of h5)cy.set(t,new Wa(t));for(let t of h5)cy.set(-t,new Wa(-t));const dy={bool:cT,uint:dT,ints:mT,float:cy},G_=new Map([...cT,...cy]),Zb=(t,e)=>G_.has(t)?G_.get(t):t.isNode===!0?t:new Wa(t,e),tte=t=>{try{return t.getNodeType()}catch{return}},Rr=function(t,e=null){return(...r)=>{if((r.length===0||!["bool","float","int","uint"].includes(t)&&r.every(s=>typeof s!="object"))&&(r=[a5(t,...r)]),r.length===1&&e!==null&&e.has(r[0]))return Re(e.get(r[0]));if(r.length===1){let s=Zb(r[0],t);return tte(s)===t?Re(s):Re(new o5(s,t))}let i=r.map(s=>Zb(s));return Re(new Lee(i,t))}},rte=t=>t==null?null:t.nodeType||t.convertTo||(typeof t=="string"?t:null);function ite(t,e){return new Proxy(new Jee(t,e),u5)}const Re=(t,e=null)=>Hee(t,e),my=(t,e=null)=>new qee(t,e),kf=(t,e=null)=>new Xee(t,e),de=(...t)=>new Yee(...t);let ste=0;const Xs=(t,e=null)=>{let r=null;e!==null&&(typeof e=="object"?r=e.return:(typeof e=="string"?r=e:console.error("THREE.TSL: Invalid layout type."),e=null));let i=new ite(t,r),s=(...n)=>{let a;my(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=i.call(a);return r==="void"&&l.toStack(),l};if(s.shaderNode=i,s.id=i.id,s.getNodeType=(...n)=>i.getNodeType(...n),s.getCacheKey=(...n)=>i.getCacheKey(...n),s.setLayout=n=>(i.setLayout(n),s),s.once=(n=null)=>(i.once=!0,i.namespace=n,s),e!==null){if(typeof e.inputs!="object"){let n={name:"fn"+ste++,type:r,inputs:[]};for(let a in e)a!=="return"&&n.inputs.push({name:a,type:e[a]});e=n}s.setLayout(e)}return s};function nte(t){return t}H("toStack",nte);const ate=new Rr("color"),za=new Rr("float",dy.float),sm=new Rr("int",dy.ints),ote=new Rr("uint",dy.uint),lte=new Rr("bool",dy.bool),c5=new Rr("vec2"),ute=new Rr("ivec2"),hte=new Rr("uvec2"),cte=new Rr("bvec2"),Tc=new Rr("vec3"),dte=new Rr("ivec3"),mte=new Rr("uvec3"),pte=new Rr("bvec3"),ql=new Rr("vec4"),fte=new Rr("ivec4"),gte=new Rr("uvec4"),yte=new Rr("bvec4"),xte=new Rr("mat2"),d5=new Rr("mat3"),bte=new Rr("mat4");H("toColor",ate),H("toFloat",za),H("toInt",sm),H("toUint",ote),H("toBool",lte),H("toVec2",c5),H("toIVec2",ute),H("toUVec2",hte),H("toBVec2",cte),H("toVec3",Tc),H("toIVec3",dte),H("toUVec3",mte),H("toBVec3",pte),H("toVec4",ql),H("toIVec4",fte),H("toUVec4",gte),H("toBVec4",yte),H("toMat2",xte),H("toMat3",d5),H("toMat4",bte);const vte=de(uT).setParameterLength(2),Tte=(t,e)=>Re(new o5(Re(t),e));H("element",vte),H("convert",Tte),H("append",t=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),t));const wte={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var yr=class Jb extends Ts{static get type(){return"OperatorNode"}constructor(e,r,i,...s){if(super(),s.length>0){let n=new Jb(e,r,i);for(let a=0;a<s.length-1;a++)n=new Jb(e,n,s[a]);r=n,i=s[s.length-1]}this.op=e,this.aNode=r,this.bNode=i,this.isOperatorNode=!0}getOperatorMethod(e,r){return e.getMethod(wte[this.op],r)}getNodeType(e){let r=this.op,i=this.aNode,s=this.bNode,n=i.getNodeType(e),a=s?s.getNodeType(e):null;if(n==="void"||a==="void")return"void";if(r==="%")return n;if(r==="~"||r==="&"||r==="|"||r==="^"||r===">>"||r==="<<")return e.getIntegerType(n);if(r==="!"||r==="&&"||r==="||"||r==="^^")return"bool";if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){let o=Math.max(e.getTypeLength(n),e.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(e.isMatrix(n)){if(a==="float")return n;if(e.isVector(a))return e.getVectorFromMatrix(n);if(e.isMatrix(a))return n}else if(e.isMatrix(a)){if(n==="float")return a;if(e.isVector(n))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(n)?a:n}}generate(e,r){let i=this.op,{aNode:s,bNode:n}=this,a=this.getNodeType(e),o=null,l=null;a==="void"?o=l=a:(o=s.getNodeType(e),l=n?n.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="||i==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):i==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):o=e.isMatrix(l)?o==="float"?"float":e.isVector(o)?e.getVectorFromMatrix(l):l=a:l=a);let h=s.build(e,o),u=n?n.build(e,l):null,c=e.getFunctionOperator(i);if(r!=="void"){let d=e.renderer.coordinateSystem===Tl;if(i==="=="||i==="!="||i==="<"||i===">"||i==="<="||i===">=")return d&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,r)}( ${h}, ${u} )`,a,r):e.format(`( ${h} ${i} ${u} )`,a,r);if(i==="%")return e.isInteger(l)?e.format(`( ${h} % ${u} )`,a,r):e.format(`${this.getOperatorMethod(e,a)}( ${h}, ${u} )`,a,r);if(i==="!"||i==="~")return e.format(`(${i}${h})`,o,r);if(c)return e.format(`${c}( ${h}, ${u} )`,a,r);if(e.isMatrix(o)&&l==="float")return e.format(`( ${u} ${i} ${h} )`,a,r);if(o==="float"&&e.isMatrix(l))return e.format(`${h} ${i} ${u}`,a,r);{let m=`( ${h} ${i} ${u} )`;return!d&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(m=`all${m}`),e.format(m,a,r)}}else if(o!=="void")return c?e.format(`${c}( ${h}, ${u} )`,a,r):e.isMatrix(o)&&l==="float"?e.format(`${u} ${i} ${h}`,a,r):e.format(`${h} ${i} ${u}`,a,r)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const m5=de(yr,"+").setParameterLength(2,1/0).setName("add"),Kb=de(yr,"-").setParameterLength(2,1/0).setName("sub"),pT=de(yr,"*").setParameterLength(2,1/0).setName("mul"),p5=de(yr,"/").setParameterLength(2,1/0).setName("div"),py=de(yr,"%").setParameterLength(2).setName("mod"),f5=de(yr,"==").setParameterLength(2).setName("equal"),Ste=de(yr,"!=").setParameterLength(2).setName("notEqual"),Mte=de(yr,"<").setParameterLength(2).setName("lessThan"),_te=de(yr,">").setParameterLength(2).setName("greaterThan"),Nte=de(yr,"<=").setParameterLength(2).setName("lessThanEqual"),Ete=de(yr,">=").setParameterLength(2).setName("greaterThanEqual"),Ate=de(yr,"&&").setParameterLength(2,1/0).setName("and"),Cte=de(yr,"||").setParameterLength(2,1/0).setName("or"),Rte=de(yr,"!").setParameterLength(1).setName("not"),Pte=de(yr,"^^").setParameterLength(2).setName("xor"),Ite=de(yr,"&").setParameterLength(2).setName("bitAnd"),Vte=de(yr,"~").setParameterLength(2).setName("bitNot"),Ote=de(yr,"|").setParameterLength(2).setName("bitOr"),Lte=de(yr,"^").setParameterLength(2).setName("bitXor"),Fte=de(yr,"<<").setParameterLength(2).setName("shiftLeft"),zte=de(yr,">>").setParameterLength(2).setName("shiftRight"),Bte=Xs(([t])=>(t.addAssign(1),t)),kte=Xs(([t])=>(t.subAssign(1),t)),Ute=Xs(([t])=>{let e=sm(t).toConst();return t.addAssign(1),e}),Dte=Xs(([t])=>{let e=sm(t).toConst();return t.subAssign(1),e});H("add",m5),H("sub",Kb),H("mul",pT),H("div",p5),H("mod",py),H("equal",f5),H("notEqual",Ste),H("lessThan",Mte),H("greaterThan",_te),H("lessThanEqual",Nte),H("greaterThanEqual",Ete),H("and",Ate),H("or",Cte),H("not",Rte),H("xor",Pte),H("bitAnd",Ite),H("bitNot",Vte),H("bitOr",Ote),H("bitXor",Lte),H("shiftLeft",Fte),H("shiftRight",zte),H("incrementBefore",Bte),H("decrementBefore",kte),H("increment",Ute),H("decrement",Dte);const $te=(t,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),py(t,e)),Gte=(t,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),py(sm(t),sm(e)));H("remainder",$te),H("modInt",Gte);var D=class zt extends Ts{static get type(){return"MathNode"}constructor(e,r,i=null,s=null){if(super(),(e===zt.MAX||e===zt.MIN)&&arguments.length>3){let n=new zt(e,r,i);for(let a=2;a<arguments.length-1;a++)n=new zt(e,n,arguments[a]);r=n,i=arguments[arguments.length-1],s=null}this.method=e,this.aNode=r,this.bNode=i,this.cNode=s,this.isMathNode=!0}getInputType(e){let r=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,s=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(s)?0:e.getTypeLength(s);return n>a&&n>o?r:a>o?i:o>n?s:r}getNodeType(e){let r=this.method;return r===zt.LENGTH||r===zt.DISTANCE||r===zt.DOT?"float":r===zt.CROSS?"vec3":r===zt.ALL||r===zt.ANY?"bool":r===zt.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:r,bNode:i,method:s}=this,n=null;if(s===zt.ONE_MINUS)n=Kb(1,r);else if(s===zt.RECIPROCAL)n=p5(1,r);else if(s===zt.DIFFERENCE)n=fT(Kb(r,i));else if(s===zt.TRANSFORM_DIRECTION){let a=r,o=i;e.isMatrix(a.getNodeType(e))?o=ql(Tc(o),0):a=ql(Tc(a),0);let l=pT(a,o).xyz;n=g5(l)}return n===null?super.setup(e):n}generate(e,r){if(e.getNodeProperties(this).outputNode)return super.generate(e,r);let s=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,h=this.cNode,u=e.renderer.coordinateSystem;if(s===zt.NEGATE)return e.format("( - "+o.build(e,a)+" )",n,r);{let c=[];return s===zt.CROSS?c.push(o.build(e,n),l.build(e,n)):u===Tl&&s===zt.STEP?c.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===Tl&&(s===zt.MIN||s===zt.MAX)?c.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):s===zt.REFRACT?c.push(o.build(e,a),l.build(e,a),h.build(e,"float")):s===zt.MIX?c.push(o.build(e,a),l.build(e,a),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":a)):(u===Wb&&s===zt.ATAN&&l!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===zt.DFDX||s===zt.DFDY)&&(console.warn(`THREE.TSL: '${s}' is not supported in the ${e.shaderStage} stage.`),s="/*"+s+"*/"),c.push(o.build(e,a)),l!==null&&c.push(l.build(e,a)),h!==null&&c.push(h.build(e,a))),e.format(`${e.getMethod(s,n)}( ${c.join(", ")} )`,n,r)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};D.ALL="all",D.ANY="any",D.RADIANS="radians",D.DEGREES="degrees",D.EXP="exp",D.EXP2="exp2",D.LOG="log",D.LOG2="log2",D.SQRT="sqrt",D.INVERSE_SQRT="inversesqrt",D.FLOOR="floor",D.CEIL="ceil",D.NORMALIZE="normalize",D.FRACT="fract",D.SIN="sin",D.COS="cos",D.TAN="tan",D.ASIN="asin",D.ACOS="acos",D.ATAN="atan",D.ABS="abs",D.SIGN="sign",D.LENGTH="length",D.NEGATE="negate",D.ONE_MINUS="oneMinus",D.DFDX="dFdx",D.DFDY="dFdy",D.ROUND="round",D.RECIPROCAL="reciprocal",D.TRUNC="trunc",D.FWIDTH="fwidth",D.TRANSPOSE="transpose",D.BITCAST="bitcast",D.EQUALS="equals",D.MIN="min",D.MAX="max",D.STEP="step",D.REFLECT="reflect",D.DISTANCE="distance",D.DIFFERENCE="difference",D.DOT="dot",D.CROSS="cross",D.POW="pow",D.TRANSFORM_DIRECTION="transformDirection",D.MIX="mix",D.CLAMP="clamp",D.REFRACT="refract",D.SMOOTHSTEP="smoothstep",D.FACEFORWARD="faceforward";const jte=za(Math.PI),Wte=de(D,D.ALL).setParameterLength(1),Hte=de(D,D.ANY).setParameterLength(1),qte=de(D,D.RADIANS).setParameterLength(1),Xte=de(D,D.DEGREES).setParameterLength(1),Yte=de(D,D.EXP).setParameterLength(1),Zte=de(D,D.EXP2).setParameterLength(1),Jte=de(D,D.LOG).setParameterLength(1),Kte=de(D,D.LOG2).setParameterLength(1),Qte=de(D,D.SQRT).setParameterLength(1),ere=de(D,D.INVERSE_SQRT).setParameterLength(1),tre=de(D,D.FLOOR).setParameterLength(1),rre=de(D,D.CEIL).setParameterLength(1),g5=de(D,D.NORMALIZE).setParameterLength(1),y5=de(D,D.FRACT).setParameterLength(1),x5=de(D,D.SIN).setParameterLength(1),ire=de(D,D.COS).setParameterLength(1),sre=de(D,D.TAN).setParameterLength(1),nre=de(D,D.ASIN).setParameterLength(1),are=de(D,D.ACOS).setParameterLength(1),b5=de(D,D.ATAN).setParameterLength(1,2),fT=de(D,D.ABS).setParameterLength(1),v5=de(D,D.SIGN).setParameterLength(1),ore=de(D,D.LENGTH).setParameterLength(1),lre=de(D,D.NEGATE).setParameterLength(1),ure=de(D,D.ONE_MINUS).setParameterLength(1),hre=de(D,D.DFDX).setParameterLength(1),cre=de(D,D.DFDY).setParameterLength(1),dre=de(D,D.ROUND).setParameterLength(1),mre=de(D,D.RECIPROCAL).setParameterLength(1),pre=de(D,D.TRUNC).setParameterLength(1),fre=de(D,D.FWIDTH).setParameterLength(1),gre=de(D,D.TRANSPOSE).setParameterLength(1),yre=(t,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),f5(t,e)),xre=de(D,D.MIN).setParameterLength(2,1/0),bre=de(D,D.MAX).setParameterLength(2,1/0),vre=de(D,D.STEP).setParameterLength(2),Tre=de(D,D.REFLECT).setParameterLength(2),wre=de(D,D.DISTANCE).setParameterLength(2),Sre=de(D,D.DIFFERENCE).setParameterLength(2),Om=de(D,D.DOT).setParameterLength(2),Mre=de(D,D.CROSS).setParameterLength(2),T5=de(D,D.POW).setParameterLength(2),_re=de(D,D.POW,2).setParameterLength(1),Nre=de(D,D.POW,3).setParameterLength(1),Ere=de(D,D.POW,4).setParameterLength(1),Are=de(D,D.TRANSFORM_DIRECTION).setParameterLength(2),Cre=t=>pT(v5(t),T5(fT(t),1/3)),Rre=t=>Om(t,t),fy=de(D,D.MIX).setParameterLength(3),w5=(t,e=0,r=1)=>Re(new D(D.CLAMP,Re(t),Re(e),Re(r))),Pre=t=>w5(t),Ire=de(D,D.REFRACT).setParameterLength(3),Vre=de(D,D.SMOOTHSTEP).setParameterLength(3),Ore=de(D,D.FACEFORWARD).setParameterLength(3),Lre=Xs(([t])=>{let e=Om(t.xy,c5(12.9898,78.233)),r=py(e,jte);return y5(x5(r).mul(43758.5453))}),Fre=(t,e,r)=>fy(e,r,t),zre=(t,e,r)=>Vre(e,r,t),Bre=(t,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),b5(t,e));H("all",Wte),H("any",Hte),H("equals",yre),H("radians",qte),H("degrees",Xte),H("exp",Yte),H("exp2",Zte),H("log",Jte),H("log2",Kte),H("sqrt",Qte),H("inverseSqrt",ere),H("floor",tre),H("ceil",rre),H("normalize",g5),H("fract",y5),H("sin",x5),H("cos",ire),H("tan",sre),H("asin",nre),H("acos",are),H("atan",b5),H("abs",fT),H("sign",v5),H("length",ore),H("lengthSq",Rre),H("negate",lre),H("oneMinus",ure),H("dFdx",hre),H("dFdy",cre),H("round",dre),H("reciprocal",mre),H("trunc",pre),H("fwidth",fre),H("atan2",Bre),H("min",xre),H("max",bre),H("step",vre),H("reflect",Tre),H("distance",wre),H("dot",Om),H("cross",Mre),H("pow",T5),H("pow2",_re),H("pow3",Nre),H("pow4",Ere),H("transformDirection",Are),H("mix",Fre),H("clamp",w5),H("refract",Ire),H("smoothstep",zre),H("faceForward",Ore),H("difference",Sre),H("saturate",Pre),H("cbrt",Cre),H("transpose",gre),H("rand",Lre);var j_=class extends Ts{static get type(){return"ArrayNode"}constructor(t,e,r=null){super(t),this.count=e,this.values=r,this.isArrayNode=!0}getNodeType(t){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(t)),this.nodeType}getElementType(t){return this.getNodeType(t)}generate(t){let e=this.getNodeType(t);return t.generateArray(e,this.count,this.values)}};const kre=(...t)=>{let e;if(t.length===1){let r=t[0];e=new j_(null,r.length,r)}else{let r=t[0],i=t[1];e=new j_(r,i)}return Re(e)};H("toArray",(t,e)=>kre(Array(e).fill(t)));var S5=class extends Cr{static get type(){return"UniformGroupNode"}constructor(t,e=!1,r=1){super("string"),this.name=t,this.shared=e,this.order=r,this.isUniformGroup=!0}serialize(t){super.serialize(t),t.name=this.name,t.version=this.version,t.shared=this.shared}deserialize(t){super.deserialize(t),this.name=t.name,this.version=t.version,this.shared=t.shared}};const Ure=t=>new S5(t),Dre=(t,e=0)=>new S5(t,!0,e),$re=Dre("render"),Gre=Ure("object");var jre=class extends hT{static get type(){return"UniformNode"}constructor(t,e=null){super(t,e),this.isUniformNode=!0,this.name="",this.groupNode=Gre}label(t){return this.name=t,this}setGroup(t){return this.groupNode=t,this}getGroup(){return this.groupNode}getUniformHash(t){return this.getHash(t)}onUpdate(t,e){let r=this.getSelf();return t=t.bind(r),super.onUpdate(i=>{let s=t(i,r);s!==void 0&&(this.value=s)},e)}generate(t,e){let r=this.getNodeType(t),i=this.getUniformHash(t),s=t.getNodeFromHash(i);s===void 0&&(t.setHashNode(this,i),s=this);let n=s.getInputType(t),a=t.getUniformFromNode(s,n,t.shaderStage,this.name||t.context.label),o=t.getPropertyName(a);return t.context.label!==void 0&&delete t.context.label,t.format(o,r,e)}};const Wre=(t,e)=>{let r=rte(e||t),i=t;return Re(new jre(i,r))};var Hre=class extends Cr{static get type(){return"PropertyNode"}constructor(t,e=null,r=!1){super(t),this.name=e,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(t){return this.name||super.getHash(t)}generate(t){let e;return this.varying===!0?(e=t.getVaryingFromNode(this,this.name),e.needsInterpolation=!0):e=t.getVarFromNode(this,this.name),t.getPropertyName(e)}};const qre=(t,e)=>Re(new Hre(t,e));var Xre=class extends Ts{static get type(){return"AssignNode"}constructor(t,e){super(),this.targetNode=t,this.sourceNode=e,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(t,e){return e==="void"?"void":this.targetNode.getNodeType(t)}needsSplitAssign(t){let{targetNode:e}=this;if(t.isAvailable("swizzleAssign")===!1&&e.isSplitNode&&e.components.length>1){let r=t.getTypeLength(e.node.getNodeType(t));return Im.join("").slice(0,r)!==e.components}return!1}setup(t){let{targetNode:e,sourceNode:r}=this,i=t.getNodeProperties(this);i.sourceNode=r,i.targetNode=e.context({assign:!0})}generate(t,e){let{targetNode:r,sourceNode:i}=t.getNodeProperties(this),s=this.needsSplitAssign(t),n=r.getNodeType(t),a=r.build(t),o=i.build(t,n),l=i.getNodeType(t),h=t.getDataFromNode(this),u;if(h.initialized===!0)e!=="void"&&(u=a);else if(s){let c=t.getVarFromNode(this,null,n),d=t.getPropertyName(c);t.addLineFlowCode(`${d} = ${o}`,this);let m=r.node,p=m.node.context({assign:!0}),f=p.build(t);for(let g=0;g<m.components.length;g++){let y=m.components[g];t.addLineFlowCode(`${f}.${y} = ${d}[ ${g} ]`,this)}e!=="void"&&(u=a)}else u=`${a} = ${o}`,(e==="void"||l==="void")&&(t.addLineFlowCode(u,this),e!=="void"&&(u=a));return h.initialized=!0,t.format(u,n,e)}};const Yre=de(Xre).setParameterLength(2);H("assign",Yre);var Zre=class extends Ts{static get type(){return"FunctionCallNode"}constructor(t=null,e={}){super(),this.functionNode=t,this.parameters=e}setParameters(t){return this.parameters=t,this}getParameters(){return this.parameters}getNodeType(t){return this.functionNode.getNodeType(t)}generate(t){let e=[],r=this.functionNode,i=r.getInputs(t),s=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(t):o.build(t,h),c};if(Array.isArray(s)){if(s.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length<i.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<i.length;)s.push(za(0));for(let o=0;o<s.length;o++)e.push(n(s[o],i[o]))}else for(let o of i){let l=s[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),e.push(n(za(0),o))):e.push(n(l,o))}return`${r.build(t,"property")}( ${e.join(", ")} )`}};const Jre=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?kf(e):my(e[0]),Re(new Zre(Re(t),e)));H("call",Jre);var Kre=class extends Cr{static get type(){return"ConditionalNode"}constructor(t,e,r=null){super(),this.condNode=t,this.ifNode=e,this.elseNode=r}getNodeType(t){let{ifNode:e,elseNode:r}=t.getNodeProperties(this);if(e===void 0)return this.setup(t),this.getNodeType(t);let i=e.getNodeType(t);if(r!==null){let s=r.getNodeType(t);if(t.getTypeLength(s)>t.getTypeLength(i))return s}return i}setup(t){let e=this.condNode.cache(),r=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,s=t.context.nodeBlock;t.getDataFromNode(r).parentNodeBlock=s,i!==null&&(t.getDataFromNode(i).parentNodeBlock=s);let n=t.getNodeProperties(this);n.condNode=e,n.ifNode=r.context({nodeBlock:r}),n.elseNode=i?i.context({nodeBlock:i}):null}generate(t,e){let r=this.getNodeType(t),i=t.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=t.getNodeProperties(this),o=t.currentFunctionNode,l=e!=="void",h=l?qre(r).build(t):"";i.nodeProperty=h;let u=s.build(t,"bool");t.addFlowCode(`
438
438
  ${t.tab}if ( ${u} ) {
439
439
 
440
440
  `).addFlowTab();let c=n.build(t,r);if(c&&(l?c=h+" = "+c+";":(c="return "+c+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),t.removeFlowTab().addFlowCode(t.tab+" "+c+`