shaders 2.0.667 → 2.0.669

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.
@@ -1,4 +1,4 @@
1
- "use strict";var vL=Object.defineProperty;var TL=(t,e,r)=>e in t?vL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Iy=(t,e,r)=>TL(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Re=require("react/jsx-runtime"),v=require("react");var wL=Object.defineProperty,SL=(t,e)=>{for(var r in e)wL(t,r,{get:e[r],enumerable:!0})};/**
1
+ "use strict";var vL=Object.defineProperty;var TL=(t,e,r)=>e in t?vL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Iy=(t,e,r)=>TL(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ie=require("react/jsx-runtime"),v=require("react");var wL=Object.defineProperty,SL=(t,e)=>{for(var r in e)wL(t,r,{get:e[r],enumerable:!0})};/**
2
2
  * @license
3
3
  * Copyright 2010-2025 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
@@ -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,M=1-y*y;if(M>Number.EPSILON){const _=Math.sqrt(M),S=Math.atan2(_,y*T);g=Math.sin(g*S)/_,o=Math.sin(o*S)/_}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],M=s[4],w=s[7],_=s[2],S=s[5],N=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*M+l*S,n[6]=a*y+o*w+l*N,n[1]=h*f+u*T+c*_,n[4]=h*g+u*M+c*S,n[7]=h*y+u*w+c*N,n[2]=d*f+m*T+p*_,n[5]=d*g+m*M+p*S,n[8]=d*y+m*w+p*N,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 M=(h+1)/2,w=(m+1)/2,_=(y+1)/2,S=(u+d)/4,N=(c+f)/4,A=(p+g)/4;return M>w&&M>_?M<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(M),s=S/i,n=N/i):w>_?w<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=S/s,n=A/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=N/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],M=i[7],w=i[11],_=i[15],S=s[0],N=s[4],A=s[8],k=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*S+o*Q+l*se+h*ye,n[4]=a*N+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*k+o*ie+l*Me+h*be,n[1]=u*S+c*Q+d*se+m*ye,n[5]=u*N+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*k+c*ie+d*Me+m*be,n[2]=p*S+f*Q+g*se+y*ye,n[6]=p*N+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*k+f*ie+g*Me+y*be,n[3]=T*S+M*Q+w*se+_*ye,n[7]=T*N+M*J+w*ve+_*Te,n[11]=T*A+M*re+w*me+_*ge,n[15]=T*k+M*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,M=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,S=r*T+i*M+s*w+n*_;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/S;return e[0]=T*N,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*N,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*N,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*N,e[4]=M*N,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*N,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*N,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*N,e[8]=w*N,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*N,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*N,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*N,e[12]=_*N,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*N,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*N,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*N,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,M=l*u,w=l*c,_=i.x,S=i.y,N=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-M)*_,s[3]=0,s[4]=(m-w)*S,s[5]=(1-(d+y))*S,s[6]=(g+T)*S,s[7]=0,s[8]=(p+M)*N,s[9]=(g-T)*N,s[10]=(1-(d+f))*N,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,k,Q){h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,k),c.fromBufferAttribute(i,Q),d.fromBufferAttribute(n,A),m.fromBufferAttribute(n,k),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[k].add(f),o[Q].add(f),l[A].add(g),l[k].add(g),l[Q].add(g))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let A=0,k=T.length;A<k;++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 M=new $,w=new $,_=new $,S=new $;function N(A){_.fromBufferAttribute(s,A),S.copy(_);const k=o[A];M.copy(k),M.sub(_.multiplyScalar(_.dot(k))).normalize(),w.crossVectors(S,k);const J=w.dot(l[A])<0?-1:1;a.setXYZW(A,M.x,M.y,M.z,J)}for(let A=0,k=T.length;A<k;++A){const Q=T[A],J=Q.start,re=Q.count;for(let ie=J,se=J+re;ie<se;ie+=3)N(e.getX(ie+0)),N(e.getX(ie+1)),N(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),M=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=M;w<_;w+=3){const S=o.getX(w),N=o.getX(w+1),A=o.getX(w+2);s=Yp(this,y,e,i,h,u,c,S,N,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),M=o.getX(g+1),w=o.getX(g+2);s=Yp(this,a,e,i,h,u,c,T,M,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),M=Math.min(l.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=M;w<_;w+=3){const S=w,N=w+1,A=w+2;s=Yp(this,y,e,i,h,u,c,S,N,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,M=g+1,w=g+2;s=Yp(this,a,e,i,h,u,c,T,M,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,M,w,_,S,N,A,k){const Q=w/N,J=_/A,re=w/2,ie=_/2,se=S/2,ve=N+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*M,Te[y]=se,h.push(Te.x,Te.y,Te.z),Te[f]=0,Te[g]=0,Te[y]=S>0?1:-1,u.push(Te.x,Te.y,Te.z),c.push(Je/N),c.push(1-ge/A),Me+=1}}for(let ge=0;ge<A;ge++)for(let be=0;be<N;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,k),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),M=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=M,Vr.height=M;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(M/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/M;return{data:ce,width:M,height:M,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 S=new em(_.data,M,M,jv,s3);S.minFilter=$s,S.magFilter=$s,S.generateMipmaps=!1,S.needsUpdate=!0;let N=f(S),A=t.characters.uniform.value,k=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!==k||Ni!==Q)&&(console.log(`Updating atlas texture: cellSize ${k} → ${_i}`),J=Mi,_=w(ri,_i,Ni),S.image.data=_.data,S.needsUpdate=!0,re.value=_.charCount,ie.value=_.cellSize,se.value=_.uvScale,A=ri,k=_i,Q=Ni)}),r(()=>{S.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=N.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),M=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 S=h-n,N=M-T,A=_-w,k=w+_,Q=Math.abs(A),J;T*M===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(M*T)*Math.sin(J*Sh/2),ie=(n+h)/2,se=(T+M)/2,ve=UM(se),me;me=T*M===0?k:Q<=180?k/2:k<360?(k+360)/2:(k-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=(S/(r*ye))**2;return He+=(N/(i*Te))**2,He+=(re/(s*be))**2,He+=Bt*(N/(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 M=.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,S=Math.sqrt(_/(_+1900)),N=M*(S*w+1-S),A=(m/(r*T))**2;return A+=(p/(i*M))**2,A+=y/N**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(M=>M*100),i=C3(qt(A3,r).map((M,w)=>M*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),M=fs(Ht(t,T.space),T.id);if(Vo(M)&&(M=0),M>=n.max)return Ht({space:"xyz-d65",coords:Oi.D65},t.space);if(M<=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,M)=>{Vo(T)&&(d.coords[M]=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[M,w]=g[T].range;return x3(M,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,M=t.colorB.uniform,w=t.colorC.uniform,_=t.size.uniform,S=t.conformity.uniform,N=t.edgeWidth.uniform,A=t.edgeCurve.uniform,k=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(S),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(S).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(S).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(S).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(S).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(S).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(N),Ot.sub(N),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(k).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,M.rgb,ut),Lt=c(Pt,w.rgb,ht),ar=T.a.add(M.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),M=n(p[g]),w=c.sample(T);f=f.add(w.mul(M))}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),M=a(0),w=a(0),_=.5,S=.5,N=Date.now();e(({pointer:Vr})=>{let zi=Date.now(),ii=Math.min((zi-N)/1e3,.016);N=zi;let he=ii>0?(Vr.x-_)/ii:0,oe=ii>0?(Vr.y-S)/ii:0;M.value=M.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(M.value*M.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]+=M.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,S=Vr.y}),r(()=>{m.dispose(),p.dispose()});let A=g.sample(o).x,k=i(n(1/128),n(1/128)),Q=g.sample(o.add(i(k.x,n(0)))).x,J=g.sample(o.add(i(n(0),k.y))).x,re=g.sample(o.add(i(k.x.negate(),n(0)))).x,ie=g.sample(o.add(i(n(0),k.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,M=t.scanlineIntensity.uniform,w=t.scanlineFrequency.uniform,_=t.brightness.uniform,S=t.contrast.uniform,N=t.curvature.uniform,A=t.scaleToFill.uniform,k=A.greaterThan(a(.5)).select(a(1).add(N.mul(a(2))),a(1)),Q=o.sub(i(.5,.5)).div(k).add(i(.5,.5)),J=Q.sub(i(.5,.5)),re=d(J),ie=N.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(S).add(a(.5)).mul(_),He=se.y.mul(w),Wr=l(He.mul(a(3.14159*2))),Hr=a(1).sub(M.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,M=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(M,m.add(w.sub(.5))),S=u(t.colorA.uniform.rgb,t.colorB.uniform.rgb,_),N=u(t.colorA.uniform.a,t.colorB.uniform.a,_);return s(S,N)}},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),M=i(d.x.mul(T),d.y.oneMinus()),w=M.mul(m),_=w.sub(a(w)),S=n(_.sub(.5)),N=n(JR(M.mul(m))),A=o(1).sub(s(p.mul(.5),p.mul(.5).add(N.mul(.5)),S)),k=a(w),Q=k.x.mul(12.9898).add(k.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,M=t.tileCount.uniform,w=i(g.greaterThanEqual(1).select(a(M,g),M),g.lessThan(1).select(o(M,g),M)),_=o(n(a(y,w)),w),S=l(y,_),N=i(.5,.5),A=a(T,.025),k=o(S,o(i(1),w)),Q=l(k,N),J=a(Q,A),re=h(S,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],M=s[4],w=s[7],_=s[2],S=s[5],N=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*M+l*S,n[6]=a*y+o*w+l*N,n[1]=h*f+u*T+c*_,n[4]=h*g+u*M+c*S,n[7]=h*y+u*w+c*N,n[2]=d*f+m*T+p*_,n[5]=d*g+m*M+p*S,n[8]=d*y+m*w+p*N,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,M=1-y*y;if(M>2**-52){let _=Math.sqrt(M),S=Math.atan2(_,y*T);g=Math.sin(g*S)/_,o=Math.sin(o*S)/_}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],M=i[7],w=i[11],_=i[15],S=s[0],N=s[4],A=s[8],k=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*S+o*Q+l*se+h*ye,n[4]=a*N+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*k+o*ie+l*Me+h*be,n[1]=u*S+c*Q+d*se+m*ye,n[5]=u*N+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*k+c*ie+d*Me+m*be,n[2]=p*S+f*Q+g*se+y*ye,n[6]=p*N+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*k+f*ie+g*Me+y*be,n[3]=T*S+M*Q+w*se+_*ye,n[7]=T*N+M*J+w*ve+_*Te,n[11]=T*A+M*re+w*me+_*ge,n[15]=T*k+M*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,M=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,S=r*T+i*M+s*w+n*_;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/S;return e[0]=T*N,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*N,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*N,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*N,e[4]=M*N,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*N,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*N,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*N,e[8]=w*N,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*N,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*N,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*N,e[12]=_*N,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*N,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*N,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*N,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,M=l*u,w=l*c,_=i.x,S=i.y,N=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-M)*_,s[3]=0,s[4]=(m-w)*S,s[5]=(1-(d+y))*S,s[6]=(g+T)*S,s[7]=0,s[8]=(p+M)*N,s[9]=(g-T)*N,s[10]=(1-(d+f))*N,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 M=(h+1)/2,w=(m+1)/2,_=(y+1)/2,S=(u+d)/4,N=(c+f)/4,A=(p+g)/4;return M>w&&M>_?M<a?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(M),s=S/i,n=N/i):w>_?w<a?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=S/s,n=A/s):_<a?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=N/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),Pe(new k_(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D_(e.slice(3).toLowerCase()),i=>Pe(new kee(t,e,Pe(i)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D_(e.slice(4).toLowerCase()),()=>Pe(new Dee(Pe(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Pe(new k_(t,e));if(/^\d+$/.test(e)===!0)return Pe(new uT(r,new Wa(Number(e),"uint")));if(/^get$/.test(e)===!0)return i=>Pe(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 Pe(Zb(t,e));if(r==="shader")return Xs(t)}return t},qee=function(t,e=null){for(let r in t)t[r]=Pe(t[r],e);return t},Xee=function(t,e=null){let r=t.length;for(let i=0;i<r;i++)t[i]=Pe(t[i],e);return t},Yee=function(t,e=null,r=null,i=null){let s=u=>Pe(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=Pe(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=Pe(t.buildFunctionNode(e)),a.set(e,o)),t.addInclude(o),n=Pe(o.call(r))}else{let a=e.jsFunc,o=r!==null||a.length>1?a(r||[],t):a(t);n=Pe(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),Pe(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 Pe(e.get(r[0]));if(r.length===1){let s=Zb(r[0],t);return tte(s)===t?Pe(s):Pe(new o5(s,t))}let i=r.map(s=>Zb(s));return Pe(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 Pe=(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)=>Pe(new o5(Pe(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)=>Pe(new D(D.CLAMP,Pe(t),Pe(e),Pe(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 Pe(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 Pe(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)=>Pe(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]),Pe(new Zre(Pe(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,M=1-y*y;if(M>Number.EPSILON){const _=Math.sqrt(M),S=Math.atan2(_,y*T);g=Math.sin(g*S)/_,o=Math.sin(o*S)/_}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],M=s[4],w=s[7],_=s[2],S=s[5],N=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*M+l*S,n[6]=a*y+o*w+l*N,n[1]=h*f+u*T+c*_,n[4]=h*g+u*M+c*S,n[7]=h*y+u*w+c*N,n[2]=d*f+m*T+p*_,n[5]=d*g+m*M+p*S,n[8]=d*y+m*w+p*N,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 M=(h+1)/2,w=(m+1)/2,_=(y+1)/2,S=(u+d)/4,N=(c+f)/4,A=(p+g)/4;return M>w&&M>_?M<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(M),s=S/i,n=N/i):w>_?w<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=S/s,n=A/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=N/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],M=i[7],w=i[11],_=i[15],S=s[0],N=s[4],A=s[8],k=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*S+o*Q+l*se+h*ye,n[4]=a*N+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*k+o*ie+l*Me+h*be,n[1]=u*S+c*Q+d*se+m*ye,n[5]=u*N+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*k+c*ie+d*Me+m*be,n[2]=p*S+f*Q+g*se+y*ye,n[6]=p*N+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*k+f*ie+g*Me+y*be,n[3]=T*S+M*Q+w*se+_*ye,n[7]=T*N+M*J+w*ve+_*Te,n[11]=T*A+M*re+w*me+_*ge,n[15]=T*k+M*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,M=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,S=r*T+i*M+s*w+n*_;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/S;return e[0]=T*N,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*N,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*N,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*N,e[4]=M*N,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*N,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*N,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*N,e[8]=w*N,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*N,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*N,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*N,e[12]=_*N,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*N,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*N,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*N,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,M=l*u,w=l*c,_=i.x,S=i.y,N=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-M)*_,s[3]=0,s[4]=(m-w)*S,s[5]=(1-(d+y))*S,s[6]=(g+T)*S,s[7]=0,s[8]=(p+M)*N,s[9]=(g-T)*N,s[10]=(1-(d+f))*N,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,k,Q){h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,k),c.fromBufferAttribute(i,Q),d.fromBufferAttribute(n,A),m.fromBufferAttribute(n,k),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[k].add(f),o[Q].add(f),l[A].add(g),l[k].add(g),l[Q].add(g))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let A=0,k=T.length;A<k;++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 M=new $,w=new $,_=new $,S=new $;function N(A){_.fromBufferAttribute(s,A),S.copy(_);const k=o[A];M.copy(k),M.sub(_.multiplyScalar(_.dot(k))).normalize(),w.crossVectors(S,k);const J=w.dot(l[A])<0?-1:1;a.setXYZW(A,M.x,M.y,M.z,J)}for(let A=0,k=T.length;A<k;++A){const Q=T[A],J=Q.start,re=Q.count;for(let ie=J,se=J+re;ie<se;ie+=3)N(e.getX(ie+0)),N(e.getX(ie+1)),N(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),M=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=M;w<_;w+=3){const S=o.getX(w),N=o.getX(w+1),A=o.getX(w+2);s=Yp(this,y,e,i,h,u,c,S,N,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),M=o.getX(g+1),w=o.getX(g+2);s=Yp(this,a,e,i,h,u,c,T,M,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),M=Math.min(l.count,Math.min(g.start+g.count,m.start+m.count));for(let w=T,_=M;w<_;w+=3){const S=w,N=w+1,A=w+2;s=Yp(this,y,e,i,h,u,c,S,N,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,M=g+1,w=g+2;s=Yp(this,a,e,i,h,u,c,T,M,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,M,w,_,S,N,A,k){const Q=w/N,J=_/A,re=w/2,ie=_/2,se=S/2,ve=N+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*M,Te[y]=se,h.push(Te.x,Te.y,Te.z),Te[f]=0,Te[g]=0,Te[y]=S>0?1:-1,u.push(Te.x,Te.y,Te.z),c.push(Je/N),c.push(1-ge/A),Me+=1}}for(let ge=0;ge<A;ge++)for(let be=0;be<N;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,k),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),M=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=M,Vr.height=M;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(M/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/M;return{data:ce,width:M,height:M,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 S=new em(_.data,M,M,jv,s3);S.minFilter=$s,S.magFilter=$s,S.generateMipmaps=!1,S.needsUpdate=!0;let N=f(S),A=t.characters.uniform.value,k=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!==k||Ni!==Q)&&(console.log(`Updating atlas texture: cellSize ${k} → ${_i}`),J=Mi,_=w(ri,_i,Ni),S.image.data=_.data,S.needsUpdate=!0,re.value=_.charCount,ie.value=_.cellSize,se.value=_.uvScale,A=ri,k=_i,Q=Ni)}),r(()=>{S.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=N.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),M=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 S=h-n,N=M-T,A=_-w,k=w+_,Q=Math.abs(A),J;T*M===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(M*T)*Math.sin(J*Sh/2),ie=(n+h)/2,se=(T+M)/2,ve=UM(se),me;me=T*M===0?k:Q<=180?k/2:k<360?(k+360)/2:(k-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=(S/(r*ye))**2;return He+=(N/(i*Te))**2,He+=(re/(s*be))**2,He+=Bt*(N/(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 M=.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,S=Math.sqrt(_/(_+1900)),N=M*(S*w+1-S),A=(m/(r*T))**2;return A+=(p/(i*M))**2,A+=y/N**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(M=>M*100),i=C3(qt(A3,r).map((M,w)=>M*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),M=fs(Ht(t,T.space),T.id);if(Vo(M)&&(M=0),M>=n.max)return Ht({space:"xyz-d65",coords:Oi.D65},t.space);if(M<=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,M)=>{Vo(T)&&(d.coords[M]=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[M,w]=g[T].range;return x3(M,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,M=t.colorB.uniform,w=t.colorC.uniform,_=t.size.uniform,S=t.conformity.uniform,N=t.edgeWidth.uniform,A=t.edgeCurve.uniform,k=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(S),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(S).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(S).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(S).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(S).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(S).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(N),Ot.sub(N),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(k).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,M.rgb,ut),Lt=c(Pt,w.rgb,ht),ar=T.a.add(M.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),M=n(p[g]),w=c.sample(T);f=f.add(w.mul(M))}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),M=a(0),w=a(0),_=.5,S=.5,N=Date.now();e(({pointer:Vr})=>{let zi=Date.now(),ii=Math.min((zi-N)/1e3,.016);N=zi;let he=ii>0?(Vr.x-_)/ii:0,oe=ii>0?(Vr.y-S)/ii:0;M.value=M.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(M.value*M.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]+=M.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,S=Vr.y}),r(()=>{m.dispose(),p.dispose()});let A=g.sample(o).x,k=i(n(1/128),n(1/128)),Q=g.sample(o.add(i(k.x,n(0)))).x,J=g.sample(o.add(i(n(0),k.y))).x,re=g.sample(o.add(i(k.x.negate(),n(0)))).x,ie=g.sample(o.add(i(n(0),k.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,M=t.scanlineIntensity.uniform,w=t.scanlineFrequency.uniform,_=t.brightness.uniform,S=t.contrast.uniform,N=t.curvature.uniform,A=t.scaleToFill.uniform,k=A.greaterThan(a(.5)).select(a(1).add(N.mul(a(2))),a(1)),Q=o.sub(i(.5,.5)).div(k).add(i(.5,.5)),J=Q.sub(i(.5,.5)),re=d(J),ie=N.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(S).add(a(.5)).mul(_),He=se.y.mul(w),Wr=l(He.mul(a(3.14159*2))),Hr=a(1).sub(M.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,M=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(M,m.add(w.sub(.5))),S=u(t.colorA.uniform.rgb,t.colorB.uniform.rgb,_),N=u(t.colorA.uniform.a,t.colorB.uniform.a,_);return s(S,N)}},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),M=i(d.x.mul(T),d.y.oneMinus()),w=M.mul(m),_=w.sub(a(w)),S=n(_.sub(.5)),N=n(JR(M.mul(m))),A=o(1).sub(s(p.mul(.5),p.mul(.5).add(N.mul(.5)),S)),k=a(w),Q=k.x.mul(12.9898).add(k.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,M=t.tileCount.uniform,w=i(g.greaterThanEqual(1).select(a(M,g),M),g.lessThan(1).select(o(M,g),M)),_=o(n(a(y,w)),w),S=l(y,_),N=i(.5,.5),A=a(T,.025),k=o(S,o(i(1),w)),Q=l(k,N),J=a(Q,A),re=h(S,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],M=s[4],w=s[7],_=s[2],S=s[5],N=s[8];return n[0]=a*f+o*T+l*_,n[3]=a*g+o*M+l*S,n[6]=a*y+o*w+l*N,n[1]=h*f+u*T+c*_,n[4]=h*g+u*M+c*S,n[7]=h*y+u*w+c*N,n[2]=d*f+m*T+p*_,n[5]=d*g+m*M+p*S,n[8]=d*y+m*w+p*N,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,M=1-y*y;if(M>2**-52){let _=Math.sqrt(M),S=Math.atan2(_,y*T);g=Math.sin(g*S)/_,o=Math.sin(o*S)/_}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],M=i[7],w=i[11],_=i[15],S=s[0],N=s[4],A=s[8],k=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*S+o*Q+l*se+h*ye,n[4]=a*N+o*J+l*ve+h*Te,n[8]=a*A+o*re+l*me+h*ge,n[12]=a*k+o*ie+l*Me+h*be,n[1]=u*S+c*Q+d*se+m*ye,n[5]=u*N+c*J+d*ve+m*Te,n[9]=u*A+c*re+d*me+m*ge,n[13]=u*k+c*ie+d*Me+m*be,n[2]=p*S+f*Q+g*se+y*ye,n[6]=p*N+f*J+g*ve+y*Te,n[10]=p*A+f*re+g*me+y*ge,n[14]=p*k+f*ie+g*Me+y*be,n[3]=T*S+M*Q+w*se+_*ye,n[7]=T*N+M*J+w*ve+_*Te,n[11]=T*A+M*re+w*me+_*ge,n[15]=T*k+M*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,M=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,S=r*T+i*M+s*w+n*_;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let N=1/S;return e[0]=T*N,e[1]=(f*d*n-c*g*n-f*s*m+i*g*m+c*s*y-i*d*y)*N,e[2]=(o*g*n-f*l*n+f*s*h-i*g*h-o*s*y+i*l*y)*N,e[3]=(c*l*n-o*d*n-c*s*h+i*d*h+o*s*m-i*l*m)*N,e[4]=M*N,e[5]=(u*g*n-p*d*n+p*s*m-r*g*m-u*s*y+r*d*y)*N,e[6]=(p*l*n-a*g*n-p*s*h+r*g*h+a*s*y-r*l*y)*N,e[7]=(a*d*n-u*l*n+u*s*h-r*d*h-a*s*m+r*l*m)*N,e[8]=w*N,e[9]=(p*c*n-u*f*n-p*i*m+r*f*m+u*i*y-r*c*y)*N,e[10]=(a*f*n-p*o*n+p*i*h-r*f*h-a*i*y+r*o*y)*N,e[11]=(u*o*n-a*c*n-u*i*h+r*c*h+a*i*m-r*o*m)*N,e[12]=_*N,e[13]=(u*f*s-p*c*s+p*i*d-r*f*d-u*i*g+r*c*g)*N,e[14]=(p*o*s-a*f*s-p*i*l+r*f*l+a*i*g-r*o*g)*N,e[15]=(a*c*s-u*o*s+u*i*l-r*c*l-a*i*d+r*o*d)*N,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,M=l*u,w=l*c,_=i.x,S=i.y,N=i.z;return s[0]=(1-(f+y))*_,s[1]=(m+w)*_,s[2]=(p-M)*_,s[3]=0,s[4]=(m-w)*S,s[5]=(1-(d+y))*S,s[6]=(g+T)*S,s[7]=0,s[8]=(p+M)*N,s[9]=(g-T)*N,s[10]=(1-(d+f))*N,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 M=(h+1)/2,w=(m+1)/2,_=(y+1)/2,S=(u+d)/4,N=(c+f)/4,A=(p+g)/4;return M>w&&M>_?M<a?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(M),s=S/i,n=N/i):w>_?w<a?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(w),i=S/s,n=A/s):_<a?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=N/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+`
@@ -447,15 +447,15 @@ ${t.tab}if ( ${u} ) {
447
447
 
448
448
  `)}else t.addFlowCode(`
449
449
 
450
- `);return t.format(h,r,e)}};const gT=de(Kre).setParameterLength(2,3);H("select",gT);const Qre=(...t)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),gT(...t));H("cond",Qre);var eie=class extends Cr{static get type(){return"ContextNode"}constructor(t,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}analyze(t){let e=t.getContext();t.setContext({...t.context,...this.value}),this.node.build(t),t.setContext(e)}setup(t){let e=t.getContext();t.setContext({...t.context,...this.value}),this.node.build(t),t.setContext(e)}generate(t,e){let r=t.getContext();t.setContext({...t.context,...this.value});let i=this.node.build(t,e);return t.setContext(r),i}};const M5=de(eie).setParameterLength(1,2),tie=(t,e)=>M5(t,{label:e});H("context",M5),H("label",tie);var rie=class extends Cr{static get type(){return"VarNode"}constructor(t,e=null,r=!1){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(t,e){return this.node.getMemberType(t,e)}getElementType(t){return this.node.getElementType(t)}getNodeType(t){return this.node.getNodeType(t)}generate(t){let{node:e,name:r,readOnly:i}=this,{renderer:s}=t,n=s.backend.isWebGPUBackend===!0,a=!1,o=!1;i&&(a=t.isDeterministic(e),o=n?i:a);let l=t.getVectorType(this.getNodeType(t)),h=e.build(t,l),u=t.getVarFromNode(this,r,l,void 0,o),c=t.getPropertyName(u),d=c;if(o)if(n)d=a?`const ${c}`:`let ${c}`;else{let m=t.getArrayCount(e);d=`const ${t.getVar(u.type,c,m)}`}return t.addLineFlowCode(`${d} = ${h}`,this),c}};const yT=de(rie),iie=(t,e=null)=>yT(t,e).toStack(),sie=(t,e=null)=>yT(t,e,!0).toStack();H("toVar",iie),H("toConst",sie);const nie=t=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),yT(t));H("temp",nie);var aie=class extends Cr{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,e=null){return this.interpolationType=t,this.interpolationSampling=e,this}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){let e=t.getNodeProperties(this),r=e.varying;if(r===void 0){let i=this.name,s=this.getNodeType(t),n=this.interpolationType,a=this.interpolationSampling;e.varying=r=t.getVaryingFromNode(this,i,s,n,a),e.node=this.node}return r.needsInterpolation||(r.needsInterpolation=t.shaderStage==="fragment"),r}setup(t){this.setupVarying(t),t.flowNodeFromShaderStage(af.VERTEX,this.node)}analyze(t){this.setupVarying(t),t.flowNodeFromShaderStage(af.VERTEX,this.node)}generate(t){let e=t.getNodeProperties(this),r=this.setupVarying(t);if(e.propertyName===void 0){let i=this.getNodeType(t),s=t.getPropertyName(r,af.VERTEX);t.flowNodeFromShaderStage(af.VERTEX,this.node,i,s),e.propertyName=s}return t.getPropertyName(r)}};const Dd=de(aie).setParameterLength(1,2),oie=t=>Dd(t);H("toVarying",Dd),H("toVertexStage",oie),H("varying",(...t)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Dd(...t))),H("vertexStage",(...t)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Dd(...t)));const lie=Xs(([t])=>{let e=t.mul(.9478672986).add(.0521327014).pow(2.4),r=t.mul(.0773993808),i=t.lessThanEqual(.04045);return fy(e,r,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uie=Xs(([t])=>{let e=t.pow(.41666).mul(1.055).sub(.055),r=t.mul(12.92),i=t.lessThanEqual(.0031308);return fy(e,r,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),xT="WorkingColorSpace";var _5=class extends Ts{static get type(){return"ColorSpaceNode"}constructor(t,e,r){super("vec4"),this.colorNode=t,this.source=e,this.target=r}resolveColorSpace(t,e){return e===xT?_r.workingColorSpace:e==="OutputColorSpace"?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){let{colorNode:e}=this,r=this.resolveColorSpace(t,this.source),i=this.resolveColorSpace(t,this.target),s=e;return _r.enabled===!1||r===i||!r||!i||(_r.getTransfer(r)===Ud&&(s=ql(lie(s.rgb),s.a)),_r.getPrimaries(r)!==_r.getPrimaries(i)&&(s=ql(d5(_r._getMatrix(new Vm,r,i)).mul(s.rgb),s.a)),_r.getTransfer(i)===Ud&&(s=ql(uie(s.rgb),s.a))),s}};const hie=(t,e)=>Pe(new _5(Pe(t),xT,e)),cie=(t,e)=>Pe(new _5(Pe(t),e,xT));H("workingToColorSpace",hie),H("colorSpaceToWorking",cie);var die=class extends uT{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){let e=super.generate(t),r=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,r,i)}},mie=class extends Cr{static get type(){return"ReferenceBaseNode"}constructor(t,e,r=null,i=null){super(),this.property=t,this.uniformType=e,this.object=r,this.count=i,this.properties=t.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=po.OBJECT}setGroup(t){return this.group=t,this}element(t){return Pe(new die(this,Pe(t)))}setNodeType(t){let e=Wre(null,t).getSelf();this.group!==null&&e.setGroup(this.group),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){let{properties:e}=this,r=t[e[0]];for(let i=1;i<e.length;i++)r=r[e[i]];return r}updateReference(t){return this.reference=this.object===null?t.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}},pie=mie,fie=class extends pie{static get type(){return"RendererReferenceNode"}constructor(t,e,r=null){super(t,e,r),this.renderer=r,this.setGroup($re)}updateReference(t){return this.reference=this.renderer===null?t.renderer:this.renderer,this.reference}};const gie=(t,e,r=null)=>Pe(new fie(t,e,r));var yie=class extends Ts{static get type(){return"ToneMappingNode"}constructor(t,e=bie,r=null){super("vec3"),this.toneMapping=t,this.exposureNode=e,this.colorNode=r}customCacheKey(){return n5(this.toneMapping)}setup(t){let e=this.colorNode||t.context.color,r=this.toneMapping;if(r===0)return e;let i=null,s=t.renderer.library.getToneMappingFunction(r);return s===null?(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=e):i=ql(s(e.rgb,this.exposureNode),e.a),i}};const xie=(t,e,r)=>Pe(new yie(t,Pe(e),Pe(r))),bie=gie("toneMappingExposure","float");H("toneMapping",(t,e,r)=>xie(e,r,t));const Sr=new Tn,uf=new r5;let vie=0;var Tie=class{constructor(t,e,r=!1){if(Array.isArray(t))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:vie++}),this.name="",this.array=t,this.itemSize=e,this.count=t===void 0?0:t.length/e,this.normalized=r,this.usage=gg,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)uf.fromBufferAttribute(this,e),uf.applyMatrix3(t),this.setXY(e,uf.x,uf.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix3(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix4(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.applyNormalMatrix(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.transformDirection(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let r=this.array[t*this.itemSize+e];return this.normalized&&(r=cn(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=Mt(r,this.array)),this.array[t*this.itemSize+e]=r,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=cn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=cn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=cn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=cn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=Mt(e,this.array),r=Mt(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=Mt(e,this.array),r=Mt(r,this.array),i=Mt(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=Mt(e,this.array),r=Mt(r,this.array),i=Mt(i,this.array),s=Mt(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==gg&&(t.usage=this.usage),t}};const Ci=new Tn;var wie=class N5{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++)Ci.fromBufferAttribute(this,r),Ci.applyMatrix4(e),this.setXYZ(r,Ci.x,Ci.y,Ci.z);return this}applyNormalMatrix(e){for(let r=0,i=this.count;r<i;r++)Ci.fromBufferAttribute(this,r),Ci.applyNormalMatrix(e),this.setXYZ(r,Ci.x,Ci.y,Ci.z);return this}transformDirection(e){for(let r=0,i=this.count;r<i;r++)Ci.fromBufferAttribute(this,r),Ci.transformDirection(e),this.setXYZ(r,Ci.x,Ci.y,Ci.z);return this}getComponent(e,r){let i=this.array[e*this.data.stride+this.offset+r];return this.normalized&&(i=cn(i,this.array)),i}setComponent(e,r,i){return this.normalized&&(i=Mt(i,this.array)),this.data.array[e*this.data.stride+this.offset+r]=i,this}setX(e,r){return this.normalized&&(r=Mt(r,this.array)),this.data.array[e*this.data.stride+this.offset]=r,this}setY(e,r){return this.normalized&&(r=Mt(r,this.array)),this.data.array[e*this.data.stride+this.offset+1]=r,this}setZ(e,r){return this.normalized&&(r=Mt(r,this.array)),this.data.array[e*this.data.stride+this.offset+2]=r,this}setW(e,r){return this.normalized&&(r=Mt(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=cn(r,this.array)),r}getY(e){let r=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(r=cn(r,this.array)),r}getZ(e){let r=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(r=cn(r,this.array)),r}getW(e){let r=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(r=cn(r,this.array)),r}setXY(e,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(r=Mt(r,this.array),i=Mt(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=Mt(r,this.array),i=Mt(i,this.array),s=Mt(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=Mt(r,this.array),i=Mt(i,this.array),s=Mt(s,this.array),n=Mt(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.");let r=[];for(let i=0;i<this.count;i++){let s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)r.push(this.data.array[s+n])}return new Tie(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 N5(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.");let r=[];for(let i=0;i<this.count;i++){let 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}}},Sie=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t===void 0?0:t.length/e,this.usage=gg,this.updateRanges=[],this.version=0,this.uuid=Bf()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[r+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bf()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bf()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Mie=class extends hT{static get type(){return"BufferAttributeNode"}constructor(t,e=null,r=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=r,this.bufferOffset=i,this.usage=gg,this.instanced=!1,this.attribute=null,this.global=!0,t&&t.isBufferAttribute===!0&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(this.bufferStride===0&&this.bufferOffset===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return this.bufferType===null&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(this.attribute!==null)return;let e=this.getNodeType(t),r=this.value,i=t.getTypeLength(e),s=this.bufferStride||i,n=this.bufferOffset,a=r.isInterleavedBuffer===!0?r:new Sie(r,s),o=new wie(a,i,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){let e=this.getNodeType(t),r=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(r),s=null;return t.shaderStage==="vertex"||t.shaderStage==="compute"?(this.name=i,s=i):s=Dd(this).build(t,e),s}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}};const _ie=(t,e=null,r=0,i=0)=>Pe(new Mie(t,e,r,i));H("toAttribute",t=>_ie(t.value));var Nie=class extends Cr{static get type(){return"ComputeNode"}constructor(t,e,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=t,this.count=e,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=po.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(t){return this.name=t,this}updateDispatchCount(){let{count:t,workgroupSize:e}=this,r=e[0];for(let i=1;i<e.length;i++)r*=e[i];this.dispatchCount=Math.ceil(t/r)}onInit(t){return this.onInitFunction=t,this}updateBefore({renderer:t}){t.compute(this)}setup(t){let e=this.computeNode.build(t);if(e){let r=t.getNodeProperties(this);r.outputComputeNode=e.outputNode,e.outputNode=null}return e}generate(t,e){let{shaderStage:r}=t;if(r==="compute"){let i=this.computeNode.build(t,"void");i!==""&&t.addLineFlowCode(i,this)}else{let i=t.getNodeProperties(this),s=i.outputComputeNode;if(s)return s.build(t,e)}}};const Eie=(t,e,r)=>Pe(new Nie(Pe(t),e,r));H("compute",Eie);var Aie=class extends Cr{static get type(){return"CacheNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isCacheNode=!0}getNodeType(t){let e=t.getCache(),r=t.getCacheFromNode(this,this.parent);t.setCache(r);let i=this.node.getNodeType(t);return t.setCache(e),i}build(t,...e){let r=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);let s=this.node.build(t,...e);return t.setCache(r),s}};const Cie=(t,e)=>Pe(new Aie(Pe(t),e));H("cache",Cie);var Rie=class extends Cr{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){let e=this.callNode.build(t,"void");return e!==""&&t.addLineFlowCode(e,this),this.outputNode.build(t)}};const Pie=de(Rie).setParameterLength(2);H("bypass",Pie);var E5=class extends Cr{static get type(){return"RemapNode"}constructor(t,e,r,i=za(0),s=za(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=r,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){let{node:t,inLowNode:e,inHighNode:r,outLowNode:i,outHighNode:s,doClamp:n}=this,a=t.sub(e).div(r.sub(e));return n===!0&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}};const Iie=de(E5,null,null,{doClamp:!1}).setParameterLength(3,5),Vie=de(E5).setParameterLength(3,5);H("remap",Iie),H("remapClamp",Vie);var Oie=class extends Cr{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){let r=this.getNodeType(t),i=this.snippet;if(r==="void")t.addLineFlowCode(i,this);else return t.format(i,r,e)}};const W_=de(Oie).setParameterLength(1,2),Lie=t=>(t?gT(t,W_("discard")):W_("discard")).toStack();H("discard",Lie);var Fie=class extends Ts{static get type(){return"RenderOutputNode"}constructor(t,e,r){super("vec4"),this.colorNode=t,this.toneMapping=e,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:t}){let e=this.colorNode||t.color,r=(this.toneMapping===null?t.toneMapping:this.toneMapping)||0,i=(this.outputColorSpace===null?t.outputColorSpace:this.outputColorSpace)||"";return r!==0&&(e=e.toneMapping(r)),i!==""&&i!==_r.workingColorSpace&&(e=e.workingToColorSpace(i)),e}};const zie=(t,e=null,r=null)=>Pe(new Fie(Pe(t),e,r));H("renderOutput",zie);var Bie=class extends Ts{static get type(){return"DebugNode"}constructor(t,e=null){super(),this.node=t,this.callback=e}getNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){let e=this.callback,r=this.node.build(t),i="--- TSL debug - "+t.shaderStage+" shader ---",s="-".repeat(i.length),n="";return n+="// #"+i+`#
450
+ `);return t.format(h,r,e)}};const gT=de(Kre).setParameterLength(2,3);H("select",gT);const Qre=(...t)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),gT(...t));H("cond",Qre);var eie=class extends Cr{static get type(){return"ContextNode"}constructor(t,e={}){super(),this.isContextNode=!0,this.node=t,this.value=e}getScope(){return this.node.getScope()}getNodeType(t){return this.node.getNodeType(t)}analyze(t){let e=t.getContext();t.setContext({...t.context,...this.value}),this.node.build(t),t.setContext(e)}setup(t){let e=t.getContext();t.setContext({...t.context,...this.value}),this.node.build(t),t.setContext(e)}generate(t,e){let r=t.getContext();t.setContext({...t.context,...this.value});let i=this.node.build(t,e);return t.setContext(r),i}};const M5=de(eie).setParameterLength(1,2),tie=(t,e)=>M5(t,{label:e});H("context",M5),H("label",tie);var rie=class extends Cr{static get type(){return"VarNode"}constructor(t,e=null,r=!1){super(),this.node=t,this.name=e,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0}getMemberType(t,e){return this.node.getMemberType(t,e)}getElementType(t){return this.node.getElementType(t)}getNodeType(t){return this.node.getNodeType(t)}generate(t){let{node:e,name:r,readOnly:i}=this,{renderer:s}=t,n=s.backend.isWebGPUBackend===!0,a=!1,o=!1;i&&(a=t.isDeterministic(e),o=n?i:a);let l=t.getVectorType(this.getNodeType(t)),h=e.build(t,l),u=t.getVarFromNode(this,r,l,void 0,o),c=t.getPropertyName(u),d=c;if(o)if(n)d=a?`const ${c}`:`let ${c}`;else{let m=t.getArrayCount(e);d=`const ${t.getVar(u.type,c,m)}`}return t.addLineFlowCode(`${d} = ${h}`,this),c}};const yT=de(rie),iie=(t,e=null)=>yT(t,e).toStack(),sie=(t,e=null)=>yT(t,e,!0).toStack();H("toVar",iie),H("toConst",sie);const nie=t=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),yT(t));H("temp",nie);var aie=class extends Cr{static get type(){return"VaryingNode"}constructor(t,e=null){super(),this.node=t,this.name=e,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(t,e=null){return this.interpolationType=t,this.interpolationSampling=e,this}getHash(t){return this.name||super.getHash(t)}getNodeType(t){return this.node.getNodeType(t)}setupVarying(t){let e=t.getNodeProperties(this),r=e.varying;if(r===void 0){let i=this.name,s=this.getNodeType(t),n=this.interpolationType,a=this.interpolationSampling;e.varying=r=t.getVaryingFromNode(this,i,s,n,a),e.node=this.node}return r.needsInterpolation||(r.needsInterpolation=t.shaderStage==="fragment"),r}setup(t){this.setupVarying(t),t.flowNodeFromShaderStage(af.VERTEX,this.node)}analyze(t){this.setupVarying(t),t.flowNodeFromShaderStage(af.VERTEX,this.node)}generate(t){let e=t.getNodeProperties(this),r=this.setupVarying(t);if(e.propertyName===void 0){let i=this.getNodeType(t),s=t.getPropertyName(r,af.VERTEX);t.flowNodeFromShaderStage(af.VERTEX,this.node,i,s),e.propertyName=s}return t.getPropertyName(r)}};const Dd=de(aie).setParameterLength(1,2),oie=t=>Dd(t);H("toVarying",Dd),H("toVertexStage",oie),H("varying",(...t)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Dd(...t))),H("vertexStage",(...t)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Dd(...t)));const lie=Xs(([t])=>{let e=t.mul(.9478672986).add(.0521327014).pow(2.4),r=t.mul(.0773993808),i=t.lessThanEqual(.04045);return fy(e,r,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),uie=Xs(([t])=>{let e=t.pow(.41666).mul(1.055).sub(.055),r=t.mul(12.92),i=t.lessThanEqual(.0031308);return fy(e,r,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),xT="WorkingColorSpace";var _5=class extends Ts{static get type(){return"ColorSpaceNode"}constructor(t,e,r){super("vec4"),this.colorNode=t,this.source=e,this.target=r}resolveColorSpace(t,e){return e===xT?_r.workingColorSpace:e==="OutputColorSpace"?t.context.outputColorSpace||t.renderer.outputColorSpace:e}setup(t){let{colorNode:e}=this,r=this.resolveColorSpace(t,this.source),i=this.resolveColorSpace(t,this.target),s=e;return _r.enabled===!1||r===i||!r||!i||(_r.getTransfer(r)===Ud&&(s=ql(lie(s.rgb),s.a)),_r.getPrimaries(r)!==_r.getPrimaries(i)&&(s=ql(d5(_r._getMatrix(new Vm,r,i)).mul(s.rgb),s.a)),_r.getTransfer(i)===Ud&&(s=ql(uie(s.rgb),s.a))),s}};const hie=(t,e)=>Re(new _5(Re(t),xT,e)),cie=(t,e)=>Re(new _5(Re(t),e,xT));H("workingToColorSpace",hie),H("colorSpaceToWorking",cie);var die=class extends uT{static get type(){return"ReferenceElementNode"}constructor(t,e){super(t,e),this.referenceNode=t,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(t){let e=super.generate(t),r=this.referenceNode.getNodeType(),i=this.getNodeType();return t.format(e,r,i)}},mie=class extends Cr{static get type(){return"ReferenceBaseNode"}constructor(t,e,r=null,i=null){super(),this.property=t,this.uniformType=e,this.object=r,this.count=i,this.properties=t.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=po.OBJECT}setGroup(t){return this.group=t,this}element(t){return Re(new die(this,Re(t)))}setNodeType(t){let e=Wre(null,t).getSelf();this.group!==null&&e.setGroup(this.group),this.node=e}getNodeType(t){return this.node===null&&(this.updateReference(t),this.updateValue()),this.node.getNodeType(t)}getValueFromReference(t=this.reference){let{properties:e}=this,r=t[e[0]];for(let i=1;i<e.length;i++)r=r[e[i]];return r}updateReference(t){return this.reference=this.object===null?t.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let t=this.getValueFromReference();Array.isArray(t)?this.node.array=t:this.node.value=t}},pie=mie,fie=class extends pie{static get type(){return"RendererReferenceNode"}constructor(t,e,r=null){super(t,e,r),this.renderer=r,this.setGroup($re)}updateReference(t){return this.reference=this.renderer===null?t.renderer:this.renderer,this.reference}};const gie=(t,e,r=null)=>Re(new fie(t,e,r));var yie=class extends Ts{static get type(){return"ToneMappingNode"}constructor(t,e=bie,r=null){super("vec3"),this.toneMapping=t,this.exposureNode=e,this.colorNode=r}customCacheKey(){return n5(this.toneMapping)}setup(t){let e=this.colorNode||t.context.color,r=this.toneMapping;if(r===0)return e;let i=null,s=t.renderer.library.getToneMappingFunction(r);return s===null?(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=e):i=ql(s(e.rgb,this.exposureNode),e.a),i}};const xie=(t,e,r)=>Re(new yie(t,Re(e),Re(r))),bie=gie("toneMappingExposure","float");H("toneMapping",(t,e,r)=>xie(e,r,t));const Sr=new Tn,uf=new r5;let vie=0;var Tie=class{constructor(t,e,r=!1){if(Array.isArray(t))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:vie++}),this.name="",this.array=t,this.itemSize=e,this.count=t===void 0?0:t.length/e,this.normalized=r,this.usage=gg,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)uf.fromBufferAttribute(this,e),uf.applyMatrix3(t),this.setXY(e,uf.x,uf.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix3(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.applyMatrix4(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.applyNormalMatrix(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)Sr.fromBufferAttribute(this,e),Sr.transformDirection(t),this.setXYZ(e,Sr.x,Sr.y,Sr.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let r=this.array[t*this.itemSize+e];return this.normalized&&(r=cn(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=Mt(r,this.array)),this.array[t*this.itemSize+e]=r,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=cn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=cn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=cn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=cn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Mt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=Mt(e,this.array),r=Mt(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=Mt(e,this.array),r=Mt(r,this.array),i=Mt(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=Mt(e,this.array),r=Mt(r,this.array),i=Mt(i,this.array),s=Mt(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==gg&&(t.usage=this.usage),t}};const Ci=new Tn;var wie=class N5{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++)Ci.fromBufferAttribute(this,r),Ci.applyMatrix4(e),this.setXYZ(r,Ci.x,Ci.y,Ci.z);return this}applyNormalMatrix(e){for(let r=0,i=this.count;r<i;r++)Ci.fromBufferAttribute(this,r),Ci.applyNormalMatrix(e),this.setXYZ(r,Ci.x,Ci.y,Ci.z);return this}transformDirection(e){for(let r=0,i=this.count;r<i;r++)Ci.fromBufferAttribute(this,r),Ci.transformDirection(e),this.setXYZ(r,Ci.x,Ci.y,Ci.z);return this}getComponent(e,r){let i=this.array[e*this.data.stride+this.offset+r];return this.normalized&&(i=cn(i,this.array)),i}setComponent(e,r,i){return this.normalized&&(i=Mt(i,this.array)),this.data.array[e*this.data.stride+this.offset+r]=i,this}setX(e,r){return this.normalized&&(r=Mt(r,this.array)),this.data.array[e*this.data.stride+this.offset]=r,this}setY(e,r){return this.normalized&&(r=Mt(r,this.array)),this.data.array[e*this.data.stride+this.offset+1]=r,this}setZ(e,r){return this.normalized&&(r=Mt(r,this.array)),this.data.array[e*this.data.stride+this.offset+2]=r,this}setW(e,r){return this.normalized&&(r=Mt(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=cn(r,this.array)),r}getY(e){let r=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(r=cn(r,this.array)),r}getZ(e){let r=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(r=cn(r,this.array)),r}getW(e){let r=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(r=cn(r,this.array)),r}setXY(e,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(r=Mt(r,this.array),i=Mt(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=Mt(r,this.array),i=Mt(i,this.array),s=Mt(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=Mt(r,this.array),i=Mt(i,this.array),s=Mt(s,this.array),n=Mt(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.");let r=[];for(let i=0;i<this.count;i++){let s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)r.push(this.data.array[s+n])}return new Tie(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 N5(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.");let r=[];for(let i=0;i<this.count;i++){let 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}}},Sie=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t===void 0?0:t.length/e,this.usage=gg,this.updateRanges=[],this.version=0,this.uuid=Bf()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let i=0,s=this.stride;i<s;i++)this.array[t+i]=e.array[r+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bf()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(e,this.stride);return r.setUsage(this.usage),r}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bf()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Mie=class extends hT{static get type(){return"BufferAttributeNode"}constructor(t,e=null,r=0,i=0){super(t,e),this.isBufferNode=!0,this.bufferType=e,this.bufferStride=r,this.bufferOffset=i,this.usage=gg,this.instanced=!1,this.attribute=null,this.global=!0,t&&t.isBufferAttribute===!0&&(this.attribute=t,this.usage=t.usage,this.instanced=t.isInstancedBufferAttribute)}getHash(t){if(this.bufferStride===0&&this.bufferOffset===0){let e=t.globalCache.getData(this.value);return e===void 0&&(e={node:this},t.globalCache.setData(this.value,e)),e.node.uuid}return this.uuid}getNodeType(t){return this.bufferType===null&&(this.bufferType=t.getTypeFromAttribute(this.attribute)),this.bufferType}setup(t){if(this.attribute!==null)return;let e=this.getNodeType(t),r=this.value,i=t.getTypeLength(e),s=this.bufferStride||i,n=this.bufferOffset,a=r.isInterleavedBuffer===!0?r:new Sie(r,s),o=new wie(a,i,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(t){let e=this.getNodeType(t),r=t.getBufferAttributeFromNode(this,e),i=t.getPropertyName(r),s=null;return t.shaderStage==="vertex"||t.shaderStage==="compute"?(this.name=i,s=i):s=Dd(this).build(t,e),s}getInputType(){return"bufferAttribute"}setUsage(t){return this.usage=t,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=t),this}setInstanced(t){return this.instanced=t,this}};const _ie=(t,e=null,r=0,i=0)=>Re(new Mie(t,e,r,i));H("toAttribute",t=>_ie(t.value));var Nie=class extends Cr{static get type(){return"ComputeNode"}constructor(t,e,r=[64]){super("void"),this.isComputeNode=!0,this.computeNode=t,this.count=e,this.workgroupSize=r,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=po.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(t){return this.name=t,this}updateDispatchCount(){let{count:t,workgroupSize:e}=this,r=e[0];for(let i=1;i<e.length;i++)r*=e[i];this.dispatchCount=Math.ceil(t/r)}onInit(t){return this.onInitFunction=t,this}updateBefore({renderer:t}){t.compute(this)}setup(t){let e=this.computeNode.build(t);if(e){let r=t.getNodeProperties(this);r.outputComputeNode=e.outputNode,e.outputNode=null}return e}generate(t,e){let{shaderStage:r}=t;if(r==="compute"){let i=this.computeNode.build(t,"void");i!==""&&t.addLineFlowCode(i,this)}else{let i=t.getNodeProperties(this),s=i.outputComputeNode;if(s)return s.build(t,e)}}};const Eie=(t,e,r)=>Re(new Nie(Re(t),e,r));H("compute",Eie);var Aie=class extends Cr{static get type(){return"CacheNode"}constructor(t,e=!0){super(),this.node=t,this.parent=e,this.isCacheNode=!0}getNodeType(t){let e=t.getCache(),r=t.getCacheFromNode(this,this.parent);t.setCache(r);let i=this.node.getNodeType(t);return t.setCache(e),i}build(t,...e){let r=t.getCache(),i=t.getCacheFromNode(this,this.parent);t.setCache(i);let s=this.node.build(t,...e);return t.setCache(r),s}};const Cie=(t,e)=>Re(new Aie(Re(t),e));H("cache",Cie);var Rie=class extends Cr{static get type(){return"BypassNode"}constructor(t,e){super(),this.isBypassNode=!0,this.outputNode=t,this.callNode=e}getNodeType(t){return this.outputNode.getNodeType(t)}generate(t){let e=this.callNode.build(t,"void");return e!==""&&t.addLineFlowCode(e,this),this.outputNode.build(t)}};const Pie=de(Rie).setParameterLength(2);H("bypass",Pie);var E5=class extends Cr{static get type(){return"RemapNode"}constructor(t,e,r,i=za(0),s=za(1)){super(),this.node=t,this.inLowNode=e,this.inHighNode=r,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){let{node:t,inLowNode:e,inHighNode:r,outLowNode:i,outHighNode:s,doClamp:n}=this,a=t.sub(e).div(r.sub(e));return n===!0&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}};const Iie=de(E5,null,null,{doClamp:!1}).setParameterLength(3,5),Vie=de(E5).setParameterLength(3,5);H("remap",Iie),H("remapClamp",Vie);var Oie=class extends Cr{static get type(){return"ExpressionNode"}constructor(t="",e="void"){super(e),this.snippet=t}generate(t,e){let r=this.getNodeType(t),i=this.snippet;if(r==="void")t.addLineFlowCode(i,this);else return t.format(i,r,e)}};const W_=de(Oie).setParameterLength(1,2),Lie=t=>(t?gT(t,W_("discard")):W_("discard")).toStack();H("discard",Lie);var Fie=class extends Ts{static get type(){return"RenderOutputNode"}constructor(t,e,r){super("vec4"),this.colorNode=t,this.toneMapping=e,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:t}){let e=this.colorNode||t.color,r=(this.toneMapping===null?t.toneMapping:this.toneMapping)||0,i=(this.outputColorSpace===null?t.outputColorSpace:this.outputColorSpace)||"";return r!==0&&(e=e.toneMapping(r)),i!==""&&i!==_r.workingColorSpace&&(e=e.workingToColorSpace(i)),e}};const zie=(t,e=null,r=null)=>Re(new Fie(Re(t),e,r));H("renderOutput",zie);var Bie=class extends Ts{static get type(){return"DebugNode"}constructor(t,e=null){super(),this.node=t,this.callback=e}getNodeType(t){return this.node.getNodeType(t)}setup(t){return this.node.build(t)}analyze(t){return this.node.build(t)}generate(t){let e=this.callback,r=this.node.build(t),i="--- TSL debug - "+t.shaderStage+" shader ---",s="-".repeat(i.length),n="";return n+="// #"+i+`#
451
451
  `,n+=t.flow.code.replace(/^\t/gm,"")+`
452
452
  `,n+="/* ... */ "+r+` /* ... */
453
453
  `,n+="// #"+s+`#
454
- `,e===null?console.log(n):e(t,n),r}};const kie=(t,e=null)=>Pe(new Bie(Pe(t),e));H("debug",kie);const Uie=Xs(([t])=>A5(t.rgb)),Die=Xs(([t,e=za(1)])=>e.mix(A5(t.rgb),t.rgb)),$ie=Xs(([t,e=za(1)])=>{let r=m5(t.r,t.g,t.b).div(3),i=t.r.max(t.g.max(t.b)),s=i.sub(r).mul(e).mul(-3);return fy(t.rgb,i,s)}),Gie=Xs(([t,e=za(1)])=>{let r=Tc(.57735,.57735,.57735),i=e.cos();return Tc(t.rgb.mul(i).add(r.cross(t.rgb).mul(e.sin()).add(r.mul(Om(r,t.rgb).mul(i.oneMinus())))))}),A5=(t,e=Tc(_r.getLuminanceCoefficients(new Tn)))=>Om(t,e),Xl={name:"Grayscale",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;if(!t)return console.error("You must pass a child component into the Grayscale shader."),e(0);let r=t||e(0,0,0,0);return e(Uie(r.rgb).rgb,r.a)}},Yl={name:"Grid",category:"Shapes & Masks",props:{color:{default:"#ffffff",transform:Nt,description:"The color of the grid lines",ui:{type:"color",label:"Color"}},cells:{default:10,description:"Number of cells along the shortest canvas edge (creates square cells)",ui:{type:"range",min:1,max:50,step:1,label:"Cells"}},thickness:{default:1,description:"Thickness of grid lines (normalized, 0.0-1.0)",ui:{type:"range",min:0,max:5,step:.1,label:"Thickness"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,fract:i,max:s,screenUV:n,viewportSize:a,fwidth:o,smoothstep:l}=Ve,h=a.x.div(a.y),u=e(n.x.mul(h),n.y.oneMinus()),c=t.cells.uniform,d=u.mul(c),m=i(d),p=t.thickness.uniform.mul(.01),f=m.x.min(m.x.oneMinus()),g=m.y.min(m.y.oneMinus()),y=o(d),T=l(p.add(y.x),p,f),M=l(p.add(y.y),p,g),w=s(T,M);return r(t.color.uniform.rgb,t.color.uniform.a.mul(w))}},Zl={name:"GridDistortion",category:"Distortions",requiresRTT:!0,props:{smoothness:{default:0,description:"How smooth and flowing the motion is",ui:{type:"range",min:0,max:1,step:.01,label:"Smoothness"}},intensity:{default:1,description:"Strength of the distortion effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},swirl:{default:0,description:"Amount of swirl motion",ui:{type:"range",min:0,max:2,step:.1,label:"Swirl"}},duration:{default:3,description:"How long the effect persists (higher = longer)",ui:{type:"range",min:0,max:10,step:.1,label:"Duration"}},radius:{default:1,description:"Radius of the distortion effect",ui:{type:"range",min:0,max:3,step:.01,label:"Radius"}},gridSize:{default:20,description:"Resolution of the distortion grid (higher = more detailed)",ui:{type:"range",min:8,max:128,step:1,label:"Grid Size"}}},fragmentNode:({uniforms:t,onBeforeRender:e,childNode:r,onCleanup:i,dimensions:s})=>{let{vec2:n,vec4:a,float:o,uniform:l,screenUV:h,convertToTexture:u,texture:c}=Ve;if(!r)return a(0,0,0,0);let d=Math.round(s.width),m=Math.round(s.height),p=u(r,d,m),f=Math.max(8,Math.min(128,Math.floor(t.gridSize.uniform.value))),g=new Float32Array(f*f*2),y=new em(g,f,f,So,gc);y.magFilter=ps,y.minFilter=ps,y.needsUpdate=!0;let T=c(y),M=l(.5),w=l(.5),_=l(0),S=l(0),N=.5,A=.5,k=Date.now();e(({pointer:ye})=>{let Te=Date.now(),ge=Math.min((Te-k)/1e3,.016);k=Te;let be=ge>0?(ye.x-N)/ge:0,Je=ge>0?(ye.y-A)/ge:0;_.value=_.value*.85+be*.15,S.value=S.value*.85+Je*.15,M.value=ye.x,w.value=ye.y;let wt=t.duration.uniform.value,Bt=t.intensity.uniform.value,He=t.radius.uniform.value*.05,Wr=t.swirl.uniform.value;for(let Hr=0;Hr<f;Hr++)for(let Qt=0;Qt<f;Qt++){let Ot=(Hr*f+Qt)*2;g[Ot]*=1-wt*ge,g[Ot+1]*=1-wt*ge;let br=(Qt+.5)/f,vr=(Hr+.5)/f,qr=br-ye.x,Wt=vr-ye.y,Ir=Math.sqrt(qr*qr+Wt*Wt);if(Ir<He*2&&Math.abs(be)+Math.abs(Je)>.01){let ui=Math.exp(-Ir*Ir/(He*He));if(g[Ot]+=_.value*ui*Bt*ge*.5,g[Ot+1]+=S.value*ui*Bt*ge*.5,Wr>0){let Zi=Math.atan2(Wt,qr)+Math.PI*.5;g[Ot]+=Math.cos(Zi)*Wr*ui*ge*2,g[Ot+1]+=Math.sin(Zi)*Wr*ui*ge*2}}g[Ot]=Math.max(-1,Math.min(1,g[Ot])),g[Ot+1]=Math.max(-1,Math.min(1,g[Ot+1]))}y.needsUpdate=!0,N=ye.x,A=ye.y}),i(()=>{y.dispose()});let Q=t.gridSize.uniform,J=o(1).div(Q),re=h.div(J).floor().mul(J).add(J.mul(.5)),ie=T.sample(re).xy,se=o(.1),ve=o(-.1),me=ie.clamp(n(ve,ve),n(se,se)),Me=h.sub(me);return p.sample(Me)}},Jl={name:"Group",category:"Layout",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Kl={name:"HalfTone",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Ql={name:"HueShift",category:"Color Adjustments",props:{shift:{default:0,description:"The amount to shift the hue by",ui:{type:"range",min:-180,max:180,step:1,label:"Shift"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r}=Ve;if(!e)return console.error("You must pass a child component into the Hue Shift shader."),r(0);let i=e||r(0,0,0,0);return r(Gie(i.rgb,t.shift.uniform).rgb,i.a)}},eu={name:"ImageTexture",category:"Textures",props:{src:{default:"https://picsum.photos/1920/1080",description:"Image URL to display",ui:{type:"text",label:"Source URL"}},fit:{default:"cover",description:"How the image should fit within the canvas"}},fragmentNode:({uniforms:t,onCleanup:e})=>{let{texture:r,screenUV:i}=Ve,s=new TK,n=s.load(t.src.uniform.value);n.colorSpace=Ps,n.flipY=!0;let a=r(n);e(()=>{n.dispose()});let o=i.xy.setY(i.y.oneMinus());return a.sample(o)}},tu={name:"Invert",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e,vec3:r}=Ve;if(!t)return console.error("You must pass a child component into the Invert shader."),e(0);let i=t||e(0,0,0,0),s=i.a,n=s.greaterThan(0).select(i.rgb.div(s),r(0,0,0)),a=r(1,1,1).sub(n),o=a.mul(s);return e(o,s)}},ru={name:"LinearGradient",category:"Gradients & Colors",props:{startColor:{default:"#1aff00",transform:Nt,description:"The starting color of the gradient",ui:{type:"color",label:"Start Color"}},endColor:{default:"#0000ff",transform:Nt,description:"The ending color of the gradient",ui:{type:"color",label:"End Color"}},angle:{default:0,transform:aT,description:"The rotation angle of the gradient (in degrees)",ui:{type:"range",min:0,max:360,step:1,label:"Angle"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the gradient",ui:{type:"position",label:"Center"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,float:i,cos:s,sin:n,dot:a,radians:o,screenUV:l,abs:h,div:u}=Ve,c=o(t.angle.uniform),d=s(c),m=n(c),p=e(d,m),f=e(t.center.uniform[0],t.center.uniform[1].oneMinus()),g=l.sub(f),y=a(g,p),T=i(.5).mul(h(d).add(h(m))),M=u(y,T.max(1e-6)),w=M.mul(.5).add(.5).clamp(i(0),i(1));return r(t.startColor.uniform,t.endColor.uniform,w)}},iu={name:"Liquify",category:"Distortions",requiresRTT:!0,props:{smoothness:{default:0,description:"How smooth and flowing the motion is (0-1)",ui:{type:"range",min:0,max:1,step:.01,label:"Smoothness"}},intensity:{default:1,description:"Strength of the distortion effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},swirl:{default:0,description:"Amount of swirl motion (0-1)",ui:{type:"range",min:0,max:1,step:.01,label:"Swirl"}},duration:{default:3,description:"How long the effect persists (higher = longer)",ui:{type:"range",min:0,max:10,step:.1,label:"Duration"}},radius:{default:1,description:"Radius of the distortion effect",ui:{type:"range",min:0,max:3,step:.01,label:"Radius"}}},fragmentNode:({uniforms:t,onBeforeRender:e,childNode:r,onCleanup:i,dimensions:s})=>{let{vec2:n,vec4:a,float:o,uniform:l,screenUV:h,convertToTexture:u,texture:c}=Ve;if(!r)return a(0,0,0,0);let d=Math.round(s.width),m=Math.round(s.height),p=u(r,d,m),f=new Float32Array(1024*2),g=new em(f,32,32,So,gc);g.magFilter=ps,g.minFilter=ps,g.needsUpdate=!0;let y=c(g),T=l(.5),M=l(.5),w=l(0),_=l(0),S=.5,N=.5,A=Date.now();e(({pointer:se})=>{let ve=Date.now(),me=Math.min((ve-A)/1e3,.016);A=ve;let Me=me>0?(se.x-S)/me:0,ye=me>0?(se.y-N)/me:0;w.value=w.value*.85+Me*.15,_.value=_.value*.85+ye*.15,T.value=se.x,M.value=se.y;let Te=t.duration.uniform.value,ge=t.intensity.uniform.value,be=t.radius.uniform.value*.05,Je=t.swirl.uniform.value;for(let wt=0;wt<32;wt++)for(let Bt=0;Bt<32;Bt++){let He=(wt*32+Bt)*2;f[He]*=1-Te*me,f[He+1]*=1-Te*me;let Wr=(Bt+.5)/32,Hr=(wt+.5)/32,Qt=Wr-se.x,Ot=Hr-se.y,br=Math.sqrt(Qt*Qt+Ot*Ot);if(br<be*2&&Math.abs(Me)+Math.abs(ye)>.01){let vr=Math.exp(-br*br/(be*be));if(f[He]+=w.value*vr*ge*me*.5,f[He+1]+=_.value*vr*ge*me*.5,Je>0){let qr=Math.atan2(Ot,Qt)+Math.PI*.5;f[He]+=Math.cos(qr)*Je*vr*me*2,f[He+1]+=Math.sin(qr)*Je*vr*me*2}}f[He]=Math.max(-1,Math.min(1,f[He])),f[He+1]=Math.max(-1,Math.min(1,f[He+1]))}g.needsUpdate=!0,S=se.x,N=se.y}),i(()=>{g.dispose()});let k=y.sample(h).xy,Q=o(.2),J=o(-.2),re=k.clamp(n(J,J),n(Q,Q)),ie=h.sub(re);return p.sample(ie)}},su={name:"Mirror",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},nu={name:"PerlinNoise",category:"Textures",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},au={name:"Pixelate",category:"Effects",requiresRTT:!0,props:{scale:{default:50,description:"Pixel size - higher values create larger, more visible pixels",ui:{type:"range",min:1,max:200,step:1,label:"Scale"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec4:i,floor:s,screenUV:n,convertToTexture:a}=Ve;if(!e)return i(0,0,0,0);let o=Math.round(r.width),l=Math.round(r.height),h=a(e,o,l),u=t.scale.uniform,c=s(n.mul(u)).div(u);return h.sample(c)}};var jie=class extends Ts{static get type(){return"PosterizeNode"}constructor(e,r){super(),this.sourceNode=e,this.stepsNode=r}setup(){let{sourceNode:e,stepsNode:r}=this;return e.mul(r).floor().div(r)}};const Wie=de(jie).setParameterLength(2),ou={name:"Posterize",category:"Color Adjustments",props:{intensity:{default:5,description:"The intensity of the posterization effect (lower is more posterized)",ui:{type:"range",min:2,max:20,step:1,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r,int:i}=Ve;if(!e)return console.error("You must pass a child component into the Posterize shader."),r(0);let s=e||r(0,0,0,0);return Wie(s,i(t.intensity.uniform))}},lu={name:"ProgressiveBlur",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},uu={name:"RadialGradient",category:"Gradients & Colors",props:{startColor:{default:"#ff0000",transform:Nt,description:"The starting color at the center of the gradient",ui:{type:"color",label:"Start Color"}},endColor:{default:"#0000ff",transform:Nt,description:"The ending color at the edge of the gradient",ui:{type:"color",label:"End Color"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the radial gradient",ui:{type:"position",label:"Center"}},radius:{default:1,description:"The radius of the gradient (normalized, 0.0-1.0)",ui:{type:"range",min:0,max:2,step:.01,label:"Radius"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,float:i,distance: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=s(l,h),c=u.div(t.radius.uniform).clamp(i(0),i(1));return r(t.startColor.uniform,t.endColor.uniform,c)}},hu={name:"Saturation",category:"Color Adjustments",props:{intensity:{default:1,description:"The intensity of the saturation effect (1 being no change)",ui:{type:"range",min:0,max:3,step:.01,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r}=Ve;if(!e)return console.error("You must pass a child component into the Saturation shader."),r(0);let i=e||r(0,0,0,0);return r(Die(i.rgb,t.intensity.uniform).rgb,i.a)}},cu={name:"SimplexNoise",category:"Textures",props:{scale:{default:2,description:"Pattern scale (higher = larger patterns)",ui:{type:"range",min:-2,max:5,step:.1,label:"Scale"}},balance:{default:0,description:"Balance between colors (negative = more background, -1 = full background range)",ui:{type:"range",min:-1,max:1,step:.01,label:"Balance"}},contrast:{default:0,description:"Pattern contrast (higher = sharper transitions)",ui:{type:"range",min:-2,max:2,step:.1,label:"Contrast"}},color:{default:"#ffffff",description:"Primary noise color",transform:Nt,ui:{type:"color",label:"Color"}},background:{default:"transparent",description:"Background color",transform:Nt,ui:{type:"color",label:"Background"}},seed:{default:0,description:"Random seed for pattern variation",ui:{type:"range",min:0,max:100,step:1,label:"Seed"}},speed:{default:1,description:"Animation speed",ui:{type:"range",min:0,max:5,step:.1,label:"Speed"}},angle:{default:45,transform:aT,description:"Direction of animation movement (in degrees)",ui:{type:"range",min:0,max:360,step:1,label:"Angle"}}},fragmentNode:({uniforms:t})=>{let e=Rb.x.div(Rb.y),r=ng(Ab.x.mul(e),Ab.y),i=QR(t.angle.uniform),s=ng(Vd(i),pl(i)).mul(Dv.mul(t.speed.uniform).mul(.1)),n=r.mul(Nb(t.scale.uniform)).add(t.seed.uniform).add(s),a=YR(0,1,KR(n).mul(.5,Nb(t.contrast.uniform)).add(.5,t.balance.uniform));return Fn(t.background.uniform,t.color.uniform,a)}},du={name:"SineWave",category:"Shapes & Masks",props:{color:{default:"#ffffff",transform:Nt,description:"The color of the sine wave",ui:{type:"color",label:"Color"}},amplitude:{default:.15,description:"The height/amplitude of the sine wave",ui:{type:"range",min:0,max:1,step:.01,label:"Amplitude"}},frequency:{default:1,description:"The frequency/number of wave cycles",ui:{type:"range",min:.1,max:20,step:.1,label:"Frequency"}},speed:{default:1,description:"The animation speed of the wave",ui:{type:"range",min:-5,max:5,step:.1,label:"Speed"}},angle:{default:0,transform:aT,description:"The rotation angle of the wave (in degrees)",ui:{type:"range",min:0,max:360,step:1,label:"Angle"}},position:{default:{x:.5,y:.5},transform:Gu,description:"The center position of the wave",ui:{type:"position",label:"Position"}},thickness:{default:.2,description:"The thickness of the wave line",ui:{type:"range",min:0,max:2,step:.01,label:"Thickness"}},softness:{default:.4,description:"Edge softness of the wave line",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,sin:i,cos:s,abs:n,smoothstep:a,screenUV:o,viewportSize:l,time:h,radians:u,PI:c}=Ve,d=l.x.div(l.y),m=e(o.x.mul(d),o.y),p=e(t.position.uniform.x.mul(d),t.position.uniform.y),f=m.sub(p),g=u(t.angle.uniform),y=s(g),T=i(g),M=f.x.mul(y).sub(f.y.mul(T)),w=f.x.mul(T).add(f.y.mul(y)),_=h.mul(t.speed.uniform),S=M.mul(t.frequency.uniform).mul(c.mul(2)).add(_),N=i(S).mul(t.amplitude.uniform),A=n(w.sub(N)),k=t.thickness.uniform.mul(.5),Q=t.softness.uniform.mul(.5),J=a(k.add(Q),k.sub(Q),A);return r(t.color.uniform.rgb,t.color.uniform.a.mul(J))}},mu={name:"SolidColor",category:"Gradients & Colors",props:{color:{default:"#5b18ca",transform:Nt,description:"The solid color to display",ui:{type:"color",label:"Color"}}},fragmentNode:({uniforms:t})=>t.color.uniform},pu={name:"Spiral",category:"Shapes & Masks",props:{colorBack:{default:"#000000",transform:Nt,description:"Background color",ui:{type:"color",label:"Background Color"}},colorFront:{default:"#ffffff",transform:Nt,description:"Spiral stroke color",ui:{type:"color",label:"Spiral Color"}},strokeWidth:{default:.5,description:"Thickness of spiral stroke",ui:{type:"range",min:0,max:2,step:.01,label:"Stroke Width"}},strokeFalloff:{default:0,description:"Stroke losing width further from center",ui:{type:"range",min:0,max:1,step:.01,label:"Stroke Falloff"}},softness:{default:0,description:"Color transition sharpness (0 = hard edge, 1 = smooth fade)",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}},speed:{default:1,description:"Animation speed (negative values reverse direction)",ui:{type:"range",min:-3,max:3,step:.1,label:"Speed"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the spiral",ui:{type:"position",label:"Center"}},scale:{default:1,description:"Scale factor for spiral bands (higher = more bands, lower = fewer bands)",ui:{type:"range",min:.1,max:5,step:.1,label:"Scale"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,float:i,atan:s,length:n,clamp:a,fract:o,abs:l,mix:h,smoothstep:u,screenUV:c,time:d,fwidth:m,viewportSize:p}=Ve,f=p.x.div(p.y),g=e(c.x.mul(f),c.y),y=e(t.center.uniform.x.mul(f),t.center.uniform.y.oneMinus()),T=g.sub(y),M=d.mul(t.speed.uniform),w=n(T),_=w,S=s(T.y,T.x).sub(M),N=i(6.283185307),A=S.div(N),k=_.mul(t.scale.uniform).add(A),Q=o(k),J=l(Q.sub(.5)).mul(2),re=a(t.strokeWidth.uniform,t.strokeFalloff.uniform.mul(.005),1),ie=a(t.strokeFalloff.uniform,0,1).mul(w).oneMinus(),se=re.mul(ie),ve=m(k),me=i(4).sub(u(.05,.4,t.strokeWidth.uniform.mul(2)).mul(u(.05,.4,t.strokeWidth.uniform.oneMinus().mul(2))).mul(3)),Me=h(me.mul(ve),m(J),a(ve,0,1)),ye=u(se.sub(Me).sub(t.softness.uniform),se.add(Me).add(t.softness.uniform),J),Te=h(t.colorBack.uniform,t.colorFront.uniform,ye);return r(Te.rgb,Te.a)}},fu={name:"Stretch",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},gu={name:"Swirl",category:"Gradients & Colors",props:{colorA:{default:"#1275d8",description:"Primary gradient color",transform:Nt,ui:{type:"color",label:"Primary Color"}},colorB:{default:"#e19136",description:"Secondary gradient color",transform:Nt,ui:{type:"color",label:"Secondary Color"}},colorC:{default:"#320485",description:"Accent gradient color",transform:Nt,ui:{type:"color",label:"Accent Color"}},speed:{default:1,description:"Flow animation speed",ui:{type:"range",min:0,max:5,step:.1,label:"Speed"}},scale:{default:5,description:"Gradient scale",ui:{type:"range",min:.1,max:20,step:.1,label:"Scale"}},complexity:{default:5,description:"Flow complexity",ui:{type:"range",min:1,max:10,step:.1,label:"Complexity"}}},fragmentNode:({uniforms:t})=>{let e=t3(),r=Dv.mul(t.speed.uniform),i=t.scale.uniform,s=t.complexity.uniform,n=pl(e.x.mul(i.mul(1.2)).add(r.mul(.8))).mul(.3),a=Vd(e.y.mul(i.mul(.9)).sub(r.mul(.6))).mul(.3),o=ng(e.x.add(pl(e.y.mul(s.mul(2)).add(r)).mul(.08)),e.y.add(Vd(e.x.mul(s.mul(1.5)).sub(r.mul(.7))).mul(.08))),l=pl(o.x.mul(i.mul(3)).add(o.y.mul(i.mul(2))).add(r.mul(.5))),h=Vd(o.x.sub(o.y).mul(i.mul(2.5)).add(r.mul(.3))),u=pl(o.x.mul(s).add(n).add(o.y.mul(s.mul(.8)).add(a)).add(r.mul(.4))),c=Fn(l,h,u.mul(.5).add(.5)),d=o.x.mul(.7).add(o.y.mul(.3)).add(c.mul(.2)),m=Fn(t.colorA.uniform,t.colorB.uniform,Cb(.1,.6,d)),p=Fn(m,t.colorC.uniform,Cb(.4,.9,d.add(u.mul(.3)))),f=pl(r.mul(3).add(d.mul(10))).mul(.02).add(1),g=p.mul(f);return at(g.rgb,g.a)}},yu={name:"TiltShift",category:"Effects",requiresRTT:!0,props:{focusDistance:{default:.5,description:"Distance from top where focus is sharpest (0 = top, 1 = bottom)",ui:{type:"range",min:0,max:1,step:.01,label:"Focus Distance"}},focusRange:{default:.2,description:"Range of the focus area",ui:{type:"range",min:.01,max:1,step:.01,label:"Focus Range"}},blurIntensity:{default:8,description:"Intensity of the blur effect",ui:{type:"range",min:0,max:50,step:.5,label:"Blur Intensity"}},angle:{default:0,description:"Angle of the tilt shift effect in degrees",ui:{type:"range",min:-90,max:90,step:1,label:"Angle"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,float:n,screenUV:a,convertToTexture:o,viewportSize:l,smoothstep:h,abs:u,sin:c,cos:d,radians:m}=Ve;if(!e)return s(0,0,0,0);let p=Math.round(r.width),f=Math.round(r.height),g=o(e,p,f),y=m(t.angle.uniform),T=d(y),M=c(y),w=a.sub(i(.5,.5)),_=i(w.x.mul(T).sub(w.y.mul(M)),w.x.mul(M).add(w.y.mul(T))).add(i(.5,.5)),S=t.focusDistance.uniform,N=u(_.y.sub(S)),A=t.focusRange.uniform.div(2),k=h(A,A.add(.1),N),Q=k.mul(t.blurIntensity.uniform).div(l.x.min(l.y)),J=[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)],re=[.0625,.125,.0625,.125,.25,.125,.0625,.125,.0625],ie=s(0);for(let me=0;me<J.length;me++){let Me=J[me].mul(Q),ye=a.add(Me),Te=n(re[me]),ge=g.sample(ye);ie=ie.add(ge.mul(Te))}let se=g.sample(a),ve=n(1).sub(k);return se.mul(ve).add(ie.mul(k))}},xu={name:"Tint",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},bu={name:"Twirl",category:"Distortions",requiresRTT:!0,props:{center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the twirl effect",ui:{type:"position",label:"Center"}},intensity:{default:1,description:"The strength of the twirl effect",ui:{type:"range",min:-5,max:5,step:.1,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,cos:n,sin:a,length:o,screenUV:l,convertToTexture:h}=Ve;if(!e)return console.error("You must pass a child component into the Twirl shader."),s(0);let u=Math.round(r.width),c=Math.round(r.height),d=h(e,u,c),m=l,p=i(t.center.uniform.x,t.center.uniform.y.oneMinus()),f=m.sub(p),g=t.intensity.uniform.mul(o(f)),y=n(g),T=a(g),M=y.mul(f.x).sub(T.mul(f.y)),w=T.mul(f.x).add(y.mul(f.y)),_=i(M.add(p.x),w.add(p.y));return s(d.sample(_))}},vu={name:"VCR",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Tu={name:"Vibrance",category:"Color Adjustments",props:{intensity:{default:0,description:"The intensity of the vibrance effect",ui:{type:"range",min:-2,max:2,step:.01,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r}=Ve;if(!e)return console.error("You must pass a child component into the Vibrance shader."),r(0);let i=e||r(0,0,0,0);return r($ie(i.rgb,t.intensity.uniform).rgb,i.a)}},wu={name:"Vignette",category:"Shapes & Masks",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Su={name:"Voronoi",category:"Textures",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}};function Hie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=Le(K(e.rgb,i),K(t.rgb,K(t.a,_e(1,i))));return at(n,s)}function qie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(t.rgb,e.rgb),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Xie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=_e(1,K(_e(1,t.rgb),_e(1,e.rgb))),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Yie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ay(Le(t.rgb,e.rgb),1),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Zie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(2,K(t.rgb,e.rgb)),a=_e(1,K(2,K(_e(1,t.rgb),_e(1,e.rgb)))),o=Fn(n,a,Ac(.5,t.rgb)),l=Le(K(o,i),K(t.rgb,K(t.a,_e(1,i))));return at(l,s)}function Jie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=XR(_e(t.rgb,e.rgb)),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Kie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=Fn(t.rgb,ay(ZR(t.rgb,_e(1,e.rgb)),1),Ac(.001,_e(1,e.rgb))),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Qie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=_e(Le(t.rgb,e.rgb),K(2,K(t.rgb,e.rgb))),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function zo(t){return Le(Le(K(t.r,.2126),K(t.g,.7152)),K(t.b,.0722))}function ese(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=_e(n,a),l=Le(e.rgb,o),h=Le(K(l,i),K(t.rgb,K(t.a,_e(1,i))));return at(h,s)}function tse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=a.div(Le(n,1e-4)),l=K(t.rgb,o),h=Le(K(l,i),K(t.rgb,K(t.a,_e(1,i))));return at(h,s)}function rse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ay(t.rgb,e.rgb),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function ise(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ny(t.rgb,e.rgb),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function sse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=Fn(at(0,0,0,1).rgb,ny(_e(1,_e(1,t.rgb).div(Le(e.rgb,1e-4))),0),Ac(1e-4,e.rgb)),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function nse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ny(Le(Le(t.rgb,e.rgb),-1),0),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function ase(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(2,K(t.rgb,e.rgb)),a=K(t.rgb,t.rgb),o=Le(n,K(a,_e(1,K(2,e.rgb)))),l=e3(t.rgb),h=Le(K(2,K(t.rgb,_e(1,e.rgb))),K(l,_e(K(2,e.rgb),1))),u=Fn(o,h,Ac(.5,e.rgb)),c=Le(K(u,i),K(t.rgb,K(t.a,_e(1,i))));return at(c,s)}function ose(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(2,K(t.rgb,e.rgb)),a=_e(1,K(2,K(_e(1,t.rgb),_e(1,e.rgb)))),o=Fn(n,a,Ac(.5,e.rgb)),l=Le(K(o,i),K(t.rgb,K(t.a,_e(1,i))));return at(l,s)}function lse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=t.rgb.sub(n),l=e.rgb.sub(a),h=o.length(),u=l.normalize(),c=Le(K(u,h),n),d=Le(K(c,i),K(t.rgb,K(t.a,_e(1,i))));return at(d,s)}function use(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=t.rgb.sub(n),l=e.rgb.sub(a),h=o.normalize(),u=l.length(),c=Le(K(h,u),n),d=Le(K(c,i),K(t.rgb,K(t.a,_e(1,i))));return at(d,s)}const H_={normal:Hie,multiply:qie,screen:Xie,linearDodge:Yie,overlay:Zie,difference:Jie,colorDodge:Kie,exclusion:Qie,color:ese,luminosity:tse,darken:rse,lighten:ise,colorBurn:sse,linearBurn:nse,softLight:ase,hardLight:ose,hue:lse,saturation:use};function hf(t,e,r="normal",i=1){return(H_[r]||H_.normal)(t,e,i)}function hse(t,e){let r=K(t.a,e.a);return at(t.rgb,r)}function cse(t,e){let r=_e(1,e.a),i=K(t.a,r);return at(t.rgb,i)}function dse(t,e){let r=$v(.2126,.7152,.0722),i=Uv(e.rgb,r),s=K(t.a,i);return at(t.rgb,s)}function mse(t,e){let r=$v(.2126,.7152,.0722),i=Uv(e.rgb,r),s=_e(1,i),n=K(t.a,s);return at(t.rgb,n)}const q_={alpha:hse,alphaInverted:cse,luminance:dse,luminanceInverted:mse};function pse(t,e,r="alpha"){return(q_[r]||q_.alpha)(t,e)}let X_=!1;const fse=()=>{try{{let{MODE:t,DEV:e}={DEV:!1,MODE:"production"};return e||t==="development"}if(typeof window<"u"&&window.location){let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".local")||t.includes("dev.")||t.startsWith("dev-")}return!1}catch{return!1}};function gse(){let t=null,e,r,i,s,n,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,l=null,h=null,u=!1,c=!1,d=!1,m=null,p=!1,f=!0,g=0,y=0,T=!1,M=0,w=0,_=!1,S=.5,N=.5,A=!1,k=!1,Q=!1,J=[],re=!1,ie=[],se=!1,ve=new Set,me=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,Me=(he,oe)=>{if(he<=0||oe<=0||he===g&&oe===y)return;let xe=performance.now();if(xe-M<8)return;let ce=g,qe=y;g=he,y=oe,M=xe,d||(d=!0),e.setSize(he,oe,!1);let ut=he/oe,ht=2*ut;r.left=-ht/2,r.right=ht/2,r.top=2/2,r.bottom=-2/2,r.updateProjectionMatrix(),s.scale.set(ht,2,1),(a.rootId&&(ce===0||qe===0)||a.rootId&&d)&&be(),Wt().catch(console.warn)},ye=he=>{if(!e||!r||!s)return;let oe=he[0];if(!oe)return;let{width:xe,height:ce}=oe.contentRect,qe=Math.round(xe),ut=Math.round(ce);qe===0||ut===0||Me(qe,ut)},Te=he=>{let oe=he[0];if(!oe)return;let xe=p;p=oe.isIntersecting;let ce=t?.getBoundingClientRect(),qe=T;if(T=p&&!!ce&&ce.width>0&&ce.height>0,p&&!xe){if(_=!0,t){let{width:ut,height:ht}=t.getBoundingClientRect(),Pt=Math.round(ut),Lt=Math.round(ht);Pt>0&&Lt>0&&(g===0||y===0||Pt!==g||Lt!==y?(Me(Pt,Lt),!qe&&T&&be()):n&&u&&a.rootId&&(n.needsUpdate=!0,be(),Wt().catch(console.warn)))}f&&Ir()}else!p&&xe&&ui()},ge=!1,be=()=>{if(!a.rootId||!n||k)return;if(a.nodes.get(a.rootId)){if(g===0||y===0){ge||(ge=!0,requestAnimationFrame(()=>{ge=!1,g>0&&y>0&&be()}));return}k=!0;try{let oe=new Set,xe=Wr(a.rootId,new Set,oe);xe&&n&&((ve.size!==oe.size||![...ve].every(qe=>oe.has(qe))||![...oe].every(qe=>ve.has(qe))||_)&&(n.fragmentNode=null,n.needsUpdate=!0,_=!1,ve=oe),n.fragmentNode=xe,n.needsUpdate=!0)}catch(oe){console.error("Error composing shader tree:",oe)}finally{k=!1}p&&Wt().catch(console.warn)}},Je=he=>{let oe=[];return a.nodes.forEach(xe=>{xe.parentId===he&&oe.push(xe)}),oe},wt=he=>{for(let[oe,xe]of a.nodes.entries())if(xe.metadata.id===he)return oe;return null},Bt=(he,oe,xe,ce)=>{if(!oe.metadata.mask?.source)return he;let qe=oe.metadata.mask.source,ut=wt(qe);if(!ut)return he;if(ce.has(ut))return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."),he;let ht=new Set(ce);ht.add(xe);let Pt=Wr(ut,ht),Lt=oe.metadata.mask.type||"alpha";return pse(he,Pt,Lt)},He=he=>{let oe=a.nodes.get(he);if(!oe||!oe.metadata.id)return!1;let xe=oe.metadata.id;for(let ce of a.nodes.values())if(ce.metadata.mask?.source===xe)return!0;return!1},Wr=(he,oe=new Set,xe)=>{if(g===0||y===0)return at(0,0,0,0);let ce=a.nodes.get(he);if(!ce)return at(0,0,0,0);let qe=Lt=>{ce.cleanupCallbacks.push(Lt)},ut=Lt=>{ce.beforeRenderCallbacks.push(Lt)},ht=Lt=>{ce.afterRenderCallbacks.push(Lt)},Pt=Je(he);if(Pt.length===0){if(ce.requiresRTT&&!T)return at(0,0,0,0);let Lt=ce.fragmentNodeFunc({uniforms:ce.uniforms??{},childNode:void 0,onCleanup:qe,onBeforeRender:ut,onAfterRender:ht,canvas:t,dimensions:{width:Math.max(512,g),height:Math.max(512,y)}});return Bt(Lt,ce,he,oe)}else{let Lt=[...Pt].sort((yt,st)=>yt.metadata.renderOrder-st.metadata.renderOrder);if(ce.parentId===null){let yt;for(let ct of Lt){let Xr;if(ct.metadata.opacity===void 0?(Xr=He(ct.id)?0:1,ct.opacityUniform.value=Xr):(Xr=ct.metadata.opacity,ct.opacityUniform.value=Xr),Xr===0&&!He(ct.id))continue;xe&&xe.add(ct.id);let Ji=Wr(ct.id,oe,xe);yt===void 0?yt=ce.requiresRTT||Xr!==1?hf(at(1,1,1,0),Ji,ct.metadata.blendMode,ct.opacityUniform):Ji:yt=hf(yt,Ji,ct.metadata.blendMode,ct.opacityUniform)}if(ce.requiresRTT&&!T)return at(0,0,0,0);let st=ce.fragmentNodeFunc({uniforms:ce.uniforms??{},childNode:yt,onCleanup:qe,onBeforeRender:ut,onAfterRender:ht,canvas:t,dimensions:{width:Math.max(512,g),height:Math.max(512,y)}});return Bt(st,ce,he,oe)}else{let yt;for(let ct of Lt){let Xr;if(ct.metadata.opacity===void 0?(Xr=He(ct.id)?0:1,ct.opacityUniform.value=Xr):(Xr=ct.metadata.opacity,ct.opacityUniform.value=Xr),Xr===0&&!He(ct.id))continue;xe&&xe.add(ct.id);let Ji=Wr(ct.id,oe,xe);yt===void 0?yt=ce.requiresRTT||Xr!==1?hf(at(1,1,1,0),Ji,ct.metadata.blendMode,ct.opacityUniform):Ji:yt=hf(yt,Ji,ct.metadata.blendMode,ct.opacityUniform)}if(ce.requiresRTT&&!T)return at(0,0,0,0);let st=ce.fragmentNodeFunc({uniforms:ce.uniforms??{},childNode:yt,onCleanup:qe,onBeforeRender:ut,onAfterRender:ht,canvas:t,dimensions:{width:Math.max(512,g),height:Math.max(512,y)}});return Bt(st,ce,he,oe)}}},Hr=(he,oe,xe,ce,qe={},ut)=>{let ht=0;if(xe!==null){let yt=Array.from(a.nodes.values()).filter(st=>st.parentId===xe);yt.length>0&&(ht=Math.max(...yt.map(st=>st.metadata.renderOrder))+1)}let Pt=ce?.opacity===void 0?1:ce.opacity,Lt=Od(Pt),ar={id:he,fragmentNodeFunc:oe,parentId:xe,requiresRTT:ut?.requiresRTT||!1,opacityUniform:Lt,metadata:{blendMode:ce?.blendMode||"normal",opacity:ce?.opacity,id:ce?.id,mask:ce?.mask,renderOrder:ce?.renderOrder===void 0?ht:ce?.renderOrder},uniforms:qe,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(he,ar),xe===null&&(a.rootId=he),n&&u&&g>0&&y>0?(J.includes(he)||J.push(he),re||(re=!0,queueMicrotask(()=>{re=!1,J=[],be()}))):n&&u&&(ge||(ge=!0,requestAnimationFrame(()=>{ge=!1,g>0&&y>0&&be()})))},Qt=(he,oe,xe)=>{let ce=a.nodes.get(he);if(!ce||!ce.uniforms)return;let qe=ce.uniforms[oe];!qe||!qe.uniform||(qe.uniform.value=xe,p&&Wt())},Ot=(he,oe)=>{let xe=a.nodes.get(he);if(!xe)return;let ce=!1;if(oe.blendMode!==void 0&&xe.metadata.blendMode!==oe.blendMode&&(xe.metadata.blendMode=oe.blendMode,ce=!0),oe.opacity!==void 0&&xe.metadata.opacity!==oe.opacity){let qe=xe.metadata.opacity===0,ut=oe.opacity===0;xe.metadata.opacity=oe.opacity,xe.opacityUniform.value=oe.opacity,qe!==ut&&(ce=!0)}oe.renderOrder!==void 0&&xe.metadata.renderOrder!==oe.renderOrder&&(xe.metadata.renderOrder=oe.renderOrder,ce=!0),oe.id!==void 0&&xe.metadata.id!==oe.id&&(xe.metadata.id=oe.id,ce=!0),oe.mask!==void 0&&(xe.metadata.mask?.source!==oe.mask?.source||xe.metadata.mask?.type!==oe.mask?.type)&&(xe.metadata.mask=oe.mask,ce=!0),ce&&n&&u?(ie.includes(he)||ie.push(he),se||(se=!0,queueMicrotask(()=>{se=!1,ie=[],be()}))):p&&Wt()},br=he=>{if(!a.nodes.has(he))return;let oe=a.nodes.get(he);if(oe&&oe.cleanupCallbacks.length>0)for(let ce of oe.cleanupCallbacks)try{ce()}catch(qe){console.error(`Error executing cleanup callback for node ${he}:`,qe)}let xe=Je(he);for(let ce of xe)br(ce.id);a.rootId===he&&(a.rootId=null),a.nodes.delete(he),n&&u&&be()},vr=he=>{let oe={deltaTime:he,pointer:{x:S,y:N},pointerActive:A,dimensions:{width:g,height:y}};for(let xe of a.nodes.values())if(xe.beforeRenderCallbacks.length>0)for(let ce of xe.beforeRenderCallbacks)try{ce(oe)}catch(qe){console.error(`Error executing before render callback for node ${xe.id}:`,qe)}},qr=he=>{let oe={deltaTime:he,pointer:{x:S,y:N},pointerActive:A,dimensions:{width:g,height:y}};for(let xe of a.nodes.values())if(xe.afterRenderCallbacks.length>0)for(let ce of xe.afterRenderCallbacks)try{ce(oe)}catch(qe){console.error(`Error executing after render callback for node ${xe.id}:`,qe)}},Wt=async()=>{if(!u||!e||!i||!r||!n||g===0||y===0)return;let he=performance.now(),oe=w>0?(he-w)/1e3:.016,xe=Math.min(oe,.1);w=he,vr(xe);try{if(k)return;e instanceof sM?await e.renderAsync(i,r).then(()=>{u&&qr(xe)}).catch(ce=>{console.error("WebGPU render error:",ce)}):(e.render(i,r),qr(xe))}catch(ce){console.error("Render frame error:",ce)}},Ir=()=>{if(o||!f||!p)return;let he=()=>{o=requestAnimationFrame(he),Wt().catch(console.warn)};he()},ui=()=>{o&&(cancelAnimationFrame(o),o=null)},Zi=he=>{if(!t)return;let oe,xe;if("touches"in he){if(he.touches.length===0)return;oe=he.touches[0].clientX,xe=he.touches[0].clientY}else oe=he.clientX,xe=he.clientY;let ce=t.getBoundingClientRect(),qe=(oe-ce.left)/ce.width,ut=(xe-ce.top)/ce.height;S=qe,N=ut},Mi=he=>{Zi(he)},ri=he=>{Zi(he)},_i=()=>{A=!1,Wt().catch(console.warn)},Ni=()=>{A=!1,Wt().catch(console.warn)},ws=()=>{A=!0,Wt().catch(console.warn)},ta=()=>{A=!0,Wt().catch(console.warn)};return{initialize:async({canvas:he})=>{if(u||c)return;c=!0,m=new AbortController;let oe=m;try{if(t=he,i=new Rg,i.background=null,r=new Pg(-1,1,1,-1,.1,10),r.position.z=1,r.lookAt(0,0,0),Q||(window.addEventListener("mousemove",Mi),window.addEventListener("touchmove",ri),window.addEventListener("mouseup",_i),window.addEventListener("touchend",Ni),he.addEventListener("mousedown",ws),he.addEventListener("touchstart",ta),Q=!0),oe.signal.aborted)return;try{if(e=new sM({canvas:he,antialias:!0,alpha:!0,depth:!1,powerPreference:"high-performance"}),await e.init(),oe.signal.aborted)return}catch(Lt){if(oe.signal.aborted)return;console.error("[Shaders] WebGPU initialization error:",Lt);return}if(oe.signal.aborted)return;e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=Ui,n=new mC({transparent:!0}),n.fragmentNode=at(0,0,0,0);let xe=new KN(2,2);s=new Dn(xe,n),i.add(s),l=new ResizeObserver(ye),l.observe(he),h=new IntersectionObserver(Te,{threshold:0}),h.observe(he);let ce=he.getBoundingClientRect();p=ce.width>0&&ce.height>0&&ce.top<window.innerHeight&&ce.bottom>0&&ce.left<window.innerWidth&&ce.right>0,T=p&&ce.width>0&&ce.height>0,f=!me();let{width:qe,height:ut}=he.getBoundingClientRect(),ht=Math.round(qe),Pt=Math.round(ut);ht>0&&Pt>0?(Me(ht,Pt),d=!0,await Wt()):d=!1,f&&p&&Ir(),oe.signal.aborted||(u=!0)}catch(xe){console.error("[Shaders] Initialization error:",xe)}finally{c=!1,m===oe&&(m=null)}},cleanup:()=>{if(m&&m.abort(),l&&(l.disconnect(),l=null),h&&(h.disconnect(),h=null),Q&&(t&&(t.removeEventListener("mousedown",ws),t.removeEventListener("touchstart",ta)),window&&(window.removeEventListener("mousemove",Mi),window.removeEventListener("touchmove",ri),window.removeEventListener("mouseup",_i),window.removeEventListener("touchend",Ni)),Q=!1),ui(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),J=[],re=!1,ie=[],se=!1,s){i&&i.remove(s);try{s.geometry&&typeof s.geometry.dispose=="function"&&s.geometry.dispose()}catch{}try{s.material instanceof Fi&&typeof s.material.dispose=="function"&&s.material.dispose()}catch{}}if(e&&typeof e.dispose=="function")try{e.dispose()}catch{}t=null,e=null,r=null,i=null,s=null,n=null,u=!1,c=!1,d=!1,m=null,g=0,y=0,p=!1,f=!0,S=.5,N=.5,A=!1},registerNode:Hr,removeNode:br,updateUniformValue:Qt,updateNodeMetadata:Ot,showLicenseWarning:()=>{!fse()||X_||(console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."),X_=!0)},isInitialized:()=>u}}const{uniform:yse}=Ve;function Fe(t,e,r){let i={};return Object.entries(t.props).forEach(([s,n])=>{let a=e[s],o=a;n.transform&&(o=n.transform(a)),i[s]={uniform:yse(o).label(`${s}_${r}`),transform:n.transform||void 0}}),i}const{vec2:Gfe,fract:jfe,sin:Wfe,dot:Hfe}=Ve,{vec2:qfe}=Ve,xse=()=>{let t={};return Object.entries({Ascii:El,Blob:Cl,Blur:Rl,Bulge:Pl,Checkerboard:Il,ChromaFlow:Vl,ChromaticAberration:Ol,Circle:Ll,ColorMapping:Fl,CRTScreen:zl,Dither:Bl,DotGrid:kl,Duotone:Ul,Exposure:Dl,FilmGrain:$l,GlassTiles:Gl,Glitch:jl,Glow:Wl,Godrays:Hl,Grayscale:Xl,Grid:Yl,GridDistortion:Zl,Group:Jl,HalfTone:Kl,HueShift:Ql,ImageTexture:eu,Invert:tu,LinearGradient:ru,Liquify:iu,Mirror:su,PerlinNoise:nu,Pixelate:au,Posterize:ou,ProgressiveBlur:lu,RadialGradient:uu,Saturation:hu,SimplexNoise:cu,SineWave:du,SolidColor:mu,Spiral:pu,Stretch:fu,Swirl:gu,TiltShift:yu,Tint:xu,Twirl:bu,VCR:vu,Vibrance:Tu,Vignette:wu,Voronoi:Su}).forEach(([r,i])=>{let s={};i.props&&Object.entries(i.props).forEach(([n,a])=>{a.ui&&(s[n]={ui:a.ui,default:a.default,description:a.description})}),t[i.name]={name:i.name,fileName:r,category:i.category||"Uncategorized",definition:i,propsMetadata:s}}),t};xse();/**
454
+ `,e===null?console.log(n):e(t,n),r}};const kie=(t,e=null)=>Re(new Bie(Re(t),e));H("debug",kie);const Uie=Xs(([t])=>A5(t.rgb)),Die=Xs(([t,e=za(1)])=>e.mix(A5(t.rgb),t.rgb)),$ie=Xs(([t,e=za(1)])=>{let r=m5(t.r,t.g,t.b).div(3),i=t.r.max(t.g.max(t.b)),s=i.sub(r).mul(e).mul(-3);return fy(t.rgb,i,s)}),Gie=Xs(([t,e=za(1)])=>{let r=Tc(.57735,.57735,.57735),i=e.cos();return Tc(t.rgb.mul(i).add(r.cross(t.rgb).mul(e.sin()).add(r.mul(Om(r,t.rgb).mul(i.oneMinus())))))}),A5=(t,e=Tc(_r.getLuminanceCoefficients(new Tn)))=>Om(t,e),Xl={name:"Grayscale",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;if(!t)return console.error("You must pass a child component into the Grayscale shader."),e(0);let r=t||e(0,0,0,0);return e(Uie(r.rgb).rgb,r.a)}},Yl={name:"Grid",category:"Shapes & Masks",props:{color:{default:"#ffffff",transform:Nt,description:"The color of the grid lines",ui:{type:"color",label:"Color"}},cells:{default:10,description:"Number of cells along the shortest canvas edge (creates square cells)",ui:{type:"range",min:1,max:50,step:1,label:"Cells"}},thickness:{default:1,description:"Thickness of grid lines (normalized, 0.0-1.0)",ui:{type:"range",min:0,max:5,step:.1,label:"Thickness"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,fract:i,max:s,screenUV:n,viewportSize:a,fwidth:o,smoothstep:l}=Ve,h=a.x.div(a.y),u=e(n.x.mul(h),n.y.oneMinus()),c=t.cells.uniform,d=u.mul(c),m=i(d),p=t.thickness.uniform.mul(.01),f=m.x.min(m.x.oneMinus()),g=m.y.min(m.y.oneMinus()),y=o(d),T=l(p.add(y.x),p,f),M=l(p.add(y.y),p,g),w=s(T,M);return r(t.color.uniform.rgb,t.color.uniform.a.mul(w))}},Zl={name:"GridDistortion",category:"Distortions",requiresRTT:!0,props:{smoothness:{default:0,description:"How smooth and flowing the motion is",ui:{type:"range",min:0,max:1,step:.01,label:"Smoothness"}},intensity:{default:1,description:"Strength of the distortion effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},swirl:{default:0,description:"Amount of swirl motion",ui:{type:"range",min:0,max:2,step:.1,label:"Swirl"}},duration:{default:3,description:"How long the effect persists (higher = longer)",ui:{type:"range",min:0,max:10,step:.1,label:"Duration"}},radius:{default:1,description:"Radius of the distortion effect",ui:{type:"range",min:0,max:3,step:.01,label:"Radius"}},gridSize:{default:20,description:"Resolution of the distortion grid (higher = more detailed)",ui:{type:"range",min:8,max:128,step:1,label:"Grid Size"}}},fragmentNode:({uniforms:t,onBeforeRender:e,childNode:r,onCleanup:i,dimensions:s})=>{let{vec2:n,vec4:a,float:o,uniform:l,screenUV:h,convertToTexture:u,texture:c}=Ve;if(!r)return a(0,0,0,0);let d=Math.round(s.width),m=Math.round(s.height),p=u(r,d,m),f=Math.max(8,Math.min(128,Math.floor(t.gridSize.uniform.value))),g=new Float32Array(f*f*2),y=new em(g,f,f,So,gc);y.magFilter=ps,y.minFilter=ps,y.needsUpdate=!0;let T=c(y),M=l(.5),w=l(.5),_=l(0),S=l(0),N=.5,A=.5,k=Date.now();e(({pointer:ye})=>{let Te=Date.now(),ge=Math.min((Te-k)/1e3,.016);k=Te;let be=ge>0?(ye.x-N)/ge:0,Je=ge>0?(ye.y-A)/ge:0;_.value=_.value*.85+be*.15,S.value=S.value*.85+Je*.15,M.value=ye.x,w.value=ye.y;let wt=t.duration.uniform.value,Bt=t.intensity.uniform.value,He=t.radius.uniform.value*.05,Wr=t.swirl.uniform.value;for(let Hr=0;Hr<f;Hr++)for(let Qt=0;Qt<f;Qt++){let Ot=(Hr*f+Qt)*2;g[Ot]*=1-wt*ge,g[Ot+1]*=1-wt*ge;let br=(Qt+.5)/f,vr=(Hr+.5)/f,qr=br-ye.x,Wt=vr-ye.y,Ir=Math.sqrt(qr*qr+Wt*Wt);if(Ir<He*2&&Math.abs(be)+Math.abs(Je)>.01){let ui=Math.exp(-Ir*Ir/(He*He));if(g[Ot]+=_.value*ui*Bt*ge*.5,g[Ot+1]+=S.value*ui*Bt*ge*.5,Wr>0){let Zi=Math.atan2(Wt,qr)+Math.PI*.5;g[Ot]+=Math.cos(Zi)*Wr*ui*ge*2,g[Ot+1]+=Math.sin(Zi)*Wr*ui*ge*2}}g[Ot]=Math.max(-1,Math.min(1,g[Ot])),g[Ot+1]=Math.max(-1,Math.min(1,g[Ot+1]))}y.needsUpdate=!0,N=ye.x,A=ye.y}),i(()=>{y.dispose()});let Q=t.gridSize.uniform,J=o(1).div(Q),re=h.div(J).floor().mul(J).add(J.mul(.5)),ie=T.sample(re).xy,se=o(.1),ve=o(-.1),me=ie.clamp(n(ve,ve),n(se,se)),Me=h.sub(me);return p.sample(Me)}},Jl={name:"Group",category:"Layout",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Kl={name:"HalfTone",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Ql={name:"HueShift",category:"Color Adjustments",props:{shift:{default:0,description:"The amount to shift the hue by",ui:{type:"range",min:-180,max:180,step:1,label:"Shift"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r}=Ve;if(!e)return console.error("You must pass a child component into the Hue Shift shader."),r(0);let i=e||r(0,0,0,0);return r(Gie(i.rgb,t.shift.uniform).rgb,i.a)}},eu={name:"ImageTexture",category:"Textures",props:{src:{default:"https://picsum.photos/1920/1080",description:"Image URL to display",ui:{type:"text",label:"Source URL"}},fit:{default:"cover",description:"How the image should fit within the canvas"}},fragmentNode:({uniforms:t,onCleanup:e})=>{let{texture:r,screenUV:i}=Ve,s=new TK,n=s.load(t.src.uniform.value);n.colorSpace=Ps,n.flipY=!0;let a=r(n);e(()=>{n.dispose()});let o=i.xy.setY(i.y.oneMinus());return a.sample(o)}},tu={name:"Invert",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e,vec3:r}=Ve;if(!t)return console.error("You must pass a child component into the Invert shader."),e(0);let i=t||e(0,0,0,0),s=i.a,n=s.greaterThan(0).select(i.rgb.div(s),r(0,0,0)),a=r(1,1,1).sub(n),o=a.mul(s);return e(o,s)}},ru={name:"LinearGradient",category:"Gradients & Colors",props:{startColor:{default:"#1aff00",transform:Nt,description:"The starting color of the gradient",ui:{type:"color",label:"Start Color"}},endColor:{default:"#0000ff",transform:Nt,description:"The ending color of the gradient",ui:{type:"color",label:"End Color"}},angle:{default:0,transform:aT,description:"The rotation angle of the gradient (in degrees)",ui:{type:"range",min:0,max:360,step:1,label:"Angle"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the gradient",ui:{type:"position",label:"Center"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,float:i,cos:s,sin:n,dot:a,radians:o,screenUV:l,abs:h,div:u}=Ve,c=o(t.angle.uniform),d=s(c),m=n(c),p=e(d,m),f=e(t.center.uniform[0],t.center.uniform[1].oneMinus()),g=l.sub(f),y=a(g,p),T=i(.5).mul(h(d).add(h(m))),M=u(y,T.max(1e-6)),w=M.mul(.5).add(.5).clamp(i(0),i(1));return r(t.startColor.uniform,t.endColor.uniform,w)}},iu={name:"Liquify",category:"Distortions",requiresRTT:!0,props:{smoothness:{default:0,description:"How smooth and flowing the motion is (0-1)",ui:{type:"range",min:0,max:1,step:.01,label:"Smoothness"}},intensity:{default:1,description:"Strength of the distortion effect",ui:{type:"range",min:0,max:5,step:.1,label:"Intensity"}},swirl:{default:0,description:"Amount of swirl motion (0-1)",ui:{type:"range",min:0,max:1,step:.01,label:"Swirl"}},duration:{default:3,description:"How long the effect persists (higher = longer)",ui:{type:"range",min:0,max:10,step:.1,label:"Duration"}},radius:{default:1,description:"Radius of the distortion effect",ui:{type:"range",min:0,max:3,step:.01,label:"Radius"}}},fragmentNode:({uniforms:t,onBeforeRender:e,childNode:r,onCleanup:i,dimensions:s})=>{let{vec2:n,vec4:a,float:o,uniform:l,screenUV:h,convertToTexture:u,texture:c}=Ve;if(!r)return a(0,0,0,0);let d=Math.round(s.width),m=Math.round(s.height),p=u(r,d,m),f=new Float32Array(1024*2),g=new em(f,32,32,So,gc);g.magFilter=ps,g.minFilter=ps,g.needsUpdate=!0;let y=c(g),T=l(.5),M=l(.5),w=l(0),_=l(0),S=.5,N=.5,A=Date.now();e(({pointer:se})=>{let ve=Date.now(),me=Math.min((ve-A)/1e3,.016);A=ve;let Me=me>0?(se.x-S)/me:0,ye=me>0?(se.y-N)/me:0;w.value=w.value*.85+Me*.15,_.value=_.value*.85+ye*.15,T.value=se.x,M.value=se.y;let Te=t.duration.uniform.value,ge=t.intensity.uniform.value,be=t.radius.uniform.value*.05,Je=t.swirl.uniform.value;for(let wt=0;wt<32;wt++)for(let Bt=0;Bt<32;Bt++){let He=(wt*32+Bt)*2;f[He]*=1-Te*me,f[He+1]*=1-Te*me;let Wr=(Bt+.5)/32,Hr=(wt+.5)/32,Qt=Wr-se.x,Ot=Hr-se.y,br=Math.sqrt(Qt*Qt+Ot*Ot);if(br<be*2&&Math.abs(Me)+Math.abs(ye)>.01){let vr=Math.exp(-br*br/(be*be));if(f[He]+=w.value*vr*ge*me*.5,f[He+1]+=_.value*vr*ge*me*.5,Je>0){let qr=Math.atan2(Ot,Qt)+Math.PI*.5;f[He]+=Math.cos(qr)*Je*vr*me*2,f[He+1]+=Math.sin(qr)*Je*vr*me*2}}f[He]=Math.max(-1,Math.min(1,f[He])),f[He+1]=Math.max(-1,Math.min(1,f[He+1]))}g.needsUpdate=!0,S=se.x,N=se.y}),i(()=>{g.dispose()});let k=y.sample(h).xy,Q=o(.2),J=o(-.2),re=k.clamp(n(J,J),n(Q,Q)),ie=h.sub(re);return p.sample(ie)}},su={name:"Mirror",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},nu={name:"PerlinNoise",category:"Textures",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},au={name:"Pixelate",category:"Effects",requiresRTT:!0,props:{scale:{default:50,description:"Pixel size - higher values create larger, more visible pixels",ui:{type:"range",min:1,max:200,step:1,label:"Scale"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec4:i,floor:s,screenUV:n,convertToTexture:a}=Ve;if(!e)return i(0,0,0,0);let o=Math.round(r.width),l=Math.round(r.height),h=a(e,o,l),u=t.scale.uniform,c=s(n.mul(u)).div(u);return h.sample(c)}};var jie=class extends Ts{static get type(){return"PosterizeNode"}constructor(e,r){super(),this.sourceNode=e,this.stepsNode=r}setup(){let{sourceNode:e,stepsNode:r}=this;return e.mul(r).floor().div(r)}};const Wie=de(jie).setParameterLength(2),ou={name:"Posterize",category:"Color Adjustments",props:{intensity:{default:5,description:"The intensity of the posterization effect (lower is more posterized)",ui:{type:"range",min:2,max:20,step:1,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r,int:i}=Ve;if(!e)return console.error("You must pass a child component into the Posterize shader."),r(0);let s=e||r(0,0,0,0);return Wie(s,i(t.intensity.uniform))}},lu={name:"ProgressiveBlur",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},uu={name:"RadialGradient",category:"Gradients & Colors",props:{startColor:{default:"#ff0000",transform:Nt,description:"The starting color at the center of the gradient",ui:{type:"color",label:"Start Color"}},endColor:{default:"#0000ff",transform:Nt,description:"The ending color at the edge of the gradient",ui:{type:"color",label:"End Color"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the radial gradient",ui:{type:"position",label:"Center"}},radius:{default:1,description:"The radius of the gradient (normalized, 0.0-1.0)",ui:{type:"range",min:0,max:2,step:.01,label:"Radius"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,mix:r,float:i,distance: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=s(l,h),c=u.div(t.radius.uniform).clamp(i(0),i(1));return r(t.startColor.uniform,t.endColor.uniform,c)}},hu={name:"Saturation",category:"Color Adjustments",props:{intensity:{default:1,description:"The intensity of the saturation effect (1 being no change)",ui:{type:"range",min:0,max:3,step:.01,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r}=Ve;if(!e)return console.error("You must pass a child component into the Saturation shader."),r(0);let i=e||r(0,0,0,0);return r(Die(i.rgb,t.intensity.uniform).rgb,i.a)}},cu={name:"SimplexNoise",category:"Textures",props:{scale:{default:2,description:"Pattern scale (higher = larger patterns)",ui:{type:"range",min:-2,max:5,step:.1,label:"Scale"}},balance:{default:0,description:"Balance between colors (negative = more background, -1 = full background range)",ui:{type:"range",min:-1,max:1,step:.01,label:"Balance"}},contrast:{default:0,description:"Pattern contrast (higher = sharper transitions)",ui:{type:"range",min:-2,max:2,step:.1,label:"Contrast"}},color:{default:"#ffffff",description:"Primary noise color",transform:Nt,ui:{type:"color",label:"Color"}},background:{default:"transparent",description:"Background color",transform:Nt,ui:{type:"color",label:"Background"}},seed:{default:0,description:"Random seed for pattern variation",ui:{type:"range",min:0,max:100,step:1,label:"Seed"}},speed:{default:1,description:"Animation speed",ui:{type:"range",min:0,max:5,step:.1,label:"Speed"}},angle:{default:45,transform:aT,description:"Direction of animation movement (in degrees)",ui:{type:"range",min:0,max:360,step:1,label:"Angle"}}},fragmentNode:({uniforms:t})=>{let e=Rb.x.div(Rb.y),r=ng(Ab.x.mul(e),Ab.y),i=QR(t.angle.uniform),s=ng(Vd(i),pl(i)).mul(Dv.mul(t.speed.uniform).mul(.1)),n=r.mul(Nb(t.scale.uniform)).add(t.seed.uniform).add(s),a=YR(0,1,KR(n).mul(.5,Nb(t.contrast.uniform)).add(.5,t.balance.uniform));return Fn(t.background.uniform,t.color.uniform,a)}},du={name:"SineWave",category:"Shapes & Masks",props:{color:{default:"#ffffff",transform:Nt,description:"The color of the sine wave",ui:{type:"color",label:"Color"}},amplitude:{default:.15,description:"The height/amplitude of the sine wave",ui:{type:"range",min:0,max:1,step:.01,label:"Amplitude"}},frequency:{default:1,description:"The frequency/number of wave cycles",ui:{type:"range",min:.1,max:20,step:.1,label:"Frequency"}},speed:{default:1,description:"The animation speed of the wave",ui:{type:"range",min:-5,max:5,step:.1,label:"Speed"}},angle:{default:0,transform:aT,description:"The rotation angle of the wave (in degrees)",ui:{type:"range",min:0,max:360,step:1,label:"Angle"}},position:{default:{x:.5,y:.5},transform:Gu,description:"The center position of the wave",ui:{type:"position",label:"Position"}},thickness:{default:.2,description:"The thickness of the wave line",ui:{type:"range",min:0,max:2,step:.01,label:"Thickness"}},softness:{default:.4,description:"Edge softness of the wave line",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,sin:i,cos:s,abs:n,smoothstep:a,screenUV:o,viewportSize:l,time:h,radians:u,PI:c}=Ve,d=l.x.div(l.y),m=e(o.x.mul(d),o.y),p=e(t.position.uniform.x.mul(d),t.position.uniform.y),f=m.sub(p),g=u(t.angle.uniform),y=s(g),T=i(g),M=f.x.mul(y).sub(f.y.mul(T)),w=f.x.mul(T).add(f.y.mul(y)),_=h.mul(t.speed.uniform),S=M.mul(t.frequency.uniform).mul(c.mul(2)).add(_),N=i(S).mul(t.amplitude.uniform),A=n(w.sub(N)),k=t.thickness.uniform.mul(.5),Q=t.softness.uniform.mul(.5),J=a(k.add(Q),k.sub(Q),A);return r(t.color.uniform.rgb,t.color.uniform.a.mul(J))}},mu={name:"SolidColor",category:"Gradients & Colors",props:{color:{default:"#5b18ca",transform:Nt,description:"The solid color to display",ui:{type:"color",label:"Color"}}},fragmentNode:({uniforms:t})=>t.color.uniform},pu={name:"Spiral",category:"Shapes & Masks",props:{colorBack:{default:"#000000",transform:Nt,description:"Background color",ui:{type:"color",label:"Background Color"}},colorFront:{default:"#ffffff",transform:Nt,description:"Spiral stroke color",ui:{type:"color",label:"Spiral Color"}},strokeWidth:{default:.5,description:"Thickness of spiral stroke",ui:{type:"range",min:0,max:2,step:.01,label:"Stroke Width"}},strokeFalloff:{default:0,description:"Stroke losing width further from center",ui:{type:"range",min:0,max:1,step:.01,label:"Stroke Falloff"}},softness:{default:0,description:"Color transition sharpness (0 = hard edge, 1 = smooth fade)",ui:{type:"range",min:0,max:1,step:.01,label:"Softness"}},speed:{default:1,description:"Animation speed (negative values reverse direction)",ui:{type:"range",min:-3,max:3,step:.1,label:"Speed"}},center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the spiral",ui:{type:"position",label:"Center"}},scale:{default:1,description:"Scale factor for spiral bands (higher = more bands, lower = fewer bands)",ui:{type:"range",min:.1,max:5,step:.1,label:"Scale"}}},fragmentNode:({uniforms:t})=>{let{vec2:e,vec4:r,float:i,atan:s,length:n,clamp:a,fract:o,abs:l,mix:h,smoothstep:u,screenUV:c,time:d,fwidth:m,viewportSize:p}=Ve,f=p.x.div(p.y),g=e(c.x.mul(f),c.y),y=e(t.center.uniform.x.mul(f),t.center.uniform.y.oneMinus()),T=g.sub(y),M=d.mul(t.speed.uniform),w=n(T),_=w,S=s(T.y,T.x).sub(M),N=i(6.283185307),A=S.div(N),k=_.mul(t.scale.uniform).add(A),Q=o(k),J=l(Q.sub(.5)).mul(2),re=a(t.strokeWidth.uniform,t.strokeFalloff.uniform.mul(.005),1),ie=a(t.strokeFalloff.uniform,0,1).mul(w).oneMinus(),se=re.mul(ie),ve=m(k),me=i(4).sub(u(.05,.4,t.strokeWidth.uniform.mul(2)).mul(u(.05,.4,t.strokeWidth.uniform.oneMinus().mul(2))).mul(3)),Me=h(me.mul(ve),m(J),a(ve,0,1)),ye=u(se.sub(Me).sub(t.softness.uniform),se.add(Me).add(t.softness.uniform),J),Te=h(t.colorBack.uniform,t.colorFront.uniform,ye);return r(Te.rgb,Te.a)}},fu={name:"Stretch",category:"Distortions",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},gu={name:"Swirl",category:"Gradients & Colors",props:{colorA:{default:"#1275d8",description:"Primary gradient color",transform:Nt,ui:{type:"color",label:"Primary Color"}},colorB:{default:"#e19136",description:"Secondary gradient color",transform:Nt,ui:{type:"color",label:"Secondary Color"}},colorC:{default:"#320485",description:"Accent gradient color",transform:Nt,ui:{type:"color",label:"Accent Color"}},speed:{default:1,description:"Flow animation speed",ui:{type:"range",min:0,max:5,step:.1,label:"Speed"}},scale:{default:5,description:"Gradient scale",ui:{type:"range",min:.1,max:20,step:.1,label:"Scale"}},complexity:{default:5,description:"Flow complexity",ui:{type:"range",min:1,max:10,step:.1,label:"Complexity"}}},fragmentNode:({uniforms:t})=>{let e=t3(),r=Dv.mul(t.speed.uniform),i=t.scale.uniform,s=t.complexity.uniform,n=pl(e.x.mul(i.mul(1.2)).add(r.mul(.8))).mul(.3),a=Vd(e.y.mul(i.mul(.9)).sub(r.mul(.6))).mul(.3),o=ng(e.x.add(pl(e.y.mul(s.mul(2)).add(r)).mul(.08)),e.y.add(Vd(e.x.mul(s.mul(1.5)).sub(r.mul(.7))).mul(.08))),l=pl(o.x.mul(i.mul(3)).add(o.y.mul(i.mul(2))).add(r.mul(.5))),h=Vd(o.x.sub(o.y).mul(i.mul(2.5)).add(r.mul(.3))),u=pl(o.x.mul(s).add(n).add(o.y.mul(s.mul(.8)).add(a)).add(r.mul(.4))),c=Fn(l,h,u.mul(.5).add(.5)),d=o.x.mul(.7).add(o.y.mul(.3)).add(c.mul(.2)),m=Fn(t.colorA.uniform,t.colorB.uniform,Cb(.1,.6,d)),p=Fn(m,t.colorC.uniform,Cb(.4,.9,d.add(u.mul(.3)))),f=pl(r.mul(3).add(d.mul(10))).mul(.02).add(1),g=p.mul(f);return at(g.rgb,g.a)}},yu={name:"TiltShift",category:"Effects",requiresRTT:!0,props:{focusDistance:{default:.5,description:"Distance from top where focus is sharpest (0 = top, 1 = bottom)",ui:{type:"range",min:0,max:1,step:.01,label:"Focus Distance"}},focusRange:{default:.2,description:"Range of the focus area",ui:{type:"range",min:.01,max:1,step:.01,label:"Focus Range"}},blurIntensity:{default:8,description:"Intensity of the blur effect",ui:{type:"range",min:0,max:50,step:.5,label:"Blur Intensity"}},angle:{default:0,description:"Angle of the tilt shift effect in degrees",ui:{type:"range",min:-90,max:90,step:1,label:"Angle"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,float:n,screenUV:a,convertToTexture:o,viewportSize:l,smoothstep:h,abs:u,sin:c,cos:d,radians:m}=Ve;if(!e)return s(0,0,0,0);let p=Math.round(r.width),f=Math.round(r.height),g=o(e,p,f),y=m(t.angle.uniform),T=d(y),M=c(y),w=a.sub(i(.5,.5)),_=i(w.x.mul(T).sub(w.y.mul(M)),w.x.mul(M).add(w.y.mul(T))).add(i(.5,.5)),S=t.focusDistance.uniform,N=u(_.y.sub(S)),A=t.focusRange.uniform.div(2),k=h(A,A.add(.1),N),Q=k.mul(t.blurIntensity.uniform).div(l.x.min(l.y)),J=[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)],re=[.0625,.125,.0625,.125,.25,.125,.0625,.125,.0625],ie=s(0);for(let me=0;me<J.length;me++){let Me=J[me].mul(Q),ye=a.add(Me),Te=n(re[me]),ge=g.sample(ye);ie=ie.add(ge.mul(Te))}let se=g.sample(a),ve=n(1).sub(k);return se.mul(ve).add(ie.mul(k))}},xu={name:"Tint",category:"Color Adjustments",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},bu={name:"Twirl",category:"Distortions",requiresRTT:!0,props:{center:{default:{x:.5,y:.5},transform:Gu,description:"The center point of the twirl effect",ui:{type:"position",label:"Center"}},intensity:{default:1,description:"The strength of the twirl effect",ui:{type:"range",min:-5,max:5,step:.1,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e,dimensions:r})=>{let{vec2:i,vec4:s,cos:n,sin:a,length:o,screenUV:l,convertToTexture:h}=Ve;if(!e)return console.error("You must pass a child component into the Twirl shader."),s(0);let u=Math.round(r.width),c=Math.round(r.height),d=h(e,u,c),m=l,p=i(t.center.uniform.x,t.center.uniform.y.oneMinus()),f=m.sub(p),g=t.intensity.uniform.mul(o(f)),y=n(g),T=a(g),M=y.mul(f.x).sub(T.mul(f.y)),w=T.mul(f.x).add(y.mul(f.y)),_=i(M.add(p.x),w.add(p.y));return s(d.sample(_))}},vu={name:"VCR",category:"Effects",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Tu={name:"Vibrance",category:"Color Adjustments",props:{intensity:{default:0,description:"The intensity of the vibrance effect",ui:{type:"range",min:-2,max:2,step:.01,label:"Intensity"}}},fragmentNode:({uniforms:t,childNode:e})=>{let{vec4:r}=Ve;if(!e)return console.error("You must pass a child component into the Vibrance shader."),r(0);let i=e||r(0,0,0,0);return r($ie(i.rgb,t.intensity.uniform).rgb,i.a)}},wu={name:"Vignette",category:"Shapes & Masks",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}},Su={name:"Voronoi",category:"Textures",props:{},fragmentNode:({childNode:t})=>{let{vec4:e}=Ve;return t||e(0)}};function Hie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=Le(K(e.rgb,i),K(t.rgb,K(t.a,_e(1,i))));return at(n,s)}function qie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(t.rgb,e.rgb),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Xie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=_e(1,K(_e(1,t.rgb),_e(1,e.rgb))),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Yie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ay(Le(t.rgb,e.rgb),1),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Zie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(2,K(t.rgb,e.rgb)),a=_e(1,K(2,K(_e(1,t.rgb),_e(1,e.rgb)))),o=Fn(n,a,Ac(.5,t.rgb)),l=Le(K(o,i),K(t.rgb,K(t.a,_e(1,i))));return at(l,s)}function Jie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=XR(_e(t.rgb,e.rgb)),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Kie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=Fn(t.rgb,ay(ZR(t.rgb,_e(1,e.rgb)),1),Ac(.001,_e(1,e.rgb))),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function Qie(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=_e(Le(t.rgb,e.rgb),K(2,K(t.rgb,e.rgb))),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function zo(t){return Le(Le(K(t.r,.2126),K(t.g,.7152)),K(t.b,.0722))}function ese(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=_e(n,a),l=Le(e.rgb,o),h=Le(K(l,i),K(t.rgb,K(t.a,_e(1,i))));return at(h,s)}function tse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=a.div(Le(n,1e-4)),l=K(t.rgb,o),h=Le(K(l,i),K(t.rgb,K(t.a,_e(1,i))));return at(h,s)}function rse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ay(t.rgb,e.rgb),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function ise(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ny(t.rgb,e.rgb),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function sse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=Fn(at(0,0,0,1).rgb,ny(_e(1,_e(1,t.rgb).div(Le(e.rgb,1e-4))),0),Ac(1e-4,e.rgb)),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function nse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=ny(Le(Le(t.rgb,e.rgb),-1),0),a=Le(K(n,i),K(t.rgb,K(t.a,_e(1,i))));return at(a,s)}function ase(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(2,K(t.rgb,e.rgb)),a=K(t.rgb,t.rgb),o=Le(n,K(a,_e(1,K(2,e.rgb)))),l=e3(t.rgb),h=Le(K(2,K(t.rgb,_e(1,e.rgb))),K(l,_e(K(2,e.rgb),1))),u=Fn(o,h,Ac(.5,e.rgb)),c=Le(K(u,i),K(t.rgb,K(t.a,_e(1,i))));return at(c,s)}function ose(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=K(2,K(t.rgb,e.rgb)),a=_e(1,K(2,K(_e(1,t.rgb),_e(1,e.rgb)))),o=Fn(n,a,Ac(.5,e.rgb)),l=Le(K(o,i),K(t.rgb,K(t.a,_e(1,i))));return at(l,s)}function lse(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=t.rgb.sub(n),l=e.rgb.sub(a),h=o.length(),u=l.normalize(),c=Le(K(u,h),n),d=Le(K(c,i),K(t.rgb,K(t.a,_e(1,i))));return at(d,s)}function use(t,e,r=1){let i=K(e.a,r),s=Le(i,K(t.a,_e(1,i))),n=zo(t.rgb),a=zo(e.rgb),o=t.rgb.sub(n),l=e.rgb.sub(a),h=o.normalize(),u=l.length(),c=Le(K(h,u),n),d=Le(K(c,i),K(t.rgb,K(t.a,_e(1,i))));return at(d,s)}const H_={normal:Hie,multiply:qie,screen:Xie,linearDodge:Yie,overlay:Zie,difference:Jie,colorDodge:Kie,exclusion:Qie,color:ese,luminosity:tse,darken:rse,lighten:ise,colorBurn:sse,linearBurn:nse,softLight:ase,hardLight:ose,hue:lse,saturation:use};function hf(t,e,r="normal",i=1){return(H_[r]||H_.normal)(t,e,i)}function hse(t,e){let r=K(t.a,e.a);return at(t.rgb,r)}function cse(t,e){let r=_e(1,e.a),i=K(t.a,r);return at(t.rgb,i)}function dse(t,e){let r=$v(.2126,.7152,.0722),i=Uv(e.rgb,r),s=K(t.a,i);return at(t.rgb,s)}function mse(t,e){let r=$v(.2126,.7152,.0722),i=Uv(e.rgb,r),s=_e(1,i),n=K(t.a,s);return at(t.rgb,n)}const q_={alpha:hse,alphaInverted:cse,luminance:dse,luminanceInverted:mse};function pse(t,e,r="alpha"){return(q_[r]||q_.alpha)(t,e)}let X_=!1;const fse=()=>{try{{let{MODE:t,DEV:e}={DEV:!1,MODE:"production"};return e||t==="development"}if(typeof window<"u"&&window.location){let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".local")||t.includes("dev.")||t.startsWith("dev-")}return!1}catch{return!1}};function gse(){let t=null,e,r,i,s,n,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,l=null,h=null,u=!1,c=!1,d=!1,m=null,p=!1,f=!0,g=0,y=0,T=!1,M=0,w=0,_=!1,S=.5,N=.5,A=!1,k=!1,Q=!1,J=[],re=!1,ie=[],se=!1,ve=new Set,me=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,Me=(he,oe)=>{if(he<=0||oe<=0||he===g&&oe===y)return;let xe=performance.now();if(xe-M<8)return;let ce=g,qe=y;g=he,y=oe,M=xe,d||(d=!0),e.setSize(he,oe,!1);let ut=he/oe,ht=2*ut;r.left=-ht/2,r.right=ht/2,r.top=2/2,r.bottom=-2/2,r.updateProjectionMatrix(),s.scale.set(ht,2,1),(a.rootId&&(ce===0||qe===0)||a.rootId&&d)&&be(),Wt().catch(console.warn)},ye=he=>{if(!e||!r||!s)return;let oe=he[0];if(!oe)return;let{width:xe,height:ce}=oe.contentRect,qe=Math.round(xe),ut=Math.round(ce);qe===0||ut===0||Me(qe,ut)},Te=he=>{let oe=he[0];if(!oe)return;let xe=p;p=oe.isIntersecting;let ce=t?.getBoundingClientRect(),qe=T;if(T=p&&!!ce&&ce.width>0&&ce.height>0,p&&!xe){if(_=!0,t){let{width:ut,height:ht}=t.getBoundingClientRect(),Pt=Math.round(ut),Lt=Math.round(ht);Pt>0&&Lt>0&&(g===0||y===0||Pt!==g||Lt!==y?(Me(Pt,Lt),!qe&&T&&be()):n&&u&&a.rootId&&(n.needsUpdate=!0,be(),Wt().catch(console.warn)))}f&&Ir()}else!p&&xe&&ui()},ge=!1,be=()=>{if(!a.rootId||!n||k)return;if(a.nodes.get(a.rootId)){if(g===0||y===0){ge||(ge=!0,requestAnimationFrame(()=>{ge=!1,g>0&&y>0&&be()}));return}k=!0;try{let oe=new Set,xe=Wr(a.rootId,new Set,oe);xe&&n&&((ve.size!==oe.size||![...ve].every(qe=>oe.has(qe))||![...oe].every(qe=>ve.has(qe))||_)&&(n.fragmentNode=null,n.needsUpdate=!0,_=!1,ve=oe),n.fragmentNode=xe,n.needsUpdate=!0)}catch(oe){console.error("Error composing shader tree:",oe)}finally{k=!1}p&&Wt().catch(console.warn)}},Je=he=>{let oe=[];return a.nodes.forEach(xe=>{xe.parentId===he&&oe.push(xe)}),oe},wt=he=>{for(let[oe,xe]of a.nodes.entries())if(xe.metadata.id===he)return oe;return null},Bt=(he,oe,xe,ce)=>{if(!oe.metadata.mask?.source)return he;let qe=oe.metadata.mask.source,ut=wt(qe);if(!ut)return he;if(ce.has(ut))return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."),he;let ht=new Set(ce);ht.add(xe);let Pt=Wr(ut,ht),Lt=oe.metadata.mask.type||"alpha";return pse(he,Pt,Lt)},He=he=>{let oe=a.nodes.get(he);if(!oe||!oe.metadata.id)return!1;let xe=oe.metadata.id;for(let ce of a.nodes.values())if(ce.metadata.mask?.source===xe)return!0;return!1},Wr=(he,oe=new Set,xe)=>{if(g===0||y===0)return at(0,0,0,0);let ce=a.nodes.get(he);if(!ce)return at(0,0,0,0);let qe=Lt=>{ce.cleanupCallbacks.push(Lt)},ut=Lt=>{ce.beforeRenderCallbacks.push(Lt)},ht=Lt=>{ce.afterRenderCallbacks.push(Lt)},Pt=Je(he);if(Pt.length===0){if(ce.requiresRTT&&!T)return at(0,0,0,0);let Lt=ce.fragmentNodeFunc({uniforms:ce.uniforms??{},childNode:void 0,onCleanup:qe,onBeforeRender:ut,onAfterRender:ht,canvas:t,dimensions:{width:Math.max(512,g),height:Math.max(512,y)}});return Bt(Lt,ce,he,oe)}else{let Lt=[...Pt].sort((yt,st)=>yt.metadata.renderOrder-st.metadata.renderOrder);if(ce.parentId===null){let yt;for(let ct of Lt){let Xr;if(ct.metadata.opacity===void 0?(Xr=He(ct.id)?0:1,ct.opacityUniform.value=Xr):(Xr=ct.metadata.opacity,ct.opacityUniform.value=Xr),Xr===0&&!He(ct.id))continue;xe&&xe.add(ct.id);let Ji=Wr(ct.id,oe,xe);yt===void 0?yt=ce.requiresRTT||Xr!==1?hf(at(1,1,1,0),Ji,ct.metadata.blendMode,ct.opacityUniform):Ji:yt=hf(yt,Ji,ct.metadata.blendMode,ct.opacityUniform)}if(ce.requiresRTT&&!T)return at(0,0,0,0);let st=ce.fragmentNodeFunc({uniforms:ce.uniforms??{},childNode:yt,onCleanup:qe,onBeforeRender:ut,onAfterRender:ht,canvas:t,dimensions:{width:Math.max(512,g),height:Math.max(512,y)}});return Bt(st,ce,he,oe)}else{let yt;for(let ct of Lt){let Xr;if(ct.metadata.opacity===void 0?(Xr=He(ct.id)?0:1,ct.opacityUniform.value=Xr):(Xr=ct.metadata.opacity,ct.opacityUniform.value=Xr),Xr===0&&!He(ct.id))continue;xe&&xe.add(ct.id);let Ji=Wr(ct.id,oe,xe);yt===void 0?yt=ce.requiresRTT||Xr!==1?hf(at(1,1,1,0),Ji,ct.metadata.blendMode,ct.opacityUniform):Ji:yt=hf(yt,Ji,ct.metadata.blendMode,ct.opacityUniform)}if(ce.requiresRTT&&!T)return at(0,0,0,0);let st=ce.fragmentNodeFunc({uniforms:ce.uniforms??{},childNode:yt,onCleanup:qe,onBeforeRender:ut,onAfterRender:ht,canvas:t,dimensions:{width:Math.max(512,g),height:Math.max(512,y)}});return Bt(st,ce,he,oe)}}},Hr=(he,oe,xe,ce,qe={},ut)=>{let ht=0;if(xe!==null){let yt=Array.from(a.nodes.values()).filter(st=>st.parentId===xe);yt.length>0&&(ht=Math.max(...yt.map(st=>st.metadata.renderOrder))+1)}let Pt=ce?.opacity===void 0?1:ce.opacity,Lt=Od(Pt),ar={id:he,fragmentNodeFunc:oe,parentId:xe,requiresRTT:ut?.requiresRTT||!1,opacityUniform:Lt,metadata:{blendMode:ce?.blendMode||"normal",opacity:ce?.opacity,id:ce?.id,mask:ce?.mask,renderOrder:ce?.renderOrder===void 0?ht:ce?.renderOrder},uniforms:qe,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(he,ar),xe===null&&(a.rootId=he),n&&u&&g>0&&y>0?(J.includes(he)||J.push(he),re||(re=!0,queueMicrotask(()=>{re=!1,J=[],be()}))):n&&u&&(ge||(ge=!0,requestAnimationFrame(()=>{ge=!1,g>0&&y>0&&be()})))},Qt=(he,oe,xe)=>{let ce=a.nodes.get(he);if(!ce||!ce.uniforms)return;let qe=ce.uniforms[oe];!qe||!qe.uniform||(qe.uniform.value=xe,p&&Wt())},Ot=(he,oe)=>{let xe=a.nodes.get(he);if(!xe)return;let ce=!1;if(oe.blendMode!==void 0&&xe.metadata.blendMode!==oe.blendMode&&(xe.metadata.blendMode=oe.blendMode,ce=!0),oe.opacity!==void 0&&xe.metadata.opacity!==oe.opacity){let qe=xe.metadata.opacity===0,ut=oe.opacity===0;xe.metadata.opacity=oe.opacity,xe.opacityUniform.value=oe.opacity,qe!==ut&&(ce=!0)}oe.renderOrder!==void 0&&xe.metadata.renderOrder!==oe.renderOrder&&(xe.metadata.renderOrder=oe.renderOrder,ce=!0),oe.id!==void 0&&xe.metadata.id!==oe.id&&(xe.metadata.id=oe.id,ce=!0),oe.mask!==void 0&&(xe.metadata.mask?.source!==oe.mask?.source||xe.metadata.mask?.type!==oe.mask?.type)&&(xe.metadata.mask=oe.mask,ce=!0),ce&&n&&u?(ie.includes(he)||ie.push(he),se||(se=!0,queueMicrotask(()=>{se=!1,ie=[],be()}))):p&&Wt()},br=he=>{if(!a.nodes.has(he))return;let oe=a.nodes.get(he);if(oe&&oe.cleanupCallbacks.length>0)for(let ce of oe.cleanupCallbacks)try{ce()}catch(qe){console.error(`Error executing cleanup callback for node ${he}:`,qe)}let xe=Je(he);for(let ce of xe)br(ce.id);a.rootId===he&&(a.rootId=null),a.nodes.delete(he),n&&u&&be()},vr=he=>{let oe={deltaTime:he,pointer:{x:S,y:N},pointerActive:A,dimensions:{width:g,height:y}};for(let xe of a.nodes.values())if(xe.beforeRenderCallbacks.length>0)for(let ce of xe.beforeRenderCallbacks)try{ce(oe)}catch(qe){console.error(`Error executing before render callback for node ${xe.id}:`,qe)}},qr=he=>{let oe={deltaTime:he,pointer:{x:S,y:N},pointerActive:A,dimensions:{width:g,height:y}};for(let xe of a.nodes.values())if(xe.afterRenderCallbacks.length>0)for(let ce of xe.afterRenderCallbacks)try{ce(oe)}catch(qe){console.error(`Error executing after render callback for node ${xe.id}:`,qe)}},Wt=async()=>{if(!u||!e||!i||!r||!n||g===0||y===0)return;let he=performance.now(),oe=w>0?(he-w)/1e3:.016,xe=Math.min(oe,.1);w=he,vr(xe);try{if(k)return;e instanceof sM?await e.renderAsync(i,r).then(()=>{u&&qr(xe)}).catch(ce=>{console.error("WebGPU render error:",ce)}):(e.render(i,r),qr(xe))}catch(ce){console.error("Render frame error:",ce)}},Ir=()=>{if(o||!f||!p)return;let he=()=>{o=requestAnimationFrame(he),Wt().catch(console.warn)};he()},ui=()=>{o&&(cancelAnimationFrame(o),o=null)},Zi=he=>{if(!t)return;let oe,xe;if("touches"in he){if(he.touches.length===0)return;oe=he.touches[0].clientX,xe=he.touches[0].clientY}else oe=he.clientX,xe=he.clientY;let ce=t.getBoundingClientRect(),qe=(oe-ce.left)/ce.width,ut=(xe-ce.top)/ce.height;S=qe,N=ut},Mi=he=>{Zi(he)},ri=he=>{Zi(he)},_i=()=>{A=!1,Wt().catch(console.warn)},Ni=()=>{A=!1,Wt().catch(console.warn)},ws=()=>{A=!0,Wt().catch(console.warn)},ta=()=>{A=!0,Wt().catch(console.warn)};return{initialize:async({canvas:he})=>{if(u||c)return;c=!0,m=new AbortController;let oe=m;try{if(t=he,i=new Rg,i.background=null,r=new Pg(-1,1,1,-1,.1,10),r.position.z=1,r.lookAt(0,0,0),Q||(window.addEventListener("mousemove",Mi),window.addEventListener("touchmove",ri),window.addEventListener("mouseup",_i),window.addEventListener("touchend",Ni),he.addEventListener("mousedown",ws),he.addEventListener("touchstart",ta),Q=!0),oe.signal.aborted)return;try{if(e=new sM({canvas:he,antialias:!0,alpha:!0,depth:!1,powerPreference:"high-performance"}),await e.init(),oe.signal.aborted)return}catch(Lt){if(oe.signal.aborted)return;console.error("[Shaders] WebGPU initialization error:",Lt);return}if(oe.signal.aborted)return;e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=Ui,n=new mC({transparent:!0}),n.fragmentNode=at(0,0,0,0);let xe=new KN(2,2);s=new Dn(xe,n),i.add(s),l=new ResizeObserver(ye),l.observe(he),h=new IntersectionObserver(Te,{threshold:0}),h.observe(he);let ce=he.getBoundingClientRect();p=ce.width>0&&ce.height>0&&ce.top<window.innerHeight&&ce.bottom>0&&ce.left<window.innerWidth&&ce.right>0,T=p&&ce.width>0&&ce.height>0,f=!me();let{width:qe,height:ut}=he.getBoundingClientRect(),ht=Math.round(qe),Pt=Math.round(ut);ht>0&&Pt>0?(Me(ht,Pt),d=!0,await Wt()):d=!1,f&&p&&Ir(),oe.signal.aborted||(u=!0)}catch(xe){console.error("[Shaders] Initialization error:",xe)}finally{c=!1,m===oe&&(m=null)}},cleanup:()=>{if(m&&m.abort(),l&&(l.disconnect(),l=null),h&&(h.disconnect(),h=null),Q&&(t&&(t.removeEventListener("mousedown",ws),t.removeEventListener("touchstart",ta)),window&&(window.removeEventListener("mousemove",Mi),window.removeEventListener("touchmove",ri),window.removeEventListener("mouseup",_i),window.removeEventListener("touchend",Ni)),Q=!1),ui(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),J=[],re=!1,ie=[],se=!1,s){i&&i.remove(s);try{s.geometry&&typeof s.geometry.dispose=="function"&&s.geometry.dispose()}catch{}try{s.material instanceof Fi&&typeof s.material.dispose=="function"&&s.material.dispose()}catch{}}if(e&&typeof e.dispose=="function")try{e.dispose()}catch{}t=null,e=null,r=null,i=null,s=null,n=null,u=!1,c=!1,d=!1,m=null,g=0,y=0,p=!1,f=!0,S=.5,N=.5,A=!1},registerNode:Hr,removeNode:br,updateUniformValue:Qt,updateNodeMetadata:Ot,showLicenseWarning:()=>{!fse()||X_||(console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."),X_=!0)},isInitialized:()=>u}}const{uniform:yse}=Ve;function Fe(t,e,r){let i={};return Object.entries(t.props).forEach(([s,n])=>{let a=e[s],o=a;n.transform&&(o=n.transform(a)),i[s]={uniform:yse(o).label(`${s}_${r}`),transform:n.transform||void 0}}),i}const{vec2:Gfe,fract:jfe,sin:Wfe,dot:Hfe}=Ve,{vec2:qfe}=Ve,xse=()=>{let t={};return Object.entries({Ascii:El,Blob:Cl,Blur:Rl,Bulge:Pl,Checkerboard:Il,ChromaFlow:Vl,ChromaticAberration:Ol,Circle:Ll,ColorMapping:Fl,CRTScreen:zl,Dither:Bl,DotGrid:kl,Duotone:Ul,Exposure:Dl,FilmGrain:$l,GlassTiles:Gl,Glitch:jl,Glow:Wl,Godrays:Hl,Grayscale:Xl,Grid:Yl,GridDistortion:Zl,Group:Jl,HalfTone:Kl,HueShift:Ql,ImageTexture:eu,Invert:tu,LinearGradient:ru,Liquify:iu,Mirror:su,PerlinNoise:nu,Pixelate:au,Posterize:ou,ProgressiveBlur:lu,RadialGradient:uu,Saturation:hu,SimplexNoise:cu,SineWave:du,SolidColor:mu,Spiral:pu,Stretch:fu,Swirl:gu,TiltShift:yu,Tint:xu,Twirl:bu,VCR:vu,Vibrance:Tu,Vignette:wu,Voronoi:Su}).forEach(([r,i])=>{let s={};i.props&&Object.entries(i.props).forEach(([n,a])=>{a.ui&&(s[n]={ui:a.ui,default:a.default,description:a.description})}),t[i.name]={name:i.name,fileName:r,category:i.category||"Uncategorized",definition:i,propsMetadata:s}}),t};xse();/**
455
455
  * @license
456
456
  * Copyright 2010-2025 Three.js Authors
457
457
  * SPDX-License-Identifier: MIT
458
- */const bse=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class vse{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=bse,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const r=e.getMRT();return r!==null&&r.has("velocity")}getRenderObjectData(e){let r=this.renderObjects.get(e);if(r===void 0){const{geometry:i,material:s,object:n}=e;if(r={material:this.getMaterialData(s),geometry:{id:i.id,attributes:this.getAttributesData(i.attributes),indexVersion:i.index?i.index.version:null,drawRange:{start:i.drawRange.start,count:i.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(r.center=n.center.clone()),n.morphTargetInfluences&&(r.morphTargetInfluences=n.morphTargetInfluences.slice()),e.bundle!==null&&(r.version=e.bundle.version),r.material.transmission>0){const{width:a,height:o}=e.context;r.bufferWidth=a,r.bufferHeight=o}this.renderObjects.set(e,r)}return r}getAttributesData(e){const r={};for(const i in e){const s=e[i];r[i]={version:s.version}}return r}containsNode(e){const r=e.material;for(const i in r)if(r[i]&&r[i].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){const r={};for(const i of this.refreshUniforms){const s=e[i];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?r[i]={id:s.id,version:s.version}:r[i]=s.clone():r[i]=s)}return r}equals(e){const{object:r,material:i,geometry:s}=e,n=this.getRenderObjectData(e);if(n.worldMatrix.equals(r.matrixWorld)!==!0)return n.worldMatrix.copy(r.matrixWorld),!1;const a=n.material;for(const f in a){const g=a[f],y=i[f];if(g.equals!==void 0){if(g.equals(y)===!1)return g.copy(y),!1}else if(y.isTexture===!0){if(g.id!==y.id||g.version!==y.version)return g.id=y.id,g.version=y.version,!1}else if(g!==y)return a[f]=y,!1}if(a.transmission>0){const{width:f,height:g}=e.context;if(n.bufferWidth!==f||n.bufferHeight!==g)return n.bufferWidth=f,n.bufferHeight=g,!1}const o=n.geometry,l=s.attributes,h=o.attributes,u=Object.keys(h),c=Object.keys(l);if(o.id!==s.id)return o.id=s.id,!1;if(u.length!==c.length)return n.geometry.attributes=this.getAttributesData(l),!1;for(const f of u){const g=h[f],y=l[f];if(y===void 0)return delete h[f],!1;if(g.version!==y.version)return g.version=y.version,!1}const d=s.index,m=o.indexVersion,p=d?d.version:null;if(m!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==s.drawRange.start||o.drawRange.count!==s.drawRange.count)return o.drawRange.start=s.drawRange.start,o.drawRange.count=s.drawRange.count,!1;if(n.morphTargetInfluences){let f=!1;for(let g=0;g<n.morphTargetInfluences.length;g++)n.morphTargetInfluences[g]!==r.morphTargetInfluences[g]&&(f=!0);if(f)return!0}return n.center&&n.center.equals(r.center)===!1?(n.center.copy(r.center),!0):(e.bundle!==null&&(n.version=e.bundle.version),!0)}needsRefresh(e,r){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(r.renderer))return!0;const{renderId:i}=r;if(this.renderId!==i)return this.renderId=i,!0;const s=e.object.static===!0,n=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return s||n?!1:this.equals(e)!==!0}}function nm(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 Tse=t=>nm(t),C5=t=>nm(t),R5=(...t)=>nm(t);function P5(t,e=!1){const r=[];t.isNode===!0&&(r.push(t.id),t=t.getSelf());for(const{property:i,childNode:s}of yg(t))r.push(nm(i.slice(0,-4)),s.getCacheKey(e));return nm(r)}function*yg(t,e=!1){for(const r in t){if(r.startsWith("_")===!0)continue;const i=t[r];if(Array.isArray(i)===!0)for(let s=0;s<i.length;s++){const 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(const s in i){const n=i[s];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:s,childNode:n})}}}const wse=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Y_=new WeakMap;function Sse(t){return wse.get(t)}function xg(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function I5(t){if(/float|int|uint/.test(t))return 1;if(/vec2/.test(t))return 2;if(/vec3/.test(t))return 3;if(/vec4/.test(t)||/mat2/.test(t))return 4;if(/mat3/.test(t))return 9;if(/mat4/.test(t))return 16;console.error("THREE.TSL: Unsupported type:",t)}function Mse(t){if(/float|int|uint/.test(t))return 1;if(/vec2/.test(t))return 2;if(/vec3/.test(t))return 3;if(/vec4/.test(t)||/mat2/.test(t))return 4;if(/mat3/.test(t))return 12;if(/mat4/.test(t))return 16;console.error("THREE.TSL: Unsupported type:",t)}function _se(t){if(/float|int|uint/.test(t))return 4;if(/vec2/.test(t))return 8;if(/vec3/.test(t)||/vec4/.test(t))return 16;if(/mat2/.test(t))return 8;if(/mat3/.test(t))return 48;if(/mat4/.test(t))return 64;console.error("THREE.TSL: Unsupported type:",t)}function Mo(t){if(t==null)return null;const 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 V5(t,...e){const 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 ja(...e):r==="vec2"?new Jt(...e):r==="vec3"?new $(...e):r==="vec4"?new Si(...e):r==="mat2"?new Jv(...e):r==="mat3"?new qs(...e):r==="mat4"?new Rt(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?F5(e[0]):null}function O5(t){let e=Y_.get(t);return e===void 0&&(e={},Y_.set(t,e)),e}function L5(t){let e="";const r=new Uint8Array(t);for(let i=0;i<r.length;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function F5(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer}const wd={VERTEX:"vertex",FRAGMENT:"fragment"},Tt={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Nse={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Rn={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},z5=["fragment","vertex"],Ese=["setup","analyze","generate"],Ase=[...z5,"compute"],Rc=["x","y","z","w"],Cse={analyze:"setup",generate:"analyze"};let Rse=0;class Ae extends Du{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Tt.NONE,this.updateBeforeType=Tt.NONE,this.updateAfterType=Tt.NONE,this.uuid=a3.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Rse++})}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,Tt.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Tt.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Tt.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(const{childNode:e}of yg(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const r of this.getChildren())r.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=R5(P5(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){const r=this.getNodeType(e);return e.getElementType(r)}getMemberType(){return"void"}getNodeType(e){const r=e.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(e):this.nodeType}getShared(e){const r=this.getHash(e);return e.getNodeFromHash(r)||this}setup(e){const r=e.getNodeProperties(this);let i=0;for(const s of this.getChildren())r["node"+i++]=s;return r.outputNode||null}analyze(e,r=null){const i=e.increaseUsage(this);if(this.parents===!0){const 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){const s=e.getNodeProperties(this);for(const n of Object.values(s))n&&n.isNode===!0&&n.build(e,this)}}generate(e,r){const{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){const i=this.getShared(e);if(this!==i)return i.build(e,r);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const n=Cse[e.buildStage];if(n&&s.buildStages[n]!==!0){const l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addNode(this),e.addChain(this);let a=null;const o=e.getBuildStage();if(o==="setup"){this.updateReference(e);const l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(const h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){const 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){const 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 yg(this)}serialize(e){const r=this.getSerializeChildren(),i={};for(const{property:s,index:n,childNode:a}of r)n!==void 0?(i[s]===void 0&&(i[s]=Number.isInteger(n)?[]:{}),i[s][n]=a.toJSON(e.meta).uuid):i[s]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const r=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const s=[];for(const n of e.inputNodes[i])s.push(r[n]);this[i]=s}else if(typeof e.inputNodes[i]=="object"){const s={};for(const n in e.inputNodes[i]){const a=e.inputNodes[i][n];s[n]=r[a]}this[i]=s}else{const s=e.inputNodes[i];this[i]=r[s]}}}toJSON(e){const{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){const l=[];for(const h in o){const u=o[h];delete u.metadata,l.push(u)}return l}if(s){const 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}}class ju extends Ae{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){const 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} ]`}}class B5 extends Ae{static get type(){return"ConvertNode"}constructor(e,r){super(),this.node=e,this.convertTo=r}getNodeType(e){const r=this.node.getNodeType(e);let i=null;for(const 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){const i=this.node,s=this.getNodeType(e),n=i.build(e,s);return e.format(n,s,r)}}class xr extends Ae{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"){const 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)){const 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)}}class Pse extends xr{static get type(){return"JoinNode"}constructor(e=[],r=null){super(r),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((r,i)=>r+e.getTypeLength(i.getNodeType(e)),0))}generate(e,r){const i=this.getNodeType(e),s=e.getTypeLength(i),n=this.nodes,a=e.getComponentType(i),o=[];let l=0;for(const 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);const p=e.getComponentType(c);p!==a&&(m=e.format(m,p,a)),o.push(m)}const h=`${e.getType(i)}( ${o.join(", ")} )`;return e.format(h,i,r)}}const Ise=Rc.join("");class Qb extends Ae{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(const r of this.components)e=Math.max(Rc.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){const i=this.node,s=e.getTypeLength(i.getNodeType(e));let n=null;if(s>1){let a=null;this.getVectorLength()>=s&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const l=i.build(e,a);this.components.length===s&&this.components===Ise.slice(0,this.components.length)?n=e.format(l,a,r):n=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}}class Vse extends xr{static get type(){return"SetNode"}constructor(e,r,i){super(),this.sourceNode=e,this.components=r,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:r,components:i,targetNode:s}=this,n=this.getNodeType(e),a=e.getComponentType(s.getNodeType(e)),o=e.getTypeFromLength(i.length,a),l=s.build(e,o),h=r.build(e,n),u=e.getTypeLength(n),c=[];for(let d=0;d<u;d++){const m=Rc[d];m===i[0]?(c.push(l),d+=i.length-1):c.push(h+"."+m)}return`${e.getType(n)}( ${c.join(", ")} )`}}class Ose extends xr{static get type(){return"FlipNode"}constructor(e,r){super(),this.sourceNode=e,this.components=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{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);const l=e.getTypeLength(s),h=[];let u=0;for(let c=0;c<l;c++){const d=Rc[c];d===r[u]?(h.push("1.0 - "+(o+"."+d)),u++):h.push(o+"."+d)}return`${e.getType(s)}( ${h.join(", ")} )`}}class bT extends Ae{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?Mo(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=Mo(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=L5(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?V5(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.")}}const Z_=/float|u?int/;class wn extends bT{static get type(){return"ConstNode"}constructor(e,r=null){super(e,r),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,r){const i=this.getNodeType(e);return Z_.test(i)&&Z_.test(r)?e.generateConst(r,this.value):e.format(this.generateConst(e),i,r)}}class Lse extends Ae{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}}let Pu=null;const Hh=new Map;function W(t,e){if(Hh.has(t)){console.warn(`THREE.TSL: Redefinition of method chaining '${t}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);Hh.set(t,e)}const k5=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),J_=t=>k5(t).split("").sort().join(""),U5={setup(t,e){const r=e.shift();return t(Lm(r),...e)},get(t,e,r){if(typeof e=="string"&&t[e]===void 0){if(t.isStackNode!==!0&&e==="assign")return(...i)=>(Pu.assign(r,...i),r);if(Hh.has(e)){const i=Hh.get(e);return t.isStackNode?(...s)=>r.add(i(...s)):(...s)=>i(r,...s)}else{if(e==="self")return t;if(e.endsWith("Assign")&&Hh.has(e.slice(0,e.length-6))){const i=Hh.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=k5(e),X(new Qb(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=J_(e.slice(3).toLowerCase()),i=>X(new Vse(t,e,X(i)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=J_(e.slice(4).toLowerCase()),()=>X(new Ose(X(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),X(new Qb(t,e));if(/^\d+$/.test(e)===!0)return X(new ju(r,new wn(Number(e),"uint")));if(/^get$/.test(e)===!0)return i=>X(new Lse(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)}},bx=new WeakMap,K_=new WeakMap,Fse=function(t,e=null){const r=Mo(t);if(r==="node"){let i=bx.get(t);return i===void 0&&(i=new Proxy(t,U5),bx.set(t,i),bx.set(i,i)),i}else{if(e===null&&(r==="float"||r==="boolean")||r&&r!=="shader"&&r!=="string")return X(e1(t,e));if(r==="shader")return z(t)}return t},zse=function(t,e=null){for(const r in t)t[r]=X(t[r],e);return t},Bse=function(t,e=null){const r=t.length;for(let i=0;i<r;i++)t[i]=X(t[i],e);return t},kse=function(t,e=null,r=null,i=null){const s=u=>X(i!==null?Object.assign(u,i):u);let n,a=e,o,l;function h(u){let c;return a?c=/[a-z]/i.test(a)?a+"()":a:c=t.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(new 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(...Mu(h(u)))):r!==null?(r=X(r),n=(...u)=>s(new t(e,...Mu(h(u)),r))):n=(...u)=>s(new t(e,...Mu(h(u)))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n},Use=function(t,...e){return X(new t(...Mu(e)))};class Dse extends Ae{constructor(e,r){super(),this.shaderNode=e,this.inputNodes=r,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,r){return this.getOutputNode(e).getMemberType(e,r)}call(e){const{shaderNode:r,inputNodes:i}=this,s=e.getNodeProperties(r),n=r.namespace&&r.namespace===e.namespace?e.getNamespace("once"):"once";if(s[n])return s[n];let a=null;if(r.layout){let o=K_.get(e.constructor);o===void 0&&(o=new WeakMap,K_.set(e.constructor,o));let l=o.get(r);l===void 0&&(l=X(e.buildFunctionNode(r)),o.set(r,l)),e.addInclude(l),a=X(l.call(i))}else{const o=r.jsFunc,l=i!==null||o.length>1?o(i||[],e):o(e);a=X(l)}return r.once&&(s[n]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const r=e.getNodeProperties(this),i=e.getOutputNamespace();return r[i]=r[i]||this.setupOutput(e),r[i]}build(e,r=null){let i=null;const s=e.getBuildStage(),n=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(s==="setup"){const l=e.getNamespace("initialized");n[l]!==!0&&(n[l]=!0,n[a]=this.getOutputNode(e),n[a].build(e)),i=n[a]}else s==="analyze"?o.build(e,r):s==="generate"&&(i=o.build(e,r)||"");return i}}class $se extends Ae{constructor(e,r){super(r),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Lm(e),X(new Dse(this,e))}setup(){return this.call()}}const Gse=[!1,!0],jse=[0,1,2,3],Wse=[-1,-2],D5=[.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],vT=new Map;for(const t of Gse)vT.set(t,new wn(t));const TT=new Map;for(const t of jse)TT.set(t,new wn(t,"uint"));const wT=new Map([...TT].map(t=>new wn(t.value,"int")));for(const t of Wse)wT.set(t,new wn(t,"int"));const gy=new Map([...wT].map(t=>new wn(t.value)));for(const t of D5)gy.set(t,new wn(t));for(const t of D5)gy.set(-t,new wn(-t));const yy={bool:vT,uint:TT,ints:wT,float:gy},Q_=new Map([...vT,...gy]),e1=(t,e)=>Q_.has(t)?Q_.get(t):t.isNode===!0?t:new wn(t,e),Hse=t=>{try{return t.getNodeType()}catch{return}},Pr=function(t,e=null){return(...r)=>{if((r.length===0||!["bool","float","int","uint"].includes(t)&&r.every(s=>typeof s!="object"))&&(r=[V5(t,...r)]),r.length===1&&e!==null&&e.has(r[0]))return X(e.get(r[0]));if(r.length===1){const s=e1(r[0],t);return Hse(s)===t?X(s):X(new B5(s,t))}const i=r.map(s=>e1(s));return X(new Pse(i,t))}},am=t=>typeof t=="object"&&t!==null?t.value:t,$5=t=>t!=null?t.nodeType||t.convertTo||(typeof t=="string"?t:null):null;function qh(t,e){return new Proxy(new $se(t,e),U5)}const X=(t,e=null)=>Fse(t,e),Lm=(t,e=null)=>new zse(t,e),Mu=(t,e=null)=>new Bse(t,e),Z=(...t)=>new kse(...t),ue=(...t)=>new Use(...t);let qse=0;const z=(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));const i=new qh(t,r),s=(...n)=>{let a;Lm(n),n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?a=[...n]:a=n[0];const 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"){const n={name:"fn"+qse++,type:r,inputs:[]};for(const a in e)a!=="return"&&n.inputs.push({name:a,type:e[a]});e=n}s.setLayout(e)}return s},t1=t=>{Pu=t},G5=()=>Pu,je=(...t)=>Pu.If(...t),Xse=(...t)=>Pu.Switch(...t);function xy(t){return Pu&&Pu.add(t),t}W("toStack",xy);const j5=new Pr("color"),C=new Pr("float",yy.float),P=new Pr("int",yy.ints),fe=new Pr("uint",yy.uint),Hn=new Pr("bool",yy.bool),ne=new Pr("vec2"),kr=new Pr("ivec2"),W5=new Pr("uvec2"),H5=new Pr("bvec2"),B=new Pr("vec3"),q5=new Pr("ivec3"),Pc=new Pr("uvec3"),ST=new Pr("bvec3"),Oe=new Pr("vec4"),X5=new Pr("ivec4"),Y5=new Pr("uvec4"),Z5=new Pr("bvec4"),by=new Pr("mat2"),Gs=new Pr("mat3"),_u=new Pr("mat4"),Yse=(t="")=>X(new wn(t,"string")),Zse=t=>X(new wn(t,"ArrayBuffer"));W("toColor",j5);W("toFloat",C);W("toInt",P);W("toUint",fe);W("toBool",Hn);W("toVec2",ne);W("toIVec2",kr);W("toUVec2",W5);W("toBVec2",H5);W("toVec3",B);W("toIVec3",q5);W("toUVec3",Pc);W("toBVec3",ST);W("toVec4",Oe);W("toIVec4",X5);W("toUVec4",Y5);W("toBVec4",Z5);W("toMat2",by);W("toMat3",Gs);W("toMat4",_u);const J5=Z(ju).setParameterLength(2),K5=(t,e)=>X(new B5(X(t),e)),Jse=(t,e)=>X(new Qb(X(t),e));W("element",J5);W("convert",K5);const Kse=t=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),xy(t));W("append",t=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),xy(t)));const Qse=(...t)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),z(...t));class gt extends Ae{static get type(){return"PropertyNode"}constructor(e,r=null,i=!1){super(e),this.name=r,this.varying=i,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let r;return this.varying===!0?(r=e.getVaryingFromNode(this,this.name),r.needsInterpolation=!0):r=e.getVarFromNode(this,this.name),e.getPropertyName(r)}}const Ic=(t,e)=>X(new gt(t,e)),om=(t,e)=>X(new gt(t,e,!0)),_s=ue(gt,"vec4","DiffuseColor"),r1=ue(gt,"vec3","EmissiveColor"),Q5=ue(gt,"float","Roughness"),ene=ue(gt,"float","Metalness"),tne=ue(gt,"float","Clearcoat"),rne=ue(gt,"float","ClearcoatRoughness"),ine=ue(gt,"vec3","Sheen"),sne=ue(gt,"float","SheenRoughness"),eP=ue(gt,"float","Iridescence"),nne=ue(gt,"float","IridescenceIOR"),ane=ue(gt,"float","IridescenceThickness"),i1=ue(gt,"float","AlphaT"),tP=ue(gt,"float","Anisotropy"),Uf=ue(gt,"vec3","AnisotropyT"),ac=ue(gt,"vec3","AnisotropyB"),one=ue(gt,"color","SpecularColor"),lne=ue(gt,"float","SpecularF90"),une=ue(gt,"float","Shininess"),oc=ue(gt,"vec4","Output"),hne=ue(gt,"float","dashSize"),cne=ue(gt,"float","gapSize"),dne=ue(gt,"float","pointWidth"),mne=ue(gt,"float","IOR"),pne=ue(gt,"float","Transmission"),fne=ue(gt,"float","Thickness"),gne=ue(gt,"float","AttenuationDistance"),yne=ue(gt,"color","AttenuationColor"),xne=ue(gt,"float","Dispersion");class rP extends Ae{static get type(){return"UniformGroupNode"}constructor(e,r=!1,i=1){super("string"),this.name=e,this.shared=r,this.order=i,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const iP=t=>new rP(t),vy=(t,e=0)=>new rP(t,!0,e),bne=vy("frame"),Ye=vy("render"),sP=iP("object");class Fm extends bT{static get type(){return"UniformNode"}constructor(e,r=null){super(e,r),this.isUniformNode=!0,this.name="",this.groupNode=sP}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,r){const i=this.getSelf();return e=e.bind(i),super.onUpdate(s=>{const n=e(s,i);n!==void 0&&(this.value=n)},r)}generate(e,r){const i=this.getNodeType(e),s=this.getUniformHash(e);let n=e.getNodeFromHash(s);n===void 0&&(e.setHashNode(this,s),n=this);const a=n.getInputType(e),o=e.getUniformFromNode(n,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,r)}}const Ie=(t,e)=>{const r=$5(e||t),i=t&&t.isNode===!0?t.node&&t.node.value||t.value:t;return X(new Fm(i,r))};class eN extends xr{static get type(){return"ArrayNode"}constructor(e,r,i=null){super(e),this.count=r,this.values=i,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const r=this.getNodeType(e);return e.generateArray(r,this.count,this.values)}}const nP=(...t)=>{let e;if(t.length===1){const r=t[0];e=new eN(null,r.length,r)}else{const r=t[0],i=t[1];e=new eN(r,i)}return X(e)};W("toArray",(t,e)=>nP(Array(e).fill(t)));class vne extends xr{static get type(){return"AssignNode"}constructor(e,r){super(),this.targetNode=e,this.sourceNode=r,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,r){return r!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:r}=this;if(e.isAvailable("swizzleAssign")===!1&&r.isSplitNode&&r.components.length>1){const i=e.getTypeLength(r.node.getNodeType(e));return Rc.join("").slice(0,i)!==r.components}return!1}setup(e){const{targetNode:r,sourceNode:i}=this,s=e.getNodeProperties(this);s.sourceNode=i,s.targetNode=r.context({assign:!0})}generate(e,r){const{targetNode:i,sourceNode:s}=e.getNodeProperties(this),n=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.build(e),l=s.build(e,a),h=s.getNodeType(e),u=e.getDataFromNode(this);let c;if(u.initialized===!0)r!=="void"&&(c=o);else if(n){const d=e.getVarFromNode(this,null,a),m=e.getPropertyName(d);e.addLineFlowCode(`${m} = ${l}`,this);const p=i.node,g=p.node.context({assign:!0}).build(e);for(let y=0;y<p.components.length;y++){const T=p.components[y];e.addLineFlowCode(`${g}.${T} = ${m}[ ${y} ]`,this)}r!=="void"&&(c=o)}else c=`${o} = ${l}`,(r==="void"||h==="void")&&(e.addLineFlowCode(c,this),r!=="void"&&(c=o));return u.initialized=!0,e.format(c,a,r)}}const aP=Z(vne).setParameterLength(2);W("assign",aP);class Tne extends xr{static get type(){return"FunctionCallNode"}constructor(e=null,r={}){super(),this.functionNode=e,this.parameters=r}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const r=[],i=this.functionNode,s=i.getInputs(e),n=this.parameters,a=(l,h)=>{const u=h.type,c=u==="pointer";let d;return c?d="&"+l.build(e):d=l.build(e,u),d};if(Array.isArray(n)){if(n.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=s.length;else if(n.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<s.length;)n.push(C(0));for(let l=0;l<n.length;l++)r.push(a(n[l],s[l]))}else for(const l of s){const h=n[l.name];h!==void 0?r.push(a(h,l)):(console.error(`THREE.TSL: Input '${l.name}' not found in 'Fn()'.`),r.push(a(C(0),l)))}return`${i.build(e,"property")}( ${r.join(", ")} )`}}const oP=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Mu(e):Lm(e[0]),X(new Tne(X(t),e)));W("call",oP);const wne={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Xt extends xr{static get type(){return"OperatorNode"}constructor(e,r,i,...s){if(super(),s.length>0){let n=new Xt(e,r,i);for(let a=0;a<s.length-1;a++)n=new Xt(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(wne[this.op],r)}getNodeType(e){const 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===">="){const 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){const i=this.op,{aNode:s,bNode:n}=this,a=this.getNodeType(e);let o=null,l=null;a!=="void"?(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):e.isMatrix(l)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(l):o=l=a:o=l=a):o=l=a;const h=s.build(e,o),u=n?n.build(e,l):null,c=e.getFunctionOperator(i);if(r!=="void"){const d=e.renderer.coordinateSystem===va;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):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 fr=Z(Xt,"+").setParameterLength(2,1/0).setName("add"),it=Z(Xt,"-").setParameterLength(2,1/0).setName("sub"),ke=Z(Xt,"*").setParameterLength(2,1/0).setName("mul"),qn=Z(Xt,"/").setParameterLength(2,1/0).setName("div"),zm=Z(Xt,"%").setParameterLength(2).setName("mod"),MT=Z(Xt,"==").setParameterLength(2).setName("equal"),lP=Z(Xt,"!=").setParameterLength(2).setName("notEqual"),uP=Z(Xt,"<").setParameterLength(2).setName("lessThan"),_T=Z(Xt,">").setParameterLength(2).setName("greaterThan"),hP=Z(Xt,"<=").setParameterLength(2).setName("lessThanEqual"),cP=Z(Xt,">=").setParameterLength(2).setName("greaterThanEqual"),dP=Z(Xt,"&&").setParameterLength(2,1/0).setName("and"),mP=Z(Xt,"||").setParameterLength(2,1/0).setName("or"),pP=Z(Xt,"!").setParameterLength(1).setName("not"),fP=Z(Xt,"^^").setParameterLength(2).setName("xor"),gP=Z(Xt,"&").setParameterLength(2).setName("bitAnd"),yP=Z(Xt,"~").setParameterLength(2).setName("bitNot"),xP=Z(Xt,"|").setParameterLength(2).setName("bitOr"),bP=Z(Xt,"^").setParameterLength(2).setName("bitXor"),vP=Z(Xt,"<<").setParameterLength(2).setName("shiftLeft"),TP=Z(Xt,">>").setParameterLength(2).setName("shiftRight"),wP=z(([t])=>(t.addAssign(1),t)),SP=z(([t])=>(t.subAssign(1),t)),MP=z(([t])=>{const e=P(t).toConst();return t.addAssign(1),e}),_P=z(([t])=>{const e=P(t).toConst();return t.subAssign(1),e});W("add",fr);W("sub",it);W("mul",ke);W("div",qn);W("mod",zm);W("equal",MT);W("notEqual",lP);W("lessThan",uP);W("greaterThan",_T);W("lessThanEqual",hP);W("greaterThanEqual",cP);W("and",dP);W("or",mP);W("not",pP);W("xor",fP);W("bitAnd",gP);W("bitNot",yP);W("bitOr",xP);W("bitXor",bP);W("shiftLeft",vP);W("shiftRight",TP);W("incrementBefore",wP);W("decrementBefore",SP);W("increment",MP);W("decrement",_P);const NP=(t,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),zm(t,e)),EP=(t,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),zm(P(t),P(e)));W("remainder",NP);W("modInt",EP);class L extends xr{static get type(){return"MathNode"}constructor(e,r,i=null,s=null){if(super(),(e===L.MAX||e===L.MIN)&&arguments.length>3){let n=new L(e,r,i);for(let a=2;a<arguments.length-1;a++)n=new L(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){const 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){const r=this.method;return r===L.LENGTH||r===L.DISTANCE||r===L.DOT?"float":r===L.CROSS?"vec3":r===L.ALL||r===L.ANY?"bool":r===L.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:r,bNode:i,method:s}=this;let n=null;if(s===L.ONE_MINUS)n=it(1,r);else if(s===L.RECIPROCAL)n=qn(1,r);else if(s===L.DIFFERENCE)n=Vt(it(r,i));else if(s===L.TRANSFORM_DIRECTION){let a=r,o=i;e.isMatrix(a.getNodeType(e))?o=Oe(B(o),0):a=Oe(B(a),0);const l=ke(a,o).xyz;n=Wu(l)}return n!==null?n:super.setup(e)}generate(e,r){if(e.getNodeProperties(this).outputNode)return super.generate(e,r);let s=this.method;const n=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,h=this.cNode,u=e.renderer.coordinateSystem;if(s===L.NEGATE)return e.format("( - "+o.build(e,a)+" )",n,r);{const c=[];return s===L.CROSS?c.push(o.build(e,n),l.build(e,n)):u===va&&s===L.STEP?c.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===va&&(s===L.MIN||s===L.MAX)?c.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):s===L.REFRACT?c.push(o.build(e,a),l.build(e,a),h.build(e,"float")):s===L.MIX?c.push(o.build(e,a),l.build(e,a),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":a)):(u===Ru&&s===L.ATAN&&l!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===L.DFDX||s===L.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}}L.ALL="all";L.ANY="any";L.RADIANS="radians";L.DEGREES="degrees";L.EXP="exp";L.EXP2="exp2";L.LOG="log";L.LOG2="log2";L.SQRT="sqrt";L.INVERSE_SQRT="inversesqrt";L.FLOOR="floor";L.CEIL="ceil";L.NORMALIZE="normalize";L.FRACT="fract";L.SIN="sin";L.COS="cos";L.TAN="tan";L.ASIN="asin";L.ACOS="acos";L.ATAN="atan";L.ABS="abs";L.SIGN="sign";L.LENGTH="length";L.NEGATE="negate";L.ONE_MINUS="oneMinus";L.DFDX="dFdx";L.DFDY="dFdy";L.ROUND="round";L.RECIPROCAL="reciprocal";L.TRUNC="trunc";L.FWIDTH="fwidth";L.TRANSPOSE="transpose";L.BITCAST="bitcast";L.EQUALS="equals";L.MIN="min";L.MAX="max";L.STEP="step";L.REFLECT="reflect";L.DISTANCE="distance";L.DIFFERENCE="difference";L.DOT="dot";L.CROSS="cross";L.POW="pow";L.TRANSFORM_DIRECTION="transformDirection";L.MIX="mix";L.CLAMP="clamp";L.REFRACT="refract";L.SMOOTHSTEP="smoothstep";L.FACEFORWARD="faceforward";const AP=C(1e-6),Sne=C(1e6),bg=C(Math.PI),Mne=C(Math.PI*2),CP=Z(L,L.ALL).setParameterLength(1),RP=Z(L,L.ANY).setParameterLength(1),PP=Z(L,L.RADIANS).setParameterLength(1),IP=Z(L,L.DEGREES).setParameterLength(1),VP=Z(L,L.EXP).setParameterLength(1),wc=Z(L,L.EXP2).setParameterLength(1),NT=Z(L,L.LOG).setParameterLength(1),Pa=Z(L,L.LOG2).setParameterLength(1),Qn=Z(L,L.SQRT).setParameterLength(1),ET=Z(L,L.INVERSE_SQRT).setParameterLength(1),zn=Z(L,L.FLOOR).setParameterLength(1),Ty=Z(L,L.CEIL).setParameterLength(1),Wu=Z(L,L.NORMALIZE).setParameterLength(1),Ha=Z(L,L.FRACT).setParameterLength(1),cs=Z(L,L.SIN).setParameterLength(1),ga=Z(L,L.COS).setParameterLength(1),OP=Z(L,L.TAN).setParameterLength(1),LP=Z(L,L.ASIN).setParameterLength(1),FP=Z(L,L.ACOS).setParameterLength(1),AT=Z(L,L.ATAN).setParameterLength(1,2),Vt=Z(L,L.ABS).setParameterLength(1),lm=Z(L,L.SIGN).setParameterLength(1),vg=Z(L,L.LENGTH).setParameterLength(1),zP=Z(L,L.NEGATE).setParameterLength(1),BP=Z(L,L.ONE_MINUS).setParameterLength(1),CT=Z(L,L.DFDX).setParameterLength(1),RT=Z(L,L.DFDY).setParameterLength(1),kP=Z(L,L.ROUND).setParameterLength(1),UP=Z(L,L.RECIPROCAL).setParameterLength(1),PT=Z(L,L.TRUNC).setParameterLength(1),DP=Z(L,L.FWIDTH).setParameterLength(1),$P=Z(L,L.TRANSPOSE).setParameterLength(1),_ne=Z(L,L.BITCAST).setParameterLength(2),GP=(t,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),MT(t,e)),js=Z(L,L.MIN).setParameterLength(2,1/0),Gr=Z(L,L.MAX).setParameterLength(2,1/0),wy=Z(L,L.STEP).setParameterLength(2),jP=Z(L,L.REFLECT).setParameterLength(2),WP=Z(L,L.DISTANCE).setParameterLength(2),HP=Z(L,L.DIFFERENCE).setParameterLength(2),Go=Z(L,L.DOT).setParameterLength(2),Sy=Z(L,L.CROSS).setParameterLength(2),pn=Z(L,L.POW).setParameterLength(2),qP=Z(L,L.POW,2).setParameterLength(1),XP=Z(L,L.POW,3).setParameterLength(1),YP=Z(L,L.POW,4).setParameterLength(1),ZP=Z(L,L.TRANSFORM_DIRECTION).setParameterLength(2),JP=t=>ke(lm(t),pn(Vt(t),1/3)),IT=t=>Go(t,t),ur=Z(L,L.MIX).setParameterLength(3),Ba=(t,e=0,r=1)=>X(new L(L.CLAMP,X(t),X(e),X(r))),KP=t=>Ba(t),QP=Z(L,L.REFRACT).setParameterLength(3),Iu=Z(L,L.SMOOTHSTEP).setParameterLength(3),VT=Z(L,L.FACEFORWARD).setParameterLength(3),eI=z(([t])=>{const i=43758.5453,s=Go(t.xy,ne(12.9898,78.233)),n=zm(s,bg);return Ha(cs(n).mul(i))}),tI=(t,e,r)=>ur(e,r,t),rI=(t,e,r)=>Iu(e,r,t),iI=(t,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),AT(t,e)),Nne=VT,Ene=ET;W("all",CP);W("any",RP);W("equals",GP);W("radians",PP);W("degrees",IP);W("exp",VP);W("exp2",wc);W("log",NT);W("log2",Pa);W("sqrt",Qn);W("inverseSqrt",ET);W("floor",zn);W("ceil",Ty);W("normalize",Wu);W("fract",Ha);W("sin",cs);W("cos",ga);W("tan",OP);W("asin",LP);W("acos",FP);W("atan",AT);W("abs",Vt);W("sign",lm);W("length",vg);W("lengthSq",IT);W("negate",zP);W("oneMinus",BP);W("dFdx",CT);W("dFdy",RT);W("round",kP);W("reciprocal",UP);W("trunc",PT);W("fwidth",DP);W("atan2",iI);W("min",js);W("max",Gr);W("step",wy);W("reflect",jP);W("distance",WP);W("dot",Go);W("cross",Sy);W("pow",pn);W("pow2",qP);W("pow3",XP);W("pow4",YP);W("transformDirection",ZP);W("mix",tI);W("clamp",Ba);W("refract",QP);W("smoothstep",rI);W("faceForward",VT);W("difference",HP);W("saturate",KP);W("cbrt",JP);W("transpose",$P);W("rand",eI);class Ane extends Ae{static get type(){return"ConditionalNode"}constructor(e,r,i=null){super(),this.condNode=e,this.ifNode=r,this.elseNode=i}getNodeType(e){const{ifNode:r,elseNode:i}=e.getNodeProperties(this);if(r===void 0)return this.setup(e),this.getNodeType(e);const s=r.getNodeType(e);if(i!==null){const n=i.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(s))return n}return s}setup(e){const r=this.condNode.cache(),i=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,n=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=n,s!==null&&(e.getDataFromNode(s).parentNodeBlock=n);const a=e.getNodeProperties(this);a.condNode=r,a.ifNode=i.context({nodeBlock:i}),a.elseNode=s?s.context({nodeBlock:s}):null}generate(e,r){const i=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:n,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,h=r!=="void",u=h?Ic(i).build(e):"";s.nodeProperty=u;const c=n.build(e,"bool");e.addFlowCode(`
458
+ */const bse=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class vse{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=bse,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const r=e.getMRT();return r!==null&&r.has("velocity")}getRenderObjectData(e){let r=this.renderObjects.get(e);if(r===void 0){const{geometry:i,material:s,object:n}=e;if(r={material:this.getMaterialData(s),geometry:{id:i.id,attributes:this.getAttributesData(i.attributes),indexVersion:i.index?i.index.version:null,drawRange:{start:i.drawRange.start,count:i.drawRange.count}},worldMatrix:n.matrixWorld.clone()},n.center&&(r.center=n.center.clone()),n.morphTargetInfluences&&(r.morphTargetInfluences=n.morphTargetInfluences.slice()),e.bundle!==null&&(r.version=e.bundle.version),r.material.transmission>0){const{width:a,height:o}=e.context;r.bufferWidth=a,r.bufferHeight=o}this.renderObjects.set(e,r)}return r}getAttributesData(e){const r={};for(const i in e){const s=e[i];r[i]={version:s.version}}return r}containsNode(e){const r=e.material;for(const i in r)if(r[i]&&r[i].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){const r={};for(const i of this.refreshUniforms){const s=e[i];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?r[i]={id:s.id,version:s.version}:r[i]=s.clone():r[i]=s)}return r}equals(e){const{object:r,material:i,geometry:s}=e,n=this.getRenderObjectData(e);if(n.worldMatrix.equals(r.matrixWorld)!==!0)return n.worldMatrix.copy(r.matrixWorld),!1;const a=n.material;for(const f in a){const g=a[f],y=i[f];if(g.equals!==void 0){if(g.equals(y)===!1)return g.copy(y),!1}else if(y.isTexture===!0){if(g.id!==y.id||g.version!==y.version)return g.id=y.id,g.version=y.version,!1}else if(g!==y)return a[f]=y,!1}if(a.transmission>0){const{width:f,height:g}=e.context;if(n.bufferWidth!==f||n.bufferHeight!==g)return n.bufferWidth=f,n.bufferHeight=g,!1}const o=n.geometry,l=s.attributes,h=o.attributes,u=Object.keys(h),c=Object.keys(l);if(o.id!==s.id)return o.id=s.id,!1;if(u.length!==c.length)return n.geometry.attributes=this.getAttributesData(l),!1;for(const f of u){const g=h[f],y=l[f];if(y===void 0)return delete h[f],!1;if(g.version!==y.version)return g.version=y.version,!1}const d=s.index,m=o.indexVersion,p=d?d.version:null;if(m!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==s.drawRange.start||o.drawRange.count!==s.drawRange.count)return o.drawRange.start=s.drawRange.start,o.drawRange.count=s.drawRange.count,!1;if(n.morphTargetInfluences){let f=!1;for(let g=0;g<n.morphTargetInfluences.length;g++)n.morphTargetInfluences[g]!==r.morphTargetInfluences[g]&&(f=!0);if(f)return!0}return n.center&&n.center.equals(r.center)===!1?(n.center.copy(r.center),!0):(e.bundle!==null&&(n.version=e.bundle.version),!0)}needsRefresh(e,r){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(r.renderer))return!0;const{renderId:i}=r;if(this.renderId!==i)return this.renderId=i,!0;const s=e.object.static===!0,n=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return s||n?!1:this.equals(e)!==!0}}function nm(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 Tse=t=>nm(t),C5=t=>nm(t),R5=(...t)=>nm(t);function P5(t,e=!1){const r=[];t.isNode===!0&&(r.push(t.id),t=t.getSelf());for(const{property:i,childNode:s}of yg(t))r.push(nm(i.slice(0,-4)),s.getCacheKey(e));return nm(r)}function*yg(t,e=!1){for(const r in t){if(r.startsWith("_")===!0)continue;const i=t[r];if(Array.isArray(i)===!0)for(let s=0;s<i.length;s++){const 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(const s in i){const n=i[s];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:r,index:s,childNode:n})}}}const wse=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Y_=new WeakMap;function Sse(t){return wse.get(t)}function xg(t){if(/[iu]?vec\d/.test(t))return t.startsWith("ivec")?Int32Array:t.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(t)||/float/.test(t))return Float32Array;if(/uint/.test(t))return Uint32Array;if(/int/.test(t))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${t}`)}function I5(t){if(/float|int|uint/.test(t))return 1;if(/vec2/.test(t))return 2;if(/vec3/.test(t))return 3;if(/vec4/.test(t)||/mat2/.test(t))return 4;if(/mat3/.test(t))return 9;if(/mat4/.test(t))return 16;console.error("THREE.TSL: Unsupported type:",t)}function Mse(t){if(/float|int|uint/.test(t))return 1;if(/vec2/.test(t))return 2;if(/vec3/.test(t))return 3;if(/vec4/.test(t)||/mat2/.test(t))return 4;if(/mat3/.test(t))return 12;if(/mat4/.test(t))return 16;console.error("THREE.TSL: Unsupported type:",t)}function _se(t){if(/float|int|uint/.test(t))return 4;if(/vec2/.test(t))return 8;if(/vec3/.test(t)||/vec4/.test(t))return 16;if(/mat2/.test(t))return 8;if(/mat3/.test(t))return 48;if(/mat4/.test(t))return 64;console.error("THREE.TSL: Unsupported type:",t)}function Mo(t){if(t==null)return null;const 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 V5(t,...e){const 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 ja(...e):r==="vec2"?new Jt(...e):r==="vec3"?new $(...e):r==="vec4"?new Si(...e):r==="mat2"?new Jv(...e):r==="mat3"?new qs(...e):r==="mat4"?new Rt(...e):t==="bool"?e[0]||!1:t==="float"||t==="int"||t==="uint"?e[0]||0:t==="string"?e[0]||"":t==="ArrayBuffer"?F5(e[0]):null}function O5(t){let e=Y_.get(t);return e===void 0&&(e={},Y_.set(t,e)),e}function L5(t){let e="";const r=new Uint8Array(t);for(let i=0;i<r.length;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function F5(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0)).buffer}const wd={VERTEX:"vertex",FRAGMENT:"fragment"},Tt={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Nse={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Rn={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},z5=["fragment","vertex"],Ese=["setup","analyze","generate"],Ase=[...z5,"compute"],Rc=["x","y","z","w"],Cse={analyze:"setup",generate:"analyze"};let Rse=0;class Ae extends Du{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Tt.NONE,this.updateBeforeType=Tt.NONE,this.updateAfterType=Tt.NONE,this.uuid=a3.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:Rse++})}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,Tt.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Tt.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Tt.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(const{childNode:e}of yg(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const r of this.getChildren())r.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=R5(P5(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){const r=this.getNodeType(e);return e.getElementType(r)}getMemberType(){return"void"}getNodeType(e){const r=e.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(e):this.nodeType}getShared(e){const r=this.getHash(e);return e.getNodeFromHash(r)||this}setup(e){const r=e.getNodeProperties(this);let i=0;for(const s of this.getChildren())r["node"+i++]=s;return r.outputNode||null}analyze(e,r=null){const i=e.increaseUsage(this);if(this.parents===!0){const 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){const s=e.getNodeProperties(this);for(const n of Object.values(s))n&&n.isNode===!0&&n.build(e,this)}}generate(e,r){const{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){const i=this.getShared(e);if(this!==i)return i.build(e,r);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const n=Cse[e.buildStage];if(n&&s.buildStages[n]!==!0){const l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addNode(this),e.addChain(this);let a=null;const o=e.getBuildStage();if(o==="setup"){this.updateReference(e);const l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(const h of Object.values(l))if(h&&h.isNode===!0){if(h.parents===!0){const 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){const 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 yg(this)}serialize(e){const r=this.getSerializeChildren(),i={};for(const{property:s,index:n,childNode:a}of r)n!==void 0?(i[s]===void 0&&(i[s]=Number.isInteger(n)?[]:{}),i[s][n]=a.toJSON(e.meta).uuid):i[s]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const r=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const s=[];for(const n of e.inputNodes[i])s.push(r[n]);this[i]=s}else if(typeof e.inputNodes[i]=="object"){const s={};for(const n in e.inputNodes[i]){const a=e.inputNodes[i][n];s[n]=r[a]}this[i]=s}else{const s=e.inputNodes[i];this[i]=r[s]}}}toJSON(e){const{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){const l=[];for(const h in o){const u=o[h];delete u.metadata,l.push(u)}return l}if(s){const 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}}class ju extends Ae{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){const 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} ]`}}class B5 extends Ae{static get type(){return"ConvertNode"}constructor(e,r){super(),this.node=e,this.convertTo=r}getNodeType(e){const r=this.node.getNodeType(e);let i=null;for(const 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){const i=this.node,s=this.getNodeType(e),n=i.build(e,s);return e.format(n,s,r)}}class xr extends Ae{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"){const 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)){const 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)}}class Pse extends xr{static get type(){return"JoinNode"}constructor(e=[],r=null){super(r),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((r,i)=>r+e.getTypeLength(i.getNodeType(e)),0))}generate(e,r){const i=this.getNodeType(e),s=e.getTypeLength(i),n=this.nodes,a=e.getComponentType(i),o=[];let l=0;for(const 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);const p=e.getComponentType(c);p!==a&&(m=e.format(m,p,a)),o.push(m)}const h=`${e.getType(i)}( ${o.join(", ")} )`;return e.format(h,i,r)}}const Ise=Rc.join("");class Qb extends Ae{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(const r of this.components)e=Math.max(Rc.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){const i=this.node,s=e.getTypeLength(i.getNodeType(e));let n=null;if(s>1){let a=null;this.getVectorLength()>=s&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const l=i.build(e,a);this.components.length===s&&this.components===Ise.slice(0,this.components.length)?n=e.format(l,a,r):n=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}}class Vse extends xr{static get type(){return"SetNode"}constructor(e,r,i){super(),this.sourceNode=e,this.components=r,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:r,components:i,targetNode:s}=this,n=this.getNodeType(e),a=e.getComponentType(s.getNodeType(e)),o=e.getTypeFromLength(i.length,a),l=s.build(e,o),h=r.build(e,n),u=e.getTypeLength(n),c=[];for(let d=0;d<u;d++){const m=Rc[d];m===i[0]?(c.push(l),d+=i.length-1):c.push(h+"."+m)}return`${e.getType(n)}( ${c.join(", ")} )`}}class Ose extends xr{static get type(){return"FlipNode"}constructor(e,r){super(),this.sourceNode=e,this.components=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{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);const l=e.getTypeLength(s),h=[];let u=0;for(let c=0;c<l;c++){const d=Rc[c];d===r[u]?(h.push("1.0 - "+(o+"."+d)),u++):h.push(o+"."+d)}return`${e.getType(s)}( ${h.join(", ")} )`}}class bT extends Ae{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?Mo(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=Mo(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=L5(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?V5(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.")}}const Z_=/float|u?int/;class wn extends bT{static get type(){return"ConstNode"}constructor(e,r=null){super(e,r),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,r){const i=this.getNodeType(e);return Z_.test(i)&&Z_.test(r)?e.generateConst(r,this.value):e.format(this.generateConst(e),i,r)}}class Lse extends Ae{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}}let Pu=null;const Hh=new Map;function W(t,e){if(Hh.has(t)){console.warn(`THREE.TSL: Redefinition of method chaining '${t}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${t} is not a function`);Hh.set(t,e)}const k5=t=>t.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),J_=t=>k5(t).split("").sort().join(""),U5={setup(t,e){const r=e.shift();return t(Lm(r),...e)},get(t,e,r){if(typeof e=="string"&&t[e]===void 0){if(t.isStackNode!==!0&&e==="assign")return(...i)=>(Pu.assign(r,...i),r);if(Hh.has(e)){const i=Hh.get(e);return t.isStackNode?(...s)=>r.add(i(...s)):(...s)=>i(r,...s)}else{if(e==="self")return t;if(e.endsWith("Assign")&&Hh.has(e.slice(0,e.length-6))){const i=Hh.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=k5(e),X(new Qb(r,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=J_(e.slice(3).toLowerCase()),i=>X(new Vse(t,e,X(i)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=J_(e.slice(4).toLowerCase()),()=>X(new Ose(X(t),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),X(new Qb(t,e));if(/^\d+$/.test(e)===!0)return X(new ju(r,new wn(Number(e),"uint")));if(/^get$/.test(e)===!0)return i=>X(new Lse(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)}},bx=new WeakMap,K_=new WeakMap,Fse=function(t,e=null){const r=Mo(t);if(r==="node"){let i=bx.get(t);return i===void 0&&(i=new Proxy(t,U5),bx.set(t,i),bx.set(i,i)),i}else{if(e===null&&(r==="float"||r==="boolean")||r&&r!=="shader"&&r!=="string")return X(e1(t,e));if(r==="shader")return z(t)}return t},zse=function(t,e=null){for(const r in t)t[r]=X(t[r],e);return t},Bse=function(t,e=null){const r=t.length;for(let i=0;i<r;i++)t[i]=X(t[i],e);return t},kse=function(t,e=null,r=null,i=null){const s=u=>X(i!==null?Object.assign(u,i):u);let n,a=e,o,l;function h(u){let c;return a?c=/[a-z]/i.test(a)?a+"()":a:c=t.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(new 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(...Mu(h(u)))):r!==null?(r=X(r),n=(...u)=>s(new t(e,...Mu(h(u)),r))):n=(...u)=>s(new t(e,...Mu(h(u)))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n},Use=function(t,...e){return X(new t(...Mu(e)))};class Dse extends Ae{constructor(e,r){super(),this.shaderNode=e,this.inputNodes=r,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,r){return this.getOutputNode(e).getMemberType(e,r)}call(e){const{shaderNode:r,inputNodes:i}=this,s=e.getNodeProperties(r),n=r.namespace&&r.namespace===e.namespace?e.getNamespace("once"):"once";if(s[n])return s[n];let a=null;if(r.layout){let o=K_.get(e.constructor);o===void 0&&(o=new WeakMap,K_.set(e.constructor,o));let l=o.get(r);l===void 0&&(l=X(e.buildFunctionNode(r)),o.set(r,l)),e.addInclude(l),a=X(l.call(i))}else{const o=r.jsFunc,l=i!==null||o.length>1?o(i||[],e):o(e);a=X(l)}return r.once&&(s[n]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const r=e.getNodeProperties(this),i=e.getOutputNamespace();return r[i]=r[i]||this.setupOutput(e),r[i]}build(e,r=null){let i=null;const s=e.getBuildStage(),n=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(s==="setup"){const l=e.getNamespace("initialized");n[l]!==!0&&(n[l]=!0,n[a]=this.getOutputNode(e),n[a].build(e)),i=n[a]}else s==="analyze"?o.build(e,r):s==="generate"&&(i=o.build(e,r)||"");return i}}class $se extends Ae{constructor(e,r){super(r),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return Lm(e),X(new Dse(this,e))}setup(){return this.call()}}const Gse=[!1,!0],jse=[0,1,2,3],Wse=[-1,-2],D5=[.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],vT=new Map;for(const t of Gse)vT.set(t,new wn(t));const TT=new Map;for(const t of jse)TT.set(t,new wn(t,"uint"));const wT=new Map([...TT].map(t=>new wn(t.value,"int")));for(const t of Wse)wT.set(t,new wn(t,"int"));const gy=new Map([...wT].map(t=>new wn(t.value)));for(const t of D5)gy.set(t,new wn(t));for(const t of D5)gy.set(-t,new wn(-t));const yy={bool:vT,uint:TT,ints:wT,float:gy},Q_=new Map([...vT,...gy]),e1=(t,e)=>Q_.has(t)?Q_.get(t):t.isNode===!0?t:new wn(t,e),Hse=t=>{try{return t.getNodeType()}catch{return}},Pr=function(t,e=null){return(...r)=>{if((r.length===0||!["bool","float","int","uint"].includes(t)&&r.every(s=>typeof s!="object"))&&(r=[V5(t,...r)]),r.length===1&&e!==null&&e.has(r[0]))return X(e.get(r[0]));if(r.length===1){const s=e1(r[0],t);return Hse(s)===t?X(s):X(new B5(s,t))}const i=r.map(s=>e1(s));return X(new Pse(i,t))}},am=t=>typeof t=="object"&&t!==null?t.value:t,$5=t=>t!=null?t.nodeType||t.convertTo||(typeof t=="string"?t:null):null;function qh(t,e){return new Proxy(new $se(t,e),U5)}const X=(t,e=null)=>Fse(t,e),Lm=(t,e=null)=>new zse(t,e),Mu=(t,e=null)=>new Bse(t,e),Z=(...t)=>new kse(...t),ue=(...t)=>new Use(...t);let qse=0;const z=(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));const i=new qh(t,r),s=(...n)=>{let a;Lm(n),n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?a=[...n]:a=n[0];const 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"){const n={name:"fn"+qse++,type:r,inputs:[]};for(const a in e)a!=="return"&&n.inputs.push({name:a,type:e[a]});e=n}s.setLayout(e)}return s},t1=t=>{Pu=t},G5=()=>Pu,je=(...t)=>Pu.If(...t),Xse=(...t)=>Pu.Switch(...t);function xy(t){return Pu&&Pu.add(t),t}W("toStack",xy);const j5=new Pr("color"),C=new Pr("float",yy.float),P=new Pr("int",yy.ints),fe=new Pr("uint",yy.uint),Hn=new Pr("bool",yy.bool),ne=new Pr("vec2"),kr=new Pr("ivec2"),W5=new Pr("uvec2"),H5=new Pr("bvec2"),B=new Pr("vec3"),q5=new Pr("ivec3"),Pc=new Pr("uvec3"),ST=new Pr("bvec3"),Oe=new Pr("vec4"),X5=new Pr("ivec4"),Y5=new Pr("uvec4"),Z5=new Pr("bvec4"),by=new Pr("mat2"),Gs=new Pr("mat3"),_u=new Pr("mat4"),Yse=(t="")=>X(new wn(t,"string")),Zse=t=>X(new wn(t,"ArrayBuffer"));W("toColor",j5);W("toFloat",C);W("toInt",P);W("toUint",fe);W("toBool",Hn);W("toVec2",ne);W("toIVec2",kr);W("toUVec2",W5);W("toBVec2",H5);W("toVec3",B);W("toIVec3",q5);W("toUVec3",Pc);W("toBVec3",ST);W("toVec4",Oe);W("toIVec4",X5);W("toUVec4",Y5);W("toBVec4",Z5);W("toMat2",by);W("toMat3",Gs);W("toMat4",_u);const J5=Z(ju).setParameterLength(2),K5=(t,e)=>X(new B5(X(t),e)),Jse=(t,e)=>X(new Qb(X(t),e));W("element",J5);W("convert",K5);const Kse=t=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),xy(t));W("append",t=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),xy(t)));const Qse=(...t)=>(console.warn("THREE.TSL: tslFn() has been renamed to Fn()."),z(...t));class gt extends Ae{static get type(){return"PropertyNode"}constructor(e,r=null,i=!1){super(e),this.name=r,this.varying=i,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let r;return this.varying===!0?(r=e.getVaryingFromNode(this,this.name),r.needsInterpolation=!0):r=e.getVarFromNode(this,this.name),e.getPropertyName(r)}}const Ic=(t,e)=>X(new gt(t,e)),om=(t,e)=>X(new gt(t,e,!0)),_s=ue(gt,"vec4","DiffuseColor"),r1=ue(gt,"vec3","EmissiveColor"),Q5=ue(gt,"float","Roughness"),ene=ue(gt,"float","Metalness"),tne=ue(gt,"float","Clearcoat"),rne=ue(gt,"float","ClearcoatRoughness"),ine=ue(gt,"vec3","Sheen"),sne=ue(gt,"float","SheenRoughness"),eP=ue(gt,"float","Iridescence"),nne=ue(gt,"float","IridescenceIOR"),ane=ue(gt,"float","IridescenceThickness"),i1=ue(gt,"float","AlphaT"),tP=ue(gt,"float","Anisotropy"),Uf=ue(gt,"vec3","AnisotropyT"),ac=ue(gt,"vec3","AnisotropyB"),one=ue(gt,"color","SpecularColor"),lne=ue(gt,"float","SpecularF90"),une=ue(gt,"float","Shininess"),oc=ue(gt,"vec4","Output"),hne=ue(gt,"float","dashSize"),cne=ue(gt,"float","gapSize"),dne=ue(gt,"float","pointWidth"),mne=ue(gt,"float","IOR"),pne=ue(gt,"float","Transmission"),fne=ue(gt,"float","Thickness"),gne=ue(gt,"float","AttenuationDistance"),yne=ue(gt,"color","AttenuationColor"),xne=ue(gt,"float","Dispersion");class rP extends Ae{static get type(){return"UniformGroupNode"}constructor(e,r=!1,i=1){super("string"),this.name=e,this.shared=r,this.order=i,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const iP=t=>new rP(t),vy=(t,e=0)=>new rP(t,!0,e),bne=vy("frame"),Ye=vy("render"),sP=iP("object");class Fm extends bT{static get type(){return"UniformNode"}constructor(e,r=null){super(e,r),this.isUniformNode=!0,this.name="",this.groupNode=sP}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,r){const i=this.getSelf();return e=e.bind(i),super.onUpdate(s=>{const n=e(s,i);n!==void 0&&(this.value=n)},r)}generate(e,r){const i=this.getNodeType(e),s=this.getUniformHash(e);let n=e.getNodeFromHash(s);n===void 0&&(e.setHashNode(this,s),n=this);const a=n.getInputType(e),o=e.getUniformFromNode(n,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,r)}}const Pe=(t,e)=>{const r=$5(e||t),i=t&&t.isNode===!0?t.node&&t.node.value||t.value:t;return X(new Fm(i,r))};class eN extends xr{static get type(){return"ArrayNode"}constructor(e,r,i=null){super(e),this.count=r,this.values=i,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const r=this.getNodeType(e);return e.generateArray(r,this.count,this.values)}}const nP=(...t)=>{let e;if(t.length===1){const r=t[0];e=new eN(null,r.length,r)}else{const r=t[0],i=t[1];e=new eN(r,i)}return X(e)};W("toArray",(t,e)=>nP(Array(e).fill(t)));class vne extends xr{static get type(){return"AssignNode"}constructor(e,r){super(),this.targetNode=e,this.sourceNode=r,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,r){return r!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:r}=this;if(e.isAvailable("swizzleAssign")===!1&&r.isSplitNode&&r.components.length>1){const i=e.getTypeLength(r.node.getNodeType(e));return Rc.join("").slice(0,i)!==r.components}return!1}setup(e){const{targetNode:r,sourceNode:i}=this,s=e.getNodeProperties(this);s.sourceNode=i,s.targetNode=r.context({assign:!0})}generate(e,r){const{targetNode:i,sourceNode:s}=e.getNodeProperties(this),n=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.build(e),l=s.build(e,a),h=s.getNodeType(e),u=e.getDataFromNode(this);let c;if(u.initialized===!0)r!=="void"&&(c=o);else if(n){const d=e.getVarFromNode(this,null,a),m=e.getPropertyName(d);e.addLineFlowCode(`${m} = ${l}`,this);const p=i.node,g=p.node.context({assign:!0}).build(e);for(let y=0;y<p.components.length;y++){const T=p.components[y];e.addLineFlowCode(`${g}.${T} = ${m}[ ${y} ]`,this)}r!=="void"&&(c=o)}else c=`${o} = ${l}`,(r==="void"||h==="void")&&(e.addLineFlowCode(c,this),r!=="void"&&(c=o));return u.initialized=!0,e.format(c,a,r)}}const aP=Z(vne).setParameterLength(2);W("assign",aP);class Tne extends xr{static get type(){return"FunctionCallNode"}constructor(e=null,r={}){super(),this.functionNode=e,this.parameters=r}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const r=[],i=this.functionNode,s=i.getInputs(e),n=this.parameters,a=(l,h)=>{const u=h.type,c=u==="pointer";let d;return c?d="&"+l.build(e):d=l.build(e,u),d};if(Array.isArray(n)){if(n.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=s.length;else if(n.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<s.length;)n.push(C(0));for(let l=0;l<n.length;l++)r.push(a(n[l],s[l]))}else for(const l of s){const h=n[l.name];h!==void 0?r.push(a(h,l)):(console.error(`THREE.TSL: Input '${l.name}' not found in 'Fn()'.`),r.push(a(C(0),l)))}return`${i.build(e,"property")}( ${r.join(", ")} )`}}const oP=(t,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Mu(e):Lm(e[0]),X(new Tne(X(t),e)));W("call",oP);const wne={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Xt extends xr{static get type(){return"OperatorNode"}constructor(e,r,i,...s){if(super(),s.length>0){let n=new Xt(e,r,i);for(let a=0;a<s.length-1;a++)n=new Xt(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(wne[this.op],r)}getNodeType(e){const 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===">="){const 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){const i=this.op,{aNode:s,bNode:n}=this,a=this.getNodeType(e);let o=null,l=null;a!=="void"?(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):e.isMatrix(l)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(l):o=l=a:o=l=a):o=l=a;const h=s.build(e,o),u=n?n.build(e,l):null,c=e.getFunctionOperator(i);if(r!=="void"){const d=e.renderer.coordinateSystem===va;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):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 fr=Z(Xt,"+").setParameterLength(2,1/0).setName("add"),it=Z(Xt,"-").setParameterLength(2,1/0).setName("sub"),ke=Z(Xt,"*").setParameterLength(2,1/0).setName("mul"),qn=Z(Xt,"/").setParameterLength(2,1/0).setName("div"),zm=Z(Xt,"%").setParameterLength(2).setName("mod"),MT=Z(Xt,"==").setParameterLength(2).setName("equal"),lP=Z(Xt,"!=").setParameterLength(2).setName("notEqual"),uP=Z(Xt,"<").setParameterLength(2).setName("lessThan"),_T=Z(Xt,">").setParameterLength(2).setName("greaterThan"),hP=Z(Xt,"<=").setParameterLength(2).setName("lessThanEqual"),cP=Z(Xt,">=").setParameterLength(2).setName("greaterThanEqual"),dP=Z(Xt,"&&").setParameterLength(2,1/0).setName("and"),mP=Z(Xt,"||").setParameterLength(2,1/0).setName("or"),pP=Z(Xt,"!").setParameterLength(1).setName("not"),fP=Z(Xt,"^^").setParameterLength(2).setName("xor"),gP=Z(Xt,"&").setParameterLength(2).setName("bitAnd"),yP=Z(Xt,"~").setParameterLength(2).setName("bitNot"),xP=Z(Xt,"|").setParameterLength(2).setName("bitOr"),bP=Z(Xt,"^").setParameterLength(2).setName("bitXor"),vP=Z(Xt,"<<").setParameterLength(2).setName("shiftLeft"),TP=Z(Xt,">>").setParameterLength(2).setName("shiftRight"),wP=z(([t])=>(t.addAssign(1),t)),SP=z(([t])=>(t.subAssign(1),t)),MP=z(([t])=>{const e=P(t).toConst();return t.addAssign(1),e}),_P=z(([t])=>{const e=P(t).toConst();return t.subAssign(1),e});W("add",fr);W("sub",it);W("mul",ke);W("div",qn);W("mod",zm);W("equal",MT);W("notEqual",lP);W("lessThan",uP);W("greaterThan",_T);W("lessThanEqual",hP);W("greaterThanEqual",cP);W("and",dP);W("or",mP);W("not",pP);W("xor",fP);W("bitAnd",gP);W("bitNot",yP);W("bitOr",xP);W("bitXor",bP);W("shiftLeft",vP);W("shiftRight",TP);W("incrementBefore",wP);W("decrementBefore",SP);W("increment",MP);W("decrement",_P);const NP=(t,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),zm(t,e)),EP=(t,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),zm(P(t),P(e)));W("remainder",NP);W("modInt",EP);class L extends xr{static get type(){return"MathNode"}constructor(e,r,i=null,s=null){if(super(),(e===L.MAX||e===L.MIN)&&arguments.length>3){let n=new L(e,r,i);for(let a=2;a<arguments.length-1;a++)n=new L(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){const 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){const r=this.method;return r===L.LENGTH||r===L.DISTANCE||r===L.DOT?"float":r===L.CROSS?"vec3":r===L.ALL||r===L.ANY?"bool":r===L.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:r,bNode:i,method:s}=this;let n=null;if(s===L.ONE_MINUS)n=it(1,r);else if(s===L.RECIPROCAL)n=qn(1,r);else if(s===L.DIFFERENCE)n=Vt(it(r,i));else if(s===L.TRANSFORM_DIRECTION){let a=r,o=i;e.isMatrix(a.getNodeType(e))?o=Oe(B(o),0):a=Oe(B(a),0);const l=ke(a,o).xyz;n=Wu(l)}return n!==null?n:super.setup(e)}generate(e,r){if(e.getNodeProperties(this).outputNode)return super.generate(e,r);let s=this.method;const n=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,h=this.cNode,u=e.renderer.coordinateSystem;if(s===L.NEGATE)return e.format("( - "+o.build(e,a)+" )",n,r);{const c=[];return s===L.CROSS?c.push(o.build(e,n),l.build(e,n)):u===va&&s===L.STEP?c.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===va&&(s===L.MIN||s===L.MAX)?c.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):s===L.REFRACT?c.push(o.build(e,a),l.build(e,a),h.build(e,"float")):s===L.MIX?c.push(o.build(e,a),l.build(e,a),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":a)):(u===Ru&&s===L.ATAN&&l!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===L.DFDX||s===L.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}}L.ALL="all";L.ANY="any";L.RADIANS="radians";L.DEGREES="degrees";L.EXP="exp";L.EXP2="exp2";L.LOG="log";L.LOG2="log2";L.SQRT="sqrt";L.INVERSE_SQRT="inversesqrt";L.FLOOR="floor";L.CEIL="ceil";L.NORMALIZE="normalize";L.FRACT="fract";L.SIN="sin";L.COS="cos";L.TAN="tan";L.ASIN="asin";L.ACOS="acos";L.ATAN="atan";L.ABS="abs";L.SIGN="sign";L.LENGTH="length";L.NEGATE="negate";L.ONE_MINUS="oneMinus";L.DFDX="dFdx";L.DFDY="dFdy";L.ROUND="round";L.RECIPROCAL="reciprocal";L.TRUNC="trunc";L.FWIDTH="fwidth";L.TRANSPOSE="transpose";L.BITCAST="bitcast";L.EQUALS="equals";L.MIN="min";L.MAX="max";L.STEP="step";L.REFLECT="reflect";L.DISTANCE="distance";L.DIFFERENCE="difference";L.DOT="dot";L.CROSS="cross";L.POW="pow";L.TRANSFORM_DIRECTION="transformDirection";L.MIX="mix";L.CLAMP="clamp";L.REFRACT="refract";L.SMOOTHSTEP="smoothstep";L.FACEFORWARD="faceforward";const AP=C(1e-6),Sne=C(1e6),bg=C(Math.PI),Mne=C(Math.PI*2),CP=Z(L,L.ALL).setParameterLength(1),RP=Z(L,L.ANY).setParameterLength(1),PP=Z(L,L.RADIANS).setParameterLength(1),IP=Z(L,L.DEGREES).setParameterLength(1),VP=Z(L,L.EXP).setParameterLength(1),wc=Z(L,L.EXP2).setParameterLength(1),NT=Z(L,L.LOG).setParameterLength(1),Pa=Z(L,L.LOG2).setParameterLength(1),Qn=Z(L,L.SQRT).setParameterLength(1),ET=Z(L,L.INVERSE_SQRT).setParameterLength(1),zn=Z(L,L.FLOOR).setParameterLength(1),Ty=Z(L,L.CEIL).setParameterLength(1),Wu=Z(L,L.NORMALIZE).setParameterLength(1),Ha=Z(L,L.FRACT).setParameterLength(1),cs=Z(L,L.SIN).setParameterLength(1),ga=Z(L,L.COS).setParameterLength(1),OP=Z(L,L.TAN).setParameterLength(1),LP=Z(L,L.ASIN).setParameterLength(1),FP=Z(L,L.ACOS).setParameterLength(1),AT=Z(L,L.ATAN).setParameterLength(1,2),Vt=Z(L,L.ABS).setParameterLength(1),lm=Z(L,L.SIGN).setParameterLength(1),vg=Z(L,L.LENGTH).setParameterLength(1),zP=Z(L,L.NEGATE).setParameterLength(1),BP=Z(L,L.ONE_MINUS).setParameterLength(1),CT=Z(L,L.DFDX).setParameterLength(1),RT=Z(L,L.DFDY).setParameterLength(1),kP=Z(L,L.ROUND).setParameterLength(1),UP=Z(L,L.RECIPROCAL).setParameterLength(1),PT=Z(L,L.TRUNC).setParameterLength(1),DP=Z(L,L.FWIDTH).setParameterLength(1),$P=Z(L,L.TRANSPOSE).setParameterLength(1),_ne=Z(L,L.BITCAST).setParameterLength(2),GP=(t,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),MT(t,e)),js=Z(L,L.MIN).setParameterLength(2,1/0),Gr=Z(L,L.MAX).setParameterLength(2,1/0),wy=Z(L,L.STEP).setParameterLength(2),jP=Z(L,L.REFLECT).setParameterLength(2),WP=Z(L,L.DISTANCE).setParameterLength(2),HP=Z(L,L.DIFFERENCE).setParameterLength(2),Go=Z(L,L.DOT).setParameterLength(2),Sy=Z(L,L.CROSS).setParameterLength(2),pn=Z(L,L.POW).setParameterLength(2),qP=Z(L,L.POW,2).setParameterLength(1),XP=Z(L,L.POW,3).setParameterLength(1),YP=Z(L,L.POW,4).setParameterLength(1),ZP=Z(L,L.TRANSFORM_DIRECTION).setParameterLength(2),JP=t=>ke(lm(t),pn(Vt(t),1/3)),IT=t=>Go(t,t),ur=Z(L,L.MIX).setParameterLength(3),Ba=(t,e=0,r=1)=>X(new L(L.CLAMP,X(t),X(e),X(r))),KP=t=>Ba(t),QP=Z(L,L.REFRACT).setParameterLength(3),Iu=Z(L,L.SMOOTHSTEP).setParameterLength(3),VT=Z(L,L.FACEFORWARD).setParameterLength(3),eI=z(([t])=>{const i=43758.5453,s=Go(t.xy,ne(12.9898,78.233)),n=zm(s,bg);return Ha(cs(n).mul(i))}),tI=(t,e,r)=>ur(e,r,t),rI=(t,e,r)=>Iu(e,r,t),iI=(t,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),AT(t,e)),Nne=VT,Ene=ET;W("all",CP);W("any",RP);W("equals",GP);W("radians",PP);W("degrees",IP);W("exp",VP);W("exp2",wc);W("log",NT);W("log2",Pa);W("sqrt",Qn);W("inverseSqrt",ET);W("floor",zn);W("ceil",Ty);W("normalize",Wu);W("fract",Ha);W("sin",cs);W("cos",ga);W("tan",OP);W("asin",LP);W("acos",FP);W("atan",AT);W("abs",Vt);W("sign",lm);W("length",vg);W("lengthSq",IT);W("negate",zP);W("oneMinus",BP);W("dFdx",CT);W("dFdy",RT);W("round",kP);W("reciprocal",UP);W("trunc",PT);W("fwidth",DP);W("atan2",iI);W("min",js);W("max",Gr);W("step",wy);W("reflect",jP);W("distance",WP);W("dot",Go);W("cross",Sy);W("pow",pn);W("pow2",qP);W("pow3",XP);W("pow4",YP);W("transformDirection",ZP);W("mix",tI);W("clamp",Ba);W("refract",QP);W("smoothstep",rI);W("faceForward",VT);W("difference",HP);W("saturate",KP);W("cbrt",JP);W("transpose",$P);W("rand",eI);class Ane extends Ae{static get type(){return"ConditionalNode"}constructor(e,r,i=null){super(),this.condNode=e,this.ifNode=r,this.elseNode=i}getNodeType(e){const{ifNode:r,elseNode:i}=e.getNodeProperties(this);if(r===void 0)return this.setup(e),this.getNodeType(e);const s=r.getNodeType(e);if(i!==null){const n=i.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(s))return n}return s}setup(e){const r=this.condNode.cache(),i=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,n=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=n,s!==null&&(e.getDataFromNode(s).parentNodeBlock=n);const a=e.getNodeProperties(this);a.condNode=r,a.ifNode=i.context({nodeBlock:i}),a.elseNode=s?s.context({nodeBlock:s}):null}generate(e,r){const i=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:n,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,h=r!=="void",u=h?Ic(i).build(e):"";s.nodeProperty=u;const c=n.build(e,"bool");e.addFlowCode(`
459
459
  ${e.tab}if ( ${c} ) {
460
460
 
461
461
  `).addFlowTab();let d=a.build(e,i);if(d&&(h?d=u+" = "+d+";":(d="return "+d+";",l===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),d="// "+d))),e.removeFlowTab().addFlowCode(e.tab+" "+d+`
@@ -468,21 +468,21 @@ ${e.tab}if ( ${c} ) {
468
468
 
469
469
  `)}else e.addFlowCode(`
470
470
 
471
- `);return e.format(u,i,r)}}const yi=Z(Ane).setParameterLength(2,3);W("select",yi);const sI=(...t)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),yi(...t));W("cond",sI);class nI extends Ae{static get type(){return"ContextNode"}constructor(e,r={}){super(),this.isContextNode=!0,this.node=e,this.value=r}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const r=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(r)}setup(e){const r=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(r)}generate(e,r){const i=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,r);return e.setContext(i),s}}const OT=Z(nI).setParameterLength(1,2),aI=(t,e)=>OT(t,{label:e});W("context",OT);W("label",aI);class Cne extends Ae{static get type(){return"VarNode"}constructor(e,r=null,i=!1){super(),this.node=e,this.name=r,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0}getMemberType(e,r){return this.node.getMemberType(e,r)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:r,name:i,readOnly:s}=this,{renderer:n}=e,a=n.backend.isWebGPUBackend===!0;let o=!1,l=!1;s&&(o=e.isDeterministic(r),l=a?s:o);const h=e.getVectorType(this.getNodeType(e)),u=r.build(e,h),c=e.getVarFromNode(this,i,h,void 0,l),d=e.getPropertyName(c);let m=d;if(l)if(a)m=o?`const ${d}`:`let ${d}`;else{const p=e.getArrayCount(r);m=`const ${e.getVar(c.type,d,p)}`}return e.addLineFlowCode(`${m} = ${u}`,this),d}}const LT=Z(Cne),oI=(t,e=null)=>LT(t,e).toStack(),lI=(t,e=null)=>LT(t,e,!0).toStack();W("toVar",oI);W("toConst",lI);const uI=t=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),LT(t));W("temp",uI);class Rne extends Ae{static get type(){return"VaryingNode"}constructor(e,r=null){super(),this.node=e,this.name=r,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,r=null){return this.interpolationType=e,this.interpolationSampling=r,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const r=e.getNodeProperties(this);let i=r.varying;if(i===void 0){const s=this.name,n=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;r.varying=i=e.getVaryingFromNode(this,s,n,a,o),r.node=this.node}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(wd.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(wd.VERTEX,this.node)}generate(e){const r=e.getNodeProperties(this),i=this.setupVarying(e);if(r.propertyName===void 0){const s=this.getNodeType(e),n=e.getPropertyName(i,wd.VERTEX);e.flowNodeFromShaderStage(wd.VERTEX,this.node,s,n),r.propertyName=n}return e.getPropertyName(i)}}const Ys=Z(Rne).setParameterLength(1,2),hI=t=>Ys(t);W("toVarying",Ys);W("toVertexStage",hI);W("varying",(...t)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Ys(...t)));W("vertexStage",(...t)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Ys(...t)));const cI=z(([t])=>{const e=t.mul(.9478672986).add(.0521327014).pow(2.4),r=t.mul(.0773993808),i=t.lessThanEqual(.04045);return ur(e,r,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),dI=z(([t])=>{const e=t.pow(.41666).mul(1.055).sub(.055),r=t.mul(12.92),i=t.lessThanEqual(.0031308);return ur(e,r,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),FT="WorkingColorSpace",Pne="OutputColorSpace";class zT extends xr{static get type(){return"ColorSpaceNode"}constructor(e,r,i){super("vec4"),this.colorNode=e,this.source=r,this.target=i}resolveColorSpace(e,r){return r===FT?or.workingColorSpace:r===Pne?e.context.outputColorSpace||e.renderer.outputColorSpace:r}setup(e){const{colorNode:r}=this,i=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let n=r;return or.enabled===!1||i===s||!i||!s||(or.getTransfer(i)===Ld&&(n=Oe(cI(n.rgb),n.a)),or.getPrimaries(i)!==or.getPrimaries(s)&&(n=Oe(Gs(or._getMatrix(new qs,i,s)).mul(n.rgb),n.a)),or.getTransfer(s)===Ld&&(n=Oe(dI(n.rgb),n.a))),n}}const mI=(t,e)=>X(new zT(X(t),FT,e)),BT=(t,e)=>X(new zT(X(t),e,FT)),Ine=(t,e,r)=>X(new zT(X(t),e,r));W("workingToColorSpace",mI);W("colorSpaceToWorking",BT);let Vne=class extends ju{static get type(){return"ReferenceElementNode"}constructor(e,r){super(e,r),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const r=super.generate(e),i=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(r,i,s)}};class One extends Ae{static get type(){return"ReferenceBaseNode"}constructor(e,r,i=null,s=null){super(),this.property=e,this.uniformType=r,this.object=i,this.count=s,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=Tt.OBJECT}setGroup(e){return this.group=e,this}element(e){return X(new Vne(this,X(e)))}setNodeType(e){const r=Ie(null,e).getSelf();this.group!==null&&r.setGroup(this.group),this.node=r}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:r}=this;let i=e[r[0]];for(let s=1;s<r.length;s++)i=i[r[s]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}class Lne extends One{static get type(){return"RendererReferenceNode"}constructor(e,r,i=null){super(e,r,i),this.renderer=i,this.setGroup(Ye)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const pI=(t,e,r=null)=>X(new Lne(t,e,r));class Fne extends xr{static get type(){return"ToneMappingNode"}constructor(e,r=gI,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=r,this.colorNode=i}customCacheKey(){return R5(this.toneMapping)}setup(e){const r=this.colorNode||e.context.color,i=this.toneMapping;if(i===Vb)return r;let s=null;const n=e.renderer.library.getToneMappingFunction(i);return n!==null?s=Oe(n(r.rgb,this.exposureNode),r.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",i),s=r),s}}const fI=(t,e,r)=>X(new Fne(t,X(e),X(r))),gI=pI("toneMappingExposure","float");W("toneMapping",(t,e,r)=>fI(e,r,t));class zne extends bT{static get type(){return"BufferAttributeNode"}constructor(e,r=null,i=0,s=0){super(e,r),this.isBufferNode=!0,this.bufferType=r,this.bufferStride=i,this.bufferOffset=s,this.usage=ug,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let r=e.globalCache.getData(this.value);return r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),r.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const r=this.getNodeType(e),i=this.value,s=e.getTypeLength(r),n=this.bufferStride||s,a=this.bufferOffset,o=i.isInterleavedBuffer===!0?i:new h3(i,n),l=new Yv(o,s,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const r=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,r),s=e.getPropertyName(i);let n=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=s,n=s):n=Ys(this).build(e,r),n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Bm=(t,e=null,r=0,i=0)=>X(new zne(t,e,r,i)),yI=(t,e=null,r=0,i=0)=>Bm(t,e,r,i).setUsage(vd),Tg=(t,e=null,r=0,i=0)=>Bm(t,e,r,i).setInstanced(!0),s1=(t,e=null,r=0,i=0)=>yI(t,e,r,i).setInstanced(!0);W("toAttribute",t=>Bm(t.value));class Bne extends Ae{static get type(){return"ComputeNode"}constructor(e,r,i=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=r,this.workgroupSize=i,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Tt.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:r}=this;let i=r[0];for(let s=1;s<r.length;s++)i*=r[s];this.dispatchCount=Math.ceil(e/i)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const r=this.computeNode.build(e);if(r){const i=e.getNodeProperties(this);i.outputComputeNode=r.outputNode,r.outputNode=null}return r}generate(e,r){const{shaderStage:i}=e;if(i==="compute"){const s=this.computeNode.build(e,"void");s!==""&&e.addLineFlowCode(s,this)}else{const n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,r)}}}const xI=(t,e,r)=>X(new Bne(X(t),e,r));W("compute",xI);class kne extends Ae{static get type(){return"CacheNode"}constructor(e,r=!0){super(),this.node=e,this.parent=r,this.isCacheNode=!0}getNodeType(e){const r=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const s=this.node.getNodeType(e);return e.setCache(r),s}build(e,...r){const i=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const n=this.node.build(e,...r);return e.setCache(i),n}}const bI=(t,e)=>X(new kne(X(t),e)),vI=(t,e)=>t.context({namespace:e});W("cache",bI);class Une extends Ae{static get type(){return"BypassNode"}constructor(e,r){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=r}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const r=this.callNode.build(e,"void");return r!==""&&e.addLineFlowCode(r,this),this.outputNode.build(e)}}const TI=Z(Une).setParameterLength(2);W("bypass",TI);class wI extends Ae{static get type(){return"RemapNode"}constructor(e,r,i,s=C(0),n=C(1)){super(),this.node=e,this.inLowNode=r,this.inHighNode=i,this.outLowNode=s,this.outHighNode=n,this.doClamp=!0}setup(){const{node:e,inLowNode:r,inHighNode:i,outLowNode:s,outHighNode:n,doClamp:a}=this;let o=e.sub(r).div(i.sub(r));return a===!0&&(o=o.clamp()),o.mul(n.sub(s)).add(s)}}const SI=Z(wI,null,null,{doClamp:!1}).setParameterLength(3,5),MI=Z(wI).setParameterLength(3,5);W("remap",SI);W("remapClamp",MI);class Dne extends Ae{static get type(){return"ExpressionNode"}constructor(e="",r="void"){super(r),this.snippet=e}generate(e,r){const i=this.getNodeType(e),s=this.snippet;if(i==="void")e.addLineFlowCode(s,this);else return e.format(s,i,r)}}const ka=Z(Dne).setParameterLength(1,2),_I=t=>(t?yi(t,ka("discard")):ka("discard")).toStack(),$ne=()=>ka("return").toStack();W("discard",_I);class Gne extends xr{static get type(){return"RenderOutputNode"}constructor(e,r,i){super("vec4"),this.colorNode=e,this.toneMapping=r,this.outputColorSpace=i,this.isRenderOutputNode=!0}setup({context:e}){let r=this.colorNode||e.color;const i=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Vb,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||og;return i!==Vb&&(r=r.toneMapping(i)),s!==og&&s!==or.workingColorSpace&&(r=r.workingToColorSpace(s)),r}}const NI=(t,e=null,r=null)=>X(new Gne(X(t),e,r));W("renderOutput",NI);class jne extends xr{static get type(){return"DebugNode"}constructor(e,r=null){super(),this.node=e,this.callback=r}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const r=this.callback,i=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(s.length);let a="";return a+="// #"+s+`#
471
+ `);return e.format(u,i,r)}}const yi=Z(Ane).setParameterLength(2,3);W("select",yi);const sI=(...t)=>(console.warn("THREE.TSL: cond() has been renamed to select()."),yi(...t));W("cond",sI);class nI extends Ae{static get type(){return"ContextNode"}constructor(e,r={}){super(),this.isContextNode=!0,this.node=e,this.value=r}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){const r=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(r)}setup(e){const r=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(r)}generate(e,r){const i=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e,r);return e.setContext(i),s}}const OT=Z(nI).setParameterLength(1,2),aI=(t,e)=>OT(t,{label:e});W("context",OT);W("label",aI);class Cne extends Ae{static get type(){return"VarNode"}constructor(e,r=null,i=!1){super(),this.node=e,this.name=r,this.global=!0,this.isVarNode=!0,this.readOnly=i,this.parents=!0}getMemberType(e,r){return this.node.getMemberType(e,r)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:r,name:i,readOnly:s}=this,{renderer:n}=e,a=n.backend.isWebGPUBackend===!0;let o=!1,l=!1;s&&(o=e.isDeterministic(r),l=a?s:o);const h=e.getVectorType(this.getNodeType(e)),u=r.build(e,h),c=e.getVarFromNode(this,i,h,void 0,l),d=e.getPropertyName(c);let m=d;if(l)if(a)m=o?`const ${d}`:`let ${d}`;else{const p=e.getArrayCount(r);m=`const ${e.getVar(c.type,d,p)}`}return e.addLineFlowCode(`${m} = ${u}`,this),d}}const LT=Z(Cne),oI=(t,e=null)=>LT(t,e).toStack(),lI=(t,e=null)=>LT(t,e,!0).toStack();W("toVar",oI);W("toConst",lI);const uI=t=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),LT(t));W("temp",uI);class Rne extends Ae{static get type(){return"VaryingNode"}constructor(e,r=null){super(),this.node=e,this.name=r,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,r=null){return this.interpolationType=e,this.interpolationSampling=r,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const r=e.getNodeProperties(this);let i=r.varying;if(i===void 0){const s=this.name,n=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;r.varying=i=e.getVaryingFromNode(this,s,n,a,o),r.node=this.node}return i.needsInterpolation||(i.needsInterpolation=e.shaderStage==="fragment"),i}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(wd.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(wd.VERTEX,this.node)}generate(e){const r=e.getNodeProperties(this),i=this.setupVarying(e);if(r.propertyName===void 0){const s=this.getNodeType(e),n=e.getPropertyName(i,wd.VERTEX);e.flowNodeFromShaderStage(wd.VERTEX,this.node,s,n),r.propertyName=n}return e.getPropertyName(i)}}const Ys=Z(Rne).setParameterLength(1,2),hI=t=>Ys(t);W("toVarying",Ys);W("toVertexStage",hI);W("varying",(...t)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),Ys(...t)));W("vertexStage",(...t)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),Ys(...t)));const cI=z(([t])=>{const e=t.mul(.9478672986).add(.0521327014).pow(2.4),r=t.mul(.0773993808),i=t.lessThanEqual(.04045);return ur(e,r,i)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),dI=z(([t])=>{const e=t.pow(.41666).mul(1.055).sub(.055),r=t.mul(12.92),i=t.lessThanEqual(.0031308);return ur(e,r,i)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),FT="WorkingColorSpace",Pne="OutputColorSpace";class zT extends xr{static get type(){return"ColorSpaceNode"}constructor(e,r,i){super("vec4"),this.colorNode=e,this.source=r,this.target=i}resolveColorSpace(e,r){return r===FT?or.workingColorSpace:r===Pne?e.context.outputColorSpace||e.renderer.outputColorSpace:r}setup(e){const{colorNode:r}=this,i=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let n=r;return or.enabled===!1||i===s||!i||!s||(or.getTransfer(i)===Ld&&(n=Oe(cI(n.rgb),n.a)),or.getPrimaries(i)!==or.getPrimaries(s)&&(n=Oe(Gs(or._getMatrix(new qs,i,s)).mul(n.rgb),n.a)),or.getTransfer(s)===Ld&&(n=Oe(dI(n.rgb),n.a))),n}}const mI=(t,e)=>X(new zT(X(t),FT,e)),BT=(t,e)=>X(new zT(X(t),e,FT)),Ine=(t,e,r)=>X(new zT(X(t),e,r));W("workingToColorSpace",mI);W("colorSpaceToWorking",BT);let Vne=class extends ju{static get type(){return"ReferenceElementNode"}constructor(e,r){super(e,r),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const r=super.generate(e),i=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(r,i,s)}};class One extends Ae{static get type(){return"ReferenceBaseNode"}constructor(e,r,i=null,s=null){super(),this.property=e,this.uniformType=r,this.object=i,this.count=s,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.updateType=Tt.OBJECT}setGroup(e){return this.group=e,this}element(e){return X(new Vne(this,X(e)))}setNodeType(e){const r=Pe(null,e).getSelf();this.group!==null&&r.setGroup(this.group),this.node=r}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:r}=this;let i=e[r[0]];for(let s=1;s<r.length;s++)i=i[r[s]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}class Lne extends One{static get type(){return"RendererReferenceNode"}constructor(e,r,i=null){super(e,r,i),this.renderer=i,this.setGroup(Ye)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const pI=(t,e,r=null)=>X(new Lne(t,e,r));class Fne extends xr{static get type(){return"ToneMappingNode"}constructor(e,r=gI,i=null){super("vec3"),this.toneMapping=e,this.exposureNode=r,this.colorNode=i}customCacheKey(){return R5(this.toneMapping)}setup(e){const r=this.colorNode||e.context.color,i=this.toneMapping;if(i===Vb)return r;let s=null;const n=e.renderer.library.getToneMappingFunction(i);return n!==null?s=Oe(n(r.rgb,this.exposureNode),r.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",i),s=r),s}}const fI=(t,e,r)=>X(new Fne(t,X(e),X(r))),gI=pI("toneMappingExposure","float");W("toneMapping",(t,e,r)=>fI(e,r,t));class zne extends bT{static get type(){return"BufferAttributeNode"}constructor(e,r=null,i=0,s=0){super(e,r),this.isBufferNode=!0,this.bufferType=r,this.bufferStride=i,this.bufferOffset=s,this.usage=ug,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let r=e.globalCache.getData(this.value);return r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),r.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const r=this.getNodeType(e),i=this.value,s=e.getTypeLength(r),n=this.bufferStride||s,a=this.bufferOffset,o=i.isInterleavedBuffer===!0?i:new h3(i,n),l=new Yv(o,s,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const r=this.getNodeType(e),i=e.getBufferAttributeFromNode(this,r),s=e.getPropertyName(i);let n=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=s,n=s):n=Ys(this).build(e,r),n}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Bm=(t,e=null,r=0,i=0)=>X(new zne(t,e,r,i)),yI=(t,e=null,r=0,i=0)=>Bm(t,e,r,i).setUsage(vd),Tg=(t,e=null,r=0,i=0)=>Bm(t,e,r,i).setInstanced(!0),s1=(t,e=null,r=0,i=0)=>yI(t,e,r,i).setInstanced(!0);W("toAttribute",t=>Bm(t.value));class Bne extends Ae{static get type(){return"ComputeNode"}constructor(e,r,i=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=r,this.workgroupSize=i,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Tt.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:r}=this;let i=r[0];for(let s=1;s<r.length;s++)i*=r[s];this.dispatchCount=Math.ceil(e/i)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const r=this.computeNode.build(e);if(r){const i=e.getNodeProperties(this);i.outputComputeNode=r.outputNode,r.outputNode=null}return r}generate(e,r){const{shaderStage:i}=e;if(i==="compute"){const s=this.computeNode.build(e,"void");s!==""&&e.addLineFlowCode(s,this)}else{const n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,r)}}}const xI=(t,e,r)=>X(new Bne(X(t),e,r));W("compute",xI);class kne extends Ae{static get type(){return"CacheNode"}constructor(e,r=!0){super(),this.node=e,this.parent=r,this.isCacheNode=!0}getNodeType(e){const r=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const s=this.node.getNodeType(e);return e.setCache(r),s}build(e,...r){const i=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const n=this.node.build(e,...r);return e.setCache(i),n}}const bI=(t,e)=>X(new kne(X(t),e)),vI=(t,e)=>t.context({namespace:e});W("cache",bI);class Une extends Ae{static get type(){return"BypassNode"}constructor(e,r){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=r}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const r=this.callNode.build(e,"void");return r!==""&&e.addLineFlowCode(r,this),this.outputNode.build(e)}}const TI=Z(Une).setParameterLength(2);W("bypass",TI);class wI extends Ae{static get type(){return"RemapNode"}constructor(e,r,i,s=C(0),n=C(1)){super(),this.node=e,this.inLowNode=r,this.inHighNode=i,this.outLowNode=s,this.outHighNode=n,this.doClamp=!0}setup(){const{node:e,inLowNode:r,inHighNode:i,outLowNode:s,outHighNode:n,doClamp:a}=this;let o=e.sub(r).div(i.sub(r));return a===!0&&(o=o.clamp()),o.mul(n.sub(s)).add(s)}}const SI=Z(wI,null,null,{doClamp:!1}).setParameterLength(3,5),MI=Z(wI).setParameterLength(3,5);W("remap",SI);W("remapClamp",MI);class Dne extends Ae{static get type(){return"ExpressionNode"}constructor(e="",r="void"){super(r),this.snippet=e}generate(e,r){const i=this.getNodeType(e),s=this.snippet;if(i==="void")e.addLineFlowCode(s,this);else return e.format(s,i,r)}}const ka=Z(Dne).setParameterLength(1,2),_I=t=>(t?yi(t,ka("discard")):ka("discard")).toStack(),$ne=()=>ka("return").toStack();W("discard",_I);class Gne extends xr{static get type(){return"RenderOutputNode"}constructor(e,r,i){super("vec4"),this.colorNode=e,this.toneMapping=r,this.outputColorSpace=i,this.isRenderOutputNode=!0}setup({context:e}){let r=this.colorNode||e.color;const i=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Vb,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||og;return i!==Vb&&(r=r.toneMapping(i)),s!==og&&s!==or.workingColorSpace&&(r=r.workingToColorSpace(s)),r}}const NI=(t,e=null,r=null)=>X(new Gne(X(t),e,r));W("renderOutput",NI);class jne extends xr{static get type(){return"DebugNode"}constructor(e,r=null){super(),this.node=e,this.callback=r}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const r=this.callback,i=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(s.length);let a="";return a+="// #"+s+`#
472
472
  `,a+=e.flow.code.replace(/^\t/mg,"")+`
473
473
  `,a+="/* ... */ "+i+` /* ... */
474
474
  `,a+="// #"+n+`#
475
- `,r!==null?r(e,a):console.log(a),i}}const EI=(t,e=null)=>X(new jne(X(t),e));W("debug",EI);function Wne(t){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}class AI extends Ae{static get type(){return"AttributeNode"}constructor(e,r=null){super(r),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let r=this.nodeType;if(r===null){const i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){const s=e.geometry.getAttribute(i);r=e.getTypeFromAttribute(s)}else r="float"}return r}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const r=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(r)===!0){const n=e.geometry.getAttribute(r),a=e.getTypeFromAttribute(n),o=e.getAttribute(r,a);return e.shaderStage==="vertex"?e.format(o.name,a,i):Ys(this).build(e,i)}else return console.warn(`AttributeNode: Vertex attribute "${r}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Bo=(t,e=null)=>X(new AI(t,e)),jt=(t=0)=>Bo("uv"+(t>0?t:""),"vec2");class Hne extends Ae{static get type(){return"TextureSizeNode"}constructor(e,r=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=r}generate(e,r){const i=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${s} )`,this.getNodeType(e),r)}}const Ro=Z(Hne).setParameterLength(1,2);class qne extends Fm{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Tt.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,r=e.images,i=r&&r.length>0?r[0]&&r[0].image||r[0]:e.image;if(i&&i.width!==void 0){const{width:s,height:n}=i;this.value=Math.log2(Math.max(s,n))}}}const CI=Z(qne).setParameterLength(1),kT=new vi;class Ua extends Fm{static get type(){return"TextureNode"}constructor(e=kT,r=null,i=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=r,this.levelNode=i,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Tt.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(r===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===n3?"uvec4":this.value.type===NJ?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return jt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=Ie(this.value.matrix)),this._matrixUniform.mul(B(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Tt.OBJECT:Tt.NONE,this}setupUV(e,r){const i=this.value;return e.isFlipY()&&(i.image instanceof ImageBitmap&&i.flipY===!0||i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0||i.isDepthTexture===!0)&&(this.sampler?r=r.flipY():r=r.setY(P(Ro(this,this.levelNode).y).sub(r.y).sub(1))),r}setup(e){const r=e.getNodeProperties(this);r.referenceNode=this.referenceNode;const i=this.value;if(!i||i.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;(s===null||e.context.forceUVContext===!0)&&e.context.getUV&&(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),r.uvNode=s,r.levelNode=n,r.biasNode=this.biasNode,r.compareNode=this.compareNode,r.gradNode=this.gradNode,r.depthNode=this.depthNode}generateUV(e,r){return r.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,r,i,s,n,a,o,l){const h=this.value;let u;return s?u=e.generateTextureLevel(h,r,i,s,a):n?u=e.generateTextureBias(h,r,i,n,a):l?u=e.generateTextureGrad(h,r,i,l,a):o?u=e.generateTextureCompare(h,r,i,o,a):this.sampler===!1?u=e.generateTextureLoad(h,r,i,a):u=e.generateTexture(h,r,i,a),u}generate(e,r){const i=this.value,s=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(r))return n+"_sampler";if(e.isReference(r))return n;{const a=e.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:c,biasNode:d,compareNode:m,depthNode:p,gradNode:f}=s,g=this.generateUV(e,u),y=c?c.build(e,"float"):null,T=d?d.build(e,"float"):null,M=p?p.build(e,"int"):null,w=m?m.build(e,"float"):null,_=f?[f[0].build(e,"vec2"),f[1].build(e,"vec2")]:null,S=e.getVarFromNode(this);o=e.getPropertyName(S);const N=this.generateSnippet(e,n,g,y,T,M,w,_);e.addLineFlowCode(`${o} = ${N}`,this),a.snippet=N,a.propertyName=o}let l=o;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(i)&&(l=BT(ka(l,h),i.colorSpace).setup(e).build(e,h)),e.format(l,h,r)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const r=this.clone();return r.uvNode=X(e),r.referenceNode=this.getSelf(),X(r)}blur(e){const r=this.clone();r.biasNode=X(e).mul(CI(r)),r.referenceNode=this.getSelf();const i=r.value;return r.generateMipmaps===!1&&(i&&i.generateMipmaps===!1||i.minFilter===$s||i.magFilter===$s)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),r.biasNode=null),X(r)}level(e){const r=this.clone();return r.levelNode=X(e),r.referenceNode=this.getSelf(),X(r)}size(e){return Ro(this,e)}bias(e){const r=this.clone();return r.biasNode=X(e),r.referenceNode=this.getSelf(),X(r)}compare(e){const r=this.clone();return r.compareNode=X(e),r.referenceNode=this.getSelf(),X(r)}grad(e,r){const i=this.clone();return i.gradNode=[X(e),X(r)],i.referenceNode=this.getSelf(),X(i)}depth(e){const r=this.clone();return r.depthNode=X(e),r.referenceNode=this.getSelf(),X(r)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,r=this._matrixUniform;r!==null&&(r.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Xne=Z(Ua).setParameterLength(1,4).setName("texture"),_t=(t=kT,e=null,r=null,i=null)=>{let s;return t&&t.isTextureNode===!0?(s=X(t.clone()),s.referenceNode=t.getSelf(),e!==null&&(s.uvNode=X(e)),r!==null&&(s.levelNode=X(r)),i!==null&&(s.biasNode=X(i))):s=Xne(t,e,r,i),s},Yne=(t=kT)=>_t(t),tr=(...t)=>_t(...t).setSampler(!1),Zne=t=>(t.isNode===!0?t:_t(t)).convert("sampler"),Jne=t=>(t.isNode===!0?t:_t(t)).convert("samplerComparison");class UT extends Fm{static get type(){return"BufferNode"}constructor(e,r,i=0){super(e,r),this.isBufferNode=!0,this.bufferType=r,this.bufferCount=i}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const km=(t,e,r)=>X(new UT(t,e,r));class Kne extends ju{static get type(){return"UniformArrayElementNode"}constructor(e,r){super(e,r),this.isArrayBufferElementNode=!0}generate(e){const r=super.generate(e),i=this.getNodeType(),s=this.node.getPaddedType();return e.format(r,s,i)}}class RI extends UT{static get type(){return"UniformArrayNode"}constructor(e,r=null){super(null),this.array=e,this.elementType=r===null?Mo(e[0]):r,this.paddedType=this.getPaddedType(),this.updateType=Tt.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let r="vec4";return e==="mat2"?r="mat2":/mat/.test(e)===!0?r="mat4":e.charAt(0)==="i"?r="ivec4":e.charAt(0)==="u"&&(r="uvec4"),r}update(){const{array:e,value:r}=this,i=this.elementType;if(i==="float"||i==="int"||i==="uint")for(let s=0;s<e.length;s++){const n=s*4;r[n]=e[s]}else if(i==="color")for(let s=0;s<e.length;s++){const n=s*4,a=e[s];r[n]=a.r,r[n+1]=a.g,r[n+2]=a.b||0}else if(i==="mat2")for(let s=0;s<e.length;s++){const n=s*4,a=e[s];r[n]=a.elements[0],r[n+1]=a.elements[1],r[n+2]=a.elements[2],r[n+3]=a.elements[3]}else if(i==="mat3")for(let s=0;s<e.length;s++){const n=s*16,a=e[s];r[n]=a.elements[0],r[n+1]=a.elements[1],r[n+2]=a.elements[2],r[n+4]=a.elements[3],r[n+5]=a.elements[4],r[n+6]=a.elements[5],r[n+8]=a.elements[6],r[n+9]=a.elements[7],r[n+10]=a.elements[8],r[n+15]=1}else if(i==="mat4")for(let s=0;s<e.length;s++){const n=s*16,a=e[s];for(let o=0;o<a.elements.length;o++)r[n+o]=a.elements[o]}else for(let s=0;s<e.length;s++){const n=s*4,a=e[s];r[n]=a.x,r[n+1]=a.y,r[n+2]=a.z||0,r[n+3]=a.w||0}}setup(e){const r=this.array.length,i=this.elementType;let s=Float32Array;const n=this.paddedType,a=e.getTypeLength(n);return i.charAt(0)==="i"&&(s=Int32Array),i.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(r*a),this.bufferCount=r,this.bufferType=n,super.setup(e)}element(e){return X(new Kne(this,X(e)))}}const dn=(t,e)=>X(new RI(t,e)),Qne=(t,e)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),X(new RI(t,e)));class eae extends Ae{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const My=Z(eae).setParameterLength(1),_y=Ie(0,"uint").label("u_cameraIndex").setGroup(vy("cameraIndex")).toVarying("v_cameraIndex"),xo=Ie("float").label("cameraNear").setGroup(Ye).onRenderUpdate(({camera:t})=>t.near),bo=Ie("float").label("cameraFar").setGroup(Ye).onRenderUpdate(({camera:t})=>t.far),Um=z(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const r=[];for(const s of t.cameras)r.push(s.projectionMatrix);e=dn(r).setGroup(Ye).label("cameraProjectionMatrices").element(t.isMultiViewCamera?My("gl_ViewID_OVR"):_y).toVar("cameraProjectionMatrix")}else e=Ie("mat4").label("cameraProjectionMatrix").setGroup(Ye).onRenderUpdate(({camera:r})=>r.projectionMatrix);return e}).once()(),tae=z(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const r=[];for(const s of t.cameras)r.push(s.projectionMatrixInverse);e=dn(r).setGroup(Ye).label("cameraProjectionMatricesInverse").element(t.isMultiViewCamera?My("gl_ViewID_OVR"):_y).toVar("cameraProjectionMatrixInverse")}else e=Ie("mat4").label("cameraProjectionMatrixInverse").setGroup(Ye).onRenderUpdate(({camera:r})=>r.projectionMatrixInverse);return e}).once()(),Zs=z(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const r=[];for(const s of t.cameras)r.push(s.matrixWorldInverse);e=dn(r).setGroup(Ye).label("cameraViewMatrices").element(t.isMultiViewCamera?My("gl_ViewID_OVR"):_y).toVar("cameraViewMatrix")}else e=Ie("mat4").label("cameraViewMatrix").setGroup(Ye).onRenderUpdate(({camera:r})=>r.matrixWorldInverse);return e}).once()(),rae=Ie("mat4").label("cameraWorldMatrix").setGroup(Ye).onRenderUpdate(({camera:t})=>t.matrixWorld),iae=Ie("mat3").label("cameraNormalMatrix").setGroup(Ye).onRenderUpdate(({camera:t})=>t.normalMatrix),sae=Ie(new $).label("cameraPosition").setGroup(Ye).onRenderUpdate(({camera:t},e)=>e.value.setFromMatrixPosition(t.matrixWorld)),tN=new qv;class Ke extends Ae{static get type(){return"Object3DNode"}constructor(e,r=null){super(),this.scope=e,this.object3d=r,this.updateType=Tt.OBJECT,this.uniformNode=new Fm(null)}getNodeType(){const e=this.scope;if(e===Ke.WORLD_MATRIX)return"mat4";if(e===Ke.POSITION||e===Ke.VIEW_POSITION||e===Ke.DIRECTION||e===Ke.SCALE)return"vec3";if(e===Ke.RADIUS)return"float"}update(e){const r=this.object3d,i=this.uniformNode,s=this.scope;if(s===Ke.WORLD_MATRIX)i.value=r.matrixWorld;else if(s===Ke.POSITION)i.value=i.value||new $,i.value.setFromMatrixPosition(r.matrixWorld);else if(s===Ke.SCALE)i.value=i.value||new $,i.value.setFromMatrixScale(r.matrixWorld);else if(s===Ke.DIRECTION)i.value=i.value||new $,r.getWorldDirection(i.value);else if(s===Ke.VIEW_POSITION){const n=e.camera;i.value=i.value||new $,i.value.setFromMatrixPosition(r.matrixWorld),i.value.applyMatrix4(n.matrixWorldInverse)}else if(s===Ke.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),tN.copy(n.boundingSphere).applyMatrix4(r.matrixWorld),i.value=tN.radius}}generate(e){const r=this.scope;return r===Ke.WORLD_MATRIX?this.uniformNode.nodeType="mat4":r===Ke.POSITION||r===Ke.VIEW_POSITION||r===Ke.DIRECTION||r===Ke.SCALE?this.uniformNode.nodeType="vec3":r===Ke.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ke.WORLD_MATRIX="worldMatrix";Ke.POSITION="position";Ke.SCALE="scale";Ke.VIEW_POSITION="viewPosition";Ke.DIRECTION="direction";Ke.RADIUS="radius";const nae=Z(Ke,Ke.DIRECTION).setParameterLength(1),aae=Z(Ke,Ke.WORLD_MATRIX).setParameterLength(1),PI=Z(Ke,Ke.POSITION).setParameterLength(1),oae=Z(Ke,Ke.SCALE).setParameterLength(1),lae=Z(Ke,Ke.VIEW_POSITION).setParameterLength(1),uae=Z(Ke,Ke.RADIUS).setParameterLength(1);class Ws extends Ke{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const hae=ue(Ws,Ws.DIRECTION),Ta=ue(Ws,Ws.WORLD_MATRIX),cae=ue(Ws,Ws.POSITION),dae=ue(Ws,Ws.SCALE),mae=ue(Ws,Ws.VIEW_POSITION),pae=ue(Ws,Ws.RADIUS),II=Ie(new qs).onObjectUpdate(({object:t},e)=>e.value.getNormalMatrix(t.matrixWorld)),fae=Ie(new Rt).onObjectUpdate(({object:t},e)=>e.value.copy(t.matrixWorld).invert()),Dm=z(t=>t.renderer.overrideNodes.modelViewMatrix||VI).once()().toVar("modelViewMatrix"),VI=Zs.mul(Ta),gae=z(t=>(t.context.isHighPrecisionModelViewMatrix=!0,Ie("mat4").onObjectUpdate(({object:e,camera:r})=>e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),yae=z(t=>{const e=t.context.isHighPrecisionModelViewMatrix;return Ie("mat3").onObjectUpdate(({object:r,camera:i})=>(e!==!0&&r.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,r.matrixWorld),r.normalMatrix.getNormalMatrix(r.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),DT=Bo("position","vec3"),cr=DT.toVarying("positionLocal"),wg=DT.toVarying("positionPrevious"),Nu=z(t=>Ta.mul(cr).xyz.toVarying(t.getNamespace("v_positionWorld")),"vec3").once("POSITION")(),OI=z(t=>cr.transformDirection(Ta).toVarying(t.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection"),"vec3").once("POSITION")(),ti=z(t=>t.context.setupPositionView().toVarying(t.getNamespace("v_positionView")),"vec3").once("POSITION")(),ms=ti.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class xae extends Ae{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:r,material:i}=e;return r.coordinateSystem===va&&i.side===oy?"false":e.getFrontFacing()}}const LI=ue(xae),$m=C(LI).mul(2).sub(1),$T=Bo("normal","vec3"),qi=z(t=>t.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),B(0,1,0)):$T,"vec3").once()().toVar("normalLocal"),FI=ti.dFdx().cross(ti.dFdy()).normalize().toVar("normalFlat"),Xn=z(t=>{let e;return t.material.flatShading===!0?e=FI:e=Ys(GT(qi),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),zI=z(t=>{let e=Xn.transformDirection(Zs);return t.material.flatShading!==!0&&(e=Ys(e,"v_normalWorld")),e},"vec3").once()().normalize().toVar("normalWorld"),Da=z(t=>{let e=t.context.setupNormal().context({getUV:null});return t.material.flatShading!==!0&&(e=e.mul($m)),e},"vec3").once()().toVar("transformedNormalView"),BI=Da.transformDirection(Zs).toVar("transformedNormalWorld"),bae=z(t=>{let e=t.context.setupClearcoatNormal().context({getUV:null});return t.material.flatShading!==!0&&(e=e.mul($m)),e},"vec3").once()().toVar("transformedClearcoatNormalView"),kI=z(([t,e=Ta])=>{const r=Gs(e),i=t.div(B(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(i).xyz}),GT=z(([t],e)=>{const r=e.renderer.overrideNodes.modelNormalViewMatrix;if(r!==null)return r.transformDirection(t);const i=II.mul(t);return Zs.transformDirection(i)}),rN=new $u,vx=new Rt,UI=Ie(0).onReference(({material:t})=>t).onObjectUpdate(({material:t})=>t.refractionRatio),vae=Ie(1).onReference(({material:t})=>t).onObjectUpdate(function({material:t,scene:e}){return t.envMap?t.envMapIntensity:e.environmentIntensity}),jT=Ie(new Rt).onReference(function(t){return t.material}).onObjectUpdate(function({material:t,scene:e}){const r=e.environment!==null&&t.envMap===null?e.environmentRotation:t.envMapRotation;return r?(rN.copy(r),vx.makeRotationFromEuler(rN)):vx.identity(),vx}),DI=ms.negate().reflect(Da),$I=ms.negate().refract(Da,UI),GI=DI.transformDirection(Zs).toVar("reflectVector"),jI=$I.transformDirection(Zs).toVar("reflectVector"),WI=new pK;class Tae extends Ua{static get type(){return"CubeTextureNode"}constructor(e,r=null,i=null,s=null){super(e,r,i,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===ag?GI:e.mapping===Ob?jI:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),B(0,0,0))}setUpdateMatrix(){}setupUV(e,r){const i=this.value;return(e.renderer.coordinateSystem===Ru||!i.isRenderTargetTexture)&&(r=B(r.x.negate(),r.yz)),jT.mul(r)}generateUV(e,r){return r.build(e,"vec3")}}const WT=Z(Tae).setParameterLength(1,4).setName("cubeTexture"),HT=(t=WI,e=null,r=null,i=null)=>{let s;return t&&t.isCubeTextureNode===!0?(s=X(t.clone()),s.referenceNode=t.getSelf(),e!==null&&(s.uvNode=X(e)),r!==null&&(s.levelNode=X(r)),i!==null&&(s.biasNode=X(i))):s=WT(t,e,r,i),s},wae=(t=WI)=>WT(t);class Sae extends ju{static get type(){return"ReferenceElementNode"}constructor(e,r){super(e,r),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const r=super.generate(e),i=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(r,i,s)}}class Ny extends Ae{static get type(){return"ReferenceNode"}constructor(e,r,i=null,s=null){super(),this.property=e,this.uniformType=r,this.object=i,this.count=s,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=Tt.OBJECT}element(e){return X(new Sae(this,X(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let r=null;this.count!==null?r=km(null,e,this.count):Array.isArray(this.getValueFromReference())?r=dn(null,e):e==="texture"?r=_t(null):e==="cubeTexture"?r=HT(null):r=Ie(null,e),this.group!==null&&r.setGroup(this.group),this.name!==null&&r.label(this.name),this.node=r.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:r}=this;let i=e[r[0]];for(let s=1;s<r.length;s++)i=i[r[s]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const Zt=(t,e,r)=>X(new Ny(t,e,r)),n1=(t,e,r,i)=>X(new Ny(t,e,i,r));class Mae extends Ny{static get type(){return"MaterialReferenceNode"}constructor(e,r,i=null){super(e,r,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const gl=(t,e,r=null)=>X(new Mae(t,e,r)),Ey=z(t=>(t.geometry.hasAttribute("tangent")===!1&&t.geometry.computeTangents(),Bo("tangent","vec4")))(),Gm=Ey.xyz.toVar("tangentLocal"),jm=Dm.mul(Oe(Gm,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),HI=jm.transformDirection(Zs).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),qT=jm.toVar("transformedTangentView"),_ae=qT.transformDirection(Zs).normalize().toVar("transformedTangentWorld"),Wm=z(([t,e],r)=>{let i=t.mul(Ey.w).xyz;return r.material.flatShading!==!0&&(i=Ys(i,e)),i}).once(),Nae=Wm($T.cross(Ey),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Eae=Wm(qi.cross(Gm),"v_bitangentLocal").normalize().toVar("bitangentLocal"),qI=Wm(Xn.cross(jm),"v_bitangentView").normalize().toVar("bitangentView"),Aae=Wm(zI.cross(HI),"v_bitangentWorld").normalize().toVar("bitangentWorld"),XI=Wm(Da.cross(qT),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Cae=XI.transformDirection(Zs).normalize().toVar("transformedBitangentWorld"),XT=Gs(jm,qI,Xn),YI=ms.mul(XT),Rae=(t,e)=>t.sub(YI.mul(e)),Pae=(()=>{let t=ac.cross(ms);return t=t.cross(ac).normalize(),t=ur(t,Da,tP.mul(Q5.oneMinus()).oneMinus().pow2().pow2()).normalize(),t})(),Iae=z(t=>{const{eye_pos:e,surf_norm:r,mapN:i,uv:s}=t,n=e.dFdx(),a=e.dFdy(),o=s.dFdx(),l=s.dFdy(),h=r,u=a.cross(h),c=h.cross(n),d=u.mul(o.x).add(c.mul(l.x)),m=u.mul(o.y).add(c.mul(l.y)),p=d.dot(d).max(m.dot(m)),f=$m.mul(p.inverseSqrt());return fr(d.mul(i.x,f),m.mul(i.y,f),h.mul(i.z)).normalize()});class Vae extends xr{static get type(){return"NormalMapNode"}constructor(e,r=null){super("vec3"),this.node=e,this.scaleNode=r,this.normalMapType=dM}setup(e){const{normalMapType:r,scaleNode:i}=this;let s=this.node.mul(2).sub(1);i!==null&&(s=B(s.xy.mul(i),s.z));let n=null;return r===AJ?n=GT(s):r===dM&&(e.hasGeometryAttribute("tangent")===!0?n=XT.mul(s).normalize():n=Iae({eye_pos:ti,surf_norm:Xn,mapN:s,uv:jt()})),n}}const a1=Z(Vae).setParameterLength(1,2),Oae=z(({textureNode:t,bumpScale:e})=>{const r=s=>t.cache().context({getUV:n=>s(n.uvNode||jt()),forceUVContext:!0}),i=C(r(s=>s));return ne(C(r(s=>s.add(s.dFdx()))).sub(i),C(r(s=>s.add(s.dFdy()))).sub(i)).mul(e)}),Lae=z(t=>{const{surf_pos:e,surf_norm:r,dHdxy:i}=t,s=e.dFdx().normalize(),n=e.dFdy().normalize(),a=r,o=n.cross(a),l=a.cross(s),h=s.dot(o).mul($m),u=h.sign().mul(i.x.mul(o).add(i.y.mul(l)));return h.abs().mul(r).sub(u).normalize()});class Fae extends xr{static get type(){return"BumpMapNode"}constructor(e,r=null){super("vec3"),this.textureNode=e,this.scaleNode=r}setup(){const e=this.scaleNode!==null?this.scaleNode:1,r=Oae({textureNode:this.textureNode,bumpScale:e});return Lae({surf_pos:ti,surf_norm:Xn,dHdxy:r})}}const ZI=Z(Fae).setParameterLength(1,2),iN=new Map;class j extends Ae{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,r){let i=iN.get(e);return i===void 0&&(i=gl(e,r),iN.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const r=e.context.material,i=this.scope;let s=null;if(i===j.COLOR){const n=r.color!==void 0?this.getColor(i):B();r.map&&r.map.isTexture===!0?s=n.mul(this.getTexture("map")):s=n}else if(i===j.OPACITY){const n=this.getFloat(i);r.alphaMap&&r.alphaMap.isTexture===!0?s=n.mul(this.getTexture("alpha")):s=n}else if(i===j.SPECULAR_STRENGTH)r.specularMap&&r.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=C(1);else if(i===j.SPECULAR_INTENSITY){const n=this.getFloat(i);r.specularIntensityMap&&r.specularIntensityMap.isTexture===!0?s=n.mul(this.getTexture(i).a):s=n}else if(i===j.SPECULAR_COLOR){const n=this.getColor(i);r.specularColorMap&&r.specularColorMap.isTexture===!0?s=n.mul(this.getTexture(i).rgb):s=n}else if(i===j.ROUGHNESS){const n=this.getFloat(i);r.roughnessMap&&r.roughnessMap.isTexture===!0?s=n.mul(this.getTexture(i).g):s=n}else if(i===j.METALNESS){const n=this.getFloat(i);r.metalnessMap&&r.metalnessMap.isTexture===!0?s=n.mul(this.getTexture(i).b):s=n}else if(i===j.EMISSIVE){const n=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(n);r.emissiveMap&&r.emissiveMap.isTexture===!0?s=a.mul(this.getTexture(i)):s=a}else if(i===j.NORMAL)r.normalMap?(s=a1(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=r.normalMapType):r.bumpMap?s=ZI(this.getTexture("bump").r,this.getFloat("bumpScale")):s=Xn;else if(i===j.CLEARCOAT){const n=this.getFloat(i);r.clearcoatMap&&r.clearcoatMap.isTexture===!0?s=n.mul(this.getTexture(i).r):s=n}else if(i===j.CLEARCOAT_ROUGHNESS){const n=this.getFloat(i);r.clearcoatRoughnessMap&&r.clearcoatRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(i).r):s=n}else if(i===j.CLEARCOAT_NORMAL)r.clearcoatNormalMap?s=a1(this.getTexture(i),this.getCache(i+"Scale","vec2")):s=Xn;else if(i===j.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));r.sheenColorMap&&r.sheenColorMap.isTexture===!0?s=n.mul(this.getTexture("sheenColor").rgb):s=n}else if(i===j.SHEEN_ROUGHNESS){const n=this.getFloat(i);r.sheenRoughnessMap&&r.sheenRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(i).a):s=n,s=s.clamp(.07,1)}else if(i===j.ANISOTROPY)if(r.anisotropyMap&&r.anisotropyMap.isTexture===!0){const n=this.getTexture(i);s=by(zh.x,zh.y,zh.y.negate(),zh.x).mul(n.rg.mul(2).sub(ne(1)).normalize().mul(n.b))}else s=zh;else if(i===j.IRIDESCENCE_THICKNESS){const n=Zt("1","float",r.iridescenceThicknessRange);if(r.iridescenceThicknessMap){const a=Zt("0","float",r.iridescenceThicknessRange);s=n.sub(a).mul(this.getTexture(i).g).add(a)}else s=n}else if(i===j.TRANSMISSION){const n=this.getFloat(i);r.transmissionMap?s=n.mul(this.getTexture(i).r):s=n}else if(i===j.THICKNESS){const n=this.getFloat(i);r.thicknessMap?s=n.mul(this.getTexture(i).g):s=n}else if(i===j.IOR)s=this.getFloat(i);else if(i===j.LIGHT_MAP)s=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===j.AO)s=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(i===j.LINE_DASH_OFFSET)s=r.dashOffset?this.getFloat(i):C(0);else{const n=this.getNodeType(e);s=this.getCache(i,n)}return s}}j.ALPHA_TEST="alphaTest";j.COLOR="color";j.OPACITY="opacity";j.SHININESS="shininess";j.SPECULAR="specular";j.SPECULAR_STRENGTH="specularStrength";j.SPECULAR_INTENSITY="specularIntensity";j.SPECULAR_COLOR="specularColor";j.REFLECTIVITY="reflectivity";j.ROUGHNESS="roughness";j.METALNESS="metalness";j.NORMAL="normal";j.CLEARCOAT="clearcoat";j.CLEARCOAT_ROUGHNESS="clearcoatRoughness";j.CLEARCOAT_NORMAL="clearcoatNormal";j.EMISSIVE="emissive";j.ROTATION="rotation";j.SHEEN="sheen";j.SHEEN_ROUGHNESS="sheenRoughness";j.ANISOTROPY="anisotropy";j.IRIDESCENCE="iridescence";j.IRIDESCENCE_IOR="iridescenceIOR";j.IRIDESCENCE_THICKNESS="iridescenceThickness";j.IOR="ior";j.TRANSMISSION="transmission";j.THICKNESS="thickness";j.ATTENUATION_DISTANCE="attenuationDistance";j.ATTENUATION_COLOR="attenuationColor";j.LINE_SCALE="scale";j.LINE_DASH_SIZE="dashSize";j.LINE_GAP_SIZE="gapSize";j.LINE_WIDTH="linewidth";j.LINE_DASH_OFFSET="dashOffset";j.POINT_SIZE="size";j.DISPERSION="dispersion";j.LIGHT_MAP="light";j.AO="ao";const JI=ue(j,j.ALPHA_TEST),KI=ue(j,j.COLOR),zae=ue(j,j.SHININESS),QI=ue(j,j.EMISSIVE),eV=ue(j,j.OPACITY),Bae=ue(j,j.SPECULAR),kae=ue(j,j.SPECULAR_INTENSITY),Uae=ue(j,j.SPECULAR_COLOR),Dae=ue(j,j.SPECULAR_STRENGTH),$ae=ue(j,j.REFLECTIVITY),Gae=ue(j,j.ROUGHNESS),jae=ue(j,j.METALNESS),tV=ue(j,j.NORMAL),Wae=ue(j,j.CLEARCOAT),Hae=ue(j,j.CLEARCOAT_ROUGHNESS),qae=ue(j,j.CLEARCOAT_NORMAL),Xae=ue(j,j.ROTATION),Yae=ue(j,j.SHEEN),Zae=ue(j,j.SHEEN_ROUGHNESS),Jae=ue(j,j.ANISOTROPY),Kae=ue(j,j.IRIDESCENCE),Qae=ue(j,j.IRIDESCENCE_IOR),eoe=ue(j,j.IRIDESCENCE_THICKNESS),toe=ue(j,j.TRANSMISSION),roe=ue(j,j.THICKNESS),ioe=ue(j,j.IOR),soe=ue(j,j.ATTENUATION_DISTANCE),noe=ue(j,j.ATTENUATION_COLOR),aoe=ue(j,j.LINE_SCALE),ooe=ue(j,j.LINE_DASH_SIZE),loe=ue(j,j.LINE_GAP_SIZE),uoe=ue(j,j.LINE_WIDTH),hoe=ue(j,j.LINE_DASH_OFFSET),coe=ue(j,j.POINT_SIZE),doe=ue(j,j.DISPERSION),rV=ue(j,j.LIGHT_MAP),iV=ue(j,j.AO),zh=Ie(new Jt).onReference(function(t){return t.material}).onRenderUpdate(function({material:t}){this.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation))}),sV=z(t=>t.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Ut extends Ae{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const r=this.getNodeType(e),i=this.scope;let s;if(i===Ut.VERTEX)s=e.getVertexIndex();else if(i===Ut.INSTANCE)s=e.getInstanceIndex();else if(i===Ut.DRAW)s=e.getDrawIndex();else if(i===Ut.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(i===Ut.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(i===Ut.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=s:n=Ys(this).build(e,r),n}}Ut.VERTEX="vertex";Ut.INSTANCE="instance";Ut.SUBGROUP="subgroup";Ut.INVOCATION_LOCAL="invocationLocal";Ut.INVOCATION_SUBGROUP="invocationSubgroup";Ut.DRAW="draw";const nV=ue(Ut,Ut.VERTEX),Po=ue(Ut,Ut.INSTANCE),moe=ue(Ut,Ut.SUBGROUP),poe=ue(Ut,Ut.INVOCATION_SUBGROUP),foe=ue(Ut,Ut.INVOCATION_LOCAL),aV=ue(Ut,Ut.DRAW);class oV extends Ae{static get type(){return"InstanceNode"}constructor(e,r,i=null){super("void"),this.count=e,this.instanceMatrix=r,this.instanceColor=i,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Tt.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:r,instanceMatrix:i,instanceColor:s}=this;let{instanceMatrixNode:n,instanceColorNode:a}=this;if(n===null){if(r<=1e3)n=km(i.array,"mat4",Math.max(r,1)).element(Po);else{const l=new wK(i.array,16,1);this.buffer=l;const h=i.usage===vd?s1:Tg,u=[h(l,"vec4",16,0),h(l,"vec4",16,4),h(l,"vec4",16,8),h(l,"vec4",16,12)];n=_u(...u)}this.instanceMatrixNode=n}if(s&&a===null){const l=new ic(s.array,3),h=s.usage===vd?s1:Tg;this.bufferColor=l,a=B(h(l,"vec3",3,0)),this.instanceColorNode=a}const o=n.mul(cr).xyz;if(cr.assign(o),e.hasGeometryAttribute("normal")){const l=kI(qi,n);qi.assign(l)}this.instanceColorNode!==null&&om("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==vd&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==vd&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const goe=Z(oV).setParameterLength(2,3);class yoe extends oV{static get type(){return"InstancedMeshNode"}constructor(e){const{count:r,instanceMatrix:i,instanceColor:s}=e;super(r,i,s),this.instancedMesh=e}}const lV=Z(yoe).setParameterLength(1);class xoe extends Ae{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Po:this.batchingIdNode=aV);const i=z(([p])=>{const f=P(Ro(tr(this.batchMesh._indirectTexture),0).x),g=P(p).mod(f),y=P(p).div(f);return tr(this.batchMesh._indirectTexture,kr(g,y)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),s=this.batchMesh._matricesTexture,n=P(Ro(tr(s),0).x),a=C(i).mul(4).toInt().toVar(),o=a.mod(n),l=a.div(n),h=_u(tr(s,kr(o,l)),tr(s,kr(o.add(1),l)),tr(s,kr(o.add(2),l)),tr(s,kr(o.add(3),l))),u=this.batchMesh._colorsTexture;if(u!==null){const f=z(([g])=>{const y=P(Ro(tr(u),0).x),T=g,M=T.mod(y),w=T.div(y);return tr(u,kr(M,w)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(i);om("vec3","vBatchColor").assign(f)}const c=Gs(h);cr.assign(h.mul(cr));const d=qi.div(B(c[0].dot(c[0]),c[1].dot(c[1]),c[2].dot(c[2]))),m=c.mul(d).xyz;qi.assign(m),e.hasGeometryAttribute("tangent")&&Gm.mulAssign(c)}}const uV=Z(xoe).setParameterLength(1);class boe extends ju{static get type(){return"StorageArrayElementNode"}constructor(e,r){super(e,r),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,r){const i=this.storageBufferNode.structTypeNode;return i?i.getMemberType(e,r):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,r){let i;const s=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),s!==!0){const n=this.getNodeType(e);i=e.format(i,n,r)}return i}}const voe=Z(boe).setParameterLength(2);class Toe extends UT{static get type(){return"StorageBufferNode"}constructor(e,r=null,i=0){let s,n=null;r&&r.isStruct?(s="struct",n=r.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):r===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=Sse(e.itemSize),i=e.count):s=r,super(e,s,i),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=Rn.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let r=e.globalCache.getData(this.value);return r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),r.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return voe(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Rn.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Bm(this.value),this._varying=Ys(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:r}=this.getAttributeData();return r.getNodeType(e)}getMemberType(e,r){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,r):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:r,varying:i}=this.getAttributeData(),s=i.build(e);return e.registerTransform(s,r),s}}const Eu=(t,e=null,r=0)=>X(new Toe(t,e,r)),woe=(t,e,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Eu(t,e,r).setPBO(!0)),sN=new WeakMap;class hV extends Ae{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Tt.OBJECT,this.skinIndexNode=Bo("skinIndex","uvec4"),this.skinWeightNode=Bo("skinWeight","vec4"),this.bindMatrixNode=Zt("bindMatrix","mat4"),this.bindMatrixInverseNode=Zt("bindMatrixInverse","mat4"),this.boneMatricesNode=n1("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=cr,this.toPositionNode=cr,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,r=this.positionNode){const{skinIndexNode:i,skinWeightNode:s,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),h=e.element(i.z),u=e.element(i.w),c=n.mul(r),d=fr(o.mul(s.x).mul(c),l.mul(s.y).mul(c),h.mul(s.z).mul(c),u.mul(s.w).mul(c));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,r=qi){const{skinIndexNode:i,skinWeightNode:s,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),h=e.element(i.z),u=e.element(i.w);let c=fr(s.x.mul(o),s.y.mul(l),s.z.mul(h),s.w.mul(u));return c=a.mul(c).mul(n),c.transformDirection(r).xyz}getPreviousSkinnedPosition(e){const r=e.object;return this.previousBoneMatricesNode===null&&(r.skeleton.previousBoneMatrices=new Float32Array(r.skeleton.boneMatrices),this.previousBoneMatricesNode=n1("skeleton.previousBoneMatrices","mat4",r.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,wg)}needsPreviousBoneMatrices(e){const r=e.renderer.getMRT();return r&&r.has("velocity")||O5(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&wg.assign(this.getPreviousSkinnedPosition(e));const r=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(r),e.hasGeometryAttribute("normal")){const i=this.getSkinnedNormal();qi.assign(i),e.hasGeometryAttribute("tangent")&&Gm.assign(i)}return r}generate(e,r){if(r!=="void")return super.generate(e,r)}update(e){const r=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;sN.get(r)!==e.frameId&&(sN.set(r,e.frameId),this.previousBoneMatricesNode!==null&&r.previousBoneMatrices.set(r.boneMatrices),r.update())}}const cV=t=>X(new hV(t)),Soe=(t,e=null)=>{const r=new hV(t);return r.positionNode=Eu(new ic(t.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Po).toVar(),r.skinIndexNode=Eu(new ic(new Uint32Array(t.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Po).toVar(),r.skinWeightNode=Eu(new ic(t.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Po).toVar(),r.bindMatrixNode=Ie(t.bindMatrix,"mat4"),r.bindMatrixInverseNode=Ie(t.bindMatrixInverse,"mat4"),r.boneMatricesNode=km(t.skeleton.boneMatrices,"mat4",t.skeleton.bones.length),r.toPositionNode=e,X(r)};class Moe extends Ae{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const r=e.getNodeProperties(this);if(r.stackNode!==void 0)return r;const i={};for(let a=0,o=this.params.length-1;a<o;a++){const l=this.params[a],h=l.isNode!==!0&&l.name||this.getVarName(a),u=l.isNode!==!0&&l.type||"int";i[h]=ka(h,u)}const s=e.addStack();r.returnsNode=this.params[this.params.length-1](i,e),r.stackNode=s;const n=this.params[0];return n.isNode!==!0&&typeof n.update=="function"&&(r.updateNode=z(this.params[0].update)(i)),e.removeStack(),r}getNodeType(e){const{returnsNode:r}=this.getProperties(e);return r?r.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const r=this.getProperties(e),i=this.params,s=r.stackNode;for(let o=0,l=i.length-1;o<l;o++){const h=i[o];let u=!1,c=null,d=null,m=null,p=null,f=null,g=null;h.isNode?h.getNodeType(e)==="bool"?(u=!0,p="bool",d=h.build(e,p)):(p="int",m=this.getVarName(o),c="0",d=h.build(e,p),f="<"):(p=h.type||"int",m=h.name||this.getVarName(o),c=h.start,d=h.end,f=h.condition,g=h.update,typeof c=="number"?c=e.generateConst(p,c):c&&c.isNode&&(c=c.build(e,p)),typeof d=="number"?d=e.generateConst(p,d):d&&d.isNode&&(d=d.build(e,p)),c!==void 0&&d===void 0?(c=c+" - 1",d="0",f=">="):d!==void 0&&c===void 0&&(c="0",f="<"),f===void 0&&(Number(c)>Number(d)?f=">=":f="<"));let y;if(u)y=`while ( ${d} )`;else{const T={start:c,end:d},M=T.start,w=T.end;let _;const S=()=>f.includes("<")?"+=":"-=";if(g!=null)switch(typeof g){case"function":_=e.flowStagesNode(r.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_=m+" "+S()+" "+e.generateConst(p,g);break;case"string":_=m+" "+g;break;default:g.isNode?_=m+" "+S()+" "+g.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),_="break /* invalid update */")}else p==="int"||p==="uint"?g=f.includes("<")?"++":"--":g=S()+" 1.",_=m+" "+g;const N=e.getVar(p,m)+" = "+M,A=m+" "+f+" "+w;y=`for ( ${N}; ${A}; ${_} )`}e.addFlowCode((o===0?`
475
+ `,r!==null?r(e,a):console.log(a),i}}const EI=(t,e=null)=>X(new jne(X(t),e));W("debug",EI);function Wne(t){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",t)}class AI extends Ae{static get type(){return"AttributeNode"}constructor(e,r=null){super(r),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let r=this.nodeType;if(r===null){const i=this.getAttributeName(e);if(e.hasGeometryAttribute(i)){const s=e.geometry.getAttribute(i);r=e.getTypeFromAttribute(s)}else r="float"}return r}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const r=this.getAttributeName(e),i=this.getNodeType(e);if(e.hasGeometryAttribute(r)===!0){const n=e.geometry.getAttribute(r),a=e.getTypeFromAttribute(n),o=e.getAttribute(r,a);return e.shaderStage==="vertex"?e.format(o.name,a,i):Ys(this).build(e,i)}else return console.warn(`AttributeNode: Vertex attribute "${r}" not found on geometry.`),e.generateConst(i)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Bo=(t,e=null)=>X(new AI(t,e)),jt=(t=0)=>Bo("uv"+(t>0?t:""),"vec2");class Hne extends Ae{static get type(){return"TextureSizeNode"}constructor(e,r=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=r}generate(e,r){const i=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${i}, ${s} )`,this.getNodeType(e),r)}}const Ro=Z(Hne).setParameterLength(1,2);class qne extends Fm{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Tt.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,r=e.images,i=r&&r.length>0?r[0]&&r[0].image||r[0]:e.image;if(i&&i.width!==void 0){const{width:s,height:n}=i;this.value=Math.log2(Math.max(s,n))}}}const CI=Z(qne).setParameterLength(1),kT=new vi;class Ua extends Fm{static get type(){return"TextureNode"}constructor(e=kT,r=null,i=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=r,this.levelNode=i,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Tt.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(r===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===n3?"uvec4":this.value.type===NJ?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return jt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=Pe(this.value.matrix)),this._matrixUniform.mul(B(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Tt.OBJECT:Tt.NONE,this}setupUV(e,r){const i=this.value;return e.isFlipY()&&(i.image instanceof ImageBitmap&&i.flipY===!0||i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0||i.isDepthTexture===!0)&&(this.sampler?r=r.flipY():r=r.setY(P(Ro(this,this.levelNode).y).sub(r.y).sub(1))),r}setup(e){const r=e.getNodeProperties(this);r.referenceNode=this.referenceNode;const i=this.value;if(!i||i.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let s=this.uvNode;(s===null||e.context.forceUVContext===!0)&&e.context.getUV&&(s=e.context.getUV(this,e)),s||(s=this.getDefaultUV()),this.updateMatrix===!0&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),r.uvNode=s,r.levelNode=n,r.biasNode=this.biasNode,r.compareNode=this.compareNode,r.gradNode=this.gradNode,r.depthNode=this.depthNode}generateUV(e,r){return r.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,r,i,s,n,a,o,l){const h=this.value;let u;return s?u=e.generateTextureLevel(h,r,i,s,a):n?u=e.generateTextureBias(h,r,i,n,a):l?u=e.generateTextureGrad(h,r,i,l,a):o?u=e.generateTextureCompare(h,r,i,o,a):this.sampler===!1?u=e.generateTextureLoad(h,r,i,a):u=e.generateTexture(h,r,i,a),u}generate(e,r){const i=this.value,s=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(r))return n+"_sampler";if(e.isReference(r))return n;{const a=e.getDataFromNode(this);let o=a.propertyName;if(o===void 0){const{uvNode:u,levelNode:c,biasNode:d,compareNode:m,depthNode:p,gradNode:f}=s,g=this.generateUV(e,u),y=c?c.build(e,"float"):null,T=d?d.build(e,"float"):null,M=p?p.build(e,"int"):null,w=m?m.build(e,"float"):null,_=f?[f[0].build(e,"vec2"),f[1].build(e,"vec2")]:null,S=e.getVarFromNode(this);o=e.getPropertyName(S);const N=this.generateSnippet(e,n,g,y,T,M,w,_);e.addLineFlowCode(`${o} = ${N}`,this),a.snippet=N,a.propertyName=o}let l=o;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(i)&&(l=BT(ka(l,h),i.colorSpace).setup(e).build(e,h)),e.format(l,h,r)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const r=this.clone();return r.uvNode=X(e),r.referenceNode=this.getSelf(),X(r)}blur(e){const r=this.clone();r.biasNode=X(e).mul(CI(r)),r.referenceNode=this.getSelf();const i=r.value;return r.generateMipmaps===!1&&(i&&i.generateMipmaps===!1||i.minFilter===$s||i.magFilter===$s)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),r.biasNode=null),X(r)}level(e){const r=this.clone();return r.levelNode=X(e),r.referenceNode=this.getSelf(),X(r)}size(e){return Ro(this,e)}bias(e){const r=this.clone();return r.biasNode=X(e),r.referenceNode=this.getSelf(),X(r)}compare(e){const r=this.clone();return r.compareNode=X(e),r.referenceNode=this.getSelf(),X(r)}grad(e,r){const i=this.clone();return i.gradNode=[X(e),X(r)],i.referenceNode=this.getSelf(),X(i)}depth(e){const r=this.clone();return r.depthNode=X(e),r.referenceNode=this.getSelf(),X(r)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,r=this._matrixUniform;r!==null&&(r.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}const Xne=Z(Ua).setParameterLength(1,4).setName("texture"),_t=(t=kT,e=null,r=null,i=null)=>{let s;return t&&t.isTextureNode===!0?(s=X(t.clone()),s.referenceNode=t.getSelf(),e!==null&&(s.uvNode=X(e)),r!==null&&(s.levelNode=X(r)),i!==null&&(s.biasNode=X(i))):s=Xne(t,e,r,i),s},Yne=(t=kT)=>_t(t),tr=(...t)=>_t(...t).setSampler(!1),Zne=t=>(t.isNode===!0?t:_t(t)).convert("sampler"),Jne=t=>(t.isNode===!0?t:_t(t)).convert("samplerComparison");class UT extends Fm{static get type(){return"BufferNode"}constructor(e,r,i=0){super(e,r),this.isBufferNode=!0,this.bufferType=r,this.bufferCount=i}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const km=(t,e,r)=>X(new UT(t,e,r));class Kne extends ju{static get type(){return"UniformArrayElementNode"}constructor(e,r){super(e,r),this.isArrayBufferElementNode=!0}generate(e){const r=super.generate(e),i=this.getNodeType(),s=this.node.getPaddedType();return e.format(r,s,i)}}class RI extends UT{static get type(){return"UniformArrayNode"}constructor(e,r=null){super(null),this.array=e,this.elementType=r===null?Mo(e[0]):r,this.paddedType=this.getPaddedType(),this.updateType=Tt.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let r="vec4";return e==="mat2"?r="mat2":/mat/.test(e)===!0?r="mat4":e.charAt(0)==="i"?r="ivec4":e.charAt(0)==="u"&&(r="uvec4"),r}update(){const{array:e,value:r}=this,i=this.elementType;if(i==="float"||i==="int"||i==="uint")for(let s=0;s<e.length;s++){const n=s*4;r[n]=e[s]}else if(i==="color")for(let s=0;s<e.length;s++){const n=s*4,a=e[s];r[n]=a.r,r[n+1]=a.g,r[n+2]=a.b||0}else if(i==="mat2")for(let s=0;s<e.length;s++){const n=s*4,a=e[s];r[n]=a.elements[0],r[n+1]=a.elements[1],r[n+2]=a.elements[2],r[n+3]=a.elements[3]}else if(i==="mat3")for(let s=0;s<e.length;s++){const n=s*16,a=e[s];r[n]=a.elements[0],r[n+1]=a.elements[1],r[n+2]=a.elements[2],r[n+4]=a.elements[3],r[n+5]=a.elements[4],r[n+6]=a.elements[5],r[n+8]=a.elements[6],r[n+9]=a.elements[7],r[n+10]=a.elements[8],r[n+15]=1}else if(i==="mat4")for(let s=0;s<e.length;s++){const n=s*16,a=e[s];for(let o=0;o<a.elements.length;o++)r[n+o]=a.elements[o]}else for(let s=0;s<e.length;s++){const n=s*4,a=e[s];r[n]=a.x,r[n+1]=a.y,r[n+2]=a.z||0,r[n+3]=a.w||0}}setup(e){const r=this.array.length,i=this.elementType;let s=Float32Array;const n=this.paddedType,a=e.getTypeLength(n);return i.charAt(0)==="i"&&(s=Int32Array),i.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(r*a),this.bufferCount=r,this.bufferType=n,super.setup(e)}element(e){return X(new Kne(this,X(e)))}}const dn=(t,e)=>X(new RI(t,e)),Qne=(t,e)=>(console.warn("THREE.TSL: uniforms() has been renamed to uniformArray()."),X(new RI(t,e)));class eae extends Ae{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const My=Z(eae).setParameterLength(1),_y=Pe(0,"uint").label("u_cameraIndex").setGroup(vy("cameraIndex")).toVarying("v_cameraIndex"),xo=Pe("float").label("cameraNear").setGroup(Ye).onRenderUpdate(({camera:t})=>t.near),bo=Pe("float").label("cameraFar").setGroup(Ye).onRenderUpdate(({camera:t})=>t.far),Um=z(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const r=[];for(const s of t.cameras)r.push(s.projectionMatrix);e=dn(r).setGroup(Ye).label("cameraProjectionMatrices").element(t.isMultiViewCamera?My("gl_ViewID_OVR"):_y).toVar("cameraProjectionMatrix")}else e=Pe("mat4").label("cameraProjectionMatrix").setGroup(Ye).onRenderUpdate(({camera:r})=>r.projectionMatrix);return e}).once()(),tae=z(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const r=[];for(const s of t.cameras)r.push(s.projectionMatrixInverse);e=dn(r).setGroup(Ye).label("cameraProjectionMatricesInverse").element(t.isMultiViewCamera?My("gl_ViewID_OVR"):_y).toVar("cameraProjectionMatrixInverse")}else e=Pe("mat4").label("cameraProjectionMatrixInverse").setGroup(Ye).onRenderUpdate(({camera:r})=>r.projectionMatrixInverse);return e}).once()(),Zs=z(({camera:t})=>{let e;if(t.isArrayCamera&&t.cameras.length>0){const r=[];for(const s of t.cameras)r.push(s.matrixWorldInverse);e=dn(r).setGroup(Ye).label("cameraViewMatrices").element(t.isMultiViewCamera?My("gl_ViewID_OVR"):_y).toVar("cameraViewMatrix")}else e=Pe("mat4").label("cameraViewMatrix").setGroup(Ye).onRenderUpdate(({camera:r})=>r.matrixWorldInverse);return e}).once()(),rae=Pe("mat4").label("cameraWorldMatrix").setGroup(Ye).onRenderUpdate(({camera:t})=>t.matrixWorld),iae=Pe("mat3").label("cameraNormalMatrix").setGroup(Ye).onRenderUpdate(({camera:t})=>t.normalMatrix),sae=Pe(new $).label("cameraPosition").setGroup(Ye).onRenderUpdate(({camera:t},e)=>e.value.setFromMatrixPosition(t.matrixWorld)),tN=new qv;class Ke extends Ae{static get type(){return"Object3DNode"}constructor(e,r=null){super(),this.scope=e,this.object3d=r,this.updateType=Tt.OBJECT,this.uniformNode=new Fm(null)}getNodeType(){const e=this.scope;if(e===Ke.WORLD_MATRIX)return"mat4";if(e===Ke.POSITION||e===Ke.VIEW_POSITION||e===Ke.DIRECTION||e===Ke.SCALE)return"vec3";if(e===Ke.RADIUS)return"float"}update(e){const r=this.object3d,i=this.uniformNode,s=this.scope;if(s===Ke.WORLD_MATRIX)i.value=r.matrixWorld;else if(s===Ke.POSITION)i.value=i.value||new $,i.value.setFromMatrixPosition(r.matrixWorld);else if(s===Ke.SCALE)i.value=i.value||new $,i.value.setFromMatrixScale(r.matrixWorld);else if(s===Ke.DIRECTION)i.value=i.value||new $,r.getWorldDirection(i.value);else if(s===Ke.VIEW_POSITION){const n=e.camera;i.value=i.value||new $,i.value.setFromMatrixPosition(r.matrixWorld),i.value.applyMatrix4(n.matrixWorldInverse)}else if(s===Ke.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),tN.copy(n.boundingSphere).applyMatrix4(r.matrixWorld),i.value=tN.radius}}generate(e){const r=this.scope;return r===Ke.WORLD_MATRIX?this.uniformNode.nodeType="mat4":r===Ke.POSITION||r===Ke.VIEW_POSITION||r===Ke.DIRECTION||r===Ke.SCALE?this.uniformNode.nodeType="vec3":r===Ke.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ke.WORLD_MATRIX="worldMatrix";Ke.POSITION="position";Ke.SCALE="scale";Ke.VIEW_POSITION="viewPosition";Ke.DIRECTION="direction";Ke.RADIUS="radius";const nae=Z(Ke,Ke.DIRECTION).setParameterLength(1),aae=Z(Ke,Ke.WORLD_MATRIX).setParameterLength(1),PI=Z(Ke,Ke.POSITION).setParameterLength(1),oae=Z(Ke,Ke.SCALE).setParameterLength(1),lae=Z(Ke,Ke.VIEW_POSITION).setParameterLength(1),uae=Z(Ke,Ke.RADIUS).setParameterLength(1);class Ws extends Ke{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const hae=ue(Ws,Ws.DIRECTION),Ta=ue(Ws,Ws.WORLD_MATRIX),cae=ue(Ws,Ws.POSITION),dae=ue(Ws,Ws.SCALE),mae=ue(Ws,Ws.VIEW_POSITION),pae=ue(Ws,Ws.RADIUS),II=Pe(new qs).onObjectUpdate(({object:t},e)=>e.value.getNormalMatrix(t.matrixWorld)),fae=Pe(new Rt).onObjectUpdate(({object:t},e)=>e.value.copy(t.matrixWorld).invert()),Dm=z(t=>t.renderer.overrideNodes.modelViewMatrix||VI).once()().toVar("modelViewMatrix"),VI=Zs.mul(Ta),gae=z(t=>(t.context.isHighPrecisionModelViewMatrix=!0,Pe("mat4").onObjectUpdate(({object:e,camera:r})=>e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),yae=z(t=>{const e=t.context.isHighPrecisionModelViewMatrix;return Pe("mat3").onObjectUpdate(({object:r,camera:i})=>(e!==!0&&r.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,r.matrixWorld),r.normalMatrix.getNormalMatrix(r.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),DT=Bo("position","vec3"),cr=DT.toVarying("positionLocal"),wg=DT.toVarying("positionPrevious"),Nu=z(t=>Ta.mul(cr).xyz.toVarying(t.getNamespace("v_positionWorld")),"vec3").once("POSITION")(),OI=z(t=>cr.transformDirection(Ta).toVarying(t.getNamespace("v_positionWorldDirection")).normalize().toVar("positionWorldDirection"),"vec3").once("POSITION")(),ti=z(t=>t.context.setupPositionView().toVarying(t.getNamespace("v_positionView")),"vec3").once("POSITION")(),ms=ti.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class xae extends Ae{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:r,material:i}=e;return r.coordinateSystem===va&&i.side===oy?"false":e.getFrontFacing()}}const LI=ue(xae),$m=C(LI).mul(2).sub(1),$T=Bo("normal","vec3"),qi=z(t=>t.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),B(0,1,0)):$T,"vec3").once()().toVar("normalLocal"),FI=ti.dFdx().cross(ti.dFdy()).normalize().toVar("normalFlat"),Xn=z(t=>{let e;return t.material.flatShading===!0?e=FI:e=Ys(GT(qi),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),zI=z(t=>{let e=Xn.transformDirection(Zs);return t.material.flatShading!==!0&&(e=Ys(e,"v_normalWorld")),e},"vec3").once()().normalize().toVar("normalWorld"),Da=z(t=>{let e=t.context.setupNormal().context({getUV:null});return t.material.flatShading!==!0&&(e=e.mul($m)),e},"vec3").once()().toVar("transformedNormalView"),BI=Da.transformDirection(Zs).toVar("transformedNormalWorld"),bae=z(t=>{let e=t.context.setupClearcoatNormal().context({getUV:null});return t.material.flatShading!==!0&&(e=e.mul($m)),e},"vec3").once()().toVar("transformedClearcoatNormalView"),kI=z(([t,e=Ta])=>{const r=Gs(e),i=t.div(B(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(i).xyz}),GT=z(([t],e)=>{const r=e.renderer.overrideNodes.modelNormalViewMatrix;if(r!==null)return r.transformDirection(t);const i=II.mul(t);return Zs.transformDirection(i)}),rN=new $u,vx=new Rt,UI=Pe(0).onReference(({material:t})=>t).onObjectUpdate(({material:t})=>t.refractionRatio),vae=Pe(1).onReference(({material:t})=>t).onObjectUpdate(function({material:t,scene:e}){return t.envMap?t.envMapIntensity:e.environmentIntensity}),jT=Pe(new Rt).onReference(function(t){return t.material}).onObjectUpdate(function({material:t,scene:e}){const r=e.environment!==null&&t.envMap===null?e.environmentRotation:t.envMapRotation;return r?(rN.copy(r),vx.makeRotationFromEuler(rN)):vx.identity(),vx}),DI=ms.negate().reflect(Da),$I=ms.negate().refract(Da,UI),GI=DI.transformDirection(Zs).toVar("reflectVector"),jI=$I.transformDirection(Zs).toVar("reflectVector"),WI=new pK;class Tae extends Ua{static get type(){return"CubeTextureNode"}constructor(e,r=null,i=null,s=null){super(e,r,i,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===ag?GI:e.mapping===Ob?jI:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),B(0,0,0))}setUpdateMatrix(){}setupUV(e,r){const i=this.value;return(e.renderer.coordinateSystem===Ru||!i.isRenderTargetTexture)&&(r=B(r.x.negate(),r.yz)),jT.mul(r)}generateUV(e,r){return r.build(e,"vec3")}}const WT=Z(Tae).setParameterLength(1,4).setName("cubeTexture"),HT=(t=WI,e=null,r=null,i=null)=>{let s;return t&&t.isCubeTextureNode===!0?(s=X(t.clone()),s.referenceNode=t.getSelf(),e!==null&&(s.uvNode=X(e)),r!==null&&(s.levelNode=X(r)),i!==null&&(s.biasNode=X(i))):s=WT(t,e,r,i),s},wae=(t=WI)=>WT(t);class Sae extends ju{static get type(){return"ReferenceElementNode"}constructor(e,r){super(e,r),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const r=super.generate(e),i=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(r,i,s)}}class Ny extends Ae{static get type(){return"ReferenceNode"}constructor(e,r,i=null,s=null){super(),this.property=e,this.uniformType=r,this.object=i,this.count=s,this.properties=e.split("."),this.reference=i,this.node=null,this.group=null,this.name=null,this.updateType=Tt.OBJECT}element(e){return X(new Sae(this,X(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let r=null;this.count!==null?r=km(null,e,this.count):Array.isArray(this.getValueFromReference())?r=dn(null,e):e==="texture"?r=_t(null):e==="cubeTexture"?r=HT(null):r=Pe(null,e),this.group!==null&&r.setGroup(this.group),this.name!==null&&r.label(this.name),this.node=r.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:r}=this;let i=e[r[0]];for(let s=1;s<r.length;s++)i=i[r[s]];return i}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const Zt=(t,e,r)=>X(new Ny(t,e,r)),n1=(t,e,r,i)=>X(new Ny(t,e,i,r));class Mae extends Ny{static get type(){return"MaterialReferenceNode"}constructor(e,r,i=null){super(e,r,i),this.material=i,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const gl=(t,e,r=null)=>X(new Mae(t,e,r)),Ey=z(t=>(t.geometry.hasAttribute("tangent")===!1&&t.geometry.computeTangents(),Bo("tangent","vec4")))(),Gm=Ey.xyz.toVar("tangentLocal"),jm=Dm.mul(Oe(Gm,0)).xyz.toVarying("v_tangentView").normalize().toVar("tangentView"),HI=jm.transformDirection(Zs).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),qT=jm.toVar("transformedTangentView"),_ae=qT.transformDirection(Zs).normalize().toVar("transformedTangentWorld"),Wm=z(([t,e],r)=>{let i=t.mul(Ey.w).xyz;return r.material.flatShading!==!0&&(i=Ys(i,e)),i}).once(),Nae=Wm($T.cross(Ey),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Eae=Wm(qi.cross(Gm),"v_bitangentLocal").normalize().toVar("bitangentLocal"),qI=Wm(Xn.cross(jm),"v_bitangentView").normalize().toVar("bitangentView"),Aae=Wm(zI.cross(HI),"v_bitangentWorld").normalize().toVar("bitangentWorld"),XI=Wm(Da.cross(qT),"v_transformedBitangentView").normalize().toVar("transformedBitangentView"),Cae=XI.transformDirection(Zs).normalize().toVar("transformedBitangentWorld"),XT=Gs(jm,qI,Xn),YI=ms.mul(XT),Rae=(t,e)=>t.sub(YI.mul(e)),Pae=(()=>{let t=ac.cross(ms);return t=t.cross(ac).normalize(),t=ur(t,Da,tP.mul(Q5.oneMinus()).oneMinus().pow2().pow2()).normalize(),t})(),Iae=z(t=>{const{eye_pos:e,surf_norm:r,mapN:i,uv:s}=t,n=e.dFdx(),a=e.dFdy(),o=s.dFdx(),l=s.dFdy(),h=r,u=a.cross(h),c=h.cross(n),d=u.mul(o.x).add(c.mul(l.x)),m=u.mul(o.y).add(c.mul(l.y)),p=d.dot(d).max(m.dot(m)),f=$m.mul(p.inverseSqrt());return fr(d.mul(i.x,f),m.mul(i.y,f),h.mul(i.z)).normalize()});class Vae extends xr{static get type(){return"NormalMapNode"}constructor(e,r=null){super("vec3"),this.node=e,this.scaleNode=r,this.normalMapType=dM}setup(e){const{normalMapType:r,scaleNode:i}=this;let s=this.node.mul(2).sub(1);i!==null&&(s=B(s.xy.mul(i),s.z));let n=null;return r===AJ?n=GT(s):r===dM&&(e.hasGeometryAttribute("tangent")===!0?n=XT.mul(s).normalize():n=Iae({eye_pos:ti,surf_norm:Xn,mapN:s,uv:jt()})),n}}const a1=Z(Vae).setParameterLength(1,2),Oae=z(({textureNode:t,bumpScale:e})=>{const r=s=>t.cache().context({getUV:n=>s(n.uvNode||jt()),forceUVContext:!0}),i=C(r(s=>s));return ne(C(r(s=>s.add(s.dFdx()))).sub(i),C(r(s=>s.add(s.dFdy()))).sub(i)).mul(e)}),Lae=z(t=>{const{surf_pos:e,surf_norm:r,dHdxy:i}=t,s=e.dFdx().normalize(),n=e.dFdy().normalize(),a=r,o=n.cross(a),l=a.cross(s),h=s.dot(o).mul($m),u=h.sign().mul(i.x.mul(o).add(i.y.mul(l)));return h.abs().mul(r).sub(u).normalize()});class Fae extends xr{static get type(){return"BumpMapNode"}constructor(e,r=null){super("vec3"),this.textureNode=e,this.scaleNode=r}setup(){const e=this.scaleNode!==null?this.scaleNode:1,r=Oae({textureNode:this.textureNode,bumpScale:e});return Lae({surf_pos:ti,surf_norm:Xn,dHdxy:r})}}const ZI=Z(Fae).setParameterLength(1,2),iN=new Map;class j extends Ae{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,r){let i=iN.get(e);return i===void 0&&(i=gl(e,r),iN.set(e,i)),i}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const r=e.context.material,i=this.scope;let s=null;if(i===j.COLOR){const n=r.color!==void 0?this.getColor(i):B();r.map&&r.map.isTexture===!0?s=n.mul(this.getTexture("map")):s=n}else if(i===j.OPACITY){const n=this.getFloat(i);r.alphaMap&&r.alphaMap.isTexture===!0?s=n.mul(this.getTexture("alpha")):s=n}else if(i===j.SPECULAR_STRENGTH)r.specularMap&&r.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=C(1);else if(i===j.SPECULAR_INTENSITY){const n=this.getFloat(i);r.specularIntensityMap&&r.specularIntensityMap.isTexture===!0?s=n.mul(this.getTexture(i).a):s=n}else if(i===j.SPECULAR_COLOR){const n=this.getColor(i);r.specularColorMap&&r.specularColorMap.isTexture===!0?s=n.mul(this.getTexture(i).rgb):s=n}else if(i===j.ROUGHNESS){const n=this.getFloat(i);r.roughnessMap&&r.roughnessMap.isTexture===!0?s=n.mul(this.getTexture(i).g):s=n}else if(i===j.METALNESS){const n=this.getFloat(i);r.metalnessMap&&r.metalnessMap.isTexture===!0?s=n.mul(this.getTexture(i).b):s=n}else if(i===j.EMISSIVE){const n=this.getFloat("emissiveIntensity"),a=this.getColor(i).mul(n);r.emissiveMap&&r.emissiveMap.isTexture===!0?s=a.mul(this.getTexture(i)):s=a}else if(i===j.NORMAL)r.normalMap?(s=a1(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=r.normalMapType):r.bumpMap?s=ZI(this.getTexture("bump").r,this.getFloat("bumpScale")):s=Xn;else if(i===j.CLEARCOAT){const n=this.getFloat(i);r.clearcoatMap&&r.clearcoatMap.isTexture===!0?s=n.mul(this.getTexture(i).r):s=n}else if(i===j.CLEARCOAT_ROUGHNESS){const n=this.getFloat(i);r.clearcoatRoughnessMap&&r.clearcoatRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(i).r):s=n}else if(i===j.CLEARCOAT_NORMAL)r.clearcoatNormalMap?s=a1(this.getTexture(i),this.getCache(i+"Scale","vec2")):s=Xn;else if(i===j.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));r.sheenColorMap&&r.sheenColorMap.isTexture===!0?s=n.mul(this.getTexture("sheenColor").rgb):s=n}else if(i===j.SHEEN_ROUGHNESS){const n=this.getFloat(i);r.sheenRoughnessMap&&r.sheenRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(i).a):s=n,s=s.clamp(.07,1)}else if(i===j.ANISOTROPY)if(r.anisotropyMap&&r.anisotropyMap.isTexture===!0){const n=this.getTexture(i);s=by(zh.x,zh.y,zh.y.negate(),zh.x).mul(n.rg.mul(2).sub(ne(1)).normalize().mul(n.b))}else s=zh;else if(i===j.IRIDESCENCE_THICKNESS){const n=Zt("1","float",r.iridescenceThicknessRange);if(r.iridescenceThicknessMap){const a=Zt("0","float",r.iridescenceThicknessRange);s=n.sub(a).mul(this.getTexture(i).g).add(a)}else s=n}else if(i===j.TRANSMISSION){const n=this.getFloat(i);r.transmissionMap?s=n.mul(this.getTexture(i).r):s=n}else if(i===j.THICKNESS){const n=this.getFloat(i);r.thicknessMap?s=n.mul(this.getTexture(i).g):s=n}else if(i===j.IOR)s=this.getFloat(i);else if(i===j.LIGHT_MAP)s=this.getTexture(i).rgb.mul(this.getFloat("lightMapIntensity"));else if(i===j.AO)s=this.getTexture(i).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(i===j.LINE_DASH_OFFSET)s=r.dashOffset?this.getFloat(i):C(0);else{const n=this.getNodeType(e);s=this.getCache(i,n)}return s}}j.ALPHA_TEST="alphaTest";j.COLOR="color";j.OPACITY="opacity";j.SHININESS="shininess";j.SPECULAR="specular";j.SPECULAR_STRENGTH="specularStrength";j.SPECULAR_INTENSITY="specularIntensity";j.SPECULAR_COLOR="specularColor";j.REFLECTIVITY="reflectivity";j.ROUGHNESS="roughness";j.METALNESS="metalness";j.NORMAL="normal";j.CLEARCOAT="clearcoat";j.CLEARCOAT_ROUGHNESS="clearcoatRoughness";j.CLEARCOAT_NORMAL="clearcoatNormal";j.EMISSIVE="emissive";j.ROTATION="rotation";j.SHEEN="sheen";j.SHEEN_ROUGHNESS="sheenRoughness";j.ANISOTROPY="anisotropy";j.IRIDESCENCE="iridescence";j.IRIDESCENCE_IOR="iridescenceIOR";j.IRIDESCENCE_THICKNESS="iridescenceThickness";j.IOR="ior";j.TRANSMISSION="transmission";j.THICKNESS="thickness";j.ATTENUATION_DISTANCE="attenuationDistance";j.ATTENUATION_COLOR="attenuationColor";j.LINE_SCALE="scale";j.LINE_DASH_SIZE="dashSize";j.LINE_GAP_SIZE="gapSize";j.LINE_WIDTH="linewidth";j.LINE_DASH_OFFSET="dashOffset";j.POINT_SIZE="size";j.DISPERSION="dispersion";j.LIGHT_MAP="light";j.AO="ao";const JI=ue(j,j.ALPHA_TEST),KI=ue(j,j.COLOR),zae=ue(j,j.SHININESS),QI=ue(j,j.EMISSIVE),eV=ue(j,j.OPACITY),Bae=ue(j,j.SPECULAR),kae=ue(j,j.SPECULAR_INTENSITY),Uae=ue(j,j.SPECULAR_COLOR),Dae=ue(j,j.SPECULAR_STRENGTH),$ae=ue(j,j.REFLECTIVITY),Gae=ue(j,j.ROUGHNESS),jae=ue(j,j.METALNESS),tV=ue(j,j.NORMAL),Wae=ue(j,j.CLEARCOAT),Hae=ue(j,j.CLEARCOAT_ROUGHNESS),qae=ue(j,j.CLEARCOAT_NORMAL),Xae=ue(j,j.ROTATION),Yae=ue(j,j.SHEEN),Zae=ue(j,j.SHEEN_ROUGHNESS),Jae=ue(j,j.ANISOTROPY),Kae=ue(j,j.IRIDESCENCE),Qae=ue(j,j.IRIDESCENCE_IOR),eoe=ue(j,j.IRIDESCENCE_THICKNESS),toe=ue(j,j.TRANSMISSION),roe=ue(j,j.THICKNESS),ioe=ue(j,j.IOR),soe=ue(j,j.ATTENUATION_DISTANCE),noe=ue(j,j.ATTENUATION_COLOR),aoe=ue(j,j.LINE_SCALE),ooe=ue(j,j.LINE_DASH_SIZE),loe=ue(j,j.LINE_GAP_SIZE),uoe=ue(j,j.LINE_WIDTH),hoe=ue(j,j.LINE_DASH_OFFSET),coe=ue(j,j.POINT_SIZE),doe=ue(j,j.DISPERSION),rV=ue(j,j.LIGHT_MAP),iV=ue(j,j.AO),zh=Pe(new Jt).onReference(function(t){return t.material}).onRenderUpdate(function({material:t}){this.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation))}),sV=z(t=>t.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Ut extends Ae{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const r=this.getNodeType(e),i=this.scope;let s;if(i===Ut.VERTEX)s=e.getVertexIndex();else if(i===Ut.INSTANCE)s=e.getInstanceIndex();else if(i===Ut.DRAW)s=e.getDrawIndex();else if(i===Ut.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(i===Ut.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(i===Ut.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+i);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=s:n=Ys(this).build(e,r),n}}Ut.VERTEX="vertex";Ut.INSTANCE="instance";Ut.SUBGROUP="subgroup";Ut.INVOCATION_LOCAL="invocationLocal";Ut.INVOCATION_SUBGROUP="invocationSubgroup";Ut.DRAW="draw";const nV=ue(Ut,Ut.VERTEX),Po=ue(Ut,Ut.INSTANCE),moe=ue(Ut,Ut.SUBGROUP),poe=ue(Ut,Ut.INVOCATION_SUBGROUP),foe=ue(Ut,Ut.INVOCATION_LOCAL),aV=ue(Ut,Ut.DRAW);class oV extends Ae{static get type(){return"InstanceNode"}constructor(e,r,i=null){super("void"),this.count=e,this.instanceMatrix=r,this.instanceColor=i,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Tt.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:r,instanceMatrix:i,instanceColor:s}=this;let{instanceMatrixNode:n,instanceColorNode:a}=this;if(n===null){if(r<=1e3)n=km(i.array,"mat4",Math.max(r,1)).element(Po);else{const l=new wK(i.array,16,1);this.buffer=l;const h=i.usage===vd?s1:Tg,u=[h(l,"vec4",16,0),h(l,"vec4",16,4),h(l,"vec4",16,8),h(l,"vec4",16,12)];n=_u(...u)}this.instanceMatrixNode=n}if(s&&a===null){const l=new ic(s.array,3),h=s.usage===vd?s1:Tg;this.bufferColor=l,a=B(h(l,"vec3",3,0)),this.instanceColorNode=a}const o=n.mul(cr).xyz;if(cr.assign(o),e.hasGeometryAttribute("normal")){const l=kI(qi,n);qi.assign(l)}this.instanceColorNode!==null&&om("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==vd&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==vd&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const goe=Z(oV).setParameterLength(2,3);class yoe extends oV{static get type(){return"InstancedMeshNode"}constructor(e){const{count:r,instanceMatrix:i,instanceColor:s}=e;super(r,i,s),this.instancedMesh=e}}const lV=Z(yoe).setParameterLength(1);class xoe extends Ae{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Po:this.batchingIdNode=aV);const i=z(([p])=>{const f=P(Ro(tr(this.batchMesh._indirectTexture),0).x),g=P(p).mod(f),y=P(p).div(f);return tr(this.batchMesh._indirectTexture,kr(g,y)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(P(this.batchingIdNode)),s=this.batchMesh._matricesTexture,n=P(Ro(tr(s),0).x),a=C(i).mul(4).toInt().toVar(),o=a.mod(n),l=a.div(n),h=_u(tr(s,kr(o,l)),tr(s,kr(o.add(1),l)),tr(s,kr(o.add(2),l)),tr(s,kr(o.add(3),l))),u=this.batchMesh._colorsTexture;if(u!==null){const f=z(([g])=>{const y=P(Ro(tr(u),0).x),T=g,M=T.mod(y),w=T.div(y);return tr(u,kr(M,w)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(i);om("vec3","vBatchColor").assign(f)}const c=Gs(h);cr.assign(h.mul(cr));const d=qi.div(B(c[0].dot(c[0]),c[1].dot(c[1]),c[2].dot(c[2]))),m=c.mul(d).xyz;qi.assign(m),e.hasGeometryAttribute("tangent")&&Gm.mulAssign(c)}}const uV=Z(xoe).setParameterLength(1);class boe extends ju{static get type(){return"StorageArrayElementNode"}constructor(e,r){super(e,r),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,r){const i=this.storageBufferNode.structTypeNode;return i?i.getMemberType(e,r):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,r){let i;const s=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?i=e.generatePBO(this):i=this.node.build(e):i=super.generate(e),s!==!0){const n=this.getNodeType(e);i=e.format(i,n,r)}return i}}const voe=Z(boe).setParameterLength(2);class Toe extends UT{static get type(){return"StorageBufferNode"}constructor(e,r=null,i=0){let s,n=null;r&&r.isStruct?(s="struct",n=r.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(i=e.count)):r===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=Sse(e.itemSize),i=e.count):s=r,super(e,s,i),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=Rn.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let r=e.globalCache.getData(this.value);return r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),r.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return voe(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Rn.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Bm(this.value),this._varying=Ys(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:r}=this.getAttributeData();return r.getNodeType(e)}getMemberType(e,r){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,r):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:r,varying:i}=this.getAttributeData(),s=i.build(e);return e.registerTransform(s,r),s}}const Eu=(t,e=null,r=0)=>X(new Toe(t,e,r)),woe=(t,e,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Eu(t,e,r).setPBO(!0)),sN=new WeakMap;class hV extends Ae{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Tt.OBJECT,this.skinIndexNode=Bo("skinIndex","uvec4"),this.skinWeightNode=Bo("skinWeight","vec4"),this.bindMatrixNode=Zt("bindMatrix","mat4"),this.bindMatrixInverseNode=Zt("bindMatrixInverse","mat4"),this.boneMatricesNode=n1("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=cr,this.toPositionNode=cr,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,r=this.positionNode){const{skinIndexNode:i,skinWeightNode:s,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),h=e.element(i.z),u=e.element(i.w),c=n.mul(r),d=fr(o.mul(s.x).mul(c),l.mul(s.y).mul(c),h.mul(s.z).mul(c),u.mul(s.w).mul(c));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,r=qi){const{skinIndexNode:i,skinWeightNode:s,bindMatrixNode:n,bindMatrixInverseNode:a}=this,o=e.element(i.x),l=e.element(i.y),h=e.element(i.z),u=e.element(i.w);let c=fr(s.x.mul(o),s.y.mul(l),s.z.mul(h),s.w.mul(u));return c=a.mul(c).mul(n),c.transformDirection(r).xyz}getPreviousSkinnedPosition(e){const r=e.object;return this.previousBoneMatricesNode===null&&(r.skeleton.previousBoneMatrices=new Float32Array(r.skeleton.boneMatrices),this.previousBoneMatricesNode=n1("skeleton.previousBoneMatrices","mat4",r.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,wg)}needsPreviousBoneMatrices(e){const r=e.renderer.getMRT();return r&&r.has("velocity")||O5(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&wg.assign(this.getPreviousSkinnedPosition(e));const r=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(r),e.hasGeometryAttribute("normal")){const i=this.getSkinnedNormal();qi.assign(i),e.hasGeometryAttribute("tangent")&&Gm.assign(i)}return r}generate(e,r){if(r!=="void")return super.generate(e,r)}update(e){const r=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;sN.get(r)!==e.frameId&&(sN.set(r,e.frameId),this.previousBoneMatricesNode!==null&&r.previousBoneMatrices.set(r.boneMatrices),r.update())}}const cV=t=>X(new hV(t)),Soe=(t,e=null)=>{const r=new hV(t);return r.positionNode=Eu(new ic(t.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Po).toVar(),r.skinIndexNode=Eu(new ic(new Uint32Array(t.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Po).toVar(),r.skinWeightNode=Eu(new ic(t.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Po).toVar(),r.bindMatrixNode=Pe(t.bindMatrix,"mat4"),r.bindMatrixInverseNode=Pe(t.bindMatrixInverse,"mat4"),r.boneMatricesNode=km(t.skeleton.boneMatrices,"mat4",t.skeleton.bones.length),r.toPositionNode=e,X(r)};class Moe extends Ae{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const r=e.getNodeProperties(this);if(r.stackNode!==void 0)return r;const i={};for(let a=0,o=this.params.length-1;a<o;a++){const l=this.params[a],h=l.isNode!==!0&&l.name||this.getVarName(a),u=l.isNode!==!0&&l.type||"int";i[h]=ka(h,u)}const s=e.addStack();r.returnsNode=this.params[this.params.length-1](i,e),r.stackNode=s;const n=this.params[0];return n.isNode!==!0&&typeof n.update=="function"&&(r.updateNode=z(this.params[0].update)(i)),e.removeStack(),r}getNodeType(e){const{returnsNode:r}=this.getProperties(e);return r?r.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const r=this.getProperties(e),i=this.params,s=r.stackNode;for(let o=0,l=i.length-1;o<l;o++){const h=i[o];let u=!1,c=null,d=null,m=null,p=null,f=null,g=null;h.isNode?h.getNodeType(e)==="bool"?(u=!0,p="bool",d=h.build(e,p)):(p="int",m=this.getVarName(o),c="0",d=h.build(e,p),f="<"):(p=h.type||"int",m=h.name||this.getVarName(o),c=h.start,d=h.end,f=h.condition,g=h.update,typeof c=="number"?c=e.generateConst(p,c):c&&c.isNode&&(c=c.build(e,p)),typeof d=="number"?d=e.generateConst(p,d):d&&d.isNode&&(d=d.build(e,p)),c!==void 0&&d===void 0?(c=c+" - 1",d="0",f=">="):d!==void 0&&c===void 0&&(c="0",f="<"),f===void 0&&(Number(c)>Number(d)?f=">=":f="<"));let y;if(u)y=`while ( ${d} )`;else{const T={start:c,end:d},M=T.start,w=T.end;let _;const S=()=>f.includes("<")?"+=":"-=";if(g!=null)switch(typeof g){case"function":_=e.flowStagesNode(r.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":_=m+" "+S()+" "+e.generateConst(p,g);break;case"string":_=m+" "+g;break;default:g.isNode?_=m+" "+S()+" "+g.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),_="break /* invalid update */")}else p==="int"||p==="uint"?g=f.includes("<")?"++":"--":g=S()+" 1.",_=m+" "+g;const N=e.getVar(p,m)+" = "+M,A=m+" "+f+" "+w;y=`for ( ${N}; ${A}; ${_} )`}e.addFlowCode((o===0?`
476
476
  `:"")+e.tab+y+` {
477
477
 
478
478
  `).addFlowTab()}const n=s.build(e,"void"),a=r.returnsNode?r.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
479
479
  `+e.tab+n);for(let o=0,l=this.params.length-1;o<l;o++)e.addFlowCode((o===0?"":e.tab)+`}
480
480
 
481
- `).removeFlowTab();return e.addFlowTab(),a}}const Et=(...t)=>X(new Moe(Mu(t,"int"))).toStack(),_oe=()=>ka("continue").toStack(),dV=()=>ka("break").toStack(),Noe=(...t)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Et(...t)),Tx=new WeakMap,ns=new Si,nN=z(({bufferMap:t,influence:e,stride:r,width:i,depth:s,offset:n})=>{const a=P(nV).mul(r).add(n),o=a.div(i),l=a.sub(o.mul(i));return tr(t,kr(l,o)).depth(s).xyz.mul(e)});function Eoe(t){const e=t.morphAttributes.position!==void 0,r=t.morphAttributes.normal!==void 0,i=t.morphAttributes.color!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=s!==void 0?s.length:0;let a=Tx.get(t);if(a===void 0||a.count!==n){let y=function(){f.dispose(),Tx.delete(t),t.removeEventListener("dispose",y)};a!==void 0&&a.texture.dispose();const o=t.morphAttributes.position||[],l=t.morphAttributes.normal||[],h=t.morphAttributes.color||[];let u=0;e===!0&&(u=1),r===!0&&(u=2),i===!0&&(u=3);let c=t.attributes.position.count*u,d=1;const m=4096;c>m&&(d=Math.ceil(c/m),c=m);const p=new Float32Array(c*d*4*n),f=new JJ(p,c,d,n);f.type=gc,f.needsUpdate=!0;const g=u*4;for(let T=0;T<n;T++){const M=o[T],w=l[T],_=h[T],S=c*d*4*T;for(let N=0;N<M.count;N++){const A=N*g;e===!0&&(ns.fromBufferAttribute(M,N),p[S+A+0]=ns.x,p[S+A+1]=ns.y,p[S+A+2]=ns.z,p[S+A+3]=0),r===!0&&(ns.fromBufferAttribute(w,N),p[S+A+4]=ns.x,p[S+A+5]=ns.y,p[S+A+6]=ns.z,p[S+A+7]=0),i===!0&&(ns.fromBufferAttribute(_,N),p[S+A+8]=ns.x,p[S+A+9]=ns.y,p[S+A+10]=ns.z,p[S+A+11]=_.itemSize===4?ns.w:1)}}a={count:n,texture:f,stride:u,size:new Jt(c,d)},Tx.set(t,a),t.addEventListener("dispose",y)}return a}class Aoe extends Ae{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Ie(1),this.updateType=Tt.OBJECT}setup(e){const{geometry:r}=e,i=r.morphAttributes.position!==void 0,s=r.hasAttribute("normal")&&r.morphAttributes.normal!==void 0,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=n!==void 0?n.length:0,{texture:o,stride:l,size:h}=Eoe(r);i===!0&&cr.mulAssign(this.morphBaseInfluence),s===!0&&qi.mulAssign(this.morphBaseInfluence);const u=P(h.width);Et(a,({i:c})=>{const d=C(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(tr(this.mesh.morphTexture,kr(P(c).add(1),P(Po))).r):d.assign(Zt("morphTargetInfluences","float").element(c).toVar()),je(d.notEqual(0),()=>{i===!0&&cr.addAssign(nN({bufferMap:o,influence:d,stride:l,width:u,depth:c,offset:P(0)})),s===!0&&qi.addAssign(nN({bufferMap:o,influence:d,stride:l,width:u,depth:c,offset:P(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((r,i)=>r+i,0)}}const mV=Z(Aoe).setParameterLength(1);class pV extends Ae{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Coe extends pV{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Roe extends nI{static get type(){return"LightingContextNode"}constructor(e,r=null,i=null,s=null){super(e),this.lightingModel=r,this.backdropNode=i,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:r}=this,i=B().toVar("directDiffuse"),s=B().toVar("directSpecular"),n=B().toVar("indirectDiffuse"),a=B().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:s,indirectDiffuse:n,indirectSpecular:a};return{radiance:B().toVar("radiance"),irradiance:B().toVar("irradiance"),iblIrradiance:B().toVar("iblIrradiance"),ambientOcclusion:C(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:e,backdropAlpha:r}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const fV=Z(Roe);class Poe extends pV{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let nd,ad;class Nr extends Ae{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===Nr.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Tt.NONE;return(this.scope===Nr.SIZE||this.scope===Nr.VIEWPORT)&&(e=Tt.RENDER),this.updateType=e,e}update({renderer:e}){const r=e.getRenderTarget();this.scope===Nr.VIEWPORT?r!==null?ad.copy(r.viewport):(e.getViewport(ad),ad.multiplyScalar(e.getPixelRatio())):r!==null?(nd.width=r.width,nd.height=r.height):e.getDrawingBufferSize(nd)}setup(){const e=this.scope;let r=null;return e===Nr.SIZE?r=Ie(nd||(nd=new Jt)):e===Nr.VIEWPORT?r=Ie(ad||(ad=new Si)):r=ne(Hm.div(Sg)),r}generate(e){if(this.scope===Nr.COORDINATE){let r=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(Sg).outputNode.build(e);r=`${e.getType("vec2")}( ${r}.x, ${i}.y - ${r}.y )`}return r}return super.generate(e)}}Nr.COORDINATE="coordinate";Nr.VIEWPORT="viewport";Nr.SIZE="size";Nr.UV="uv";const jo=ue(Nr,Nr.UV),Sg=ue(Nr,Nr.SIZE),Hm=ue(Nr,Nr.COORDINATE),YT=ue(Nr,Nr.VIEWPORT),gV=YT.zw,yV=Hm.sub(YT.xy),Ioe=yV.div(gV),Voe=z(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),Sg),"vec2").once()(),Ooe=z(()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),jo),"vec2").once()(),Loe=z(()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),jo.flipY()),"vec2").once()(),od=new Jt;class Ay extends Ua{static get type(){return"ViewportTextureNode"}constructor(e=jo,r=null,i=null){i===null&&(i=new c3,i.minFilter=i3),super(i,e,r),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Tt.FRAME}updateBefore(e){const r=e.renderer;r.getDrawingBufferSize(od);const i=this.value;(i.image.width!==od.width||i.image.height!==od.height)&&(i.image.width=od.width,i.image.height=od.height,i.needsUpdate=!0);const s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,r.copyFramebufferToTexture(i),i.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Foe=Z(Ay).setParameterLength(0,3),zoe=Z(Ay,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let wx=null;class Boe extends Ay{static get type(){return"ViewportDepthTextureNode"}constructor(e=jo,r=null){wx===null&&(wx=new Am),super(e,r,wx)}}const ZT=Z(Boe).setParameterLength(0,2);class Gi extends Ae{static get type(){return"ViewportDepthNode"}constructor(e,r=null){super("float"),this.scope=e,this.valueNode=r,this.isViewportDepthNode=!0}generate(e){const{scope:r}=this;return r===Gi.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:r}=this,i=this.valueNode;let s=null;if(r===Gi.DEPTH_BASE)i!==null&&(s=bV().assign(i));else if(r===Gi.DEPTH)e.isPerspectiveCamera?s=xV(ti.z,xo,bo):s=lc(ti.z,xo,bo);else if(r===Gi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const n=JT(i,xo,bo);s=lc(n,xo,bo)}else s=i;else s=lc(ti.z,xo,bo);return s}}Gi.DEPTH_BASE="depthBase";Gi.DEPTH="depth";Gi.LINEAR_DEPTH="linearDepth";const lc=(t,e,r)=>t.add(e).div(e.sub(r)),koe=(t,e,r)=>e.sub(r).mul(t).sub(e),xV=(t,e,r)=>e.add(t).mul(r).div(r.sub(e).mul(t)),JT=(t,e,r)=>e.mul(r).div(r.sub(e).mul(t).sub(r)),KT=(t,e,r)=>{e=e.max(1e-6).toVar();const i=Pa(t.negate().div(e)),s=Pa(r.div(e));return i.div(s)},Uoe=(t,e,r)=>{const i=t.mul(NT(r.div(e)));return C(Math.E).pow(i).mul(e).negate()},bV=Z(Gi,Gi.DEPTH_BASE),QT=ue(Gi,Gi.DEPTH),Mg=Z(Gi,Gi.LINEAR_DEPTH).setParameterLength(0,1),Doe=Mg(ZT());QT.assign=t=>bV(t);class ks extends Ae{static get type(){return"ClippingNode"}constructor(e=ks.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const r=e.clippingContext,{intersectionPlanes:i,unionPlanes:s}=r;return this.hardwareClipping=e.material.hardwareClipping,this.scope===ks.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,s):this.scope===ks.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(i,s)}setupAlphaToCoverage(e,r){return z(()=>{const i=C().toVar("distanceToPlane"),s=C().toVar("distanceToGradient"),n=C(1).toVar("clipOpacity"),a=r.length;if(this.hardwareClipping===!1&&a>0){const l=dn(r);Et(a,({i:h})=>{const u=l.element(h);i.assign(ti.dot(u.xyz).negate().add(u.w)),s.assign(i.fwidth().div(2)),n.mulAssign(Iu(s.negate(),s,i))})}const o=e.length;if(o>0){const l=dn(e),h=C(1).toVar("intersectionClipOpacity");Et(o,({i:u})=>{const c=l.element(u);i.assign(ti.dot(c.xyz).negate().add(c.w)),s.assign(i.fwidth().div(2)),h.mulAssign(Iu(s.negate(),s,i).oneMinus())}),n.mulAssign(h.oneMinus())}_s.a.mulAssign(n),_s.a.equal(0).discard()})()}setupDefault(e,r){return z(()=>{const i=r.length;if(this.hardwareClipping===!1&&i>0){const n=dn(r);Et(i,({i:a})=>{const o=n.element(a);ti.dot(o.xyz).greaterThan(o.w).discard()})}const s=e.length;if(s>0){const n=dn(e),a=Hn(!0).toVar("clipped");Et(s,({i:o})=>{const l=n.element(o);a.assign(ti.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,r){const i=e.length;return r.enableHardwareClipping(i),z(()=>{const s=dn(e),n=My(r.getClipDistance());Et(i,({i:a})=>{const o=s.element(a),l=ti.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}}ks.ALPHA_TO_COVERAGE="alphaToCoverage";ks.DEFAULT="default";ks.HARDWARE="hardware";const $oe=()=>X(new ks),Goe=()=>X(new ks(ks.ALPHA_TO_COVERAGE)),joe=()=>X(new ks(ks.HARDWARE)),Woe=.05,aN=z(([t])=>Ha(ke(1e4,cs(ke(17,t.x).add(ke(.1,t.y)))).mul(fr(.1,Vt(cs(ke(13,t.y).add(t.x))))))),oN=z(([t])=>aN(ne(aN(t.xy),t.z))),Hoe=z(([t])=>{const e=Gr(vg(CT(t.xyz)),vg(RT(t.xyz))),r=C(1).div(C(Woe).mul(e)).toVar("pixScale"),i=ne(wc(zn(Pa(r))),wc(Ty(Pa(r)))),s=ne(oN(zn(i.x.mul(t.xyz))),oN(zn(i.y.mul(t.xyz)))),n=Ha(Pa(r)),a=fr(ke(n.oneMinus(),s.x),ke(n,s.y)),o=js(n,n.oneMinus()),l=B(a.mul(a).div(ke(2,o).mul(it(1,o))),a.sub(ke(.5,o)).div(it(1,o)),it(1,it(1,a).mul(it(1,a)).div(ke(2,o).mul(it(1,o))))),h=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return Ba(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class qoe extends AI{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const r=this.getAttributeName(e),i=e.hasGeometryAttribute(r);let s;return i===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new Si(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const vV=(t=0)=>X(new qoe(t));class Sc extends Fb{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+P5(this)}build(e){this.setup(e)}setupObserver(e){return new vse(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const r=e.renderer,i=r.getRenderTarget();e.addStack();const s=this.setupVertex(e),n=this.vertexNode||s;e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(i!==null?i.depthBuffer===!0&&this.setupDepth(e):r.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);o!==null&&e.stack.add(o);const h=Oe(l,_s.a).max(0);a=this.setupOutput(e,h),oc.assign(a);const u=this.outputNode!==null;if(u&&(a=this.outputNode),i!==null){const c=r.getMRT(),d=this.mrtNode;c!==null?(u&&oc.assign(a),a=c,d!==null&&(a=c.merge(d))):d!==null&&(a=d)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Oe(l)),a=this.setupOutput(e,l)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:r,intersectionPlanes:i}=e.clippingContext;let s=null;if(r.length>0||i.length>0){const n=e.renderer.samples;this.alphaToCoverage&&n>1?s=Goe():e.stack.add($oe())}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const r=e.clippingContext.unionPlanes.length;r>0&&r<=8&&e.isAvailable("clipDistance")&&(e.stack.add(joe()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:r,camera:i}=e;let s=this.depthNode;if(s===null){const n=r.getMRT();n&&n.has("depth")?s=n.get("depth"):r.logarithmicDepthBuffer===!0&&(i.isPerspectiveCamera?s=KT(ti.z,xo,bo):s=lc(ti.z,xo,bo))}s!==null&&QT.assign(s).toStack()}setupPositionView(){return Dm.mul(cr).xyz}setupModelViewProjection(){return Um.mul(ti)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),sV}setupPosition(e){const{object:r,geometry:i}=e;if((i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&mV(r).toStack(),r.isSkinnedMesh===!0&&cV(r).toStack(),this.displacementMap){const s=gl("displacementMap","texture"),n=gl("displacementScale","float"),a=gl("displacementBias","float");cr.addAssign(qi.normalize().mul(s.x.mul(n).add(a)))}return r.isBatchedMesh&&uV(r).toStack(),r.isInstancedMesh&&r.instanceMatrix&&r.instanceMatrix.isInstancedBufferAttribute===!0&&lV(r).toStack(),this.positionNode!==null&&cr.assign(vI(this.positionNode,"POSITION")),cr}setupDiffuseColor({object:e,geometry:r}){this.maskNode!==null&&Hn(this.maskNode).not().discard();let i=this.colorNode?Oe(this.colorNode):KI;this.vertexColors===!0&&r.hasAttribute("color")&&(i=i.mul(vV())),e.instanceColor&&(i=om("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=om("vec3","vBatchColor").mul(i)),_s.assign(i);const s=this.opacityNode?C(this.opacityNode):eV;_s.a.assign(_s.a.mul(s));let n=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(n=this.alphaTestNode!==null?C(this.alphaTestNode):JI,_s.a.lessThanEqual(n).discard()),this.alphaHash===!0&&_s.a.lessThan(Hoe(cr)).discard(),this.transparent===!1&&this.blending===Ib&&this.alphaToCoverage===!1?_s.a.assign(1):n===null&&_s.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?B(0):_s.rgb}setupNormal(){return this.normalNode?B(this.normalNode):tV}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?gl("envMap","cubeTexture"):gl("envMap","texture")),e}setupLightMap(e){let r=null;return e.material.lightMap&&(r=new Poe(rV)),r}setupLights(e){const r=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&r.push(i);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&r.push(s),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:iV;r.push(new Coe(a))}let n=this.lightsNode||e.lightsNode;return r.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...r])),n}setupLightingModel(){}setupLighting(e){const{material:r}=e,{backdropNode:i,backdropAlphaNode:s,emissiveNode:n}=this,o=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let l=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){const h=this.setupLightingModel(e)||null;l=fV(o,h,i,s)}else i!==null&&(l=B(s!==null?ur(l,i,s):i));return(n&&n.isNode===!0||r.emissive&&r.emissive.isColor===!0)&&(r1.assign(B(n||QI)),l=l.add(r1)),l}setupFog(e,r){const i=e.fogNode;return i&&(oc.assign(r),r=Oe(i)),r}setupOutput(e,r){return this.fog===!0&&(r=this.setupFog(e,r)),r}setDefaultValues(e){for(const i in e){const s=e[i];this[i]===void 0&&(this[i]=s,s&&s.clone&&(this[i]=s.clone()))}const r=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const i in r)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&r[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,r[i])}toJSON(e){const r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});const i=Fb.prototype.toJSON.call(this,e),s=yg(this);i.inputNodes={};for(const{property:a,childNode:o}of s)i.inputNodes[a]=o.toJSON(e).uuid;function n(a){const o=[];for(const l in a){const h=a[l];delete h.metadata,o.push(h)}return o}if(r){const a=n(e.textures),o=n(e.images),l=n(e.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}let Sx=null;class Xoe extends Ay{static get type(){return"ViewportSharedTextureNode"}constructor(e=jo,r=null){Sx===null&&(Sx=new c3),super(e,r,Sx)}updateReference(){return this}}const Yoe=Z(Xoe).setParameterLength(0,2),Zoe=t=>X(t).mul(.5).add(.5),Joe=t=>X(t).mul(2).sub(1);class Koe extends xr{static get type(){return"EquirectUVNode"}constructor(e=OI){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,r=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return ne(r,i)}}const TV=Z(Koe).setParameterLength(0,1),wV=z(({f0:t,f90:e,dotVH:r})=>{const i=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return t.mul(i.oneMinus()).add(e.mul(i))}),Qoe=z(t=>t.diffuseColor.mul(1/Math.PI)),SV=z(t=>{if(t.geometry.hasAttribute("normal")===!1)return C(0);const e=Xn.dFdx().abs().max(Xn.dFdy().abs());return e.x.max(e.y).max(e.z)}),ele=z(t=>{const{roughness:e}=t,r=SV();let i=e.max(.0525);return i=i.add(r),i=i.min(1),i}),MV=z(({alpha:t,dotNL:e,dotNV:r})=>{const i=t.pow2(),s=e.mul(i.add(i.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return qn(.5,s.add(n).max(AP))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),tle=z(({alphaT:t,alphaB:e,dotTV:r,dotBV:i,dotTL:s,dotBL:n,dotNV:a,dotNL:o})=>{const l=o.mul(B(t.mul(r),e.mul(i),a).length()),h=a.mul(B(t.mul(s),e.mul(n),o).length());return qn(.5,l.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),_V=z(({alpha:t,dotNH:e})=>{const r=t.pow2(),i=e.pow2().mul(r.oneMinus()).oneMinus();return r.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),rle=C(1/Math.PI),ile=z(({alphaT:t,alphaB:e,dotNH:r,dotTH:i,dotBH:s})=>{const n=t.mul(e),a=B(e.mul(i),t.mul(s),n.mul(r)),o=a.dot(a),l=n.div(o);return rle.mul(n.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),sle=z(t=>{const{lightDirection:e,f0:r,f90:i,roughness:s,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=t,l=t.normalView||Da,h=s.pow2(),u=e.add(ms).normalize(),c=l.dot(e).clamp(),d=l.dot(ms).clamp(),m=l.dot(u).clamp(),p=ms.dot(u).clamp();let f=wV({f0:r,f90:i,dotVH:p}),g,y;if(am(a)&&(f=eP.mix(f,n)),am(o)){const T=Uf.dot(e),M=Uf.dot(ms),w=Uf.dot(u),_=ac.dot(e),S=ac.dot(ms),N=ac.dot(u);g=tle({alphaT:i1,alphaB:h,dotTV:M,dotBV:S,dotTL:T,dotBL:_,dotNV:d,dotNL:c}),y=ile({alphaT:i1,alphaB:h,dotNH:m,dotTH:w,dotBH:N})}else g=MV({alpha:h,dotNL:c,dotNV:d}),y=_V({alpha:h,dotNH:m});return f.mul(g).mul(y)}),nle=z(({roughness:t,dotNV:e})=>{const r=Oe(-1,-.0275,-.572,.022),i=Oe(1,.0425,1.04,-.04),s=t.mul(r).add(i),n=s.x.mul(s.x).min(e.mul(-9.28).exp2()).mul(s.x).add(s.y);return ne(-1.04,1.04).mul(n).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),ale=z(({f:t,f90:e,dotVH:r})=>{const i=r.oneMinus().saturate(),s=i.mul(i),n=i.mul(s,s).clamp(0,.9999);return t.sub(B(e).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),Cy=1/6,NV=t=>ke(Cy,ke(t,ke(t,t.negate().add(3)).sub(3)).add(1)),o1=t=>ke(Cy,ke(t,ke(t,ke(3,t).sub(6))).add(4)),EV=t=>ke(Cy,ke(t,ke(t,ke(-3,t).add(3)).add(3)).add(1)),l1=t=>ke(Cy,pn(t,3)),lN=t=>NV(t).add(o1(t)),uN=t=>EV(t).add(l1(t)),hN=t=>fr(-1,o1(t).div(NV(t).add(o1(t)))),cN=t=>fr(1,l1(t).div(EV(t).add(l1(t)))),dN=(t,e,r)=>{const i=t.uvNode,s=ke(i,e.zw).add(.5),n=zn(s),a=Ha(s),o=lN(a.x),l=uN(a.x),h=hN(a.x),u=cN(a.x),c=hN(a.y),d=cN(a.y),m=ne(n.x.add(h),n.y.add(c)).sub(.5).mul(e.xy),p=ne(n.x.add(u),n.y.add(c)).sub(.5).mul(e.xy),f=ne(n.x.add(h),n.y.add(d)).sub(.5).mul(e.xy),g=ne(n.x.add(u),n.y.add(d)).sub(.5).mul(e.xy),y=lN(a.y).mul(fr(o.mul(t.sample(m).level(r)),l.mul(t.sample(p).level(r)))),T=uN(a.y).mul(fr(o.mul(t.sample(f).level(r)),l.mul(t.sample(g).level(r))));return y.add(T)},ole=z(([t,e=C(3)])=>{const r=ne(t.size(P(e))),i=ne(t.size(P(e.add(1)))),s=qn(1,r),n=qn(1,i),a=dN(t,Oe(s,r),zn(e)),o=dN(t,Oe(n,i),Ty(e));return Ha(e).mix(a,o)});B(.04);C(1);const mN=C(1),u1=C(-2),cf=C(.8),Mx=C(-1),df=C(.4),_x=C(2),mf=C(.305),Nx=C(3),pN=C(.21),lle=C(4),fN=C(4),ule=C(16),hle=z(([t])=>{const e=B(Vt(t)).toVar(),r=C(-1).toVar();return je(e.x.greaterThan(e.z),()=>{je(e.x.greaterThan(e.y),()=>{r.assign(yi(t.x.greaterThan(0),0,3))}).Else(()=>{r.assign(yi(t.y.greaterThan(0),1,4))})}).Else(()=>{je(e.z.greaterThan(e.y),()=>{r.assign(yi(t.z.greaterThan(0),2,5))}).Else(()=>{r.assign(yi(t.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),cle=z(([t,e])=>{const r=ne().toVar();return je(e.equal(0),()=>{r.assign(ne(t.z,t.y).div(Vt(t.x)))}).ElseIf(e.equal(1),()=>{r.assign(ne(t.x.negate(),t.z.negate()).div(Vt(t.y)))}).ElseIf(e.equal(2),()=>{r.assign(ne(t.x.negate(),t.y).div(Vt(t.z)))}).ElseIf(e.equal(3),()=>{r.assign(ne(t.z.negate(),t.y).div(Vt(t.x)))}).ElseIf(e.equal(4),()=>{r.assign(ne(t.x.negate(),t.z).div(Vt(t.y)))}).Else(()=>{r.assign(ne(t.x,t.y).div(Vt(t.z)))}),ke(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),dle=z(([t])=>{const e=C(0).toVar();return je(t.greaterThanEqual(cf),()=>{e.assign(mN.sub(t).mul(Mx.sub(u1)).div(mN.sub(cf)).add(u1))}).ElseIf(t.greaterThanEqual(df),()=>{e.assign(cf.sub(t).mul(_x.sub(Mx)).div(cf.sub(df)).add(Mx))}).ElseIf(t.greaterThanEqual(mf),()=>{e.assign(df.sub(t).mul(Nx.sub(_x)).div(df.sub(mf)).add(_x))}).ElseIf(t.greaterThanEqual(pN),()=>{e.assign(mf.sub(t).mul(lle.sub(Nx)).div(mf.sub(pN)).add(Nx))}).Else(()=>{e.assign(C(-2).mul(Pa(ke(1.16,t))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),AV=z(([t,e])=>{const r=t.toVar();r.assign(ke(2,r).sub(1));const i=B(r,1).toVar();return je(e.equal(0),()=>{i.assign(i.zyx)}).ElseIf(e.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),CV=z(([t,e,r,i,s,n])=>{const a=C(r),o=B(e),l=Ba(dle(a),u1,n),h=Ha(l),u=zn(l),c=B(h1(t,o,u,i,s,n)).toVar();return je(h.notEqual(0),()=>{const d=B(h1(t,o,u.add(1),i,s,n)).toVar();c.assign(ur(c,d,h))}),c}),h1=z(([t,e,r,i,s,n])=>{const a=C(r).toVar(),o=B(e),l=C(hle(o)).toVar(),h=C(Gr(fN.sub(a),0)).toVar();a.assign(Gr(a,fN));const u=C(wc(a)).toVar(),c=ne(cle(o,l).mul(u.sub(2)).add(1)).toVar();return je(l.greaterThan(2),()=>{c.y.addAssign(u),l.subAssign(3)}),c.x.addAssign(l.mul(u)),c.x.addAssign(h.mul(ke(3,ule))),c.y.addAssign(ke(4,wc(n).sub(u))),c.x.mulAssign(i),c.y.mulAssign(s),t.sample(c).grad(ne(),ne())}),Ex=z(({envMap:t,mipInt:e,outputDirection:r,theta:i,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=ga(i),h=r.mul(l).add(s.cross(r).mul(cs(i))).add(s.mul(s.dot(r).mul(l.oneMinus())));return h1(t,h,e,n,a,o)}),RV=z(({n:t,latitudinal:e,poleAxis:r,outputDirection:i,weights:s,samples:n,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})=>{const d=B(yi(e,r,Sy(r,i))).toVar();je(d.equal(B(0)),()=>{d.assign(B(i.z,0,i.x.negate()))}),d.assign(Wu(d));const m=B().toVar();return m.addAssign(s.element(0).mul(Ex({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),Et({start:P(1),end:t},({i:p})=>{je(p.greaterThanEqual(n),()=>{dV()});const f=C(a.mul(C(p))).toVar();m.addAssign(s.element(p).mul(Ex({theta:f.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),m.addAssign(s.element(p).mul(Ex({theta:f,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})))}),Oe(m,1)}),Xh=4,gN=[.125,.215,.35,.446,.526,.582],yl=20,Ax=new d3(-1,1,1,-1,0,1),mle=new mK(90,1),yN=new ja;let Cx=null,Rx=0,Px=0;const dl=(1+Math.sqrt(5))/2,Ah=1/dl,xN=[new $(-dl,Ah,0),new $(dl,Ah,0),new $(-Ah,0,dl),new $(Ah,0,dl),new $(0,dl,-Ah),new $(0,dl,Ah),new $(-1,1,-1),new $(1,1,-1),new $(-1,1,1),new $(1,1,1)],ple=new $,PV=new WeakMap,fle=[3,1,5,0,4,2],Ix=AV(jt(),Bo("faceIndex")).normalize(),ew=B(Ix.x,Ix.y,Ix.z);class gle{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,r=0,i=.1,s=100,n={}){const{size:a=256,position:o=ple,renderTarget:l=null}=n;if(this._setSize(a),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const u=l||this._allocateTarget();return n.renderTarget=u,this.fromSceneAsync(e,r,i,s,n),u}Cx=this._renderer.getRenderTarget(),Rx=this._renderer.getActiveCubeFace(),Px=this._renderer.getActiveMipmapLevel();const h=l||this._allocateTarget();return h.depthBuffer=!0,this._init(h),this._sceneToCubeUV(e,i,s,h,o),r>0&&this._blur(h,0,0,r),this._applyPMREM(h),this._cleanup(h),h}async fromSceneAsync(e,r=0,i=.1,s=100,n={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,r,i,s,n)}fromEquirectangular(e,r=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const i=r||this._allocateTarget();return this.fromEquirectangularAsync(e,i),i}return this._fromTexture(e,r)}async fromEquirectangularAsync(e,r=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,r)}fromCubemap(e,r=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const i=r||this._allocateTarget();return this.fromCubemapAsync(e,r),i}return this._fromTexture(e,r)}async fromCubemapAsync(e,r=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,r)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=TN(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===ag||e.mapping===Ob?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Cx,Rx,Px),e.scissorTest=!1,pf(e,0,0,e.width,e.height)}_fromTexture(e,r){this._setSizeFromTexture(e),Cx=this._renderer.getRenderTarget(),Rx=this._renderer.getActiveCubeFace(),Px=this._renderer.getActiveMipmapLevel();const i=r||this._allocateTarget();return this._init(i),this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),r=4*this._cubeSize;return bN(e,r)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bN(e.width,e.height);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=yle(r)),this._blurMaterial=xle(r,e.width,e.height)}}async _compileMaterial(e){const r=new cg(this._lodPlanes[0],e);await this._renderer.compile(r,Ax)}_sceneToCubeUV(e,r,i,s,n){const a=mle;a.near=r,a.far=i;const o=[1,1,1,1,-1,1],l=[1,-1,1,-1,1,-1],h=this._renderer,u=h.autoClear;h.getClearColor(yN),h.autoClear=!1;let c=this._backgroundBox;if(c===null){const p=new l3({name:"PMREM.Background",side:oy,depthWrite:!1,depthTest:!1});c=new cg(new Xv,p)}let d=!1;const m=e.background;m?m.isColor&&(c.material.color.copy(m),e.background=null,d=!0):(c.material.color.copy(yN),d=!0),h.setRenderTarget(s),h.clear(),d&&h.render(c,a);for(let p=0;p<6;p++){const f=p%3;f===0?(a.up.set(0,o[p],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x+l[p],n.y,n.z)):f===1?(a.up.set(0,0,o[p]),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y+l[p],n.z)):(a.up.set(0,o[p],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y,n.z+l[p]));const g=this._cubeSize;pf(s,f*g,p>2?g:0,g,g),h.render(e,a)}h.autoClear=u,e.background=m}_textureToCubeUV(e,r){const i=this._renderer,s=e.mapping===ag||e.mapping===Ob;s?this._cubemapMaterial===null&&(this._cubemapMaterial=vN(e)):this._equirectMaterial===null&&(this._equirectMaterial=TN(e));const n=s?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=n;const o=this._cubeSize;pf(r,0,0,3*o,2*o),i.setRenderTarget(r),i.render(a,Ax)}_applyPMREM(e){const r=this._renderer,i=r.autoClear;r.autoClear=!1;const s=this._lodPlanes.length;for(let n=1;n<s;n++){const a=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),o=xN[(s-n-1)%xN.length];this._blur(e,n-1,n,a,o)}r.autoClear=i}_blur(e,r,i,s,n){const a=this._pingPongRenderTarget;this._halfBlur(e,a,r,i,s,"latitudinal",n),this._halfBlur(a,e,i,i,s,"longitudinal",n)}_halfBlur(e,r,i,s,n,a,o){const l=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,c=this._lodMeshes[s];c.material=h;const d=PV.get(h),m=this._sizeLods[i]-1,p=isFinite(n)?Math.PI/(2*m):2*Math.PI/(2*yl-1),f=n/p,g=isFinite(n)?1+Math.floor(u*f):yl;g>yl&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${yl}`);const y=[];let T=0;for(let N=0;N<yl;++N){const A=N/f,k=Math.exp(-A*A/2);y.push(k),N===0?T+=k:N<g&&(T+=2*k)}for(let N=0;N<y.length;N++)y[N]=y[N]/T;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=g,d.weights.array=y,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:M}=this;d.dTheta.value=p,d.mipInt.value=M-i;const w=this._sizeLods[s],_=3*w*(s>M-Xh?s-M+Xh:0),S=4*(this._cubeSize-w);pf(r,_,S,3*w,2*w),l.setRenderTarget(r),l.render(c,Ax)}}function yle(t){const e=[],r=[],i=[],s=[];let n=t;const a=t-Xh+1+gN.length;for(let o=0;o<a;o++){const l=Math.pow(2,n);r.push(l);let h=1/l;o>t-Xh?h=gN[o-t+Xh-1]:o===0&&(h=0),i.push(h);const u=1/(l-2),c=-u,d=1+u,m=[c,c,d,c,d,d,c,c,d,d,c,d],p=6,f=6,g=3,y=2,T=1,M=new Float32Array(g*f*p),w=new Float32Array(y*f*p),_=new Float32Array(T*f*p);for(let N=0;N<p;N++){const A=N%3*2/3-1,k=N>2?0:-1,Q=[A,k,0,A+2/3,k,0,A+2/3,k+1,0,A,k,0,A+2/3,k+1,0,A,k+1,0],J=fle[N];M.set(Q,g*f*J),w.set(m,y*f*J);const re=[J,J,J,J,J,J];_.set(re,T*f*J)}const S=new Cc;S.setAttribute("position",new Bs(M,g)),S.setAttribute("uv",new Bs(w,y)),S.setAttribute("faceIndex",new Bs(_,T)),e.push(S),s.push(new cg(S,null)),n>Xh&&n--}return{lodPlanes:e,sizeLods:r,sigmas:i,lodMeshes:s}}function bN(t,e){const r={magFilter:ps,minFilter:ps,generateMipmaps:!1,type:wo,format:jv,colorSpace:lg},i=new Nm(t,e,r);return i.texture.mapping=MJ,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function pf(t,e,r,i,s){t.viewport.set(e,r,i,s),t.scissor.set(e,r,i,s)}function tw(t){const e=new Sc;return e.depthTest=!1,e.depthWrite=!1,e.blending=wJ,e.name=`PMREM_${t}`,e}function xle(t,e,r){const i=dn(new Array(yl).fill(0)),s=Ie(new $(0,1,0)),n=Ie(0),a=C(yl),o=Ie(0),l=Ie(1),h=_t(null),u=Ie(0),c=C(1/e),d=C(1/r),m=C(t),p={n:a,latitudinal:o,weights:i,poleAxis:s,outputDirection:ew,dTheta:n,samples:l,envMap:h,mipInt:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:m},f=tw("blur");return f.fragmentNode=RV({...p,latitudinal:o.equal(1)}),PV.set(f,p),f}function vN(t){const e=tw("cubemap");return e.fragmentNode=HT(t,ew),e}function TN(t){const e=tw("equirect");return e.fragmentNode=_t(t,TV(ew),0),e}const wN=new WeakMap;function ble(t){const e=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:r,maxMip:e}}function vle(t,e,r){const i=Tle(e);let s=i.get(t);if((s!==void 0?s.pmremVersion:-1)!==t.pmremVersion){const a=t.image;if(t.isCubeTexture)if(Sle(a))s=r.fromCubemap(t,s);else return null;else if(Mle(a))s=r.fromEquirectangular(t,s);else return null;s.pmremVersion=t.pmremVersion,i.set(t,s)}return s.texture}function Tle(t){let e=wN.get(t);return e===void 0&&(e=new WeakMap,wN.set(t,e)),e}class wle extends xr{static get type(){return"PMREMNode"}constructor(e,r=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=r,this.levelNode=i,this._generator=null;const s=new vi;s.isRenderTargetTexture=!0,this._texture=_t(s),this._width=Ie(0),this._height=Ie(0),this._maxMip=Ie(0),this.updateBeforeType=Tt.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const r=ble(e.image.height);this._texture.value=e,this._width.value=r.texelWidth,this._height.value=r.texelHeight,this._maxMip.value=r.maxMip}updateBefore(e){let r=this._pmrem;const i=r?r.pmremVersion:-1,s=this._value;i!==s.pmremVersion&&(s.isPMREMTexture===!0?r=s:r=vle(s,e.renderer,this._generator),r!==null&&(this._pmrem=r,this.updateFromTexture(r)))}setup(e){this._generator===null&&(this._generator=new gle(e.renderer)),this.updateBefore(e);let r=this.uvNode;r===null&&e.context.getUV&&(r=e.context.getUV(this)),r=jT.mul(B(r.x,r.y.negate(),r.z));let i=this.levelNode;return i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),CV(this._texture,r,i,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function Sle(t){if(t==null)return!1;let e=0;const r=6;for(let i=0;i<r;i++)t[i]!==void 0&&e++;return e===r}function Mle(t){return t==null?!1:t.height>0}const _le=Z(wle).setParameterLength(1,3);class Nle extends xr{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=B(ms.z,0,ms.x.negate()).normalize(),r=ms.cross(e);return ne(e.dot(Da),r.dot(Da)).mul(.495).add(.5)}}const Ele=ue(Nle);class Ale extends xr{static get type(){return"RotateNode"}constructor(e,r){super(),this.positionNode=e,this.rotationNode=r}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:r,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){const n=r.cos(),a=r.sin();return by(n,a,a.negate(),n).mul(i)}else{const n=r,a=_u(Oe(1,0,0,0),Oe(0,ga(n.x),cs(n.x).negate(),0),Oe(0,cs(n.x),ga(n.x),0),Oe(0,0,0,1)),o=_u(Oe(ga(n.y),0,cs(n.y),0),Oe(0,1,0,0),Oe(cs(n.y).negate(),0,ga(n.y),0),Oe(0,0,0,1)),l=_u(Oe(ga(n.z),cs(n.z).negate(),0,0),Oe(cs(n.z),ga(n.z),0,0),Oe(0,0,1,0),Oe(0,0,0,1));return a.mul(o).mul(l).mul(Oe(i,1)).xyz}}}const IV=Z(Ale).setParameterLength(2);Ic("vec3");Ic("vec3");Ic("vec3");class Cle{constructor(){this.weakMap=new WeakMap}get(e){let r=this.weakMap;for(let i=0;i<e.length-1;i++)if(r=r.get(e[i]),r===void 0)return;return r.get(e[e.length-1])}set(e,r){let i=this.weakMap;for(let s=0;s<e.length-1;s++){const n=e[s];i.has(n)===!1&&i.set(n,new WeakMap),i=i.get(n)}return i.set(e[e.length-1],r),this}delete(e){let r=this.weakMap;for(let i=0;i<e.length-1;i++)if(r=r.get(e[i]),r===void 0)return!1;return r.delete(e[e.length-1])}}class Rle extends gt{static get type(){return"ParameterNode"}constructor(e,r=null){super(e,r),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ple=(t,e)=>X(new Rle(t,e));class Ile extends Ae{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,r){return this.outputNode?this.outputNode.getMemberType(e,r):"void"}add(e){return this.nodes.push(e),this}If(e,r){const i=new qh(r);return this._currentCond=yi(e,i),this.add(this._currentCond)}ElseIf(e,r){const i=new qh(r),s=yi(e,i);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new qh(e),this}Switch(e){return this._expressionNode=X(e),this}Case(...e){const r=[];if(e.length>=2)for(let o=0;o<e.length-1;o++)r.push(this._expressionNode.equal(X(e[o])));else throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");const i=e[e.length-1],s=new qh(i);let n=r[0];for(let o=1;o<r.length;o++)n=n.or(r[o]);const a=yi(n,s);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...r){const i=G5();t1(this);const s=e.buildStage;for(const n of this.nodes)if(s==="setup")n.build(e);else if(s==="analyze")n.build(e,this);else if(s==="generate"){const a=e.getDataFromNode(n,"any").stages,o=a&&a[e.shaderStage];if(n.isVarNode&&o&&o.length===1&&o[0]&&o[0].isStackNode)continue;n.build(e,"void")}return t1(i),this.outputNode?this.outputNode.build(e,...r):super.build(e,...r)}else(...e){return console.warn("THREE.TSL: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("THREE.TSL: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Vle=Z(Ile).setParameterLength(0,1);function Ole(t){return Object.entries(t).map(([e,r])=>typeof r=="string"?{name:e,type:r,atomic:!1}:{name:e,type:r.type,atomic:r.atomic||!1})}class Lle extends Ae{static get type(){return"StructTypeNode"}constructor(e,r=null){super("struct"),this.membersLayout=Ole(e),this.name=r,this.isStructLayoutNode=!0}getLength(){const r=Float32Array.BYTES_PER_ELEMENT;let i=0;for(const s of this.membersLayout){const n=s.type,a=Mse(n)*r,o=_se(n),l=i%8,h=l%o,u=l+h;i+=h,u!==0&&8-u<a&&(i+=8-u),i+=a}return Math.ceil(i/8)*8/r}getMemberType(e,r){const i=this.membersLayout.find(s=>s.name===r);return i?i.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Fle extends Ae{static get type(){return"StructNode"}constructor(e,r){super("vec3"),this.structLayoutNode=e,this.values=r,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,r){return this.structLayoutNode.getMemberType(e,r)}generate(e){const r=e.getVarFromNode(this),i=r.type,s=e.getPropertyName(r);return e.addLineFlowCode(`${s} = ${e.generateStruct(i,this.structLayoutNode.membersLayout,this.values)}`,this),r.name}}const zle=(t,e=null)=>{const r=new Lle(t,e),i=(...s)=>{let n=null;if(s.length>0)if(s[0].isNode){n={};const a=Object.keys(t);for(let o=0;o<s.length;o++)n[a[o]]=s[o]}else n=s[0];return X(new Fle(r,n))};return i.layout=r,i.isStruct=!0,i};class VV extends Ae{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const r=e.getNodeProperties(this);if(r.membersLayout===void 0){const i=this.members,s=[];for(let n=0;n<i.length;n++){const a="m"+n,o=i[n].getNodeType(e);s.push({name:a,type:o,index:n})}r.membersLayout=s,r.structType=e.getOutputStructTypeFromNode(this,r.membersLayout)}return r.structType.name}generate(e){const r=e.getOutputStructName(),i=this.members,s=r!==""?r+".":"";for(let n=0;n<i.length;n++){const a=i[n].build(e);e.addLineFlowCode(`${s}m${n} = ${a}`,this)}return r}}const Ble=Z(VV);function OV(t,e){for(let r=0;r<t.length;r++)if(t[r].name===e)return r;return-1}class kle extends VV{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const r={...this.outputNodes,...e.outputNodes};return LV(r)}setup(e){const r=this.outputNodes,i=e.renderer.getRenderTarget(),s=[],n=i.textures;for(const a in r){const o=OV(n,a);s[o]=Oe(r[a])}return this.members=s,super.setup(e)}}const LV=Z(kle),Ule=z(([t])=>{const e=t.toUint().mul(747796405).add(2891336453),r=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),c1=(t,e)=>pn(ke(4,t.mul(it(1,t))),e),Dle=(t,e)=>t.lessThan(.5)?c1(t.mul(2),e).div(2):it(1,c1(ke(it(1,t),2),e).div(2)),$le=(t,e,r)=>pn(qn(pn(t,e),fr(pn(t,e),pn(it(1,t),r))),1/e),Gle=(t,e)=>cs(bg.mul(e.mul(t).sub(1))).div(bg.mul(e.mul(t).sub(1))),ya=z(([t])=>t.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),jle=z(([t])=>B(ya(t.z.add(ya(t.y.mul(1)))),ya(t.z.add(ya(t.x.mul(1)))),ya(t.y.add(ya(t.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wle=z(([t,e,r])=>{const i=B(t).toVar(),s=C(1.4).toVar(),n=C(0).toVar(),a=B(i).toVar();return Et({start:C(0),end:C(3),type:"float",condition:"<="},()=>{const o=B(jle(a.mul(2))).toVar();i.addAssign(o.add(r.mul(C(.1).mul(e)))),a.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);const l=C(ya(i.z.add(ya(i.x.add(ya(i.y)))))).toVar();n.addAssign(l.div(s)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Hle extends Ae{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...r){super(),this.functionNodes=e,this.parametersNodes=r,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const r=this.parametersNodes;let i=this._candidateFnCall;if(i===null){let s=null,n=-1;for(const a of this.functionNodes){const l=a.shaderNode.layout;if(l===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=l.inputs;if(r.length===h.length){let u=0;for(let c=0;c<r.length;c++){const d=r[c],m=h[c];d.getNodeType(e)===m.type?u++:u=0}u>n&&(s=a,n=u)}}this._candidateFnCall=i=s(...r)}return i}}const qle=Z(Hle),li=t=>(...e)=>qle(t,...e),Hu=Ie(0).setGroup(Ye).onRenderUpdate(t=>t.time),FV=Ie(0).setGroup(Ye).onRenderUpdate(t=>t.deltaTime),Xle=Ie(0,"uint").setGroup(Ye).onRenderUpdate(t=>t.frameId),Yle=(t=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),Hu.mul(t)),Zle=(t=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),Hu.mul(t)),Jle=(t=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),FV.mul(t)),Kle=(t=Hu)=>t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Qle=(t=Hu)=>t.fract().round(),eue=(t=Hu)=>t.add(.5).fract().mul(2).sub(1).abs(),tue=(t=Hu)=>t.fract(),rue=z(([t,e,r=ne(.5)])=>IV(t.sub(r),e).add(r)),iue=z(([t,e,r=ne(.5)])=>{const i=t.sub(r),s=i.dot(i),a=s.mul(s).mul(e);return t.add(i.mul(a))}),sue=z(({position:t=null,horizontal:e=!0,vertical:r=!1})=>{let i;t!==null?(i=Ta.toVar(),i[3][0]=t.x,i[3][1]=t.y,i[3][2]=t.z):i=Ta;const s=Zs.mul(i);return am(e)&&(s[0][0]=Ta[0].length(),s[0][1]=0,s[0][2]=0),am(r)&&(s[1][0]=0,s[1][1]=Ta[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Um.mul(s).mul(cr)}),nue=z(([t=null])=>{const e=Mg();return Mg(ZT(t)).sub(e).lessThan(0).select(jo,t)});class aue extends Ae{static get type(){return"SpriteSheetUVNode"}constructor(e,r=jt(),i=C(0)){super("vec2"),this.countNode=e,this.uvNode=r,this.frameNode=i}setup(){const{frameNode:e,uvNode:r,countNode:i}=this,{width:s,height:n}=i,a=e.mod(s.mul(n)).floor(),o=a.mod(s),l=n.sub(a.add(1).div(s).ceil()),h=i.reciprocal(),u=ne(o,l);return r.add(u).mul(h)}}const oue=Z(aue).setParameterLength(3);class lue extends Ae{static get type(){return"TriplanarTexturesNode"}constructor(e,r=null,i=null,s=C(1),n=cr,a=qi){super("vec4"),this.textureXNode=e,this.textureYNode=r,this.textureZNode=i,this.scaleNode=s,this.positionNode=n,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:r,textureZNode:i,scaleNode:s,positionNode:n,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(B(1)));const l=n.yz.mul(s),h=n.zx.mul(s),u=n.xy.mul(s),c=e.value,d=r!==null?r.value:c,m=i!==null?i.value:c,p=_t(c,l).mul(o.x),f=_t(d,h).mul(o.y),g=_t(m,u).mul(o.z);return fr(p,f,g)}}const zV=Z(lue).setParameterLength(1,6),uue=(...t)=>zV(...t),Ch=new yK,nl=new $,Rh=new $,Vx=new $,ld=new Rt,ff=new $(0,0,-1),En=new Si,ud=new $,gf=new $,hd=new Si,yf=new Jt,_g=new Nm,hue=jo.flipX();_g.depthTexture=new Am(1,1);let xf=!1;class rw extends Ua{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||_g.texture,hue),this._reflectorBaseNode=e.reflector||new cue(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=X(new rw({defaultTexture:_g.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class cue extends Ae{static get type(){return"ReflectorBaseNode"}constructor(e,r={}){super();const{target:i=new yn,resolution:s=1,generateMipmaps:n=!1,bounces:a=!0,depth:o=!1}=r;this.textureNode=e,this.target=i,this.resolution=s,this.generateMipmaps=n,this.bounces=a,this.depth=o,this.updateBeforeType=a?Tt.RENDER:Tt.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,r){const i=this.resolution;r.getDrawingBufferSize(yf),e.setSize(Math.round(yf.width*i),Math.round(yf.height*i))}setup(e){return this._updateResolution(_g,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let r=this.virtualCameras.get(e);return r===void 0&&(r=e.clone(),this.virtualCameras.set(e,r)),r}getRenderTarget(e){let r=this.renderTargets.get(e);return r===void 0&&(r=new Nm(0,0,{type:wo}),this.generateMipmaps===!0&&(r.texture.minFilter=_J,r.texture.generateMipmaps=!0),this.depth===!0&&(r.depthTexture=new Am),this.renderTargets.set(e,r)),r}updateBefore(e){if(this.bounces===!1&&xf)return!1;xf=!0;const{scene:r,camera:i,renderer:s,material:n}=e,{target:a}=this,o=this.getVirtualCamera(i),l=this.getRenderTarget(o);s.getDrawingBufferSize(yf),this._updateResolution(l,s),Rh.setFromMatrixPosition(a.matrixWorld),Vx.setFromMatrixPosition(i.matrixWorld),ld.extractRotation(a.matrixWorld),nl.set(0,0,1),nl.applyMatrix4(ld),ud.subVectors(Rh,Vx);const h=ud.dot(nl)>0;let u=!1;if(h===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){xf=!1;return}u=!0}ud.reflect(nl).negate(),ud.add(Rh),ld.extractRotation(i.matrixWorld),ff.set(0,0,-1),ff.applyMatrix4(ld),ff.add(Vx),gf.subVectors(Rh,ff),gf.reflect(nl).negate(),gf.add(Rh),o.coordinateSystem=i.coordinateSystem,o.position.copy(ud),o.up.set(0,1,0),o.up.applyMatrix4(ld),o.up.reflect(nl),o.lookAt(gf),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),Ch.setFromNormalAndCoplanarPoint(nl,Rh),Ch.applyMatrix4(o.matrixWorldInverse),En.set(Ch.normal.x,Ch.normal.y,Ch.normal.z,Ch.constant);const c=o.projectionMatrix;hd.x=(Math.sign(En.x)+c.elements[8])/c.elements[0],hd.y=(Math.sign(En.y)+c.elements[9])/c.elements[5],hd.z=-1,hd.w=(1+c.elements[10])/c.elements[14],En.multiplyScalar(1/En.dot(hd));const d=0;c.elements[2]=En.x,c.elements[6]=En.y,c.elements[10]=s.coordinateSystem===Ru?En.z-d:En.z+1-d,c.elements[14]=En.w,this.textureNode.value=l.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=l.depthTexture),n.visible=!1;const m=s.getRenderTarget(),p=s.getMRT(),f=s.autoClear;s.setMRT(null),s.setRenderTarget(l),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(r,o),this.hasOutput=!0),s.setMRT(p),s.setRenderTarget(m),s.autoClear=f,n.visible=!0,xf=!1,this.forceUpdate=!1}}const due=t=>X(new rw(t)),Ox=new d3(-1,1,1,-1,0,1);class mue extends Cc{constructor(e=!1){super();const r=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new rc([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new rc(r,2))}}const pue=new mue;class BV extends cg{constructor(e=null){super(pue,e),this.camera=Ox,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Ox)}render(e){e.render(this,Ox)}}const fue=new Jt;class gue extends Ua{static get type(){return"RTTNode"}constructor(e,r=null,i=null,s={type:wo}){const n=new Nm(r,i,s);super(n.texture,jt()),this.node=e,this.width=r,this.height=i,this.pixelRatio=1,this.renderTarget=n,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new BV(new Sc),this.updateBeforeType=Tt.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,r){this.width=e,this.height=r;const i=e*this.pixelRatio,s=r*this.pixelRatio;this.renderTarget.setSize(i,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const i=e.getSize(fue);this.setSize(i.width,i.height)}this._quadMesh.material.fragmentNode=this._rttNode;const r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(r)}clone(){const e=new Ua(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const kV=(t,...e)=>X(new gue(X(t),...e)),yue=(t,...e)=>t.isTextureNode?t:t.isPassNode?t.getTextureNode():kV(t,...e),Bh=z(([t,e,r],i)=>{let s;i.renderer.coordinateSystem===Ru?(t=ne(t.x,t.y.oneMinus()).mul(2).sub(1),s=Oe(B(t,e),1)):s=Oe(B(t.x,t.y.oneMinus(),e).mul(2).sub(1),1);const n=Oe(r.mul(s));return n.xyz.div(n.w)}),xue=z(([t,e])=>{const r=e.mul(Oe(t,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return ne(i.x,i.y.oneMinus())}),bue=z(([t,e,r])=>{const i=Ro(tr(e)),s=kr(t.mul(i)).toVar(),n=tr(e,s).toVar(),a=tr(e,s.sub(kr(2,0))).toVar(),o=tr(e,s.sub(kr(1,0))).toVar(),l=tr(e,s.add(kr(1,0))).toVar(),h=tr(e,s.add(kr(2,0))).toVar(),u=tr(e,s.add(kr(0,2))).toVar(),c=tr(e,s.add(kr(0,1))).toVar(),d=tr(e,s.sub(kr(0,1))).toVar(),m=tr(e,s.sub(kr(0,2))).toVar(),p=Vt(it(C(2).mul(o).sub(a),n)).toVar(),f=Vt(it(C(2).mul(l).sub(h),n)).toVar(),g=Vt(it(C(2).mul(c).sub(u),n)).toVar(),y=Vt(it(C(2).mul(d).sub(m),n)).toVar(),T=Bh(t,n,r).toVar(),M=p.lessThan(f).select(T.sub(Bh(t.sub(ne(C(1).div(i.x),0)),o,r)),T.negate().add(Bh(t.add(ne(C(1).div(i.x),0)),l,r))),w=g.lessThan(y).select(T.sub(Bh(t.add(ne(0,C(1).div(i.y))),c,r)),T.negate().add(Bh(t.sub(ne(0,C(1).div(i.y))),d,r)));return Wu(Sy(M,w))});class vue extends ic{constructor(e,r,i=Float32Array){const s=ArrayBuffer.isView(e)?e:new i(e*r);super(s,r),this.isStorageInstancedBufferAttribute=!0}}class Tue extends Bs{constructor(e,r,i=Float32Array){const s=ArrayBuffer.isView(e)?e:new i(e*r);super(s,r),this.isStorageBufferAttribute=!0}}const wue=(t,e="float")=>{let r,i;e.isStruct===!0?(r=e.layout.getLength(),i=xg("float")):(r=I5(e),i=xg(e));const s=new Tue(t,r,i);return Eu(s,e,t)},Sue=(t,e="float")=>{let r,i;e.isStruct===!0?(r=e.layout.getLength(),i=xg("float")):(r=I5(e),i=xg(e));const s=new vue(t,r,i);return Eu(s,e,t)};class Mue extends Ae{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const _ue=ue(Mue),cd=new $u,Lx=new Rt;class ji extends Ae{static get type(){return"SceneNode"}constructor(e=ji.BACKGROUND_BLURRINESS,r=null){super(),this.scope=e,this.scene=r}setup(e){const r=this.scope,i=this.scene!==null?this.scene:e.scene;let s;return r===ji.BACKGROUND_BLURRINESS?s=Zt("backgroundBlurriness","float",i):r===ji.BACKGROUND_INTENSITY?s=Zt("backgroundIntensity","float",i):r===ji.BACKGROUND_ROTATION?s=Ie("mat4").label("backgroundRotation").setGroup(Ye).onRenderUpdate(()=>{const n=i.background;return n!==null&&n.isTexture&&n.mapping!==Gv?(cd.copy(i.backgroundRotation),cd.x*=-1,cd.y*=-1,cd.z*=-1,Lx.makeRotationFromEuler(cd)):Lx.identity(),Lx}):console.error("THREE.SceneNode: Unknown scope:",r),s}}ji.BACKGROUND_BLURRINESS="backgroundBlurriness";ji.BACKGROUND_INTENSITY="backgroundIntensity";ji.BACKGROUND_ROTATION="backgroundRotation";const Nue=ue(ji,ji.BACKGROUND_BLURRINESS),Eue=ue(ji,ji.BACKGROUND_INTENSITY),Aue=ue(ji,ji.BACKGROUND_ROTATION);class Cue extends Ua{static get type(){return"StorageTextureNode"}constructor(e,r,i=null){super(e,r),this.storeNode=i,this.isStorageTextureNode=!0,this.access=Rn.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const r=e.getNodeProperties(this);return r.storeNode=this.storeNode,r}setAccess(e){return this.access=e,this}generate(e,r){let i;return this.storeNode!==null?i=this.generateStore(e):i=super.generate(e,r),i}toReadWrite(){return this.setAccess(Rn.READ_WRITE)}toReadOnly(){return this.setAccess(Rn.READ_ONLY)}toWriteOnly(){return this.setAccess(Rn.WRITE_ONLY)}generateStore(e){const r=e.getNodeProperties(this),{uvNode:i,storeNode:s,depthNode:n}=r,a=super.generate(e,"property"),o=i.build(e,"uvec2"),l=s.build(e,"vec4"),h=n?n.build(e,"int"):null,u=e.generateTextureStore(e,a,o,h,l);e.addLineFlowCode(u,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const UV=Z(Cue).setParameterLength(1,3),Rue=(t,e,r)=>{const i=UV(t,e,r);return r!==null&&i.toStack(),i},Pue=z(({texture:t,uv:e})=>{const i=B().toVar();return je(e.x.lessThan(1e-4),()=>{i.assign(B(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{i.assign(B(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{i.assign(B(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{i.assign(B(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{i.assign(B(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{i.assign(B(0,0,-1))}).Else(()=>{const n=t.sample(e.add(B(-.01,0,0))).r.sub(t.sample(e.add(B(.01,0,0))).r),a=t.sample(e.add(B(0,-.01,0))).r.sub(t.sample(e.add(B(0,.01,0))).r),o=t.sample(e.add(B(0,0,-.01))).r.sub(t.sample(e.add(B(0,0,.01))).r);i.assign(B(n,a,o))}),i.normalize()});class Iue extends Ua{static get type(){return"Texture3DNode"}constructor(e,r=null,i=null){super(e,r,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return B(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,r){const i=this.value;return e.isFlipY()&&(i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0)&&(this.sampler?r=r.flipY():r=r.setY(P(Ro(this,this.levelNode).y).sub(r.y).sub(1))),r}generateUV(e,r){return r.build(e,"vec3")}normal(e){return Pue({texture:this,uv:e})}}const Vue=Z(Iue).setParameterLength(1,3);class Oue extends Ny{static get type(){return"UserDataNode"}constructor(e,r,i=null){super(e,r,i),this.userData=i}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Lue=(t,e,r)=>X(new Oue(t,e,r)),SN=new WeakMap;class Fue extends xr{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Tt.OBJECT,this.updateAfterType=Tt.OBJECT,this.previousModelWorldMatrix=Ie(new Rt),this.previousProjectionMatrix=Ie(new Rt).setGroup(Ye),this.previousCameraViewMatrix=Ie(new Rt)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:r,object:i}){const s=MN(i);this.previousModelWorldMatrix.value.copy(s);const n=DV(r);n.frameId!==e&&(n.frameId=e,n.previousProjectionMatrix===void 0?(n.previousProjectionMatrix=new Rt,n.previousCameraViewMatrix=new Rt,n.currentProjectionMatrix=new Rt,n.currentCameraViewMatrix=new Rt,n.previousProjectionMatrix.copy(this.projectionMatrix||r.projectionMatrix),n.previousCameraViewMatrix.copy(r.matrixWorldInverse)):(n.previousProjectionMatrix.copy(n.currentProjectionMatrix),n.previousCameraViewMatrix.copy(n.currentCameraViewMatrix)),n.currentProjectionMatrix.copy(this.projectionMatrix||r.projectionMatrix),n.currentCameraViewMatrix.copy(r.matrixWorldInverse),this.previousProjectionMatrix.value.copy(n.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(n.previousCameraViewMatrix))}updateAfter({object:e}){MN(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Um:Ie(this.projectionMatrix),r=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),i=e.mul(Dm).mul(cr),s=this.previousProjectionMatrix.mul(r).mul(wg),n=i.xy.div(i.w),a=s.xy.div(s.w);return it(n,a)}}function DV(t){let e=SN.get(t);return e===void 0&&(e={},SN.set(t,e)),e}function MN(t,e=0){const r=DV(t);let i=r[e];return i===void 0&&(r[e]=i=new Rt,r[e].copy(t.matrixWorld)),i}const zue=ue(Fue),$V=z(([t,e])=>js(1,t.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),GV=z(([t,e])=>js(t.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),jV=z(([t,e])=>t.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),WV=z(([t,e])=>ur(t.mul(2).mul(e),t.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),wy(.5,t))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Bue=z(([t,e])=>{const r=e.a.add(t.a.mul(e.a.oneMinus()));return Oe(e.rgb.mul(e.a).add(t.rgb.mul(t.a).mul(e.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kue=z(([t])=>Oe(t.rgb.mul(t.a),t.a),{color:"vec4",return:"vec4"}),Uue=z(([t])=>(je(t.a.equal(0),()=>Oe(0)),Oe(t.rgb.div(t.a),t.a)),{color:"vec4",return:"vec4"}),Due=(...t)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),$V(t)),$ue=(...t)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),GV(t)),Gue=(...t)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),jV(t)),jue=(...t)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),WV(t)),Wue=z(([t])=>iw(t.rgb)),Hue=z(([t,e=C(1)])=>e.mix(iw(t.rgb),t.rgb)),que=z(([t,e=C(1)])=>{const r=fr(t.r,t.g,t.b).div(3),i=t.r.max(t.g.max(t.b)),s=i.sub(r).mul(e).mul(-3);return ur(t.rgb,i,s)}),Xue=z(([t,e=C(1)])=>{const r=B(.57735,.57735,.57735),i=e.cos();return B(t.rgb.mul(i).add(r.cross(t.rgb).mul(e.sin()).add(r.mul(Go(r,t.rgb).mul(i.oneMinus())))))}),iw=(t,e=B(or.getLuminanceCoefficients(new $)))=>Go(t,e),Yue=z(([t,e=B(1),r=B(0),i=B(1),s=C(1),n=B(or.getLuminanceCoefficients(new $,lg))])=>{const a=t.rgb.dot(B(n)),o=Gr(t.rgb.mul(e).add(r),0).toVar(),l=o.pow(i).toVar();return je(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),je(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),je(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(s))),Oe(o.rgb,t.a)});class Zue extends xr{static get type(){return"PosterizeNode"}constructor(e,r){super(),this.sourceNode=e,this.stepsNode=r}setup(){const{sourceNode:e,stepsNode:r}=this;return e.mul(r).floor().div(r)}}const Jue=Z(Zue).setParameterLength(2),bf=new Jt;class HV extends Ua{static get type(){return"PassTextureNode"}constructor(e,r){super(r),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class _N extends HV{static get type(){return"PassMultipleTextureNode"}constructor(e,r,i=!1){super(e,null),this.textureName=r,this.previousTexture=i}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Yn extends xr{static get type(){return"PassNode"}constructor(e,r,i,s={}){super("vec4"),this.scope=e,this.scene=r,this.camera=i,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const n=new Am;n.isRenderTargetTexture=!0,n.name="depth";const a=new Nm(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wo,...s});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Ie(0),this._cameraFar=Ie(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Tt.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let r=this._textures[e];return r===void 0&&(r=this.renderTarget.texture.clone(),r.name=e,this._textures[e]=r,this.renderTarget.textures.push(r)),r}getPreviousTexture(e){let r=this._previousTextures[e];return r===void 0&&(r=this.getTexture(e).clone(),this._previousTextures[e]=r),r}toggleTexture(e){const r=this._previousTextures[e];if(r!==void 0){const i=this._textures[e],s=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[s]=r,this._textures[e]=r,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let r=this._textureNodes[e];return r===void 0&&(r=X(new _N(this,e)),r.updateTexture(),this._textureNodes[e]=r),r}getPreviousTextureNode(e="output"){let r=this._previousTextureNodes[e];return r===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),r=X(new _N(this,e,!0)),r.updateTexture(),this._previousTextureNodes[e]=r),r}getViewZNode(e="depth"){let r=this._viewZNodes[e];if(r===void 0){const i=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=r=JT(this.getTextureNode(e),i,s)}return r}getLinearDepthNode(e="depth"){let r=this._linearDepthNodes[e];if(r===void 0){const i=this._cameraNear,s=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=r=lc(n,i,s)}return r}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===Yn.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:r}=e,{scene:i}=this;let s,n;const a=r.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,s=r.xr.getCamera(),r.xr.updateCamera(s),bf.set(a.width,a.height)):(s=this.camera,n=r.getPixelRatio(),r.getSize(bf)),this._pixelRatio=n,this.setSize(bf.width,bf.height);const o=r.getRenderTarget(),l=r.getMRT(),h=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const u in this._previousTextures)this.toggleTexture(u);r.setRenderTarget(this.renderTarget),r.setMRT(this._mrt),r.render(i,s),r.setRenderTarget(o),r.setMRT(l),s.layers.mask=h}setSize(e,r){this._width=e,this._height=r;const i=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(i,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Yn.COLOR="color";Yn.DEPTH="depth";const Kue=(t,e,r)=>X(new Yn(Yn.COLOR,t,e,r)),Que=(t,e)=>X(new HV(t,e)),ehe=(t,e,r)=>X(new Yn(Yn.DEPTH,t,e,r));class the extends Yn{static get type(){return"ToonOutlinePassNode"}constructor(e,r,i,s,n){super(Yn.COLOR,e,r),this.colorNode=i,this.thicknessNode=s,this.alphaNode=n,this._materialCache=new WeakMap}updateBefore(e){const{renderer:r}=e,i=r.getRenderObjectFunction();r.setRenderObjectFunction((s,n,a,o,l,h,u,c)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const d=this._getOutlineMaterial(l);r.renderObject(s,n,a,o,d,h,u,c)}r.renderObject(s,n,a,o,l,h,u,c)}),super.updateBefore(e),r.setRenderObjectFunction(i)}_createMaterial(){const e=new Sc;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=oy;const r=qi.negate(),i=Um.mul(Dm),s=C(1),n=i.mul(Oe(cr,1)),a=i.mul(Oe(cr.add(r),1)),o=Wu(n.sub(a));return e.vertexNode=n.add(o.mul(this.thicknessNode).mul(n.w).mul(s)),e.colorNode=Oe(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let r=this._materialCache.get(e);return r===void 0&&(r=this._createMaterial(),this._materialCache.set(e,r)),r}}const rhe=(t,e,r=new ja(0,0,0),i=.003,s=1)=>X(new the(t,e,X(r),X(i),X(s))),ihe=z(([t,e])=>t.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),she=z(([t,e])=>(t=t.mul(e),t.div(t.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nhe=z(([t,e])=>{t=t.mul(e),t=t.sub(.004).max(0);const r=t.mul(t.mul(6.2).add(.5)),i=t.mul(t.mul(6.2).add(1.7)).add(.06);return r.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ahe=z(([t])=>{const e=t.mul(t.add(.0245786)).sub(90537e-9),r=t.mul(t.add(.432951).mul(.983729)).add(.238081);return e.div(r)}),ohe=z(([t,e])=>{const r=Gs(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=Gs(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return t=t.mul(e).div(.6),t=r.mul(t),t=ahe(t),t=i.mul(t),t.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),lhe=Gs(B(1.6605,-.1246,-.0182),B(-.5876,1.1329,-.1006),B(-.0728,-.0083,1.1187)),uhe=Gs(B(.6274,.0691,.0164),B(.3293,.9195,.088),B(.0433,.0113,.8956)),hhe=z(([t])=>{const e=B(t).toVar(),r=B(e.mul(e)).toVar(),i=B(r.mul(r)).toVar();return C(15.5).mul(i.mul(r)).sub(ke(40.14,i.mul(e))).add(ke(31.96,i).sub(ke(6.868,r.mul(e))).add(ke(.4298,r).add(ke(.1191,e).sub(.00232))))}),che=z(([t,e])=>{const r=B(t).toVar(),i=Gs(B(.856627153315983,.137318972929847,.11189821299995),B(.0951212405381588,.761241990602591,.0767994186031903),B(.0482516061458583,.101439036467562,.811302368396859)),s=Gs(B(1.1271005818144368,-.1413297634984383,-.14132976349843826),B(-.11060664309660323,1.157823702216272,-.11060664309660294),B(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=C(-12.47393),a=C(4.026069);return r.mulAssign(e),r.assign(uhe.mul(r)),r.assign(i.mul(r)),r.assign(Gr(r,1e-10)),r.assign(Pa(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Ba(r,0,1)),r.assign(hhe(r)),r.assign(s.mul(r)),r.assign(pn(Gr(B(0),r),B(2.2))),r.assign(lhe.mul(r)),r.assign(Ba(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),dhe=z(([t,e])=>{const r=C(.76),i=C(.15);t=t.mul(e);const s=js(t.r,js(t.g,t.b)),n=yi(s.lessThan(.08),s.sub(ke(6.25,s.mul(s))),.04);t.subAssign(n);const a=Gr(t.r,Gr(t.g,t.b));je(a.lessThan(r),()=>t);const o=it(1,r),l=it(1,o.mul(o).div(a.add(o.sub(r))));t.mulAssign(l.div(a));const h=it(1,qn(1,i.mul(a.sub(l)).add(1)));return ur(t,B(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Lr extends Ae{static get type(){return"CodeNode"}constructor(e="",r=[],i=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=r,this.language=i}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const r=this.getIncludes(e);for(const s of r)s.build(e);const i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ry=Z(Lr).setParameterLength(1,3),mhe=(t,e)=>Ry(t,e,"js"),phe=(t,e)=>Ry(t,e,"wgsl"),fhe=(t,e)=>Ry(t,e,"glsl");class ghe extends Lr{static get type(){return"FunctionNode"}constructor(e="",r=[],i=""){super(e,r,i)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const r=e.getDataFromNode(this);let i=r.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),r.nodeFunction=i),i}generate(e,r){super.generate(e);const i=this.getNodeFunction(e),s=i.name,n=i.type,a=e.getCodeFromNode(this,n);s!==""&&(a.name=s);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+`
481
+ `).removeFlowTab();return e.addFlowTab(),a}}const Et=(...t)=>X(new Moe(Mu(t,"int"))).toStack(),_oe=()=>ka("continue").toStack(),dV=()=>ka("break").toStack(),Noe=(...t)=>(console.warn("THREE.TSL: loop() has been renamed to Loop()."),Et(...t)),Tx=new WeakMap,ns=new Si,nN=z(({bufferMap:t,influence:e,stride:r,width:i,depth:s,offset:n})=>{const a=P(nV).mul(r).add(n),o=a.div(i),l=a.sub(o.mul(i));return tr(t,kr(l,o)).depth(s).xyz.mul(e)});function Eoe(t){const e=t.morphAttributes.position!==void 0,r=t.morphAttributes.normal!==void 0,i=t.morphAttributes.color!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=s!==void 0?s.length:0;let a=Tx.get(t);if(a===void 0||a.count!==n){let y=function(){f.dispose(),Tx.delete(t),t.removeEventListener("dispose",y)};a!==void 0&&a.texture.dispose();const o=t.morphAttributes.position||[],l=t.morphAttributes.normal||[],h=t.morphAttributes.color||[];let u=0;e===!0&&(u=1),r===!0&&(u=2),i===!0&&(u=3);let c=t.attributes.position.count*u,d=1;const m=4096;c>m&&(d=Math.ceil(c/m),c=m);const p=new Float32Array(c*d*4*n),f=new JJ(p,c,d,n);f.type=gc,f.needsUpdate=!0;const g=u*4;for(let T=0;T<n;T++){const M=o[T],w=l[T],_=h[T],S=c*d*4*T;for(let N=0;N<M.count;N++){const A=N*g;e===!0&&(ns.fromBufferAttribute(M,N),p[S+A+0]=ns.x,p[S+A+1]=ns.y,p[S+A+2]=ns.z,p[S+A+3]=0),r===!0&&(ns.fromBufferAttribute(w,N),p[S+A+4]=ns.x,p[S+A+5]=ns.y,p[S+A+6]=ns.z,p[S+A+7]=0),i===!0&&(ns.fromBufferAttribute(_,N),p[S+A+8]=ns.x,p[S+A+9]=ns.y,p[S+A+10]=ns.z,p[S+A+11]=_.itemSize===4?ns.w:1)}}a={count:n,texture:f,stride:u,size:new Jt(c,d)},Tx.set(t,a),t.addEventListener("dispose",y)}return a}class Aoe extends Ae{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Pe(1),this.updateType=Tt.OBJECT}setup(e){const{geometry:r}=e,i=r.morphAttributes.position!==void 0,s=r.hasAttribute("normal")&&r.morphAttributes.normal!==void 0,n=r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color,a=n!==void 0?n.length:0,{texture:o,stride:l,size:h}=Eoe(r);i===!0&&cr.mulAssign(this.morphBaseInfluence),s===!0&&qi.mulAssign(this.morphBaseInfluence);const u=P(h.width);Et(a,({i:c})=>{const d=C(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(tr(this.mesh.morphTexture,kr(P(c).add(1),P(Po))).r):d.assign(Zt("morphTargetInfluences","float").element(c).toVar()),je(d.notEqual(0),()=>{i===!0&&cr.addAssign(nN({bufferMap:o,influence:d,stride:l,width:u,depth:c,offset:P(0)})),s===!0&&qi.addAssign(nN({bufferMap:o,influence:d,stride:l,width:u,depth:c,offset:P(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((r,i)=>r+i,0)}}const mV=Z(Aoe).setParameterLength(1);class pV extends Ae{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Coe extends pV{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Roe extends nI{static get type(){return"LightingContextNode"}constructor(e,r=null,i=null,s=null){super(e),this.lightingModel=r,this.backdropNode=i,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:r}=this,i=B().toVar("directDiffuse"),s=B().toVar("directSpecular"),n=B().toVar("indirectDiffuse"),a=B().toVar("indirectSpecular"),o={directDiffuse:i,directSpecular:s,indirectDiffuse:n,indirectSpecular:a};return{radiance:B().toVar("radiance"),irradiance:B().toVar("irradiance"),iblIrradiance:B().toVar("iblIrradiance"),ambientOcclusion:C(1).toVar("ambientOcclusion"),reflectedLight:o,backdrop:e,backdropAlpha:r}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const fV=Z(Roe);class Poe extends pV{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let nd,ad;class Nr extends Ae{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===Nr.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Tt.NONE;return(this.scope===Nr.SIZE||this.scope===Nr.VIEWPORT)&&(e=Tt.RENDER),this.updateType=e,e}update({renderer:e}){const r=e.getRenderTarget();this.scope===Nr.VIEWPORT?r!==null?ad.copy(r.viewport):(e.getViewport(ad),ad.multiplyScalar(e.getPixelRatio())):r!==null?(nd.width=r.width,nd.height=r.height):e.getDrawingBufferSize(nd)}setup(){const e=this.scope;let r=null;return e===Nr.SIZE?r=Pe(nd||(nd=new Jt)):e===Nr.VIEWPORT?r=Pe(ad||(ad=new Si)):r=ne(Hm.div(Sg)),r}generate(e){if(this.scope===Nr.COORDINATE){let r=e.getFragCoord();if(e.isFlipY()){const i=e.getNodeProperties(Sg).outputNode.build(e);r=`${e.getType("vec2")}( ${r}.x, ${i}.y - ${r}.y )`}return r}return super.generate(e)}}Nr.COORDINATE="coordinate";Nr.VIEWPORT="viewport";Nr.SIZE="size";Nr.UV="uv";const jo=ue(Nr,Nr.UV),Sg=ue(Nr,Nr.SIZE),Hm=ue(Nr,Nr.COORDINATE),YT=ue(Nr,Nr.VIEWPORT),gV=YT.zw,yV=Hm.sub(YT.xy),Ioe=yV.div(gV),Voe=z(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),Sg),"vec2").once()(),Ooe=z(()=>(console.warn('THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),jo),"vec2").once()(),Loe=z(()=>(console.warn('THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),jo.flipY()),"vec2").once()(),od=new Jt;class Ay extends Ua{static get type(){return"ViewportTextureNode"}constructor(e=jo,r=null,i=null){i===null&&(i=new c3,i.minFilter=i3),super(i,e,r),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Tt.FRAME}updateBefore(e){const r=e.renderer;r.getDrawingBufferSize(od);const i=this.value;(i.image.width!==od.width||i.image.height!==od.height)&&(i.image.width=od.width,i.image.height=od.height,i.needsUpdate=!0);const s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,r.copyFramebufferToTexture(i),i.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Foe=Z(Ay).setParameterLength(0,3),zoe=Z(Ay,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let wx=null;class Boe extends Ay{static get type(){return"ViewportDepthTextureNode"}constructor(e=jo,r=null){wx===null&&(wx=new Am),super(e,r,wx)}}const ZT=Z(Boe).setParameterLength(0,2);class Gi extends Ae{static get type(){return"ViewportDepthNode"}constructor(e,r=null){super("float"),this.scope=e,this.valueNode=r,this.isViewportDepthNode=!0}generate(e){const{scope:r}=this;return r===Gi.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:r}=this,i=this.valueNode;let s=null;if(r===Gi.DEPTH_BASE)i!==null&&(s=bV().assign(i));else if(r===Gi.DEPTH)e.isPerspectiveCamera?s=xV(ti.z,xo,bo):s=lc(ti.z,xo,bo);else if(r===Gi.LINEAR_DEPTH)if(i!==null)if(e.isPerspectiveCamera){const n=JT(i,xo,bo);s=lc(n,xo,bo)}else s=i;else s=lc(ti.z,xo,bo);return s}}Gi.DEPTH_BASE="depthBase";Gi.DEPTH="depth";Gi.LINEAR_DEPTH="linearDepth";const lc=(t,e,r)=>t.add(e).div(e.sub(r)),koe=(t,e,r)=>e.sub(r).mul(t).sub(e),xV=(t,e,r)=>e.add(t).mul(r).div(r.sub(e).mul(t)),JT=(t,e,r)=>e.mul(r).div(r.sub(e).mul(t).sub(r)),KT=(t,e,r)=>{e=e.max(1e-6).toVar();const i=Pa(t.negate().div(e)),s=Pa(r.div(e));return i.div(s)},Uoe=(t,e,r)=>{const i=t.mul(NT(r.div(e)));return C(Math.E).pow(i).mul(e).negate()},bV=Z(Gi,Gi.DEPTH_BASE),QT=ue(Gi,Gi.DEPTH),Mg=Z(Gi,Gi.LINEAR_DEPTH).setParameterLength(0,1),Doe=Mg(ZT());QT.assign=t=>bV(t);class ks extends Ae{static get type(){return"ClippingNode"}constructor(e=ks.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const r=e.clippingContext,{intersectionPlanes:i,unionPlanes:s}=r;return this.hardwareClipping=e.material.hardwareClipping,this.scope===ks.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(i,s):this.scope===ks.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(i,s)}setupAlphaToCoverage(e,r){return z(()=>{const i=C().toVar("distanceToPlane"),s=C().toVar("distanceToGradient"),n=C(1).toVar("clipOpacity"),a=r.length;if(this.hardwareClipping===!1&&a>0){const l=dn(r);Et(a,({i:h})=>{const u=l.element(h);i.assign(ti.dot(u.xyz).negate().add(u.w)),s.assign(i.fwidth().div(2)),n.mulAssign(Iu(s.negate(),s,i))})}const o=e.length;if(o>0){const l=dn(e),h=C(1).toVar("intersectionClipOpacity");Et(o,({i:u})=>{const c=l.element(u);i.assign(ti.dot(c.xyz).negate().add(c.w)),s.assign(i.fwidth().div(2)),h.mulAssign(Iu(s.negate(),s,i).oneMinus())}),n.mulAssign(h.oneMinus())}_s.a.mulAssign(n),_s.a.equal(0).discard()})()}setupDefault(e,r){return z(()=>{const i=r.length;if(this.hardwareClipping===!1&&i>0){const n=dn(r);Et(i,({i:a})=>{const o=n.element(a);ti.dot(o.xyz).greaterThan(o.w).discard()})}const s=e.length;if(s>0){const n=dn(e),a=Hn(!0).toVar("clipped");Et(s,({i:o})=>{const l=n.element(o);a.assign(ti.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,r){const i=e.length;return r.enableHardwareClipping(i),z(()=>{const s=dn(e),n=My(r.getClipDistance());Et(i,({i:a})=>{const o=s.element(a),l=ti.dot(o.xyz).sub(o.w).negate();n.element(a).assign(l)})})()}}ks.ALPHA_TO_COVERAGE="alphaToCoverage";ks.DEFAULT="default";ks.HARDWARE="hardware";const $oe=()=>X(new ks),Goe=()=>X(new ks(ks.ALPHA_TO_COVERAGE)),joe=()=>X(new ks(ks.HARDWARE)),Woe=.05,aN=z(([t])=>Ha(ke(1e4,cs(ke(17,t.x).add(ke(.1,t.y)))).mul(fr(.1,Vt(cs(ke(13,t.y).add(t.x))))))),oN=z(([t])=>aN(ne(aN(t.xy),t.z))),Hoe=z(([t])=>{const e=Gr(vg(CT(t.xyz)),vg(RT(t.xyz))),r=C(1).div(C(Woe).mul(e)).toVar("pixScale"),i=ne(wc(zn(Pa(r))),wc(Ty(Pa(r)))),s=ne(oN(zn(i.x.mul(t.xyz))),oN(zn(i.y.mul(t.xyz)))),n=Ha(Pa(r)),a=fr(ke(n.oneMinus(),s.x),ke(n,s.y)),o=js(n,n.oneMinus()),l=B(a.mul(a).div(ke(2,o).mul(it(1,o))),a.sub(ke(.5,o)).div(it(1,o)),it(1,it(1,a).mul(it(1,a)).div(ke(2,o).mul(it(1,o))))),h=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return Ba(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class qoe extends AI{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const r=this.getAttributeName(e),i=e.hasGeometryAttribute(r);let s;return i===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new Si(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const vV=(t=0)=>X(new qoe(t));class Sc extends Fb{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+P5(this)}build(e){this.setup(e)}setupObserver(e){return new vse(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const r=e.renderer,i=r.getRenderTarget();e.addStack();const s=this.setupVertex(e),n=this.vertexNode||s;e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(i!==null?i.depthBuffer===!0&&this.setupDepth(e):r.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);o!==null&&e.stack.add(o);const h=Oe(l,_s.a).max(0);a=this.setupOutput(e,h),oc.assign(a);const u=this.outputNode!==null;if(u&&(a=this.outputNode),i!==null){const c=r.getMRT(),d=this.mrtNode;c!==null?(u&&oc.assign(a),a=c,d!==null&&(a=c.merge(d))):d!==null&&(a=d)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Oe(l)),a=this.setupOutput(e,l)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:r,intersectionPlanes:i}=e.clippingContext;let s=null;if(r.length>0||i.length>0){const n=e.renderer.samples;this.alphaToCoverage&&n>1?s=Goe():e.stack.add($oe())}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const r=e.clippingContext.unionPlanes.length;r>0&&r<=8&&e.isAvailable("clipDistance")&&(e.stack.add(joe()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:r,camera:i}=e;let s=this.depthNode;if(s===null){const n=r.getMRT();n&&n.has("depth")?s=n.get("depth"):r.logarithmicDepthBuffer===!0&&(i.isPerspectiveCamera?s=KT(ti.z,xo,bo):s=lc(ti.z,xo,bo))}s!==null&&QT.assign(s).toStack()}setupPositionView(){return Dm.mul(cr).xyz}setupModelViewProjection(){return Um.mul(ti)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),sV}setupPosition(e){const{object:r,geometry:i}=e;if((i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)&&mV(r).toStack(),r.isSkinnedMesh===!0&&cV(r).toStack(),this.displacementMap){const s=gl("displacementMap","texture"),n=gl("displacementScale","float"),a=gl("displacementBias","float");cr.addAssign(qi.normalize().mul(s.x.mul(n).add(a)))}return r.isBatchedMesh&&uV(r).toStack(),r.isInstancedMesh&&r.instanceMatrix&&r.instanceMatrix.isInstancedBufferAttribute===!0&&lV(r).toStack(),this.positionNode!==null&&cr.assign(vI(this.positionNode,"POSITION")),cr}setupDiffuseColor({object:e,geometry:r}){this.maskNode!==null&&Hn(this.maskNode).not().discard();let i=this.colorNode?Oe(this.colorNode):KI;this.vertexColors===!0&&r.hasAttribute("color")&&(i=i.mul(vV())),e.instanceColor&&(i=om("vec3","vInstanceColor").mul(i)),e.isBatchedMesh&&e._colorsTexture&&(i=om("vec3","vBatchColor").mul(i)),_s.assign(i);const s=this.opacityNode?C(this.opacityNode):eV;_s.a.assign(_s.a.mul(s));let n=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(n=this.alphaTestNode!==null?C(this.alphaTestNode):JI,_s.a.lessThanEqual(n).discard()),this.alphaHash===!0&&_s.a.lessThan(Hoe(cr)).discard(),this.transparent===!1&&this.blending===Ib&&this.alphaToCoverage===!1?_s.a.assign(1):n===null&&_s.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?B(0):_s.rgb}setupNormal(){return this.normalNode?B(this.normalNode):tV}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?gl("envMap","cubeTexture"):gl("envMap","texture")),e}setupLightMap(e){let r=null;return e.material.lightMap&&(r=new Poe(rV)),r}setupLights(e){const r=[],i=this.setupEnvironment(e);i&&i.isLightingNode&&r.push(i);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&r.push(s),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:iV;r.push(new Coe(a))}let n=this.lightsNode||e.lightsNode;return r.length>0&&(n=e.renderer.lighting.createNode([...n.getLights(),...r])),n}setupLightingModel(){}setupLighting(e){const{material:r}=e,{backdropNode:i,backdropAlphaNode:s,emissiveNode:n}=this,o=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let l=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){const h=this.setupLightingModel(e)||null;l=fV(o,h,i,s)}else i!==null&&(l=B(s!==null?ur(l,i,s):i));return(n&&n.isNode===!0||r.emissive&&r.emissive.isColor===!0)&&(r1.assign(B(n||QI)),l=l.add(r1)),l}setupFog(e,r){const i=e.fogNode;return i&&(oc.assign(r),r=Oe(i)),r}setupOutput(e,r){return this.fog===!0&&(r=this.setupFog(e,r)),r}setDefaultValues(e){for(const i in e){const s=e[i];this[i]===void 0&&(this[i]=s,s&&s.clone&&(this[i]=s.clone()))}const r=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const i in r)Object.getOwnPropertyDescriptor(this.constructor.prototype,i)===void 0&&r[i].get!==void 0&&Object.defineProperty(this.constructor.prototype,i,r[i])}toJSON(e){const r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});const i=Fb.prototype.toJSON.call(this,e),s=yg(this);i.inputNodes={};for(const{property:a,childNode:o}of s)i.inputNodes[a]=o.toJSON(e).uuid;function n(a){const o=[];for(const l in a){const h=a[l];delete h.metadata,o.push(h)}return o}if(r){const a=n(e.textures),o=n(e.images),l=n(e.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}let Sx=null;class Xoe extends Ay{static get type(){return"ViewportSharedTextureNode"}constructor(e=jo,r=null){Sx===null&&(Sx=new c3),super(e,r,Sx)}updateReference(){return this}}const Yoe=Z(Xoe).setParameterLength(0,2),Zoe=t=>X(t).mul(.5).add(.5),Joe=t=>X(t).mul(2).sub(1);class Koe extends xr{static get type(){return"EquirectUVNode"}constructor(e=OI){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,r=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),i=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return ne(r,i)}}const TV=Z(Koe).setParameterLength(0,1),wV=z(({f0:t,f90:e,dotVH:r})=>{const i=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return t.mul(i.oneMinus()).add(e.mul(i))}),Qoe=z(t=>t.diffuseColor.mul(1/Math.PI)),SV=z(t=>{if(t.geometry.hasAttribute("normal")===!1)return C(0);const e=Xn.dFdx().abs().max(Xn.dFdy().abs());return e.x.max(e.y).max(e.z)}),ele=z(t=>{const{roughness:e}=t,r=SV();let i=e.max(.0525);return i=i.add(r),i=i.min(1),i}),MV=z(({alpha:t,dotNL:e,dotNV:r})=>{const i=t.pow2(),s=e.mul(i.add(i.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(i.add(i.oneMinus().mul(e.pow2())).sqrt());return qn(.5,s.add(n).max(AP))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),tle=z(({alphaT:t,alphaB:e,dotTV:r,dotBV:i,dotTL:s,dotBL:n,dotNV:a,dotNL:o})=>{const l=o.mul(B(t.mul(r),e.mul(i),a).length()),h=a.mul(B(t.mul(s),e.mul(n),o).length());return qn(.5,l.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),_V=z(({alpha:t,dotNH:e})=>{const r=t.pow2(),i=e.pow2().mul(r.oneMinus()).oneMinus();return r.div(i.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),rle=C(1/Math.PI),ile=z(({alphaT:t,alphaB:e,dotNH:r,dotTH:i,dotBH:s})=>{const n=t.mul(e),a=B(e.mul(i),t.mul(s),n.mul(r)),o=a.dot(a),l=n.div(o);return rle.mul(n.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),sle=z(t=>{const{lightDirection:e,f0:r,f90:i,roughness:s,f:n,USE_IRIDESCENCE:a,USE_ANISOTROPY:o}=t,l=t.normalView||Da,h=s.pow2(),u=e.add(ms).normalize(),c=l.dot(e).clamp(),d=l.dot(ms).clamp(),m=l.dot(u).clamp(),p=ms.dot(u).clamp();let f=wV({f0:r,f90:i,dotVH:p}),g,y;if(am(a)&&(f=eP.mix(f,n)),am(o)){const T=Uf.dot(e),M=Uf.dot(ms),w=Uf.dot(u),_=ac.dot(e),S=ac.dot(ms),N=ac.dot(u);g=tle({alphaT:i1,alphaB:h,dotTV:M,dotBV:S,dotTL:T,dotBL:_,dotNV:d,dotNL:c}),y=ile({alphaT:i1,alphaB:h,dotNH:m,dotTH:w,dotBH:N})}else g=MV({alpha:h,dotNL:c,dotNV:d}),y=_V({alpha:h,dotNH:m});return f.mul(g).mul(y)}),nle=z(({roughness:t,dotNV:e})=>{const r=Oe(-1,-.0275,-.572,.022),i=Oe(1,.0425,1.04,-.04),s=t.mul(r).add(i),n=s.x.mul(s.x).min(e.mul(-9.28).exp2()).mul(s.x).add(s.y);return ne(-1.04,1.04).mul(n).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),ale=z(({f:t,f90:e,dotVH:r})=>{const i=r.oneMinus().saturate(),s=i.mul(i),n=i.mul(s,s).clamp(0,.9999);return t.sub(B(e).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),Cy=1/6,NV=t=>ke(Cy,ke(t,ke(t,t.negate().add(3)).sub(3)).add(1)),o1=t=>ke(Cy,ke(t,ke(t,ke(3,t).sub(6))).add(4)),EV=t=>ke(Cy,ke(t,ke(t,ke(-3,t).add(3)).add(3)).add(1)),l1=t=>ke(Cy,pn(t,3)),lN=t=>NV(t).add(o1(t)),uN=t=>EV(t).add(l1(t)),hN=t=>fr(-1,o1(t).div(NV(t).add(o1(t)))),cN=t=>fr(1,l1(t).div(EV(t).add(l1(t)))),dN=(t,e,r)=>{const i=t.uvNode,s=ke(i,e.zw).add(.5),n=zn(s),a=Ha(s),o=lN(a.x),l=uN(a.x),h=hN(a.x),u=cN(a.x),c=hN(a.y),d=cN(a.y),m=ne(n.x.add(h),n.y.add(c)).sub(.5).mul(e.xy),p=ne(n.x.add(u),n.y.add(c)).sub(.5).mul(e.xy),f=ne(n.x.add(h),n.y.add(d)).sub(.5).mul(e.xy),g=ne(n.x.add(u),n.y.add(d)).sub(.5).mul(e.xy),y=lN(a.y).mul(fr(o.mul(t.sample(m).level(r)),l.mul(t.sample(p).level(r)))),T=uN(a.y).mul(fr(o.mul(t.sample(f).level(r)),l.mul(t.sample(g).level(r))));return y.add(T)},ole=z(([t,e=C(3)])=>{const r=ne(t.size(P(e))),i=ne(t.size(P(e.add(1)))),s=qn(1,r),n=qn(1,i),a=dN(t,Oe(s,r),zn(e)),o=dN(t,Oe(n,i),Ty(e));return Ha(e).mix(a,o)});B(.04);C(1);const mN=C(1),u1=C(-2),cf=C(.8),Mx=C(-1),df=C(.4),_x=C(2),mf=C(.305),Nx=C(3),pN=C(.21),lle=C(4),fN=C(4),ule=C(16),hle=z(([t])=>{const e=B(Vt(t)).toVar(),r=C(-1).toVar();return je(e.x.greaterThan(e.z),()=>{je(e.x.greaterThan(e.y),()=>{r.assign(yi(t.x.greaterThan(0),0,3))}).Else(()=>{r.assign(yi(t.y.greaterThan(0),1,4))})}).Else(()=>{je(e.z.greaterThan(e.y),()=>{r.assign(yi(t.z.greaterThan(0),2,5))}).Else(()=>{r.assign(yi(t.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),cle=z(([t,e])=>{const r=ne().toVar();return je(e.equal(0),()=>{r.assign(ne(t.z,t.y).div(Vt(t.x)))}).ElseIf(e.equal(1),()=>{r.assign(ne(t.x.negate(),t.z.negate()).div(Vt(t.y)))}).ElseIf(e.equal(2),()=>{r.assign(ne(t.x.negate(),t.y).div(Vt(t.z)))}).ElseIf(e.equal(3),()=>{r.assign(ne(t.z.negate(),t.y).div(Vt(t.x)))}).ElseIf(e.equal(4),()=>{r.assign(ne(t.x.negate(),t.z).div(Vt(t.y)))}).Else(()=>{r.assign(ne(t.x,t.y).div(Vt(t.z)))}),ke(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),dle=z(([t])=>{const e=C(0).toVar();return je(t.greaterThanEqual(cf),()=>{e.assign(mN.sub(t).mul(Mx.sub(u1)).div(mN.sub(cf)).add(u1))}).ElseIf(t.greaterThanEqual(df),()=>{e.assign(cf.sub(t).mul(_x.sub(Mx)).div(cf.sub(df)).add(Mx))}).ElseIf(t.greaterThanEqual(mf),()=>{e.assign(df.sub(t).mul(Nx.sub(_x)).div(df.sub(mf)).add(_x))}).ElseIf(t.greaterThanEqual(pN),()=>{e.assign(mf.sub(t).mul(lle.sub(Nx)).div(mf.sub(pN)).add(Nx))}).Else(()=>{e.assign(C(-2).mul(Pa(ke(1.16,t))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),AV=z(([t,e])=>{const r=t.toVar();r.assign(ke(2,r).sub(1));const i=B(r,1).toVar();return je(e.equal(0),()=>{i.assign(i.zyx)}).ElseIf(e.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),CV=z(([t,e,r,i,s,n])=>{const a=C(r),o=B(e),l=Ba(dle(a),u1,n),h=Ha(l),u=zn(l),c=B(h1(t,o,u,i,s,n)).toVar();return je(h.notEqual(0),()=>{const d=B(h1(t,o,u.add(1),i,s,n)).toVar();c.assign(ur(c,d,h))}),c}),h1=z(([t,e,r,i,s,n])=>{const a=C(r).toVar(),o=B(e),l=C(hle(o)).toVar(),h=C(Gr(fN.sub(a),0)).toVar();a.assign(Gr(a,fN));const u=C(wc(a)).toVar(),c=ne(cle(o,l).mul(u.sub(2)).add(1)).toVar();return je(l.greaterThan(2),()=>{c.y.addAssign(u),l.subAssign(3)}),c.x.addAssign(l.mul(u)),c.x.addAssign(h.mul(ke(3,ule))),c.y.addAssign(ke(4,wc(n).sub(u))),c.x.mulAssign(i),c.y.mulAssign(s),t.sample(c).grad(ne(),ne())}),Ex=z(({envMap:t,mipInt:e,outputDirection:r,theta:i,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=ga(i),h=r.mul(l).add(s.cross(r).mul(cs(i))).add(s.mul(s.dot(r).mul(l.oneMinus())));return h1(t,h,e,n,a,o)}),RV=z(({n:t,latitudinal:e,poleAxis:r,outputDirection:i,weights:s,samples:n,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})=>{const d=B(yi(e,r,Sy(r,i))).toVar();je(d.equal(B(0)),()=>{d.assign(B(i.z,0,i.x.negate()))}),d.assign(Wu(d));const m=B().toVar();return m.addAssign(s.element(0).mul(Ex({theta:0,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),Et({start:P(1),end:t},({i:p})=>{je(p.greaterThanEqual(n),()=>{dV()});const f=C(a.mul(C(p))).toVar();m.addAssign(s.element(p).mul(Ex({theta:f.mul(-1),axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),m.addAssign(s.element(p).mul(Ex({theta:f,axis:d,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})))}),Oe(m,1)}),Xh=4,gN=[.125,.215,.35,.446,.526,.582],yl=20,Ax=new d3(-1,1,1,-1,0,1),mle=new mK(90,1),yN=new ja;let Cx=null,Rx=0,Px=0;const dl=(1+Math.sqrt(5))/2,Ah=1/dl,xN=[new $(-dl,Ah,0),new $(dl,Ah,0),new $(-Ah,0,dl),new $(Ah,0,dl),new $(0,dl,-Ah),new $(0,dl,Ah),new $(-1,1,-1),new $(1,1,-1),new $(-1,1,1),new $(1,1,1)],ple=new $,PV=new WeakMap,fle=[3,1,5,0,4,2],Ix=AV(jt(),Bo("faceIndex")).normalize(),ew=B(Ix.x,Ix.y,Ix.z);class gle{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,r=0,i=.1,s=100,n={}){const{size:a=256,position:o=ple,renderTarget:l=null}=n;if(this._setSize(a),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const u=l||this._allocateTarget();return n.renderTarget=u,this.fromSceneAsync(e,r,i,s,n),u}Cx=this._renderer.getRenderTarget(),Rx=this._renderer.getActiveCubeFace(),Px=this._renderer.getActiveMipmapLevel();const h=l||this._allocateTarget();return h.depthBuffer=!0,this._init(h),this._sceneToCubeUV(e,i,s,h,o),r>0&&this._blur(h,0,0,r),this._applyPMREM(h),this._cleanup(h),h}async fromSceneAsync(e,r=0,i=.1,s=100,n={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,r,i,s,n)}fromEquirectangular(e,r=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const i=r||this._allocateTarget();return this.fromEquirectangularAsync(e,i),i}return this._fromTexture(e,r)}async fromEquirectangularAsync(e,r=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,r)}fromCubemap(e,r=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const i=r||this._allocateTarget();return this.fromCubemapAsync(e,r),i}return this._fromTexture(e,r)}async fromCubemapAsync(e,r=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,r)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=vN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=TN(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===ag||e.mapping===Ob?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Cx,Rx,Px),e.scissorTest=!1,pf(e,0,0,e.width,e.height)}_fromTexture(e,r){this._setSizeFromTexture(e),Cx=this._renderer.getRenderTarget(),Rx=this._renderer.getActiveCubeFace(),Px=this._renderer.getActiveMipmapLevel();const i=r||this._allocateTarget();return this._init(i),this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),r=4*this._cubeSize;return bN(e,r)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bN(e.width,e.height);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=yle(r)),this._blurMaterial=xle(r,e.width,e.height)}}async _compileMaterial(e){const r=new cg(this._lodPlanes[0],e);await this._renderer.compile(r,Ax)}_sceneToCubeUV(e,r,i,s,n){const a=mle;a.near=r,a.far=i;const o=[1,1,1,1,-1,1],l=[1,-1,1,-1,1,-1],h=this._renderer,u=h.autoClear;h.getClearColor(yN),h.autoClear=!1;let c=this._backgroundBox;if(c===null){const p=new l3({name:"PMREM.Background",side:oy,depthWrite:!1,depthTest:!1});c=new cg(new Xv,p)}let d=!1;const m=e.background;m?m.isColor&&(c.material.color.copy(m),e.background=null,d=!0):(c.material.color.copy(yN),d=!0),h.setRenderTarget(s),h.clear(),d&&h.render(c,a);for(let p=0;p<6;p++){const f=p%3;f===0?(a.up.set(0,o[p],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x+l[p],n.y,n.z)):f===1?(a.up.set(0,0,o[p]),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y+l[p],n.z)):(a.up.set(0,o[p],0),a.position.set(n.x,n.y,n.z),a.lookAt(n.x,n.y,n.z+l[p]));const g=this._cubeSize;pf(s,f*g,p>2?g:0,g,g),h.render(e,a)}h.autoClear=u,e.background=m}_textureToCubeUV(e,r){const i=this._renderer,s=e.mapping===ag||e.mapping===Ob;s?this._cubemapMaterial===null&&(this._cubemapMaterial=vN(e)):this._equirectMaterial===null&&(this._equirectMaterial=TN(e));const n=s?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=n;const o=this._cubeSize;pf(r,0,0,3*o,2*o),i.setRenderTarget(r),i.render(a,Ax)}_applyPMREM(e){const r=this._renderer,i=r.autoClear;r.autoClear=!1;const s=this._lodPlanes.length;for(let n=1;n<s;n++){const a=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),o=xN[(s-n-1)%xN.length];this._blur(e,n-1,n,a,o)}r.autoClear=i}_blur(e,r,i,s,n){const a=this._pingPongRenderTarget;this._halfBlur(e,a,r,i,s,"latitudinal",n),this._halfBlur(a,e,i,i,s,"longitudinal",n)}_halfBlur(e,r,i,s,n,a,o){const l=this._renderer,h=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,c=this._lodMeshes[s];c.material=h;const d=PV.get(h),m=this._sizeLods[i]-1,p=isFinite(n)?Math.PI/(2*m):2*Math.PI/(2*yl-1),f=n/p,g=isFinite(n)?1+Math.floor(u*f):yl;g>yl&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${yl}`);const y=[];let T=0;for(let N=0;N<yl;++N){const A=N/f,k=Math.exp(-A*A/2);y.push(k),N===0?T+=k:N<g&&(T+=2*k)}for(let N=0;N<y.length;N++)y[N]=y[N]/T;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=g,d.weights.array=y,d.latitudinal.value=a==="latitudinal"?1:0,o&&(d.poleAxis.value=o);const{_lodMax:M}=this;d.dTheta.value=p,d.mipInt.value=M-i;const w=this._sizeLods[s],_=3*w*(s>M-Xh?s-M+Xh:0),S=4*(this._cubeSize-w);pf(r,_,S,3*w,2*w),l.setRenderTarget(r),l.render(c,Ax)}}function yle(t){const e=[],r=[],i=[],s=[];let n=t;const a=t-Xh+1+gN.length;for(let o=0;o<a;o++){const l=Math.pow(2,n);r.push(l);let h=1/l;o>t-Xh?h=gN[o-t+Xh-1]:o===0&&(h=0),i.push(h);const u=1/(l-2),c=-u,d=1+u,m=[c,c,d,c,d,d,c,c,d,d,c,d],p=6,f=6,g=3,y=2,T=1,M=new Float32Array(g*f*p),w=new Float32Array(y*f*p),_=new Float32Array(T*f*p);for(let N=0;N<p;N++){const A=N%3*2/3-1,k=N>2?0:-1,Q=[A,k,0,A+2/3,k,0,A+2/3,k+1,0,A,k,0,A+2/3,k+1,0,A,k+1,0],J=fle[N];M.set(Q,g*f*J),w.set(m,y*f*J);const re=[J,J,J,J,J,J];_.set(re,T*f*J)}const S=new Cc;S.setAttribute("position",new Bs(M,g)),S.setAttribute("uv",new Bs(w,y)),S.setAttribute("faceIndex",new Bs(_,T)),e.push(S),s.push(new cg(S,null)),n>Xh&&n--}return{lodPlanes:e,sizeLods:r,sigmas:i,lodMeshes:s}}function bN(t,e){const r={magFilter:ps,minFilter:ps,generateMipmaps:!1,type:wo,format:jv,colorSpace:lg},i=new Nm(t,e,r);return i.texture.mapping=MJ,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function pf(t,e,r,i,s){t.viewport.set(e,r,i,s),t.scissor.set(e,r,i,s)}function tw(t){const e=new Sc;return e.depthTest=!1,e.depthWrite=!1,e.blending=wJ,e.name=`PMREM_${t}`,e}function xle(t,e,r){const i=dn(new Array(yl).fill(0)),s=Pe(new $(0,1,0)),n=Pe(0),a=C(yl),o=Pe(0),l=Pe(1),h=_t(null),u=Pe(0),c=C(1/e),d=C(1/r),m=C(t),p={n:a,latitudinal:o,weights:i,poleAxis:s,outputDirection:ew,dTheta:n,samples:l,envMap:h,mipInt:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:m},f=tw("blur");return f.fragmentNode=RV({...p,latitudinal:o.equal(1)}),PV.set(f,p),f}function vN(t){const e=tw("cubemap");return e.fragmentNode=HT(t,ew),e}function TN(t){const e=tw("equirect");return e.fragmentNode=_t(t,TV(ew),0),e}const wN=new WeakMap;function ble(t){const e=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:r,maxMip:e}}function vle(t,e,r){const i=Tle(e);let s=i.get(t);if((s!==void 0?s.pmremVersion:-1)!==t.pmremVersion){const a=t.image;if(t.isCubeTexture)if(Sle(a))s=r.fromCubemap(t,s);else return null;else if(Mle(a))s=r.fromEquirectangular(t,s);else return null;s.pmremVersion=t.pmremVersion,i.set(t,s)}return s.texture}function Tle(t){let e=wN.get(t);return e===void 0&&(e=new WeakMap,wN.set(t,e)),e}class wle extends xr{static get type(){return"PMREMNode"}constructor(e,r=null,i=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=r,this.levelNode=i,this._generator=null;const s=new vi;s.isRenderTargetTexture=!0,this._texture=_t(s),this._width=Pe(0),this._height=Pe(0),this._maxMip=Pe(0),this.updateBeforeType=Tt.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const r=ble(e.image.height);this._texture.value=e,this._width.value=r.texelWidth,this._height.value=r.texelHeight,this._maxMip.value=r.maxMip}updateBefore(e){let r=this._pmrem;const i=r?r.pmremVersion:-1,s=this._value;i!==s.pmremVersion&&(s.isPMREMTexture===!0?r=s:r=vle(s,e.renderer,this._generator),r!==null&&(this._pmrem=r,this.updateFromTexture(r)))}setup(e){this._generator===null&&(this._generator=new gle(e.renderer)),this.updateBefore(e);let r=this.uvNode;r===null&&e.context.getUV&&(r=e.context.getUV(this)),r=jT.mul(B(r.x,r.y.negate(),r.z));let i=this.levelNode;return i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),CV(this._texture,r,i,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function Sle(t){if(t==null)return!1;let e=0;const r=6;for(let i=0;i<r;i++)t[i]!==void 0&&e++;return e===r}function Mle(t){return t==null?!1:t.height>0}const _le=Z(wle).setParameterLength(1,3);class Nle extends xr{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=B(ms.z,0,ms.x.negate()).normalize(),r=ms.cross(e);return ne(e.dot(Da),r.dot(Da)).mul(.495).add(.5)}}const Ele=ue(Nle);class Ale extends xr{static get type(){return"RotateNode"}constructor(e,r){super(),this.positionNode=e,this.rotationNode=r}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:r,positionNode:i}=this;if(this.getNodeType(e)==="vec2"){const n=r.cos(),a=r.sin();return by(n,a,a.negate(),n).mul(i)}else{const n=r,a=_u(Oe(1,0,0,0),Oe(0,ga(n.x),cs(n.x).negate(),0),Oe(0,cs(n.x),ga(n.x),0),Oe(0,0,0,1)),o=_u(Oe(ga(n.y),0,cs(n.y),0),Oe(0,1,0,0),Oe(cs(n.y).negate(),0,ga(n.y),0),Oe(0,0,0,1)),l=_u(Oe(ga(n.z),cs(n.z).negate(),0,0),Oe(cs(n.z),ga(n.z),0,0),Oe(0,0,1,0),Oe(0,0,0,1));return a.mul(o).mul(l).mul(Oe(i,1)).xyz}}}const IV=Z(Ale).setParameterLength(2);Ic("vec3");Ic("vec3");Ic("vec3");class Cle{constructor(){this.weakMap=new WeakMap}get(e){let r=this.weakMap;for(let i=0;i<e.length-1;i++)if(r=r.get(e[i]),r===void 0)return;return r.get(e[e.length-1])}set(e,r){let i=this.weakMap;for(let s=0;s<e.length-1;s++){const n=e[s];i.has(n)===!1&&i.set(n,new WeakMap),i=i.get(n)}return i.set(e[e.length-1],r),this}delete(e){let r=this.weakMap;for(let i=0;i<e.length-1;i++)if(r=r.get(e[i]),r===void 0)return!1;return r.delete(e[e.length-1])}}class Rle extends gt{static get type(){return"ParameterNode"}constructor(e,r=null){super(e,r),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ple=(t,e)=>X(new Rle(t,e));class Ile extends Ae{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,r){return this.outputNode?this.outputNode.getMemberType(e,r):"void"}add(e){return this.nodes.push(e),this}If(e,r){const i=new qh(r);return this._currentCond=yi(e,i),this.add(this._currentCond)}ElseIf(e,r){const i=new qh(r),s=yi(e,i);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new qh(e),this}Switch(e){return this._expressionNode=X(e),this}Case(...e){const r=[];if(e.length>=2)for(let o=0;o<e.length-1;o++)r.push(this._expressionNode.equal(X(e[o])));else throw new Error("TSL: Invalid parameter length. Case() requires at least two parameters.");const i=e[e.length-1],s=new qh(i);let n=r[0];for(let o=1;o<r.length;o++)n=n.or(r[o]);const a=yi(n,s);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...r){const i=G5();t1(this);const s=e.buildStage;for(const n of this.nodes)if(s==="setup")n.build(e);else if(s==="analyze")n.build(e,this);else if(s==="generate"){const a=e.getDataFromNode(n,"any").stages,o=a&&a[e.shaderStage];if(n.isVarNode&&o&&o.length===1&&o[0]&&o[0].isStackNode)continue;n.build(e,"void")}return t1(i),this.outputNode?this.outputNode.build(e,...r):super.build(e,...r)}else(...e){return console.warn("THREE.TSL: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("THREE.TSL: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Vle=Z(Ile).setParameterLength(0,1);function Ole(t){return Object.entries(t).map(([e,r])=>typeof r=="string"?{name:e,type:r,atomic:!1}:{name:e,type:r.type,atomic:r.atomic||!1})}class Lle extends Ae{static get type(){return"StructTypeNode"}constructor(e,r=null){super("struct"),this.membersLayout=Ole(e),this.name=r,this.isStructLayoutNode=!0}getLength(){const r=Float32Array.BYTES_PER_ELEMENT;let i=0;for(const s of this.membersLayout){const n=s.type,a=Mse(n)*r,o=_se(n),l=i%8,h=l%o,u=l+h;i+=h,u!==0&&8-u<a&&(i+=8-u),i+=a}return Math.ceil(i/8)*8/r}getMemberType(e,r){const i=this.membersLayout.find(s=>s.name===r);return i?i.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Fle extends Ae{static get type(){return"StructNode"}constructor(e,r){super("vec3"),this.structLayoutNode=e,this.values=r,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,r){return this.structLayoutNode.getMemberType(e,r)}generate(e){const r=e.getVarFromNode(this),i=r.type,s=e.getPropertyName(r);return e.addLineFlowCode(`${s} = ${e.generateStruct(i,this.structLayoutNode.membersLayout,this.values)}`,this),r.name}}const zle=(t,e=null)=>{const r=new Lle(t,e),i=(...s)=>{let n=null;if(s.length>0)if(s[0].isNode){n={};const a=Object.keys(t);for(let o=0;o<s.length;o++)n[a[o]]=s[o]}else n=s[0];return X(new Fle(r,n))};return i.layout=r,i.isStruct=!0,i};class VV extends Ae{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const r=e.getNodeProperties(this);if(r.membersLayout===void 0){const i=this.members,s=[];for(let n=0;n<i.length;n++){const a="m"+n,o=i[n].getNodeType(e);s.push({name:a,type:o,index:n})}r.membersLayout=s,r.structType=e.getOutputStructTypeFromNode(this,r.membersLayout)}return r.structType.name}generate(e){const r=e.getOutputStructName(),i=this.members,s=r!==""?r+".":"";for(let n=0;n<i.length;n++){const a=i[n].build(e);e.addLineFlowCode(`${s}m${n} = ${a}`,this)}return r}}const Ble=Z(VV);function OV(t,e){for(let r=0;r<t.length;r++)if(t[r].name===e)return r;return-1}class kle extends VV{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const r={...this.outputNodes,...e.outputNodes};return LV(r)}setup(e){const r=this.outputNodes,i=e.renderer.getRenderTarget(),s=[],n=i.textures;for(const a in r){const o=OV(n,a);s[o]=Oe(r[a])}return this.members=s,super.setup(e)}}const LV=Z(kle),Ule=z(([t])=>{const e=t.toUint().mul(747796405).add(2891336453),r=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return r.shiftRight(22).bitXor(r).toFloat().mul(1/2**32)}),c1=(t,e)=>pn(ke(4,t.mul(it(1,t))),e),Dle=(t,e)=>t.lessThan(.5)?c1(t.mul(2),e).div(2):it(1,c1(ke(it(1,t),2),e).div(2)),$le=(t,e,r)=>pn(qn(pn(t,e),fr(pn(t,e),pn(it(1,t),r))),1/e),Gle=(t,e)=>cs(bg.mul(e.mul(t).sub(1))).div(bg.mul(e.mul(t).sub(1))),ya=z(([t])=>t.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),jle=z(([t])=>B(ya(t.z.add(ya(t.y.mul(1)))),ya(t.z.add(ya(t.x.mul(1)))),ya(t.y.add(ya(t.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wle=z(([t,e,r])=>{const i=B(t).toVar(),s=C(1.4).toVar(),n=C(0).toVar(),a=B(i).toVar();return Et({start:C(0),end:C(3),type:"float",condition:"<="},()=>{const o=B(jle(a.mul(2))).toVar();i.addAssign(o.add(r.mul(C(.1).mul(e)))),a.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);const l=C(ya(i.z.add(ya(i.x.add(ya(i.y)))))).toVar();n.addAssign(l.div(s)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Hle extends Ae{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...r){super(),this.functionNodes=e,this.parametersNodes=r,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const r=this.parametersNodes;let i=this._candidateFnCall;if(i===null){let s=null,n=-1;for(const a of this.functionNodes){const l=a.shaderNode.layout;if(l===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=l.inputs;if(r.length===h.length){let u=0;for(let c=0;c<r.length;c++){const d=r[c],m=h[c];d.getNodeType(e)===m.type?u++:u=0}u>n&&(s=a,n=u)}}this._candidateFnCall=i=s(...r)}return i}}const qle=Z(Hle),li=t=>(...e)=>qle(t,...e),Hu=Pe(0).setGroup(Ye).onRenderUpdate(t=>t.time),FV=Pe(0).setGroup(Ye).onRenderUpdate(t=>t.deltaTime),Xle=Pe(0,"uint").setGroup(Ye).onRenderUpdate(t=>t.frameId),Yle=(t=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),Hu.mul(t)),Zle=(t=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),Hu.mul(t)),Jle=(t=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),FV.mul(t)),Kle=(t=Hu)=>t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Qle=(t=Hu)=>t.fract().round(),eue=(t=Hu)=>t.add(.5).fract().mul(2).sub(1).abs(),tue=(t=Hu)=>t.fract(),rue=z(([t,e,r=ne(.5)])=>IV(t.sub(r),e).add(r)),iue=z(([t,e,r=ne(.5)])=>{const i=t.sub(r),s=i.dot(i),a=s.mul(s).mul(e);return t.add(i.mul(a))}),sue=z(({position:t=null,horizontal:e=!0,vertical:r=!1})=>{let i;t!==null?(i=Ta.toVar(),i[3][0]=t.x,i[3][1]=t.y,i[3][2]=t.z):i=Ta;const s=Zs.mul(i);return am(e)&&(s[0][0]=Ta[0].length(),s[0][1]=0,s[0][2]=0),am(r)&&(s[1][0]=0,s[1][1]=Ta[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,Um.mul(s).mul(cr)}),nue=z(([t=null])=>{const e=Mg();return Mg(ZT(t)).sub(e).lessThan(0).select(jo,t)});class aue extends Ae{static get type(){return"SpriteSheetUVNode"}constructor(e,r=jt(),i=C(0)){super("vec2"),this.countNode=e,this.uvNode=r,this.frameNode=i}setup(){const{frameNode:e,uvNode:r,countNode:i}=this,{width:s,height:n}=i,a=e.mod(s.mul(n)).floor(),o=a.mod(s),l=n.sub(a.add(1).div(s).ceil()),h=i.reciprocal(),u=ne(o,l);return r.add(u).mul(h)}}const oue=Z(aue).setParameterLength(3);class lue extends Ae{static get type(){return"TriplanarTexturesNode"}constructor(e,r=null,i=null,s=C(1),n=cr,a=qi){super("vec4"),this.textureXNode=e,this.textureYNode=r,this.textureZNode=i,this.scaleNode=s,this.positionNode=n,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:r,textureZNode:i,scaleNode:s,positionNode:n,normalNode:a}=this;let o=a.abs().normalize();o=o.div(o.dot(B(1)));const l=n.yz.mul(s),h=n.zx.mul(s),u=n.xy.mul(s),c=e.value,d=r!==null?r.value:c,m=i!==null?i.value:c,p=_t(c,l).mul(o.x),f=_t(d,h).mul(o.y),g=_t(m,u).mul(o.z);return fr(p,f,g)}}const zV=Z(lue).setParameterLength(1,6),uue=(...t)=>zV(...t),Ch=new yK,nl=new $,Rh=new $,Vx=new $,ld=new Rt,ff=new $(0,0,-1),En=new Si,ud=new $,gf=new $,hd=new Si,yf=new Jt,_g=new Nm,hue=jo.flipX();_g.depthTexture=new Am(1,1);let xf=!1;class rw extends Ua{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||_g.texture,hue),this._reflectorBaseNode=e.reflector||new cue(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=X(new rw({defaultTexture:_g.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class cue extends Ae{static get type(){return"ReflectorBaseNode"}constructor(e,r={}){super();const{target:i=new yn,resolution:s=1,generateMipmaps:n=!1,bounces:a=!0,depth:o=!1}=r;this.textureNode=e,this.target=i,this.resolution=s,this.generateMipmaps=n,this.bounces=a,this.depth=o,this.updateBeforeType=a?Tt.RENDER:Tt.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,r){const i=this.resolution;r.getDrawingBufferSize(yf),e.setSize(Math.round(yf.width*i),Math.round(yf.height*i))}setup(e){return this._updateResolution(_g,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let r=this.virtualCameras.get(e);return r===void 0&&(r=e.clone(),this.virtualCameras.set(e,r)),r}getRenderTarget(e){let r=this.renderTargets.get(e);return r===void 0&&(r=new Nm(0,0,{type:wo}),this.generateMipmaps===!0&&(r.texture.minFilter=_J,r.texture.generateMipmaps=!0),this.depth===!0&&(r.depthTexture=new Am),this.renderTargets.set(e,r)),r}updateBefore(e){if(this.bounces===!1&&xf)return!1;xf=!0;const{scene:r,camera:i,renderer:s,material:n}=e,{target:a}=this,o=this.getVirtualCamera(i),l=this.getRenderTarget(o);s.getDrawingBufferSize(yf),this._updateResolution(l,s),Rh.setFromMatrixPosition(a.matrixWorld),Vx.setFromMatrixPosition(i.matrixWorld),ld.extractRotation(a.matrixWorld),nl.set(0,0,1),nl.applyMatrix4(ld),ud.subVectors(Rh,Vx);const h=ud.dot(nl)>0;let u=!1;if(h===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){xf=!1;return}u=!0}ud.reflect(nl).negate(),ud.add(Rh),ld.extractRotation(i.matrixWorld),ff.set(0,0,-1),ff.applyMatrix4(ld),ff.add(Vx),gf.subVectors(Rh,ff),gf.reflect(nl).negate(),gf.add(Rh),o.coordinateSystem=i.coordinateSystem,o.position.copy(ud),o.up.set(0,1,0),o.up.applyMatrix4(ld),o.up.reflect(nl),o.lookAt(gf),o.near=i.near,o.far=i.far,o.updateMatrixWorld(),o.projectionMatrix.copy(i.projectionMatrix),Ch.setFromNormalAndCoplanarPoint(nl,Rh),Ch.applyMatrix4(o.matrixWorldInverse),En.set(Ch.normal.x,Ch.normal.y,Ch.normal.z,Ch.constant);const c=o.projectionMatrix;hd.x=(Math.sign(En.x)+c.elements[8])/c.elements[0],hd.y=(Math.sign(En.y)+c.elements[9])/c.elements[5],hd.z=-1,hd.w=(1+c.elements[10])/c.elements[14],En.multiplyScalar(1/En.dot(hd));const d=0;c.elements[2]=En.x,c.elements[6]=En.y,c.elements[10]=s.coordinateSystem===Ru?En.z-d:En.z+1-d,c.elements[14]=En.w,this.textureNode.value=l.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=l.depthTexture),n.visible=!1;const m=s.getRenderTarget(),p=s.getMRT(),f=s.autoClear;s.setMRT(null),s.setRenderTarget(l),s.autoClear=!0,u?(s.clear(),this.hasOutput=!1):(s.render(r,o),this.hasOutput=!0),s.setMRT(p),s.setRenderTarget(m),s.autoClear=f,n.visible=!0,xf=!1,this.forceUpdate=!1}}const due=t=>X(new rw(t)),Ox=new d3(-1,1,1,-1,0,1);class mue extends Cc{constructor(e=!1){super();const r=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new rc([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new rc(r,2))}}const pue=new mue;class BV extends cg{constructor(e=null){super(pue,e),this.camera=Ox,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,Ox)}render(e){e.render(this,Ox)}}const fue=new Jt;class gue extends Ua{static get type(){return"RTTNode"}constructor(e,r=null,i=null,s={type:wo}){const n=new Nm(r,i,s);super(n.texture,jt()),this.node=e,this.width=r,this.height=i,this.pixelRatio=1,this.renderTarget=n,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new BV(new Sc),this.updateBeforeType=Tt.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,r){this.width=e,this.height=r;const i=e*this.pixelRatio,s=r*this.pixelRatio;this.renderTarget.setSize(i,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const i=e.getSize(fue);this.setSize(i.width,i.height)}this._quadMesh.material.fragmentNode=this._rttNode;const r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(r)}clone(){const e=new Ua(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const kV=(t,...e)=>X(new gue(X(t),...e)),yue=(t,...e)=>t.isTextureNode?t:t.isPassNode?t.getTextureNode():kV(t,...e),Bh=z(([t,e,r],i)=>{let s;i.renderer.coordinateSystem===Ru?(t=ne(t.x,t.y.oneMinus()).mul(2).sub(1),s=Oe(B(t,e),1)):s=Oe(B(t.x,t.y.oneMinus(),e).mul(2).sub(1),1);const n=Oe(r.mul(s));return n.xyz.div(n.w)}),xue=z(([t,e])=>{const r=e.mul(Oe(t,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return ne(i.x,i.y.oneMinus())}),bue=z(([t,e,r])=>{const i=Ro(tr(e)),s=kr(t.mul(i)).toVar(),n=tr(e,s).toVar(),a=tr(e,s.sub(kr(2,0))).toVar(),o=tr(e,s.sub(kr(1,0))).toVar(),l=tr(e,s.add(kr(1,0))).toVar(),h=tr(e,s.add(kr(2,0))).toVar(),u=tr(e,s.add(kr(0,2))).toVar(),c=tr(e,s.add(kr(0,1))).toVar(),d=tr(e,s.sub(kr(0,1))).toVar(),m=tr(e,s.sub(kr(0,2))).toVar(),p=Vt(it(C(2).mul(o).sub(a),n)).toVar(),f=Vt(it(C(2).mul(l).sub(h),n)).toVar(),g=Vt(it(C(2).mul(c).sub(u),n)).toVar(),y=Vt(it(C(2).mul(d).sub(m),n)).toVar(),T=Bh(t,n,r).toVar(),M=p.lessThan(f).select(T.sub(Bh(t.sub(ne(C(1).div(i.x),0)),o,r)),T.negate().add(Bh(t.add(ne(C(1).div(i.x),0)),l,r))),w=g.lessThan(y).select(T.sub(Bh(t.add(ne(0,C(1).div(i.y))),c,r)),T.negate().add(Bh(t.sub(ne(0,C(1).div(i.y))),d,r)));return Wu(Sy(M,w))});class vue extends ic{constructor(e,r,i=Float32Array){const s=ArrayBuffer.isView(e)?e:new i(e*r);super(s,r),this.isStorageInstancedBufferAttribute=!0}}class Tue extends Bs{constructor(e,r,i=Float32Array){const s=ArrayBuffer.isView(e)?e:new i(e*r);super(s,r),this.isStorageBufferAttribute=!0}}const wue=(t,e="float")=>{let r,i;e.isStruct===!0?(r=e.layout.getLength(),i=xg("float")):(r=I5(e),i=xg(e));const s=new Tue(t,r,i);return Eu(s,e,t)},Sue=(t,e="float")=>{let r,i;e.isStruct===!0?(r=e.layout.getLength(),i=xg("float")):(r=I5(e),i=xg(e));const s=new vue(t,r,i);return Eu(s,e,t)};class Mue extends Ae{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const _ue=ue(Mue),cd=new $u,Lx=new Rt;class ji extends Ae{static get type(){return"SceneNode"}constructor(e=ji.BACKGROUND_BLURRINESS,r=null){super(),this.scope=e,this.scene=r}setup(e){const r=this.scope,i=this.scene!==null?this.scene:e.scene;let s;return r===ji.BACKGROUND_BLURRINESS?s=Zt("backgroundBlurriness","float",i):r===ji.BACKGROUND_INTENSITY?s=Zt("backgroundIntensity","float",i):r===ji.BACKGROUND_ROTATION?s=Pe("mat4").label("backgroundRotation").setGroup(Ye).onRenderUpdate(()=>{const n=i.background;return n!==null&&n.isTexture&&n.mapping!==Gv?(cd.copy(i.backgroundRotation),cd.x*=-1,cd.y*=-1,cd.z*=-1,Lx.makeRotationFromEuler(cd)):Lx.identity(),Lx}):console.error("THREE.SceneNode: Unknown scope:",r),s}}ji.BACKGROUND_BLURRINESS="backgroundBlurriness";ji.BACKGROUND_INTENSITY="backgroundIntensity";ji.BACKGROUND_ROTATION="backgroundRotation";const Nue=ue(ji,ji.BACKGROUND_BLURRINESS),Eue=ue(ji,ji.BACKGROUND_INTENSITY),Aue=ue(ji,ji.BACKGROUND_ROTATION);class Cue extends Ua{static get type(){return"StorageTextureNode"}constructor(e,r,i=null){super(e,r),this.storeNode=i,this.isStorageTextureNode=!0,this.access=Rn.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const r=e.getNodeProperties(this);return r.storeNode=this.storeNode,r}setAccess(e){return this.access=e,this}generate(e,r){let i;return this.storeNode!==null?i=this.generateStore(e):i=super.generate(e,r),i}toReadWrite(){return this.setAccess(Rn.READ_WRITE)}toReadOnly(){return this.setAccess(Rn.READ_ONLY)}toWriteOnly(){return this.setAccess(Rn.WRITE_ONLY)}generateStore(e){const r=e.getNodeProperties(this),{uvNode:i,storeNode:s,depthNode:n}=r,a=super.generate(e,"property"),o=i.build(e,"uvec2"),l=s.build(e,"vec4"),h=n?n.build(e,"int"):null,u=e.generateTextureStore(e,a,o,h,l);e.addLineFlowCode(u,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e}}const UV=Z(Cue).setParameterLength(1,3),Rue=(t,e,r)=>{const i=UV(t,e,r);return r!==null&&i.toStack(),i},Pue=z(({texture:t,uv:e})=>{const i=B().toVar();return je(e.x.lessThan(1e-4),()=>{i.assign(B(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{i.assign(B(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{i.assign(B(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{i.assign(B(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{i.assign(B(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{i.assign(B(0,0,-1))}).Else(()=>{const n=t.sample(e.add(B(-.01,0,0))).r.sub(t.sample(e.add(B(.01,0,0))).r),a=t.sample(e.add(B(0,-.01,0))).r.sub(t.sample(e.add(B(0,.01,0))).r),o=t.sample(e.add(B(0,0,-.01))).r.sub(t.sample(e.add(B(0,0,.01))).r);i.assign(B(n,a,o))}),i.normalize()});class Iue extends Ua{static get type(){return"Texture3DNode"}constructor(e,r=null,i=null){super(e,r,i),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return B(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,r){const i=this.value;return e.isFlipY()&&(i.isRenderTargetTexture===!0||i.isFramebufferTexture===!0)&&(this.sampler?r=r.flipY():r=r.setY(P(Ro(this,this.levelNode).y).sub(r.y).sub(1))),r}generateUV(e,r){return r.build(e,"vec3")}normal(e){return Pue({texture:this,uv:e})}}const Vue=Z(Iue).setParameterLength(1,3);class Oue extends Ny{static get type(){return"UserDataNode"}constructor(e,r,i=null){super(e,r,i),this.userData=i}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Lue=(t,e,r)=>X(new Oue(t,e,r)),SN=new WeakMap;class Fue extends xr{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Tt.OBJECT,this.updateAfterType=Tt.OBJECT,this.previousModelWorldMatrix=Pe(new Rt),this.previousProjectionMatrix=Pe(new Rt).setGroup(Ye),this.previousCameraViewMatrix=Pe(new Rt)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:r,object:i}){const s=MN(i);this.previousModelWorldMatrix.value.copy(s);const n=DV(r);n.frameId!==e&&(n.frameId=e,n.previousProjectionMatrix===void 0?(n.previousProjectionMatrix=new Rt,n.previousCameraViewMatrix=new Rt,n.currentProjectionMatrix=new Rt,n.currentCameraViewMatrix=new Rt,n.previousProjectionMatrix.copy(this.projectionMatrix||r.projectionMatrix),n.previousCameraViewMatrix.copy(r.matrixWorldInverse)):(n.previousProjectionMatrix.copy(n.currentProjectionMatrix),n.previousCameraViewMatrix.copy(n.currentCameraViewMatrix)),n.currentProjectionMatrix.copy(this.projectionMatrix||r.projectionMatrix),n.currentCameraViewMatrix.copy(r.matrixWorldInverse),this.previousProjectionMatrix.value.copy(n.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(n.previousCameraViewMatrix))}updateAfter({object:e}){MN(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Um:Pe(this.projectionMatrix),r=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),i=e.mul(Dm).mul(cr),s=this.previousProjectionMatrix.mul(r).mul(wg),n=i.xy.div(i.w),a=s.xy.div(s.w);return it(n,a)}}function DV(t){let e=SN.get(t);return e===void 0&&(e={},SN.set(t,e)),e}function MN(t,e=0){const r=DV(t);let i=r[e];return i===void 0&&(r[e]=i=new Rt,r[e].copy(t.matrixWorld)),i}const zue=ue(Fue),$V=z(([t,e])=>js(1,t.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),GV=z(([t,e])=>js(t.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),jV=z(([t,e])=>t.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),WV=z(([t,e])=>ur(t.mul(2).mul(e),t.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),wy(.5,t))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Bue=z(([t,e])=>{const r=e.a.add(t.a.mul(e.a.oneMinus()));return Oe(e.rgb.mul(e.a).add(t.rgb.mul(t.a).mul(e.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kue=z(([t])=>Oe(t.rgb.mul(t.a),t.a),{color:"vec4",return:"vec4"}),Uue=z(([t])=>(je(t.a.equal(0),()=>Oe(0)),Oe(t.rgb.div(t.a),t.a)),{color:"vec4",return:"vec4"}),Due=(...t)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),$V(t)),$ue=(...t)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),GV(t)),Gue=(...t)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),jV(t)),jue=(...t)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),WV(t)),Wue=z(([t])=>iw(t.rgb)),Hue=z(([t,e=C(1)])=>e.mix(iw(t.rgb),t.rgb)),que=z(([t,e=C(1)])=>{const r=fr(t.r,t.g,t.b).div(3),i=t.r.max(t.g.max(t.b)),s=i.sub(r).mul(e).mul(-3);return ur(t.rgb,i,s)}),Xue=z(([t,e=C(1)])=>{const r=B(.57735,.57735,.57735),i=e.cos();return B(t.rgb.mul(i).add(r.cross(t.rgb).mul(e.sin()).add(r.mul(Go(r,t.rgb).mul(i.oneMinus())))))}),iw=(t,e=B(or.getLuminanceCoefficients(new $)))=>Go(t,e),Yue=z(([t,e=B(1),r=B(0),i=B(1),s=C(1),n=B(or.getLuminanceCoefficients(new $,lg))])=>{const a=t.rgb.dot(B(n)),o=Gr(t.rgb.mul(e).add(r),0).toVar(),l=o.pow(i).toVar();return je(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),je(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),je(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(s))),Oe(o.rgb,t.a)});class Zue extends xr{static get type(){return"PosterizeNode"}constructor(e,r){super(),this.sourceNode=e,this.stepsNode=r}setup(){const{sourceNode:e,stepsNode:r}=this;return e.mul(r).floor().div(r)}}const Jue=Z(Zue).setParameterLength(2),bf=new Jt;class HV extends Ua{static get type(){return"PassTextureNode"}constructor(e,r){super(r),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class _N extends HV{static get type(){return"PassMultipleTextureNode"}constructor(e,r,i=!1){super(e,null),this.textureName=r,this.previousTexture=i}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Yn extends xr{static get type(){return"PassNode"}constructor(e,r,i,s={}){super("vec4"),this.scope=e,this.scene=r,this.camera=i,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const n=new Am;n.isRenderTargetTexture=!0,n.name="depth";const a=new Nm(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:wo,...s});a.texture.name="output",a.depthTexture=n,this.renderTarget=a,this._textures={output:a.texture,depth:n},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Pe(0),this._cameraFar=Pe(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=Tt.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let r=this._textures[e];return r===void 0&&(r=this.renderTarget.texture.clone(),r.name=e,this._textures[e]=r,this.renderTarget.textures.push(r)),r}getPreviousTexture(e){let r=this._previousTextures[e];return r===void 0&&(r=this.getTexture(e).clone(),this._previousTextures[e]=r),r}toggleTexture(e){const r=this._previousTextures[e];if(r!==void 0){const i=this._textures[e],s=this.renderTarget.textures.indexOf(i);this.renderTarget.textures[s]=r,this._textures[e]=r,this._previousTextures[e]=i,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let r=this._textureNodes[e];return r===void 0&&(r=X(new _N(this,e)),r.updateTexture(),this._textureNodes[e]=r),r}getPreviousTextureNode(e="output"){let r=this._previousTextureNodes[e];return r===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),r=X(new _N(this,e,!0)),r.updateTexture(),this._previousTextureNodes[e]=r),r}getViewZNode(e="depth"){let r=this._viewZNodes[e];if(r===void 0){const i=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=r=JT(this.getTextureNode(e),i,s)}return r}getLinearDepthNode(e="depth"){let r=this._linearDepthNodes[e];if(r===void 0){const i=this._cameraNear,s=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=r=lc(n,i,s)}return r}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=e.getColorBufferType(),this.scope===Yn.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:r}=e,{scene:i}=this;let s,n;const a=r.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(n=1,s=r.xr.getCamera(),r.xr.updateCamera(s),bf.set(a.width,a.height)):(s=this.camera,n=r.getPixelRatio(),r.getSize(bf)),this._pixelRatio=n,this.setSize(bf.width,bf.height);const o=r.getRenderTarget(),l=r.getMRT(),h=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const u in this._previousTextures)this.toggleTexture(u);r.setRenderTarget(this.renderTarget),r.setMRT(this._mrt),r.render(i,s),r.setRenderTarget(o),r.setMRT(l),s.layers.mask=h}setSize(e,r){this._width=e,this._height=r;const i=this._width*this._pixelRatio*this._resolution,s=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(i,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Yn.COLOR="color";Yn.DEPTH="depth";const Kue=(t,e,r)=>X(new Yn(Yn.COLOR,t,e,r)),Que=(t,e)=>X(new HV(t,e)),ehe=(t,e,r)=>X(new Yn(Yn.DEPTH,t,e,r));class the extends Yn{static get type(){return"ToonOutlinePassNode"}constructor(e,r,i,s,n){super(Yn.COLOR,e,r),this.colorNode=i,this.thicknessNode=s,this.alphaNode=n,this._materialCache=new WeakMap}updateBefore(e){const{renderer:r}=e,i=r.getRenderObjectFunction();r.setRenderObjectFunction((s,n,a,o,l,h,u,c)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const d=this._getOutlineMaterial(l);r.renderObject(s,n,a,o,d,h,u,c)}r.renderObject(s,n,a,o,l,h,u,c)}),super.updateBefore(e),r.setRenderObjectFunction(i)}_createMaterial(){const e=new Sc;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=oy;const r=qi.negate(),i=Um.mul(Dm),s=C(1),n=i.mul(Oe(cr,1)),a=i.mul(Oe(cr.add(r),1)),o=Wu(n.sub(a));return e.vertexNode=n.add(o.mul(this.thicknessNode).mul(n.w).mul(s)),e.colorNode=Oe(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let r=this._materialCache.get(e);return r===void 0&&(r=this._createMaterial(),this._materialCache.set(e,r)),r}}const rhe=(t,e,r=new ja(0,0,0),i=.003,s=1)=>X(new the(t,e,X(r),X(i),X(s))),ihe=z(([t,e])=>t.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),she=z(([t,e])=>(t=t.mul(e),t.div(t.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nhe=z(([t,e])=>{t=t.mul(e),t=t.sub(.004).max(0);const r=t.mul(t.mul(6.2).add(.5)),i=t.mul(t.mul(6.2).add(1.7)).add(.06);return r.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ahe=z(([t])=>{const e=t.mul(t.add(.0245786)).sub(90537e-9),r=t.mul(t.add(.432951).mul(.983729)).add(.238081);return e.div(r)}),ohe=z(([t,e])=>{const r=Gs(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=Gs(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return t=t.mul(e).div(.6),t=r.mul(t),t=ahe(t),t=i.mul(t),t.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),lhe=Gs(B(1.6605,-.1246,-.0182),B(-.5876,1.1329,-.1006),B(-.0728,-.0083,1.1187)),uhe=Gs(B(.6274,.0691,.0164),B(.3293,.9195,.088),B(.0433,.0113,.8956)),hhe=z(([t])=>{const e=B(t).toVar(),r=B(e.mul(e)).toVar(),i=B(r.mul(r)).toVar();return C(15.5).mul(i.mul(r)).sub(ke(40.14,i.mul(e))).add(ke(31.96,i).sub(ke(6.868,r.mul(e))).add(ke(.4298,r).add(ke(.1191,e).sub(.00232))))}),che=z(([t,e])=>{const r=B(t).toVar(),i=Gs(B(.856627153315983,.137318972929847,.11189821299995),B(.0951212405381588,.761241990602591,.0767994186031903),B(.0482516061458583,.101439036467562,.811302368396859)),s=Gs(B(1.1271005818144368,-.1413297634984383,-.14132976349843826),B(-.11060664309660323,1.157823702216272,-.11060664309660294),B(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=C(-12.47393),a=C(4.026069);return r.mulAssign(e),r.assign(uhe.mul(r)),r.assign(i.mul(r)),r.assign(Gr(r,1e-10)),r.assign(Pa(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(Ba(r,0,1)),r.assign(hhe(r)),r.assign(s.mul(r)),r.assign(pn(Gr(B(0),r),B(2.2))),r.assign(lhe.mul(r)),r.assign(Ba(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),dhe=z(([t,e])=>{const r=C(.76),i=C(.15);t=t.mul(e);const s=js(t.r,js(t.g,t.b)),n=yi(s.lessThan(.08),s.sub(ke(6.25,s.mul(s))),.04);t.subAssign(n);const a=Gr(t.r,Gr(t.g,t.b));je(a.lessThan(r),()=>t);const o=it(1,r),l=it(1,o.mul(o).div(a.add(o.sub(r))));t.mulAssign(l.div(a));const h=it(1,qn(1,i.mul(a.sub(l)).add(1)));return ur(t,B(l),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Lr extends Ae{static get type(){return"CodeNode"}constructor(e="",r=[],i=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=r,this.language=i}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const r=this.getIncludes(e);for(const s of r)s.build(e);const i=e.getCodeFromNode(this,this.getNodeType(e));return i.code=this.code,i.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ry=Z(Lr).setParameterLength(1,3),mhe=(t,e)=>Ry(t,e,"js"),phe=(t,e)=>Ry(t,e,"wgsl"),fhe=(t,e)=>Ry(t,e,"glsl");class ghe extends Lr{static get type(){return"FunctionNode"}constructor(e="",r=[],i=""){super(e,r,i)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const r=e.getDataFromNode(this);let i=r.nodeFunction;return i===void 0&&(i=e.parser.parseFunction(this.code),r.nodeFunction=i),i}generate(e,r){super.generate(e);const i=this.getNodeFunction(e),s=i.name,n=i.type,a=e.getCodeFromNode(this,n);s!==""&&(a.name=s);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+`
482
482
  `,r==="property"?o:e.format(`${o}()`,n,r)}}const qV=(t,e=[],r="")=>{for(let n=0;n<e.length;n++){const a=e[n];typeof a=="function"&&(e[n]=a.functionNode)}const i=X(new ghe(t,e,r)),s=(...n)=>i.call(...n);return s.functionNode=i,s},yhe=(t,e)=>qV(t,e,"glsl"),xhe=(t,e)=>qV(t,e,"wgsl");class bhe extends Ae{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Du,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:C()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=L5(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let r=null;e.value!==null&&(e.inputType==="ArrayBuffer"?r=F5(e.value):e.inputType==="Texture"?r=e.meta.textures[e.value]:r=e.meta.nodes[e.value]||null),this.value=r,this.inputType=e.inputType,this.outputType=e.outputType}}const Df=Z(bhe).setParameterLength(1);class XV extends Map{get(e,r=null,...i){if(this.has(e))return super.get(e);if(r!==null){const s=r(...i);return this.set(e,s),s}}}class vhe{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const r=this.parameters[e];return r?r.getValue():null}}const $f=new XV;class The extends Ae{static get type(){return"ScriptableNode"}constructor(e=null,r={}){super(),this.codeNode=e,this.parameters=r,this._local=new XV,this._output=Df(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,r){return this._local.set(e,r)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const r of this.getLayout())if(r.inputType&&(r.id===e||r.name===e))return r}getOutputLayout(e){for(const r of this.getLayout())if(r.outputType&&(r.id===e||r.name===e))return r}setOutput(e,r){const i=this._outputs;return i[e]===void 0?i[e]=Df(r):i[e].value=r,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,r){const i=this.parameters;return r&&r.isScriptableNode?(this.deleteParameter(e),i[e]=r,i[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):r&&r.isScriptableValueNode?(this.deleteParameter(e),i[e]=r,i[e].events.addEventListener("refresh",this.onRefresh)):i[e]===void 0?(i[e]=Df(r),i[e].events.addEventListener("refresh",this.onRefresh)):i[e].value=r,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let r=this.parameters[e];return r&&(r.isScriptableNode&&(r=r.getDefaultOutput()),r.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...r){const s=this.getObject()[e];if(typeof s=="function")return s(...r)}async callAsync(e,...r){const s=this.getObject()[e];if(typeof s=="function")return s.constructor.name==="AsyncFunction"?await s(...r):s(...r)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),r=(h,u)=>this.setOutput(h,u),i=new vhe(this),s=$f.get("THREE"),n=$f.get("TSL"),a=this.getMethod(),o=[i,this._local,$f,e,r,s,n];this._object=a(...o);const l=this._object.layout;if(l&&(l.cache===!1&&this._local.clear(),this._output.outputType=l.outputType||null,Array.isArray(l.elements)))for(const h of l.elements){const u=h.id||h.name;h.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=h.inputType),h.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const r in this.parameters){let i=this.parameters[r];i.isScriptableNode&&(i=i.getDefaultOutput()),i.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:C()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],i=["layout","init","main","dispose"].join(", "),s="var "+i+`; var output = {};
483
483
  `,n=`
484
484
  return { ...output, `+i+" };",a=s+this.codeNode.code+n;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const r=[Tse(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const i in this.parameters)r.push(this.parameters[i].getCacheKey(e));return C5(r)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const whe=Z(The).setParameterLength(1,2);function YV(t){let e;const r=t.context.getViewZ;return r!==void 0&&(e=r(this)),(e||ti.z).negate()}const ZV=z(([t,e],r)=>{const i=YV(r);return Iu(t,e,i)}),JV=z(([t],e)=>{const r=YV(e);return t.mul(t,r,r).negate().exp().oneMinus()}),sw=z(([t,e])=>Oe(e.toFloat().mix(oc.rgb,t.toVec3()),oc.a));function She(t,e,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),sw(t,ZV(e,r))}function Mhe(t,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),sw(t,JV(e))}let al=null,ol=null;class _he extends Ae{static get type(){return"RangeNode"}constructor(e=C(),r=C()){super(),this.minNode=e,this.maxNode=r}getVectorLength(e){const r=e.getTypeLength(Mo(this.minNode.value)),i=e.getTypeLength(Mo(this.maxNode.value));return r>i?r:i}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const r=e.object;let i=null;if(r.count>1){const s=this.minNode.value,n=this.maxNode.value,a=e.getTypeLength(Mo(s)),o=e.getTypeLength(Mo(n));al=al||new Si,ol=ol||new Si,al.setScalar(0),ol.setScalar(0),a===1?al.setScalar(s):s.isColor?al.set(s.r,s.g,s.b,1):al.set(s.x,s.y,s.z||0,s.w||0),o===1?ol.setScalar(n):n.isColor?ol.set(n.r,n.g,n.b,1):ol.set(n.x,n.y,n.z||0,n.w||0);const l=4,h=l*r.count,u=new Float32Array(h);for(let d=0;d<h;d++){const m=d%l,p=al.getComponent(m),f=ol.getComponent(m);u[d]=a3.lerp(p,f,Math.random())}const c=this.getNodeType(e);if(r.count<=4096)i=km(u,"vec4",r.count).element(Po).convert(c);else{const d=new ic(u,4);e.geometry.setAttribute("__range"+this.id,d),i=Tg(d).convert(c)}}else i=C(0);return i}}const Nhe=Z(_he).setParameterLength(2);class Ehe extends Ae{static get type(){return"ComputeBuiltinNode"}constructor(e,r){super(r),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,r){const i=this.getBuiltinName(e),s=this.getNodeType(e);return e.shaderStage==="compute"?e.format(i,s,r):(console.warn(`ComputeBuiltinNode: Compute built-in value ${i} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(s))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const qm=(t,e)=>X(new Ehe(t,e)),Ahe=qm("numWorkgroups","uvec3"),Che=qm("workgroupId","uvec3"),Rhe=qm("globalId","uvec3"),Phe=qm("localId","uvec3"),Ihe=qm("subgroupSize","uint");class Vhe extends Ae{constructor(e){super(),this.scope=e}generate(e){const{scope:r}=this,{renderer:i}=e;i.backend.isWebGLBackend===!0?e.addFlowCode(` // ${r}Barrier
485
- `):e.addLineFlowCode(`${r}Barrier()`,this)}}const nw=Z(Vhe),Ohe=()=>nw("workgroup").toStack(),Lhe=()=>nw("storage").toStack(),Fhe=()=>nw("texture").toStack();class zhe extends ju{constructor(e,r){super(e,r),this.isWorkgroupInfoElementNode=!0}generate(e,r){let i;const s=e.context.assign;if(i=super.generate(e),s!==!0){const n=this.getNodeType(e);i=e.format(i,n,r)}return i}}class Bhe extends Ae{constructor(e,r,i=0){super(r),this.bufferType=r,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.elementType=r,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return X(new zhe(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const khe=(t,e)=>X(new Bhe("Workgroup",t,e));class jr extends Ae{static get type(){return"AtomicFunctionNode"}constructor(e,r,i){super("uint"),this.method=e,this.pointerNode=r,this.valueNode=i,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const r=e.getNodeProperties(this),i=r.parents,s=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,l=this.valueNode,h=[];h.push(`&${o.build(e,a)}`),l!==null&&h.push(l.build(e,a));const u=`${e.getMethod(s,n)}( ${h.join(", ")} )`;if(i.length===1&&i[0].isStackNode===!0)e.addLineFlowCode(u,this);else return r.constNode===void 0&&(r.constNode=ka(u,n).toConst()),r.constNode.build(e)}}jr.ATOMIC_LOAD="atomicLoad";jr.ATOMIC_STORE="atomicStore";jr.ATOMIC_ADD="atomicAdd";jr.ATOMIC_SUB="atomicSub";jr.ATOMIC_MAX="atomicMax";jr.ATOMIC_MIN="atomicMin";jr.ATOMIC_AND="atomicAnd";jr.ATOMIC_OR="atomicOr";jr.ATOMIC_XOR="atomicXor";const Uhe=Z(jr),ea=(t,e,r)=>Uhe(t,e,r).toStack(),Dhe=t=>ea(jr.ATOMIC_LOAD,t,null),$he=(t,e)=>ea(jr.ATOMIC_STORE,t,e),Ghe=(t,e)=>ea(jr.ATOMIC_ADD,t,e),jhe=(t,e)=>ea(jr.ATOMIC_SUB,t,e),Whe=(t,e)=>ea(jr.ATOMIC_MAX,t,e),Hhe=(t,e)=>ea(jr.ATOMIC_MIN,t,e),qhe=(t,e)=>ea(jr.ATOMIC_AND,t,e),Xhe=(t,e)=>ea(jr.ATOMIC_OR,t,e),Yhe=(t,e)=>ea(jr.ATOMIC_XOR,t,e);let vf;function Py(t){vf=vf||new WeakMap;let e=vf.get(t);return e===void 0&&vf.set(t,e={}),e}function aw(t){const e=Py(t);return e.shadowMatrix||(e.shadowMatrix=Ie("mat4").setGroup(Ye).onRenderUpdate(r=>((t.castShadow!==!0||r.renderer.shadowMap.enabled===!1)&&t.shadow.updateMatrices(t),t.shadow.matrix)))}function Zhe(t,e=Nu){const r=aw(t).mul(e);return r.xyz.div(r.w)}function KV(t){const e=Py(t);return e.position||(e.position=Ie(new $).setGroup(Ye).onRenderUpdate((r,i)=>i.value.setFromMatrixPosition(t.matrixWorld)))}function QV(t){const e=Py(t);return e.targetPosition||(e.targetPosition=Ie(new $).setGroup(Ye).onRenderUpdate((r,i)=>i.value.setFromMatrixPosition(t.target.matrixWorld)))}function Jhe(t){const e=Py(t);return e.viewPosition||(e.viewPosition=Ie(new $).setGroup(Ye).onRenderUpdate(({camera:r},i)=>{i.value=i.value||new $,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(r.matrixWorldInverse)}))}const Khe=t=>Zs.transformDirection(KV(t).sub(QV(t))),Qhe=t=>t.sort((e,r)=>e.id-r.id),ece=(t,e)=>{for(const r of e)if(r.isAnalyticLightNode&&r.light.id===t)return r;return null},Fx=new WeakMap,dd=[];class tce extends Ae{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=B().toVar(),this.totalSpecularNode=B().toVar(),this.outgoingLightNode=B().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let i=0;i<e.length;i++){const s=e[i];if(dd.push(s.id),dd.push(s.castShadow?1:0),s.isSpotLight===!0){const n=s.map!==null?s.map.id:-1,a=s.colorNode?s.colorNode.getCacheKey():-1;dd.push(n,a)}}const r=C5(dd);return dd.length=0,r}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const r=[];for(const i of this._lightNodes)r.push(i.getSelf().getHash());this._lightNodesHash="lights-"+r.join(",")}return this._lightNodesHash}analyze(e){const r=e.getNodeProperties(this);for(const i of r.nodes)i.build(e);r.outputNode.build(e)}setupLightsNode(e){const r=[],i=this._lightNodes,s=Qhe(this._lights),n=e.renderer.library;for(const a of s)if(a.isNode)r.push(X(a));else{let o=null;if(i!==null&&(o=ece(a.id,i)),o===null){const l=n.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let h=null;Fx.has(a)?h=Fx.get(a):(h=X(new l(a)),Fx.set(a,h)),r.push(h)}}this._lightNodes=r}setupDirectLight(e,r,i){const{lightingModel:s,reflectedLight:n}=e.context;s.direct({...i,lightNode:r,reflectedLight:n},e)}setupDirectRectAreaLight(e,r,i){const{lightingModel:s,reflectedLight:n}=e.context;s.directRectArea({...i,lightNode:r,reflectedLight:n},e)}setupLights(e,r){for(const i of r)i.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const r=e.lightsNode;e.lightsNode=this;let i=this.outgoingLightNode;const s=e.context,n=s.lightingModel,a=e.getNodeProperties(this);if(n){const{totalDiffuseNode:o,totalSpecularNode:l}=this;s.outgoingLight=i;const h=e.addStack();a.nodes=h.nodes,n.start(e);const{backdrop:u,backdropAlpha:c}=s,{directDiffuse:d,directSpecular:m,indirectDiffuse:p,indirectSpecular:f}=s.reflectedLight;let g=d.add(p);u!==null&&(c!==null?g=B(c.mix(g,u)):g=B(u),s.material.transparent=!0),o.assign(g),l.assign(m.add(f)),i.assign(o.add(l)),n.finish(e),i=i.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=r,i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}const rce=(t=[])=>X(new tce).setLights(t);class ice extends Ae{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Tt.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:r}){ow.assign(r.receivedShadowPositionNode||e.shadowPositionWorld||Nu)}}const ow=Ic("vec3","shadowPositionWorld");function sce(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new ja),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function nce(t,e){return e=sce(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function ace(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function oce(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function lce(t,e){return e=oce(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function uce(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function hce(t,e,r){return r=nce(t,r),r=lce(e,r),r}function cce(t,e,r){ace(t,r),uce(e,r)}const NN=new WeakMap,eO=z(({depthTexture:t,shadowCoord:e,depthLayer:r})=>{let i=_t(t,e.xy).label("t_basic");return t.isArrayTexture&&(i=i.depth(r)),i.compare(e.z)}),tO=z(({depthTexture:t,shadowCoord:e,shadow:r,depthLayer:i})=>{const s=(g,y)=>{let T=_t(t,g);return t.isArrayTexture&&(T=T.depth(i)),T.compare(y)},n=Zt("mapSize","vec2",r).setGroup(Ye),a=Zt("radius","float",r).setGroup(Ye),o=ne(1).div(n),l=o.x.negate().mul(a),h=o.y.negate().mul(a),u=o.x.mul(a),c=o.y.mul(a),d=l.div(2),m=h.div(2),p=u.div(2),f=c.div(2);return fr(s(e.xy.add(ne(l,h)),e.z),s(e.xy.add(ne(0,h)),e.z),s(e.xy.add(ne(u,h)),e.z),s(e.xy.add(ne(d,m)),e.z),s(e.xy.add(ne(0,m)),e.z),s(e.xy.add(ne(p,m)),e.z),s(e.xy.add(ne(l,0)),e.z),s(e.xy.add(ne(d,0)),e.z),s(e.xy,e.z),s(e.xy.add(ne(p,0)),e.z),s(e.xy.add(ne(u,0)),e.z),s(e.xy.add(ne(d,f)),e.z),s(e.xy.add(ne(0,f)),e.z),s(e.xy.add(ne(p,f)),e.z),s(e.xy.add(ne(l,c)),e.z),s(e.xy.add(ne(0,c)),e.z),s(e.xy.add(ne(u,c)),e.z)).mul(1/17)}),rO=z(({depthTexture:t,shadowCoord:e,shadow:r,depthLayer:i})=>{const s=(c,d)=>{let m=_t(t,c);return t.isArrayTexture&&(m=m.depth(i)),m.compare(d)},n=Zt("mapSize","vec2",r).setGroup(Ye),a=ne(1).div(n),o=a.x,l=a.y,h=e.xy,u=Ha(h.mul(n).add(.5));return h.subAssign(u.mul(a)),fr(s(h,e.z),s(h.add(ne(o,0)),e.z),s(h.add(ne(0,l)),e.z),s(h.add(a),e.z),ur(s(h.add(ne(o.negate(),0)),e.z),s(h.add(ne(o.mul(2),0)),e.z),u.x),ur(s(h.add(ne(o.negate(),l)),e.z),s(h.add(ne(o.mul(2),l)),e.z),u.x),ur(s(h.add(ne(0,l.negate())),e.z),s(h.add(ne(0,l.mul(2))),e.z),u.y),ur(s(h.add(ne(o,l.negate())),e.z),s(h.add(ne(o,l.mul(2))),e.z),u.y),ur(ur(s(h.add(ne(o.negate(),l.negate())),e.z),s(h.add(ne(o.mul(2),l.negate())),e.z),u.x),ur(s(h.add(ne(o.negate(),l.mul(2))),e.z),s(h.add(ne(o.mul(2),l.mul(2))),e.z),u.x),u.y)).mul(1/9)}),iO=z(({depthTexture:t,shadowCoord:e,depthLayer:r})=>{const i=C(1).toVar();let s=_t(t).sample(e.xy);t.isArrayTexture&&(s=s.depth(r)),s=s.rg;const n=wy(e.z,s.x);return je(n.notEqual(C(1)),()=>{const a=e.z.sub(s.x),o=Gr(0,s.y.mul(s.y));let l=o.div(o.add(a.mul(a)));l=Ba(it(l,.3).div(.95-.3)),i.assign(Ba(Gr(n,l)))}),i}),dce=z(([t,e,r])=>{let i=Nu.sub(t).length();return i=i.sub(e).div(r.sub(e)),i=i.saturate(),i}),mce=t=>{const e=t.shadow.camera,r=Zt("near","float",e).setGroup(Ye),i=Zt("far","float",e).setGroup(Ye),s=PI(t);return dce(s,r,i)},sO=t=>{let e=NN.get(t);if(e===void 0){const r=t.isPointLight?mce(t):null;e=new Sc,e.colorNode=Oe(0,0,0,1),e.depthNode=r,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,NN.set(t,e)}return e},EN=new Cle,Ph=[],nO=(t,e,r,i)=>{Ph[0]=t,Ph[1]=e;let s=EN.get(Ph);return(s===void 0||s.shadowType!==r||s.useVelocity!==i)&&(s=(n,a,o,l,h,u,...c)=>{(n.castShadow===!0||n.receiveShadow&&r===Ff)&&(i&&(O5(n).useVelocity=!0),n.onBeforeShadow(t,n,o,e.camera,l,a.overrideMaterial,u),t.renderObject(n,a,o,l,h,u,...c),n.onAfterShadow(t,n,o,e.camera,l,a.overrideMaterial,u))},s.shadowType=r,s.useVelocity=i,EN.set(Ph,s)),Ph[0]=null,Ph[1]=null,s},pce=z(({samples:t,radius:e,size:r,shadowPass:i,depthLayer:s})=>{const n=C(0).toVar("meanVertical"),a=C(0).toVar("squareMeanVertical"),o=t.lessThanEqual(C(1)).select(C(0),C(2).div(t.sub(1))),l=t.lessThanEqual(C(1)).select(C(0),C(-1));Et({start:P(0),end:P(t),type:"int",condition:"<"},({i:u})=>{const c=l.add(C(u).mul(o));let d=i.sample(fr(Hm.xy,ne(0,c).mul(e)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(t),a.divAssign(t);const h=Qn(a.sub(n.mul(n)));return ne(n,h)}),fce=z(({samples:t,radius:e,size:r,shadowPass:i,depthLayer:s})=>{const n=C(0).toVar("meanHorizontal"),a=C(0).toVar("squareMeanHorizontal"),o=t.lessThanEqual(C(1)).select(C(0),C(2).div(t.sub(1))),l=t.lessThanEqual(C(1)).select(C(0),C(-1));Et({start:P(0),end:P(t),type:"int",condition:"<"},({i:u})=>{const c=l.add(C(u).mul(o));let d=i.sample(fr(Hm.xy,ne(c,0).mul(e)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),n.addAssign(d.x),a.addAssign(fr(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(t),a.divAssign(t);const h=Qn(a.sub(n.mul(n)));return ne(n,h)}),gce=[eO,tO,rO,iO];let zx;const Tf=new BV;class aO extends ice{static get type(){return"ShadowNode"}constructor(e,r=null){super(e),this.shadow=r||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:r,depthTexture:i,shadowCoord:s,shadow:n,depthLayer:a}){const o=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),l=r({depthTexture:i,shadowCoord:s,shadow:n,depthLayer:a});return o.select(l,C(1))}setupShadowCoord(e,r){const{shadow:i}=this,{renderer:s}=e,n=Zt("bias","float",i).setGroup(Ye);let a=r,o;if(i.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,s.coordinateSystem===Ru&&(o=o.mul(2).sub(1));else{const l=a.w;a=a.xy.div(l);const h=Zt("near","float",i.camera).setGroup(Ye),u=Zt("far","float",i.camera).setGroup(Ye);o=KT(l.negate(),h,u)}return a=B(a.x,a.y.oneMinus(),o.add(n)),a}getShadowFilterFn(e){return gce[e]}setupRenderTarget(e,r){const i=new Am(e.mapSize.width,e.mapSize.height);i.name="ShadowDepthTexture",i.compareFunction=CJ;const s=r.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=i,{shadowMap:s,depthTexture:i}}setupShadow(e){const{renderer:r}=e,{light:i,shadow:s}=this,n=r.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),n===Ff&&s.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depthBuffer:!1}));let y=_t(a);a.isArrayTexture&&(y=y.depth(this.depthLayer));let T=_t(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(T=T.depth(this.depthLayer));const M=Zt("blurSamples","float",s).setGroup(Ye),w=Zt("radius","float",s).setGroup(Ye),_=Zt("mapSize","vec2",s).setGroup(Ye);let S=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Sc);S.fragmentNode=pce({samples:M,radius:w,size:_,shadowPass:y,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMVertical",S=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Sc),S.fragmentNode=fce({samples:M,radius:w,size:_,shadowPass:T,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMHorizontal"}const l=Zt("intensity","float",s).setGroup(Ye),h=Zt("normalBias","float",s).setGroup(Ye),u=aw(i).mul(ow.add(BI.mul(h))),c=this.setupShadowCoord(e,u),d=s.filterNode||this.getShadowFilterFn(r.shadowMap.type)||null;if(d===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const m=n===Ff&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:m,shadowCoord:c,shadow:s,depthLayer:this.depthLayer});let f=_t(o.texture,c);a.isArrayTexture&&(f=f.depth(this.depthLayer));const g=ur(1,p.rgb.mix(f,1),l.mul(f.a)).toVar();return this.shadowMap=o,this.shadow.map=o,g}setup(e){if(e.renderer.shadowMap.enabled!==!1)return z(()=>{let r=this._node;return this.setupShadowPosition(e),r===null&&(this._node=r=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:r,shadowMap:i,light:s}=this,{renderer:n,scene:a}=e;r.updateMatrices(s),i.setSize(r.mapSize.width,r.mapSize.height,i.depth),n.render(a,r.camera)}updateShadow(e){const{shadowMap:r,light:i,shadow:s}=this,{renderer:n,scene:a,camera:o}=e,l=n.shadowMap.type,h=r.depthTexture.version;this._depthVersionCached=h;const u=s.camera.layers.mask;(s.camera.layers.mask&4294967294)===0&&(s.camera.layers.mask=o.layers.mask);const c=n.getRenderObjectFunction(),d=n.getMRT(),m=d?d.has("velocity"):!1;zx=hce(n,a,zx),a.overrideMaterial=sO(i),n.setRenderObjectFunction(nO(n,s,l,m)),n.setClearColor(0,0),n.setRenderTarget(r),this.renderShadow(e),n.setRenderObjectFunction(c),l===Ff&&s.isPointLightShadow!==!0&&this.vsmPass(n),s.camera.layers.mask=u,cce(n,a,zx)}vsmPass(e){const{shadow:r}=this,i=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(r.mapSize.width,r.mapSize.height,i),this.vsmShadowMapHorizontal.setSize(r.mapSize.width,r.mapSize.height,i),e.setRenderTarget(this.vsmShadowMapVertical),Tf.material=this.vsmMaterialVertical,Tf.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Tf.material=this.vsmMaterialHorizontal,Tf.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:r}=this;let i=r.needsUpdate||r.autoUpdate;i&&(this._cameraFrameId[e.camera]===e.frameId&&(i=!1),this._cameraFrameId[e.camera]=e.frameId),i&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(r.needsUpdate=!1))}}const yce=(t,e)=>X(new aO(t,e)),xce=new ja,on=z(([t,e])=>{const r=t.toVar(),i=Vt(r),s=qn(1,Gr(i.x,Gr(i.y,i.z)));i.mulAssign(s),r.mulAssign(s.mul(e.mul(2).oneMinus()));const n=ne(r.xy).toVar(),o=e.mul(1.5).oneMinus();return je(i.z.greaterThanEqual(o),()=>{je(r.z.greaterThan(0),()=>{n.x.assign(it(4,r.x))})}).ElseIf(i.x.greaterThanEqual(o),()=>{const l=lm(r.x);n.x.assign(r.z.mul(l).add(l.mul(2)))}).ElseIf(i.y.greaterThanEqual(o),()=>{const l=lm(r.y);n.x.assign(r.x.add(l.mul(2)).add(2)),n.y.assign(r.z.mul(l).sub(2))}),ne(.125,.25).mul(n).add(ne(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),oO=z(({depthTexture:t,bd3D:e,dp:r,texelSize:i})=>_t(t,on(e,i.y)).compare(r)),lO=z(({depthTexture:t,bd3D:e,dp:r,texelSize:i,shadow:s})=>{const n=Zt("radius","float",s).setGroup(Ye),a=ne(-1,1).mul(n).mul(i.y);return _t(t,on(e.add(a.xyy),i.y)).compare(r).add(_t(t,on(e.add(a.yyy),i.y)).compare(r)).add(_t(t,on(e.add(a.xyx),i.y)).compare(r)).add(_t(t,on(e.add(a.yyx),i.y)).compare(r)).add(_t(t,on(e,i.y)).compare(r)).add(_t(t,on(e.add(a.xxy),i.y)).compare(r)).add(_t(t,on(e.add(a.yxy),i.y)).compare(r)).add(_t(t,on(e.add(a.xxx),i.y)).compare(r)).add(_t(t,on(e.add(a.yxx),i.y)).compare(r)).mul(1/9)}),bce=z(({filterFn:t,depthTexture:e,shadowCoord:r,shadow:i})=>{const s=r.xyz.toVar(),n=s.length(),a=Ie("float").setGroup(Ye).onRenderUpdate(()=>i.camera.near),o=Ie("float").setGroup(Ye).onRenderUpdate(()=>i.camera.far),l=Zt("bias","float",i).setGroup(Ye),h=Ie(i.mapSize).setGroup(Ye),u=C(1).toVar();return je(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),()=>{const c=n.sub(a).div(o.sub(a)).toVar();c.addAssign(l);const d=s.normalize(),m=ne(1).div(h.mul(ne(4,2)));u.assign(t({depthTexture:e,bd3D:d,dp:c,texelSize:m,shadow:i}))}),u}),AN=new Si,Ih=new Jt,md=new Jt;class vce extends aO{static get type(){return"PointShadowNode"}constructor(e,r=null){super(e,r)}getShadowFilterFn(e){return e===TJ?oO:lO}setupShadowCoord(e,r){return r}setupShadowFilter(e,{filterFn:r,shadowTexture:i,depthTexture:s,shadowCoord:n,shadow:a}){return bce({filterFn:r,shadowTexture:i,depthTexture:s,shadowCoord:n,shadow:a})}renderShadow(e){const{shadow:r,shadowMap:i,light:s}=this,{renderer:n,scene:a}=e,o=r.getFrameExtents();md.copy(r.mapSize),md.multiply(o),i.setSize(md.width,md.height),Ih.copy(r.mapSize);const l=n.autoClear,h=n.getClearColor(xce),u=n.getClearAlpha();n.autoClear=!1,n.setClearColor(r.clearColor,r.clearAlpha),n.clear();const c=r.getViewportCount();for(let d=0;d<c;d++){const m=r.getViewport(d),p=Ih.x*m.x,f=md.y-Ih.y-Ih.y*m.y;AN.set(p,f,Ih.x*m.z,Ih.y*m.w),i.viewport.copy(AN),r.updateMatrices(s,d),n.render(a,r.camera)}n.autoClear=l,n.setClearColor(h,u)}}const Tce=(t,e)=>X(new vce(t,e)),uO=z(({lightDistance:t,cutoffDistance:e,decayExponent:r})=>{const i=t.pow(r).max(.01).reciprocal();return e.greaterThan(0).select(i.mul(t.div(e).pow4().oneMinus().clamp().pow2()),i)}),wce=({color:t,lightVector:e,cutoffDistance:r,decayExponent:i})=>{const s=e.normalize(),n=e.length(),a=uO({lightDistance:n,cutoffDistance:r,decayExponent:i}),o=t.mul(a);return{lightDirection:s,lightColor:o}},Sce=z(([t=jt()])=>{const e=t.mul(2),r=e.x.floor(),i=e.y.floor();return r.add(i).mod(2).sign()}),Mce=z(([t=jt()],{renderer:e,material:r})=>{const i=IT(t.mul(2).sub(1));let s;if(r.alphaToCoverage&&e.samples>1){const n=C(i.fwidth()).toVar();s=Iu(n.oneMinus(),n.add(1),i).oneMinus()}else s=yi(i.greaterThan(1),0,1);return s}),$d=z(([t,e,r])=>{const i=C(r).toVar(),s=C(e).toVar(),n=Hn(t).toVar();return yi(n,s,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Ng=z(([t,e])=>{const r=Hn(e).toVar(),i=C(t).toVar();return yi(r,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),mr=z(([t])=>{const e=C(t).toVar();return P(zn(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),$t=z(([t,e])=>{const r=C(t).toVar();return e.assign(mr(r)),r.sub(C(e))}),_ce=z(([t,e,r,i,s,n])=>{const a=C(n).toVar(),o=C(s).toVar(),l=C(i).toVar(),h=C(r).toVar(),u=C(e).toVar(),c=C(t).toVar(),d=C(it(1,o)).toVar();return it(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Nce=z(([t,e,r,i,s,n])=>{const a=C(n).toVar(),o=C(s).toVar(),l=B(i).toVar(),h=B(r).toVar(),u=B(e).toVar(),c=B(t).toVar(),d=C(it(1,o)).toVar();return it(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),hO=li([_ce,Nce]),Ece=z(([t,e,r,i,s,n,a,o,l,h,u])=>{const c=C(u).toVar(),d=C(h).toVar(),m=C(l).toVar(),p=C(o).toVar(),f=C(a).toVar(),g=C(n).toVar(),y=C(s).toVar(),T=C(i).toVar(),M=C(r).toVar(),w=C(e).toVar(),_=C(t).toVar(),S=C(it(1,m)).toVar(),N=C(it(1,d)).toVar();return C(it(1,c)).toVar().mul(N.mul(_.mul(S).add(w.mul(m))).add(d.mul(M.mul(S).add(T.mul(m))))).add(c.mul(N.mul(y.mul(S).add(g.mul(m))).add(d.mul(f.mul(S).add(p.mul(m))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Ace=z(([t,e,r,i,s,n,a,o,l,h,u])=>{const c=C(u).toVar(),d=C(h).toVar(),m=C(l).toVar(),p=B(o).toVar(),f=B(a).toVar(),g=B(n).toVar(),y=B(s).toVar(),T=B(i).toVar(),M=B(r).toVar(),w=B(e).toVar(),_=B(t).toVar(),S=C(it(1,m)).toVar(),N=C(it(1,d)).toVar();return C(it(1,c)).toVar().mul(N.mul(_.mul(S).add(w.mul(m))).add(d.mul(M.mul(S).add(T.mul(m))))).add(c.mul(N.mul(y.mul(S).add(g.mul(m))).add(d.mul(f.mul(S).add(p.mul(m))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),cO=li([Ece,Ace]),Cce=z(([t,e,r])=>{const i=C(r).toVar(),s=C(e).toVar(),n=fe(t).toVar(),a=fe(n.bitAnd(fe(7))).toVar(),o=C($d(a.lessThan(fe(4)),s,i)).toVar(),l=C(ke(2,$d(a.lessThan(fe(4)),i,s))).toVar();return Ng(o,Hn(a.bitAnd(fe(1)))).add(Ng(l,Hn(a.bitAnd(fe(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Rce=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=C(e).toVar(),o=fe(t).toVar(),l=fe(o.bitAnd(fe(15))).toVar(),h=C($d(l.lessThan(fe(8)),a,n)).toVar(),u=C($d(l.lessThan(fe(4)),n,$d(l.equal(fe(12)).or(l.equal(fe(14))),a,s))).toVar();return Ng(h,Hn(l.bitAnd(fe(1)))).add(Ng(u,Hn(l.bitAnd(fe(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Kr=li([Cce,Rce]),Pce=z(([t,e,r])=>{const i=C(r).toVar(),s=C(e).toVar(),n=Pc(t).toVar();return B(Kr(n.x,s,i),Kr(n.y,s,i),Kr(n.z,s,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Ice=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=C(e).toVar(),o=Pc(t).toVar();return B(Kr(o.x,a,n,s),Kr(o.y,a,n,s),Kr(o.z,a,n,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),As=li([Pce,Ice]),Vce=z(([t])=>{const e=C(t).toVar();return ke(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Oce=z(([t])=>{const e=C(t).toVar();return ke(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Lce=z(([t])=>{const e=B(t).toVar();return ke(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),dO=li([Vce,Lce]),Fce=z(([t])=>{const e=B(t).toVar();return ke(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),mO=li([Oce,Fce]),ls=z(([t,e])=>{const r=P(e).toVar(),i=fe(t).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(P(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),pO=z(([t,e,r])=>{t.subAssign(r),t.bitXorAssign(ls(r,P(4))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(ls(t,P(6))),t.addAssign(r),r.subAssign(e),r.bitXorAssign(ls(e,P(8))),e.addAssign(t),t.subAssign(r),t.bitXorAssign(ls(r,P(16))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(ls(t,P(19))),t.addAssign(r),r.subAssign(e),r.bitXorAssign(ls(e,P(4))),e.addAssign(t)}),Xm=z(([t,e,r])=>{const i=fe(r).toVar(),s=fe(e).toVar(),n=fe(t).toVar();return i.bitXorAssign(s),i.subAssign(ls(s,P(14))),n.bitXorAssign(i),n.subAssign(ls(i,P(11))),s.bitXorAssign(n),s.subAssign(ls(n,P(25))),i.bitXorAssign(s),i.subAssign(ls(s,P(16))),n.bitXorAssign(i),n.subAssign(ls(i,P(4))),s.bitXorAssign(n),s.subAssign(ls(n,P(14))),i.bitXorAssign(s),i.subAssign(ls(s,P(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Ti=z(([t])=>{const e=fe(t).toVar();return C(e).div(C(fe(P(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Bn=z(([t])=>{const e=C(t).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),zce=z(([t])=>{const e=P(t).toVar(),r=fe(fe(1)).toVar(),i=fe(fe(P(3735928559)).add(r.shiftLeft(fe(2))).add(fe(13))).toVar();return Xm(i.add(fe(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Bce=z(([t,e])=>{const r=P(e).toVar(),i=P(t).toVar(),s=fe(fe(2)).toVar(),n=fe().toVar(),a=fe().toVar(),o=fe().toVar();return n.assign(a.assign(o.assign(fe(P(3735928559)).add(s.shiftLeft(fe(2))).add(fe(13))))),n.addAssign(fe(i)),a.addAssign(fe(r)),Xm(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),kce=z(([t,e,r])=>{const i=P(r).toVar(),s=P(e).toVar(),n=P(t).toVar(),a=fe(fe(3)).toVar(),o=fe().toVar(),l=fe().toVar(),h=fe().toVar();return o.assign(l.assign(h.assign(fe(P(3735928559)).add(a.shiftLeft(fe(2))).add(fe(13))))),o.addAssign(fe(n)),l.addAssign(fe(s)),h.addAssign(fe(i)),Xm(o,l,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Uce=z(([t,e,r,i])=>{const s=P(i).toVar(),n=P(r).toVar(),a=P(e).toVar(),o=P(t).toVar(),l=fe(fe(4)).toVar(),h=fe().toVar(),u=fe().toVar(),c=fe().toVar();return h.assign(u.assign(c.assign(fe(P(3735928559)).add(l.shiftLeft(fe(2))).add(fe(13))))),h.addAssign(fe(o)),u.addAssign(fe(a)),c.addAssign(fe(n)),pO(h,u,c),h.addAssign(fe(s)),Xm(h,u,c)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Dce=z(([t,e,r,i,s])=>{const n=P(s).toVar(),a=P(i).toVar(),o=P(r).toVar(),l=P(e).toVar(),h=P(t).toVar(),u=fe(fe(5)).toVar(),c=fe().toVar(),d=fe().toVar(),m=fe().toVar();return c.assign(d.assign(m.assign(fe(P(3735928559)).add(u.shiftLeft(fe(2))).add(fe(13))))),c.addAssign(fe(h)),d.addAssign(fe(l)),m.addAssign(fe(o)),pO(c,d,m),c.addAssign(fe(a)),d.addAssign(fe(n)),Xm(c,d,m)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),vt=li([zce,Bce,kce,Uce,Dce]),$ce=z(([t,e])=>{const r=P(e).toVar(),i=P(t).toVar(),s=fe(vt(i,r)).toVar(),n=Pc().toVar();return n.x.assign(s.bitAnd(P(255))),n.y.assign(s.shiftRight(P(8)).bitAnd(P(255))),n.z.assign(s.shiftRight(P(16)).bitAnd(P(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Gce=z(([t,e,r])=>{const i=P(r).toVar(),s=P(e).toVar(),n=P(t).toVar(),a=fe(vt(n,s,i)).toVar(),o=Pc().toVar();return o.x.assign(a.bitAnd(P(255))),o.y.assign(a.shiftRight(P(8)).bitAnd(P(255))),o.z.assign(a.shiftRight(P(16)).bitAnd(P(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Cs=li([$ce,Gce]),jce=z(([t])=>{const e=ne(t).toVar(),r=P().toVar(),i=P().toVar(),s=C($t(e.x,r)).toVar(),n=C($t(e.y,i)).toVar(),a=C(Bn(s)).toVar(),o=C(Bn(n)).toVar(),l=C(hO(Kr(vt(r,i),s,n),Kr(vt(r.add(P(1)),i),s.sub(1),n),Kr(vt(r,i.add(P(1))),s,n.sub(1)),Kr(vt(r.add(P(1)),i.add(P(1))),s.sub(1),n.sub(1)),a,o)).toVar();return dO(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Wce=z(([t])=>{const e=B(t).toVar(),r=P().toVar(),i=P().toVar(),s=P().toVar(),n=C($t(e.x,r)).toVar(),a=C($t(e.y,i)).toVar(),o=C($t(e.z,s)).toVar(),l=C(Bn(n)).toVar(),h=C(Bn(a)).toVar(),u=C(Bn(o)).toVar(),c=C(cO(Kr(vt(r,i,s),n,a,o),Kr(vt(r.add(P(1)),i,s),n.sub(1),a,o),Kr(vt(r,i.add(P(1)),s),n,a.sub(1),o),Kr(vt(r.add(P(1)),i.add(P(1)),s),n.sub(1),a.sub(1),o),Kr(vt(r,i,s.add(P(1))),n,a,o.sub(1)),Kr(vt(r.add(P(1)),i,s.add(P(1))),n.sub(1),a,o.sub(1)),Kr(vt(r,i.add(P(1)),s.add(P(1))),n,a.sub(1),o.sub(1)),Kr(vt(r.add(P(1)),i.add(P(1)),s.add(P(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return mO(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),lw=li([jce,Wce]),Hce=z(([t])=>{const e=ne(t).toVar(),r=P().toVar(),i=P().toVar(),s=C($t(e.x,r)).toVar(),n=C($t(e.y,i)).toVar(),a=C(Bn(s)).toVar(),o=C(Bn(n)).toVar(),l=B(hO(As(Cs(r,i),s,n),As(Cs(r.add(P(1)),i),s.sub(1),n),As(Cs(r,i.add(P(1))),s,n.sub(1)),As(Cs(r.add(P(1)),i.add(P(1))),s.sub(1),n.sub(1)),a,o)).toVar();return dO(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qce=z(([t])=>{const e=B(t).toVar(),r=P().toVar(),i=P().toVar(),s=P().toVar(),n=C($t(e.x,r)).toVar(),a=C($t(e.y,i)).toVar(),o=C($t(e.z,s)).toVar(),l=C(Bn(n)).toVar(),h=C(Bn(a)).toVar(),u=C(Bn(o)).toVar(),c=B(cO(As(Cs(r,i,s),n,a,o),As(Cs(r.add(P(1)),i,s),n.sub(1),a,o),As(Cs(r,i.add(P(1)),s),n,a.sub(1),o),As(Cs(r.add(P(1)),i.add(P(1)),s),n.sub(1),a.sub(1),o),As(Cs(r,i,s.add(P(1))),n,a,o.sub(1)),As(Cs(r.add(P(1)),i,s.add(P(1))),n.sub(1),a,o.sub(1)),As(Cs(r,i.add(P(1)),s.add(P(1))),n,a.sub(1),o.sub(1)),As(Cs(r.add(P(1)),i.add(P(1)),s.add(P(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return mO(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),uw=li([Hce,qce]),Xce=z(([t])=>{const e=C(t).toVar(),r=P(mr(e)).toVar();return Ti(vt(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Yce=z(([t])=>{const e=ne(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar();return Ti(vt(r,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Zce=z(([t])=>{const e=B(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar();return Ti(vt(r,i,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Jce=z(([t])=>{const e=Oe(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar(),n=P(mr(e.w)).toVar();return Ti(vt(r,i,s,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),Kce=li([Xce,Yce,Zce,Jce]),Qce=z(([t])=>{const e=C(t).toVar(),r=P(mr(e)).toVar();return B(Ti(vt(r,P(0))),Ti(vt(r,P(1))),Ti(vt(r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ede=z(([t])=>{const e=ne(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar();return B(Ti(vt(r,i,P(0))),Ti(vt(r,i,P(1))),Ti(vt(r,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),tde=z(([t])=>{const e=B(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar();return B(Ti(vt(r,i,s,P(0))),Ti(vt(r,i,s,P(1))),Ti(vt(r,i,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),rde=z(([t])=>{const e=Oe(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar(),n=P(mr(e.w)).toVar();return B(Ti(vt(r,i,s,n,P(0))),Ti(vt(r,i,s,n,P(1))),Ti(vt(r,i,s,n,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),fO=li([Qce,ede,tde,rde]),Eg=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar(),l=C(0).toVar(),h=C(1).toVar();return Et(a,()=>{l.addAssign(h.mul(lw(o))),h.mulAssign(s),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gO=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar(),l=B(0).toVar(),h=C(1).toVar();return Et(a,()=>{l.addAssign(h.mul(uw(o))),h.mulAssign(s),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),ide=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar();return ne(Eg(o,a,n,s),Eg(o.add(B(P(19),P(193),P(17))),a,n,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),sde=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar(),l=B(gO(o,a,n,s)).toVar(),h=C(Eg(o.add(B(P(19),P(193),P(17))),a,n,s)).toVar();return Oe(l,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),nde=z(([t,e,r,i,s,n,a])=>{const o=P(a).toVar(),l=C(n).toVar(),h=P(s).toVar(),u=P(i).toVar(),c=P(r).toVar(),d=P(e).toVar(),m=ne(t).toVar(),p=B(fO(ne(d.add(u),c.add(h)))).toVar(),f=ne(p.x,p.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);const g=ne(ne(C(d),C(c)).add(f)).toVar(),y=ne(g.sub(m)).toVar();return je(o.equal(P(2)),()=>Vt(y.x).add(Vt(y.y))),je(o.equal(P(3)),()=>Gr(Vt(y.x),Vt(y.y))),Go(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),ade=z(([t,e,r,i,s,n,a,o,l])=>{const h=P(l).toVar(),u=C(o).toVar(),c=P(a).toVar(),d=P(n).toVar(),m=P(s).toVar(),p=P(i).toVar(),f=P(r).toVar(),g=P(e).toVar(),y=B(t).toVar(),T=B(fO(B(g.add(m),f.add(d),p.add(c)))).toVar();T.subAssign(.5),T.mulAssign(u),T.addAssign(.5);const M=B(B(C(g),C(f),C(p)).add(T)).toVar(),w=B(M.sub(y)).toVar();return je(h.equal(P(2)),()=>Vt(w.x).add(Vt(w.y)).add(Vt(w.z))),je(h.equal(P(3)),()=>Gr(Vt(w.x),Vt(w.y),Vt(w.z))),Go(w,w)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Vc=li([nde,ade]),ode=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=ne(t).toVar(),a=P().toVar(),o=P().toVar(),l=ne($t(n.x,a),$t(n.y,o)).toVar(),h=C(1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:c})=>{const d=C(Vc(l,u,c,a,o,s,i)).toVar();h.assign(js(h,d))})}),je(i.equal(P(0)),()=>{h.assign(Qn(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),lde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=ne(t).toVar(),a=P().toVar(),o=P().toVar(),l=ne($t(n.x,a),$t(n.y,o)).toVar(),h=ne(1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:c})=>{const d=C(Vc(l,u,c,a,o,s,i)).toVar();je(d.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.y.assign(d)})})}),je(i.equal(P(0)),()=>{h.assign(Qn(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),ude=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=ne(t).toVar(),a=P().toVar(),o=P().toVar(),l=ne($t(n.x,a),$t(n.y,o)).toVar(),h=B(1e6,1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:c})=>{const d=C(Vc(l,u,c,a,o,s,i)).toVar();je(d.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(d)}).ElseIf(d.lessThan(h.z),()=>{h.z.assign(d)})})}),je(i.equal(P(0)),()=>{h.assign(Qn(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),hde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=B(t).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),h=B($t(n.x,a),$t(n.y,o),$t(n.z,l)).toVar(),u=C(1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:c})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{Et({start:-1,end:P(1),name:"z",condition:"<="},({z:m})=>{const p=C(Vc(h,c,d,m,a,o,l,s,i)).toVar();u.assign(js(u,p))})})}),je(i.equal(P(0)),()=>{u.assign(Qn(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),cde=li([ode,hde]),dde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=B(t).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),h=B($t(n.x,a),$t(n.y,o),$t(n.z,l)).toVar(),u=ne(1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:c})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{Et({start:-1,end:P(1),name:"z",condition:"<="},({z:m})=>{const p=C(Vc(h,c,d,m,a,o,l,s,i)).toVar();je(p.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(p)}).ElseIf(p.lessThan(u.y),()=>{u.y.assign(p)})})})}),je(i.equal(P(0)),()=>{u.assign(Qn(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),mde=li([lde,dde]),pde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=B(t).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),h=B($t(n.x,a),$t(n.y,o),$t(n.z,l)).toVar(),u=B(1e6,1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:c})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{Et({start:-1,end:P(1),name:"z",condition:"<="},({z:m})=>{const p=C(Vc(h,c,d,m,a,o,l,s,i)).toVar();je(p.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(p)}).ElseIf(p.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(p)}).ElseIf(p.lessThan(u.z),()=>{u.z.assign(p)})})})}),je(i.equal(P(0)),()=>{u.assign(Qn(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),fde=li([ude,pde]),gde=z(([t])=>{const e=t.y,r=t.z,i=B().toVar();return je(e.lessThan(1e-4),()=>{i.assign(B(r,r,r))}).Else(()=>{let s=t.x;s=s.sub(zn(s)).mul(6).toVar();const n=P(PT(s)),a=s.sub(C(n)),o=r.mul(e.oneMinus()),l=r.mul(e.mul(a).oneMinus()),h=r.mul(e.mul(a.oneMinus()).oneMinus());je(n.equal(P(0)),()=>{i.assign(B(r,h,o))}).ElseIf(n.equal(P(1)),()=>{i.assign(B(l,r,o))}).ElseIf(n.equal(P(2)),()=>{i.assign(B(o,r,h))}).ElseIf(n.equal(P(3)),()=>{i.assign(B(o,l,r))}).ElseIf(n.equal(P(4)),()=>{i.assign(B(h,o,r))}).Else(()=>{i.assign(B(r,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),yde=z(([t])=>{const e=B(t).toVar(),r=C(e.x).toVar(),i=C(e.y).toVar(),s=C(e.z).toVar(),n=C(js(r,js(i,s))).toVar(),a=C(Gr(r,Gr(i,s))).toVar(),o=C(a.sub(n)).toVar(),l=C().toVar(),h=C().toVar(),u=C().toVar();return u.assign(a),je(a.greaterThan(0),()=>{h.assign(o.div(a))}).Else(()=>{h.assign(0)}),je(h.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{je(r.greaterThanEqual(a),()=>{l.assign(i.sub(s).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(fr(2,s.sub(r).div(o)))}).Else(()=>{l.assign(fr(4,r.sub(i).div(o)))}),l.mulAssign(1/6),je(l.lessThan(0),()=>{l.addAssign(1)})}),B(l,h,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),xde=z(([t])=>{const e=B(t).toVar(),r=ST(_T(e,B(.04045))).toVar(),i=B(e.div(12.92)).toVar(),s=B(pn(Gr(e.add(B(.055)),B(0)).div(1.055),B(2.4))).toVar();return ur(i,s,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),yO=(t,e)=>{t=C(t),e=C(e);const r=ne(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Iu(t.sub(r),t.add(r),e)},xO=(t,e,r,i)=>ur(t,e,r[i].clamp()),bde=(t,e,r=jt())=>xO(t,e,r,"x"),vde=(t,e,r=jt())=>xO(t,e,r,"y"),bO=(t,e,r,i,s)=>ur(t,e,yO(r,i[s])),Tde=(t,e,r,i=jt())=>bO(t,e,r,i,"x"),wde=(t,e,r,i=jt())=>bO(t,e,r,i,"y"),Sde=(t=1,e=0,r=jt())=>r.mul(t).add(e),Mde=(t,e=1)=>(t=C(t),t.abs().pow(e).mul(t.sign())),_de=(t,e=1,r=.5)=>C(t).sub(r).mul(e).add(r),Nde=(t=jt(),e=1,r=0)=>lw(t.convert("vec2|vec3")).mul(e).add(r),Ede=(t=jt(),e=1,r=0)=>uw(t.convert("vec2|vec3")).mul(e).add(r),Ade=(t=jt(),e=1,r=0)=>(t=t.convert("vec2|vec3"),Oe(uw(t),lw(t.add(ne(19,73)))).mul(e).add(r)),Cde=(t=jt(),e=1)=>cde(t.convert("vec2|vec3"),e,P(1)),Rde=(t=jt(),e=1)=>mde(t.convert("vec2|vec3"),e,P(1)),Pde=(t=jt(),e=1)=>fde(t.convert("vec2|vec3"),e,P(1)),Ide=(t=jt())=>Kce(t.convert("vec2|vec3")),Vde=(t=jt(),e=3,r=2,i=.5,s=1)=>Eg(t,P(e),r,i).mul(s),Ode=(t=jt(),e=3,r=2,i=.5,s=1)=>ide(t,P(e),r,i).mul(s),Lde=(t=jt(),e=3,r=2,i=.5,s=1)=>gO(t,P(e),r,i).mul(s),Fde=(t=jt(),e=3,r=2,i=.5,s=1)=>sde(t,P(e),r,i).mul(s),zde=z(([t,e,r])=>{const i=Wu(t).toVar(),s=it(C(.5).mul(e.sub(r)),Nu).div(i).toVar(),n=it(C(-.5).mul(e.sub(r)),Nu).div(i).toVar(),a=B().toVar();a.x=i.x.greaterThan(C(0)).select(s.x,n.x),a.y=i.y.greaterThan(C(0)).select(s.y,n.y),a.z=i.z.greaterThan(C(0)).select(s.z,n.z);const o=js(a.x,a.y,a.z).toVar();return Nu.add(i.mul(o)).toVar().sub(r)}),Bde=z(([t,e])=>{const r=t.x,i=t.y,s=t.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(i)),n=n.add(e.element(2).mul(2*.511664).mul(s)),n=n.add(e.element(3).mul(2*.511664).mul(r)),n=n.add(e.element(4).mul(2*.429043).mul(r).mul(i)),n=n.add(e.element(5).mul(2*.429043).mul(i).mul(s)),n=n.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(r).mul(s)),n=n.add(e.element(8).mul(.429043).mul(ke(r,r).sub(ke(i,i)))),n});var b=Object.freeze({__proto__:null,BRDF_GGX:sle,BRDF_Lambert:Qoe,BasicPointShadowFilter:oO,BasicShadowFilter:eO,Break:dV,Const:lI,Continue:_oe,DFGApprox:nle,D_GGX:_V,Discard:_I,EPSILON:AP,F_Schlick:wV,Fn:z,INFINITY:Sne,If:je,Loop:Et,NodeAccess:Rn,NodeShaderStage:wd,NodeType:Nse,NodeUpdateType:Tt,PCFShadowFilter:tO,PCFSoftShadowFilter:rO,PI:bg,PI2:Mne,PointShadowFilter:lO,Return:$ne,Schlick_to_F0:ale,ScriptableNodeResources:$f,ShaderNode:qh,Stack:xy,Switch:Xse,TBNViewMatrix:XT,VSMShadowFilter:iO,V_GGX_SmithCorrelated:MV,Var:oI,abs:Vt,acesFilmicToneMapping:ohe,acos:FP,add:fr,addMethodChaining:W,addNodeElement:Wne,agxToneMapping:che,all:CP,alphaT:i1,and:dP,anisotropy:tP,anisotropyB:ac,anisotropyT:Uf,any:RP,append:Kse,array:nP,arrayBuffer:Zse,asin:LP,assign:aP,atan:AT,atan2:iI,atomicAdd:Ghe,atomicAnd:qhe,atomicFunc:ea,atomicLoad:Dhe,atomicMax:Whe,atomicMin:Hhe,atomicOr:Xhe,atomicStore:$he,atomicSub:jhe,atomicXor:Yhe,attenuationColor:yne,attenuationDistance:gne,attribute:Bo,attributeArray:wue,backgroundBlurriness:Nue,backgroundIntensity:Eue,backgroundRotation:Aue,batch:uV,billboarding:sue,bitAnd:gP,bitNot:yP,bitOr:xP,bitXor:bP,bitangentGeometry:Nae,bitangentLocal:Eae,bitangentView:qI,bitangentWorld:Aae,bitcast:_ne,blendBurn:$V,blendColor:Bue,blendDodge:GV,blendOverlay:WV,blendScreen:jV,blur:RV,bool:Hn,buffer:km,bufferAttribute:Bm,bumpMap:ZI,burn:Due,bvec2:H5,bvec3:ST,bvec4:Z5,bypass:TI,cache:bI,call:oP,cameraFar:bo,cameraIndex:_y,cameraNear:xo,cameraNormalMatrix:iae,cameraPosition:sae,cameraProjectionMatrix:Um,cameraProjectionMatrixInverse:tae,cameraViewMatrix:Zs,cameraWorldMatrix:rae,cbrt:JP,cdl:Yue,ceil:Ty,checker:Sce,cineonToneMapping:nhe,clamp:Ba,clearcoat:tne,clearcoatRoughness:rne,code:Ry,color:j5,colorSpaceToWorking:BT,colorToDirection:Joe,compute:xI,computeSkinning:Soe,cond:sI,context:OT,convert:K5,convertColorSpace:Ine,convertToTexture:yue,cos:ga,cross:Sy,cubeTexture:HT,cubeTextureBase:WT,cubeToUV:on,dFdx:CT,dFdy:RT,dashSize:hne,debug:EI,decrement:_P,decrementBefore:SP,defaultBuildStages:Ese,defaultShaderStages:z5,defined:am,degrees:IP,deltaTime:FV,densityFog:Mhe,densityFogFactor:JV,depth:QT,depthPass:ehe,difference:HP,diffuseColor:_s,directPointLight:wce,directionToColor:Zoe,dispersion:xne,distance:WP,div:qn,dodge:$ue,dot:Go,drawIndex:aV,dynamicBufferAttribute:yI,element:J5,emissive:r1,equal:MT,equals:GP,equirectUV:TV,exp:VP,exp2:wc,expression:ka,faceDirection:$m,faceForward:VT,faceforward:Nne,float:C,floor:zn,fog:sw,fract:Ha,frameGroup:bne,frameId:Xle,frontFacing:LI,fwidth:DP,gain:Dle,gapSize:cne,getConstNodeType:$5,getCurrentStack:G5,getDirection:AV,getDistanceAttenuation:uO,getGeometryRoughness:SV,getNormalFromDepth:bue,getParallaxCorrectNormal:zde,getRoughness:ele,getScreenPosition:xue,getShIrradianceAt:Bde,getShadowMaterial:sO,getShadowRenderObjectFunction:nO,getTextureIndex:OV,getViewPosition:Bh,globalId:Rhe,glsl:fhe,glslFn:yhe,grayscale:Wue,greaterThan:_T,greaterThanEqual:cP,hash:Ule,highpModelNormalViewMatrix:yae,highpModelViewMatrix:gae,hue:Xue,increment:MP,incrementBefore:wP,instance:goe,instanceIndex:Po,instancedArray:Sue,instancedBufferAttribute:Tg,instancedDynamicBufferAttribute:s1,instancedMesh:lV,int:P,inverseSqrt:ET,inversesqrt:Ene,invocationLocalIndex:foe,invocationSubgroupIndex:poe,ior:mne,iridescence:eP,iridescenceIOR:nne,iridescenceThickness:ane,ivec2:kr,ivec3:q5,ivec4:X5,js:mhe,label:aI,length:vg,lengthSq:IT,lessThan:uP,lessThanEqual:hP,lightPosition:KV,lightProjectionUV:Zhe,lightShadowMatrix:aw,lightTargetDirection:Khe,lightTargetPosition:QV,lightViewPosition:Jhe,lightingContext:fV,lights:rce,linearDepth:Mg,linearToneMapping:ihe,localId:Phe,log:NT,log2:Pa,logarithmicDepthToViewZ:Uoe,loop:Noe,luminance:iw,mat2:by,mat3:Gs,mat4:_u,matcapUV:Ele,materialAO:iV,materialAlphaTest:JI,materialAnisotropy:Jae,materialAnisotropyVector:zh,materialAttenuationColor:noe,materialAttenuationDistance:soe,materialClearcoat:Wae,materialClearcoatNormal:qae,materialClearcoatRoughness:Hae,materialColor:KI,materialDispersion:doe,materialEmissive:QI,materialEnvIntensity:vae,materialEnvRotation:jT,materialIOR:ioe,materialIridescence:Kae,materialIridescenceIOR:Qae,materialIridescenceThickness:eoe,materialLightMap:rV,materialLineDashOffset:hoe,materialLineDashSize:ooe,materialLineGapSize:loe,materialLineScale:aoe,materialLineWidth:uoe,materialMetalness:jae,materialNormal:tV,materialOpacity:eV,materialPointSize:coe,materialReference:gl,materialReflectivity:$ae,materialRefractionRatio:UI,materialRotation:Xae,materialRoughness:Gae,materialSheen:Yae,materialSheenRoughness:Zae,materialShininess:zae,materialSpecular:Bae,materialSpecularColor:Uae,materialSpecularIntensity:kae,materialSpecularStrength:Dae,materialThickness:roe,materialTransmission:toe,max:Gr,maxMipLevel:CI,mediumpModelViewMatrix:VI,metalness:ene,min:js,mix:ur,mixElement:tI,mod:zm,modInt:EP,modelDirection:hae,modelNormalMatrix:II,modelPosition:cae,modelRadius:pae,modelScale:dae,modelViewMatrix:Dm,modelViewPosition:mae,modelViewProjection:sV,modelWorldMatrix:Ta,modelWorldMatrixInverse:fae,morphReference:mV,mrt:LV,mul:ke,mx_aastep:yO,mx_cell_noise_float:Ide,mx_contrast:_de,mx_fractal_noise_float:Vde,mx_fractal_noise_vec2:Ode,mx_fractal_noise_vec3:Lde,mx_fractal_noise_vec4:Fde,mx_hsvtorgb:gde,mx_noise_float:Nde,mx_noise_vec3:Ede,mx_noise_vec4:Ade,mx_ramplr:bde,mx_ramptb:vde,mx_rgbtohsv:yde,mx_safepower:Mde,mx_splitlr:Tde,mx_splittb:wde,mx_srgb_texture_to_lin_rec709:xde,mx_transform_uv:Sde,mx_worley_noise_float:Cde,mx_worley_noise_vec2:Rde,mx_worley_noise_vec3:Pde,namespace:vI,negate:zP,neutralToneMapping:dhe,nodeArray:Mu,nodeImmutable:ue,nodeObject:X,nodeObjects:Lm,nodeProxy:Z,normalFlat:FI,normalGeometry:$T,normalLocal:qi,normalMap:a1,normalView:Xn,normalWorld:zI,normalize:Wu,not:pP,notEqual:lP,numWorkgroups:Ahe,objectDirection:nae,objectGroup:sP,objectPosition:PI,objectRadius:uae,objectScale:oae,objectViewPosition:lae,objectWorldMatrix:aae,oneMinus:BP,or:mP,orthographicDepthToViewZ:koe,oscSawtooth:tue,oscSine:Kle,oscSquare:Qle,oscTriangle:eue,output:oc,outputStruct:Ble,overlay:jue,overloadingFn:li,parabola:c1,parallaxDirection:YI,parallaxUV:Rae,parameter:Ple,pass:Kue,passTexture:Que,pcurve:$le,perspectiveDepthToViewZ:JT,pmremTexture:_le,pointShadow:Tce,pointUV:_ue,pointWidth:dne,positionGeometry:DT,positionLocal:cr,positionPrevious:wg,positionView:ti,positionViewDirection:ms,positionWorld:Nu,positionWorldDirection:OI,posterize:Jue,pow:pn,pow2:qP,pow3:XP,pow4:YP,premult:kue,property:Ic,radians:PP,rand:eI,range:Nhe,rangeFog:She,rangeFogFactor:ZV,reciprocal:UP,reference:Zt,referenceBuffer:n1,reflect:jP,reflectVector:GI,reflectView:DI,reflector:due,refract:QP,refractVector:jI,refractView:$I,reinhardToneMapping:she,remainder:NP,remap:SI,remapClamp:MI,renderGroup:Ye,renderOutput:NI,rendererReference:pI,rotate:IV,rotateUV:rue,roughness:Q5,round:kP,rtt:kV,sRGBTransferEOTF:cI,sRGBTransferOETF:dI,sampler:Zne,samplerComparison:Jne,saturate:KP,saturation:Hue,screen:Gue,screenCoordinate:Hm,screenSize:Sg,screenUV:jo,scriptable:whe,scriptableValue:Df,select:yi,setCurrentStack:t1,shaderStages:Ase,shadow:yce,shadowPositionWorld:ow,shapeCircle:Mce,sharedUniformGroup:vy,sheen:ine,sheenRoughness:sne,shiftLeft:vP,shiftRight:TP,shininess:une,sign:lm,sin:cs,sinc:Gle,skinning:cV,smoothstep:Iu,smoothstepElement:rI,specularColor:one,specularF90:lne,spherizeUV:iue,split:Jse,spritesheetUV:oue,sqrt:Qn,stack:Vle,step:wy,storage:Eu,storageBarrier:Lhe,storageObject:woe,storageTexture:UV,string:Yse,struct:zle,sub:it,subgroupIndex:moe,subgroupSize:Ihe,tan:OP,tangentGeometry:Ey,tangentLocal:Gm,tangentView:jm,tangentWorld:HI,temp:uI,texture:_t,texture3D:Vue,textureBarrier:Fhe,textureBicubic:ole,textureCubeUV:CV,textureLoad:tr,textureSize:Ro,textureStore:Rue,thickness:fne,time:Hu,timerDelta:Jle,timerGlobal:Zle,timerLocal:Yle,toneMapping:fI,toneMappingExposure:gI,toonOutlinePass:rhe,transformDirection:ZP,transformNormal:kI,transformNormalToView:GT,transformedBentNormalView:Pae,transformedBitangentView:XI,transformedBitangentWorld:Cae,transformedClearcoatNormalView:bae,transformedNormalView:Da,transformedNormalWorld:BI,transformedTangentView:qT,transformedTangentWorld:_ae,transmission:pne,transpose:$P,triNoise3D:Wle,triplanarTexture:uue,triplanarTextures:zV,trunc:PT,tslFn:Qse,uint:fe,uniform:Ie,uniformArray:dn,uniformCubeTexture:wae,uniformGroup:iP,uniformTexture:Yne,uniforms:Qne,unpremult:Uue,userData:Lue,uv:jt,uvec2:W5,uvec3:Pc,uvec4:Y5,varying:Ys,varyingProperty:om,vec2:ne,vec3:B,vec4:Oe,vectorComponents:Rc,velocity:zue,vertexColor:vV,vertexIndex:nV,vertexStage:hI,vibrance:que,viewZToLogarithmicDepth:KT,viewZToOrthographicDepth:lc,viewZToPerspectiveDepth:xV,viewport:YT,viewportBottomLeft:Loe,viewportCoordinate:yV,viewportDepthTexture:ZT,viewportLinearDepth:Doe,viewportMipTexture:zoe,viewportResolution:Voe,viewportSafeUV:nue,viewportSharedTexture:Yoe,viewportSize:gV,viewportTexture:Foe,viewportTopLeft:Ooe,viewportUV:Ioe,wgsl:phe,wgslFn:xhe,workgroupArray:khe,workgroupBarrier:Ohe,workgroupId:Che,workingToColorSpace:mI,xor:fP});const Vh=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4};Rn.READ_ONLY+"",Rn.WRITE_ONLY+"",Rn.READ_WRITE+"";Vh&&Vh.VERTEX,Vh&&Vh.FRAGMENT,Vh&&Vh.COMPUTE;const ll={tsl_xor:new Lr("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Lr("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Lr("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Lr("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Lr("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Lr("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Lr("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Lr("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Lr("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Lr("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Lr("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Lr("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Lr(`
485
+ `):e.addLineFlowCode(`${r}Barrier()`,this)}}const nw=Z(Vhe),Ohe=()=>nw("workgroup").toStack(),Lhe=()=>nw("storage").toStack(),Fhe=()=>nw("texture").toStack();class zhe extends ju{constructor(e,r){super(e,r),this.isWorkgroupInfoElementNode=!0}generate(e,r){let i;const s=e.context.assign;if(i=super.generate(e),s!==!0){const n=this.getNodeType(e);i=e.format(i,n,r)}return i}}class Bhe extends Ae{constructor(e,r,i=0){super(r),this.bufferType=r,this.bufferCount=i,this.isWorkgroupInfoNode=!0,this.elementType=r,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return X(new zhe(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const khe=(t,e)=>X(new Bhe("Workgroup",t,e));class jr extends Ae{static get type(){return"AtomicFunctionNode"}constructor(e,r,i){super("uint"),this.method=e,this.pointerNode=r,this.valueNode=i,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const r=e.getNodeProperties(this),i=r.parents,s=this.method,n=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,l=this.valueNode,h=[];h.push(`&${o.build(e,a)}`),l!==null&&h.push(l.build(e,a));const u=`${e.getMethod(s,n)}( ${h.join(", ")} )`;if(i.length===1&&i[0].isStackNode===!0)e.addLineFlowCode(u,this);else return r.constNode===void 0&&(r.constNode=ka(u,n).toConst()),r.constNode.build(e)}}jr.ATOMIC_LOAD="atomicLoad";jr.ATOMIC_STORE="atomicStore";jr.ATOMIC_ADD="atomicAdd";jr.ATOMIC_SUB="atomicSub";jr.ATOMIC_MAX="atomicMax";jr.ATOMIC_MIN="atomicMin";jr.ATOMIC_AND="atomicAnd";jr.ATOMIC_OR="atomicOr";jr.ATOMIC_XOR="atomicXor";const Uhe=Z(jr),ea=(t,e,r)=>Uhe(t,e,r).toStack(),Dhe=t=>ea(jr.ATOMIC_LOAD,t,null),$he=(t,e)=>ea(jr.ATOMIC_STORE,t,e),Ghe=(t,e)=>ea(jr.ATOMIC_ADD,t,e),jhe=(t,e)=>ea(jr.ATOMIC_SUB,t,e),Whe=(t,e)=>ea(jr.ATOMIC_MAX,t,e),Hhe=(t,e)=>ea(jr.ATOMIC_MIN,t,e),qhe=(t,e)=>ea(jr.ATOMIC_AND,t,e),Xhe=(t,e)=>ea(jr.ATOMIC_OR,t,e),Yhe=(t,e)=>ea(jr.ATOMIC_XOR,t,e);let vf;function Py(t){vf=vf||new WeakMap;let e=vf.get(t);return e===void 0&&vf.set(t,e={}),e}function aw(t){const e=Py(t);return e.shadowMatrix||(e.shadowMatrix=Pe("mat4").setGroup(Ye).onRenderUpdate(r=>((t.castShadow!==!0||r.renderer.shadowMap.enabled===!1)&&t.shadow.updateMatrices(t),t.shadow.matrix)))}function Zhe(t,e=Nu){const r=aw(t).mul(e);return r.xyz.div(r.w)}function KV(t){const e=Py(t);return e.position||(e.position=Pe(new $).setGroup(Ye).onRenderUpdate((r,i)=>i.value.setFromMatrixPosition(t.matrixWorld)))}function QV(t){const e=Py(t);return e.targetPosition||(e.targetPosition=Pe(new $).setGroup(Ye).onRenderUpdate((r,i)=>i.value.setFromMatrixPosition(t.target.matrixWorld)))}function Jhe(t){const e=Py(t);return e.viewPosition||(e.viewPosition=Pe(new $).setGroup(Ye).onRenderUpdate(({camera:r},i)=>{i.value=i.value||new $,i.value.setFromMatrixPosition(t.matrixWorld),i.value.applyMatrix4(r.matrixWorldInverse)}))}const Khe=t=>Zs.transformDirection(KV(t).sub(QV(t))),Qhe=t=>t.sort((e,r)=>e.id-r.id),ece=(t,e)=>{for(const r of e)if(r.isAnalyticLightNode&&r.light.id===t)return r;return null},Fx=new WeakMap,dd=[];class tce extends Ae{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=B().toVar(),this.totalSpecularNode=B().toVar(),this.outgoingLightNode=B().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let i=0;i<e.length;i++){const s=e[i];if(dd.push(s.id),dd.push(s.castShadow?1:0),s.isSpotLight===!0){const n=s.map!==null?s.map.id:-1,a=s.colorNode?s.colorNode.getCacheKey():-1;dd.push(n,a)}}const r=C5(dd);return dd.length=0,r}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const r=[];for(const i of this._lightNodes)r.push(i.getSelf().getHash());this._lightNodesHash="lights-"+r.join(",")}return this._lightNodesHash}analyze(e){const r=e.getNodeProperties(this);for(const i of r.nodes)i.build(e);r.outputNode.build(e)}setupLightsNode(e){const r=[],i=this._lightNodes,s=Qhe(this._lights),n=e.renderer.library;for(const a of s)if(a.isNode)r.push(X(a));else{let o=null;if(i!==null&&(o=ece(a.id,i)),o===null){const l=n.getLightNodeClass(a.constructor);if(l===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let h=null;Fx.has(a)?h=Fx.get(a):(h=X(new l(a)),Fx.set(a,h)),r.push(h)}}this._lightNodes=r}setupDirectLight(e,r,i){const{lightingModel:s,reflectedLight:n}=e.context;s.direct({...i,lightNode:r,reflectedLight:n},e)}setupDirectRectAreaLight(e,r,i){const{lightingModel:s,reflectedLight:n}=e.context;s.directRectArea({...i,lightNode:r,reflectedLight:n},e)}setupLights(e,r){for(const i of r)i.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const r=e.lightsNode;e.lightsNode=this;let i=this.outgoingLightNode;const s=e.context,n=s.lightingModel,a=e.getNodeProperties(this);if(n){const{totalDiffuseNode:o,totalSpecularNode:l}=this;s.outgoingLight=i;const h=e.addStack();a.nodes=h.nodes,n.start(e);const{backdrop:u,backdropAlpha:c}=s,{directDiffuse:d,directSpecular:m,indirectDiffuse:p,indirectSpecular:f}=s.reflectedLight;let g=d.add(p);u!==null&&(c!==null?g=B(c.mix(g,u)):g=B(u),s.material.transparent=!0),o.assign(g),l.assign(m.add(f)),i.assign(o.add(l)),n.finish(e),i=i.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=r,i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}const rce=(t=[])=>X(new tce).setLights(t);class ice extends Ae{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Tt.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:r}){ow.assign(r.receivedShadowPositionNode||e.shadowPositionWorld||Nu)}}const ow=Ic("vec3","shadowPositionWorld");function sce(t,e={}){return e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.renderTarget=t.getRenderTarget(),e.activeCubeFace=t.getActiveCubeFace(),e.activeMipmapLevel=t.getActiveMipmapLevel(),e.renderObjectFunction=t.getRenderObjectFunction(),e.pixelRatio=t.getPixelRatio(),e.mrt=t.getMRT(),e.clearColor=t.getClearColor(e.clearColor||new ja),e.clearAlpha=t.getClearAlpha(),e.autoClear=t.autoClear,e.scissorTest=t.getScissorTest(),e}function nce(t,e){return e=sce(t,e),t.setMRT(null),t.setRenderObjectFunction(null),t.setClearColor(0,1),t.autoClear=!0,e}function ace(t,e){t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),t.setRenderObjectFunction(e.renderObjectFunction),t.setPixelRatio(e.pixelRatio),t.setMRT(e.mrt),t.setClearColor(e.clearColor,e.clearAlpha),t.autoClear=e.autoClear,t.setScissorTest(e.scissorTest)}function oce(t,e={}){return e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial,e}function lce(t,e){return e=oce(t,e),t.background=null,t.backgroundNode=null,t.overrideMaterial=null,e}function uce(t,e){t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial}function hce(t,e,r){return r=nce(t,r),r=lce(e,r),r}function cce(t,e,r){ace(t,r),uce(e,r)}const NN=new WeakMap,eO=z(({depthTexture:t,shadowCoord:e,depthLayer:r})=>{let i=_t(t,e.xy).label("t_basic");return t.isArrayTexture&&(i=i.depth(r)),i.compare(e.z)}),tO=z(({depthTexture:t,shadowCoord:e,shadow:r,depthLayer:i})=>{const s=(g,y)=>{let T=_t(t,g);return t.isArrayTexture&&(T=T.depth(i)),T.compare(y)},n=Zt("mapSize","vec2",r).setGroup(Ye),a=Zt("radius","float",r).setGroup(Ye),o=ne(1).div(n),l=o.x.negate().mul(a),h=o.y.negate().mul(a),u=o.x.mul(a),c=o.y.mul(a),d=l.div(2),m=h.div(2),p=u.div(2),f=c.div(2);return fr(s(e.xy.add(ne(l,h)),e.z),s(e.xy.add(ne(0,h)),e.z),s(e.xy.add(ne(u,h)),e.z),s(e.xy.add(ne(d,m)),e.z),s(e.xy.add(ne(0,m)),e.z),s(e.xy.add(ne(p,m)),e.z),s(e.xy.add(ne(l,0)),e.z),s(e.xy.add(ne(d,0)),e.z),s(e.xy,e.z),s(e.xy.add(ne(p,0)),e.z),s(e.xy.add(ne(u,0)),e.z),s(e.xy.add(ne(d,f)),e.z),s(e.xy.add(ne(0,f)),e.z),s(e.xy.add(ne(p,f)),e.z),s(e.xy.add(ne(l,c)),e.z),s(e.xy.add(ne(0,c)),e.z),s(e.xy.add(ne(u,c)),e.z)).mul(1/17)}),rO=z(({depthTexture:t,shadowCoord:e,shadow:r,depthLayer:i})=>{const s=(c,d)=>{let m=_t(t,c);return t.isArrayTexture&&(m=m.depth(i)),m.compare(d)},n=Zt("mapSize","vec2",r).setGroup(Ye),a=ne(1).div(n),o=a.x,l=a.y,h=e.xy,u=Ha(h.mul(n).add(.5));return h.subAssign(u.mul(a)),fr(s(h,e.z),s(h.add(ne(o,0)),e.z),s(h.add(ne(0,l)),e.z),s(h.add(a),e.z),ur(s(h.add(ne(o.negate(),0)),e.z),s(h.add(ne(o.mul(2),0)),e.z),u.x),ur(s(h.add(ne(o.negate(),l)),e.z),s(h.add(ne(o.mul(2),l)),e.z),u.x),ur(s(h.add(ne(0,l.negate())),e.z),s(h.add(ne(0,l.mul(2))),e.z),u.y),ur(s(h.add(ne(o,l.negate())),e.z),s(h.add(ne(o,l.mul(2))),e.z),u.y),ur(ur(s(h.add(ne(o.negate(),l.negate())),e.z),s(h.add(ne(o.mul(2),l.negate())),e.z),u.x),ur(s(h.add(ne(o.negate(),l.mul(2))),e.z),s(h.add(ne(o.mul(2),l.mul(2))),e.z),u.x),u.y)).mul(1/9)}),iO=z(({depthTexture:t,shadowCoord:e,depthLayer:r})=>{const i=C(1).toVar();let s=_t(t).sample(e.xy);t.isArrayTexture&&(s=s.depth(r)),s=s.rg;const n=wy(e.z,s.x);return je(n.notEqual(C(1)),()=>{const a=e.z.sub(s.x),o=Gr(0,s.y.mul(s.y));let l=o.div(o.add(a.mul(a)));l=Ba(it(l,.3).div(.95-.3)),i.assign(Ba(Gr(n,l)))}),i}),dce=z(([t,e,r])=>{let i=Nu.sub(t).length();return i=i.sub(e).div(r.sub(e)),i=i.saturate(),i}),mce=t=>{const e=t.shadow.camera,r=Zt("near","float",e).setGroup(Ye),i=Zt("far","float",e).setGroup(Ye),s=PI(t);return dce(s,r,i)},sO=t=>{let e=NN.get(t);if(e===void 0){const r=t.isPointLight?mce(t):null;e=new Sc,e.colorNode=Oe(0,0,0,1),e.depthNode=r,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,NN.set(t,e)}return e},EN=new Cle,Ph=[],nO=(t,e,r,i)=>{Ph[0]=t,Ph[1]=e;let s=EN.get(Ph);return(s===void 0||s.shadowType!==r||s.useVelocity!==i)&&(s=(n,a,o,l,h,u,...c)=>{(n.castShadow===!0||n.receiveShadow&&r===Ff)&&(i&&(O5(n).useVelocity=!0),n.onBeforeShadow(t,n,o,e.camera,l,a.overrideMaterial,u),t.renderObject(n,a,o,l,h,u,...c),n.onAfterShadow(t,n,o,e.camera,l,a.overrideMaterial,u))},s.shadowType=r,s.useVelocity=i,EN.set(Ph,s)),Ph[0]=null,Ph[1]=null,s},pce=z(({samples:t,radius:e,size:r,shadowPass:i,depthLayer:s})=>{const n=C(0).toVar("meanVertical"),a=C(0).toVar("squareMeanVertical"),o=t.lessThanEqual(C(1)).select(C(0),C(2).div(t.sub(1))),l=t.lessThanEqual(C(1)).select(C(0),C(-1));Et({start:P(0),end:P(t),type:"int",condition:"<"},({i:u})=>{const c=l.add(C(u).mul(o));let d=i.sample(fr(Hm.xy,ne(0,c).mul(e)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(t),a.divAssign(t);const h=Qn(a.sub(n.mul(n)));return ne(n,h)}),fce=z(({samples:t,radius:e,size:r,shadowPass:i,depthLayer:s})=>{const n=C(0).toVar("meanHorizontal"),a=C(0).toVar("squareMeanHorizontal"),o=t.lessThanEqual(C(1)).select(C(0),C(2).div(t.sub(1))),l=t.lessThanEqual(C(1)).select(C(0),C(-1));Et({start:P(0),end:P(t),type:"int",condition:"<"},({i:u})=>{const c=l.add(C(u).mul(o));let d=i.sample(fr(Hm.xy,ne(c,0).mul(e)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),n.addAssign(d.x),a.addAssign(fr(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(t),a.divAssign(t);const h=Qn(a.sub(n.mul(n)));return ne(n,h)}),gce=[eO,tO,rO,iO];let zx;const Tf=new BV;class aO extends ice{static get type(){return"ShadowNode"}constructor(e,r=null){super(e),this.shadow=r||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:r,depthTexture:i,shadowCoord:s,shadow:n,depthLayer:a}){const o=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),l=r({depthTexture:i,shadowCoord:s,shadow:n,depthLayer:a});return o.select(l,C(1))}setupShadowCoord(e,r){const{shadow:i}=this,{renderer:s}=e,n=Zt("bias","float",i).setGroup(Ye);let a=r,o;if(i.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,s.coordinateSystem===Ru&&(o=o.mul(2).sub(1));else{const l=a.w;a=a.xy.div(l);const h=Zt("near","float",i.camera).setGroup(Ye),u=Zt("far","float",i.camera).setGroup(Ye);o=KT(l.negate(),h,u)}return a=B(a.x,a.y.oneMinus(),o.add(n)),a}getShadowFilterFn(e){return gce[e]}setupRenderTarget(e,r){const i=new Am(e.mapSize.width,e.mapSize.height);i.name="ShadowDepthTexture",i.compareFunction=CJ;const s=r.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=i,{shadowMap:s,depthTexture:i}}setupShadow(e){const{renderer:r}=e,{light:i,shadow:s}=this,n=r.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(s,e);if(s.camera.updateProjectionMatrix(),n===Ff&&s.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:So,type:wo,depthBuffer:!1}));let y=_t(a);a.isArrayTexture&&(y=y.depth(this.depthLayer));let T=_t(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(T=T.depth(this.depthLayer));const M=Zt("blurSamples","float",s).setGroup(Ye),w=Zt("radius","float",s).setGroup(Ye),_=Zt("mapSize","vec2",s).setGroup(Ye);let S=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Sc);S.fragmentNode=pce({samples:M,radius:w,size:_,shadowPass:y,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMVertical",S=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Sc),S.fragmentNode=fce({samples:M,radius:w,size:_,shadowPass:T,depthLayer:this.depthLayer}).context(e.getSharedContext()),S.name="VSMHorizontal"}const l=Zt("intensity","float",s).setGroup(Ye),h=Zt("normalBias","float",s).setGroup(Ye),u=aw(i).mul(ow.add(BI.mul(h))),c=this.setupShadowCoord(e,u),d=s.filterNode||this.getShadowFilterFn(r.shadowMap.type)||null;if(d===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const m=n===Ff&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:m,shadowCoord:c,shadow:s,depthLayer:this.depthLayer});let f=_t(o.texture,c);a.isArrayTexture&&(f=f.depth(this.depthLayer));const g=ur(1,p.rgb.mix(f,1),l.mul(f.a)).toVar();return this.shadowMap=o,this.shadow.map=o,g}setup(e){if(e.renderer.shadowMap.enabled!==!1)return z(()=>{let r=this._node;return this.setupShadowPosition(e),r===null&&(this._node=r=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:r,shadowMap:i,light:s}=this,{renderer:n,scene:a}=e;r.updateMatrices(s),i.setSize(r.mapSize.width,r.mapSize.height,i.depth),n.render(a,r.camera)}updateShadow(e){const{shadowMap:r,light:i,shadow:s}=this,{renderer:n,scene:a,camera:o}=e,l=n.shadowMap.type,h=r.depthTexture.version;this._depthVersionCached=h;const u=s.camera.layers.mask;(s.camera.layers.mask&4294967294)===0&&(s.camera.layers.mask=o.layers.mask);const c=n.getRenderObjectFunction(),d=n.getMRT(),m=d?d.has("velocity"):!1;zx=hce(n,a,zx),a.overrideMaterial=sO(i),n.setRenderObjectFunction(nO(n,s,l,m)),n.setClearColor(0,0),n.setRenderTarget(r),this.renderShadow(e),n.setRenderObjectFunction(c),l===Ff&&s.isPointLightShadow!==!0&&this.vsmPass(n),s.camera.layers.mask=u,cce(n,a,zx)}vsmPass(e){const{shadow:r}=this,i=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(r.mapSize.width,r.mapSize.height,i),this.vsmShadowMapHorizontal.setSize(r.mapSize.width,r.mapSize.height,i),e.setRenderTarget(this.vsmShadowMapVertical),Tf.material=this.vsmMaterialVertical,Tf.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Tf.material=this.vsmMaterialHorizontal,Tf.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:r}=this;let i=r.needsUpdate||r.autoUpdate;i&&(this._cameraFrameId[e.camera]===e.frameId&&(i=!1),this._cameraFrameId[e.camera]=e.frameId),i&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(r.needsUpdate=!1))}}const yce=(t,e)=>X(new aO(t,e)),xce=new ja,on=z(([t,e])=>{const r=t.toVar(),i=Vt(r),s=qn(1,Gr(i.x,Gr(i.y,i.z)));i.mulAssign(s),r.mulAssign(s.mul(e.mul(2).oneMinus()));const n=ne(r.xy).toVar(),o=e.mul(1.5).oneMinus();return je(i.z.greaterThanEqual(o),()=>{je(r.z.greaterThan(0),()=>{n.x.assign(it(4,r.x))})}).ElseIf(i.x.greaterThanEqual(o),()=>{const l=lm(r.x);n.x.assign(r.z.mul(l).add(l.mul(2)))}).ElseIf(i.y.greaterThanEqual(o),()=>{const l=lm(r.y);n.x.assign(r.x.add(l.mul(2)).add(2)),n.y.assign(r.z.mul(l).sub(2))}),ne(.125,.25).mul(n).add(ne(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),oO=z(({depthTexture:t,bd3D:e,dp:r,texelSize:i})=>_t(t,on(e,i.y)).compare(r)),lO=z(({depthTexture:t,bd3D:e,dp:r,texelSize:i,shadow:s})=>{const n=Zt("radius","float",s).setGroup(Ye),a=ne(-1,1).mul(n).mul(i.y);return _t(t,on(e.add(a.xyy),i.y)).compare(r).add(_t(t,on(e.add(a.yyy),i.y)).compare(r)).add(_t(t,on(e.add(a.xyx),i.y)).compare(r)).add(_t(t,on(e.add(a.yyx),i.y)).compare(r)).add(_t(t,on(e,i.y)).compare(r)).add(_t(t,on(e.add(a.xxy),i.y)).compare(r)).add(_t(t,on(e.add(a.yxy),i.y)).compare(r)).add(_t(t,on(e.add(a.xxx),i.y)).compare(r)).add(_t(t,on(e.add(a.yxx),i.y)).compare(r)).mul(1/9)}),bce=z(({filterFn:t,depthTexture:e,shadowCoord:r,shadow:i})=>{const s=r.xyz.toVar(),n=s.length(),a=Pe("float").setGroup(Ye).onRenderUpdate(()=>i.camera.near),o=Pe("float").setGroup(Ye).onRenderUpdate(()=>i.camera.far),l=Zt("bias","float",i).setGroup(Ye),h=Pe(i.mapSize).setGroup(Ye),u=C(1).toVar();return je(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),()=>{const c=n.sub(a).div(o.sub(a)).toVar();c.addAssign(l);const d=s.normalize(),m=ne(1).div(h.mul(ne(4,2)));u.assign(t({depthTexture:e,bd3D:d,dp:c,texelSize:m,shadow:i}))}),u}),AN=new Si,Ih=new Jt,md=new Jt;class vce extends aO{static get type(){return"PointShadowNode"}constructor(e,r=null){super(e,r)}getShadowFilterFn(e){return e===TJ?oO:lO}setupShadowCoord(e,r){return r}setupShadowFilter(e,{filterFn:r,shadowTexture:i,depthTexture:s,shadowCoord:n,shadow:a}){return bce({filterFn:r,shadowTexture:i,depthTexture:s,shadowCoord:n,shadow:a})}renderShadow(e){const{shadow:r,shadowMap:i,light:s}=this,{renderer:n,scene:a}=e,o=r.getFrameExtents();md.copy(r.mapSize),md.multiply(o),i.setSize(md.width,md.height),Ih.copy(r.mapSize);const l=n.autoClear,h=n.getClearColor(xce),u=n.getClearAlpha();n.autoClear=!1,n.setClearColor(r.clearColor,r.clearAlpha),n.clear();const c=r.getViewportCount();for(let d=0;d<c;d++){const m=r.getViewport(d),p=Ih.x*m.x,f=md.y-Ih.y-Ih.y*m.y;AN.set(p,f,Ih.x*m.z,Ih.y*m.w),i.viewport.copy(AN),r.updateMatrices(s,d),n.render(a,r.camera)}n.autoClear=l,n.setClearColor(h,u)}}const Tce=(t,e)=>X(new vce(t,e)),uO=z(({lightDistance:t,cutoffDistance:e,decayExponent:r})=>{const i=t.pow(r).max(.01).reciprocal();return e.greaterThan(0).select(i.mul(t.div(e).pow4().oneMinus().clamp().pow2()),i)}),wce=({color:t,lightVector:e,cutoffDistance:r,decayExponent:i})=>{const s=e.normalize(),n=e.length(),a=uO({lightDistance:n,cutoffDistance:r,decayExponent:i}),o=t.mul(a);return{lightDirection:s,lightColor:o}},Sce=z(([t=jt()])=>{const e=t.mul(2),r=e.x.floor(),i=e.y.floor();return r.add(i).mod(2).sign()}),Mce=z(([t=jt()],{renderer:e,material:r})=>{const i=IT(t.mul(2).sub(1));let s;if(r.alphaToCoverage&&e.samples>1){const n=C(i.fwidth()).toVar();s=Iu(n.oneMinus(),n.add(1),i).oneMinus()}else s=yi(i.greaterThan(1),0,1);return s}),$d=z(([t,e,r])=>{const i=C(r).toVar(),s=C(e).toVar(),n=Hn(t).toVar();return yi(n,s,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Ng=z(([t,e])=>{const r=Hn(e).toVar(),i=C(t).toVar();return yi(r,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),mr=z(([t])=>{const e=C(t).toVar();return P(zn(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),$t=z(([t,e])=>{const r=C(t).toVar();return e.assign(mr(r)),r.sub(C(e))}),_ce=z(([t,e,r,i,s,n])=>{const a=C(n).toVar(),o=C(s).toVar(),l=C(i).toVar(),h=C(r).toVar(),u=C(e).toVar(),c=C(t).toVar(),d=C(it(1,o)).toVar();return it(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Nce=z(([t,e,r,i,s,n])=>{const a=C(n).toVar(),o=C(s).toVar(),l=B(i).toVar(),h=B(r).toVar(),u=B(e).toVar(),c=B(t).toVar(),d=C(it(1,o)).toVar();return it(1,a).mul(c.mul(d).add(u.mul(o))).add(a.mul(h.mul(d).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),hO=li([_ce,Nce]),Ece=z(([t,e,r,i,s,n,a,o,l,h,u])=>{const c=C(u).toVar(),d=C(h).toVar(),m=C(l).toVar(),p=C(o).toVar(),f=C(a).toVar(),g=C(n).toVar(),y=C(s).toVar(),T=C(i).toVar(),M=C(r).toVar(),w=C(e).toVar(),_=C(t).toVar(),S=C(it(1,m)).toVar(),N=C(it(1,d)).toVar();return C(it(1,c)).toVar().mul(N.mul(_.mul(S).add(w.mul(m))).add(d.mul(M.mul(S).add(T.mul(m))))).add(c.mul(N.mul(y.mul(S).add(g.mul(m))).add(d.mul(f.mul(S).add(p.mul(m))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Ace=z(([t,e,r,i,s,n,a,o,l,h,u])=>{const c=C(u).toVar(),d=C(h).toVar(),m=C(l).toVar(),p=B(o).toVar(),f=B(a).toVar(),g=B(n).toVar(),y=B(s).toVar(),T=B(i).toVar(),M=B(r).toVar(),w=B(e).toVar(),_=B(t).toVar(),S=C(it(1,m)).toVar(),N=C(it(1,d)).toVar();return C(it(1,c)).toVar().mul(N.mul(_.mul(S).add(w.mul(m))).add(d.mul(M.mul(S).add(T.mul(m))))).add(c.mul(N.mul(y.mul(S).add(g.mul(m))).add(d.mul(f.mul(S).add(p.mul(m))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),cO=li([Ece,Ace]),Cce=z(([t,e,r])=>{const i=C(r).toVar(),s=C(e).toVar(),n=fe(t).toVar(),a=fe(n.bitAnd(fe(7))).toVar(),o=C($d(a.lessThan(fe(4)),s,i)).toVar(),l=C(ke(2,$d(a.lessThan(fe(4)),i,s))).toVar();return Ng(o,Hn(a.bitAnd(fe(1)))).add(Ng(l,Hn(a.bitAnd(fe(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Rce=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=C(e).toVar(),o=fe(t).toVar(),l=fe(o.bitAnd(fe(15))).toVar(),h=C($d(l.lessThan(fe(8)),a,n)).toVar(),u=C($d(l.lessThan(fe(4)),n,$d(l.equal(fe(12)).or(l.equal(fe(14))),a,s))).toVar();return Ng(h,Hn(l.bitAnd(fe(1)))).add(Ng(u,Hn(l.bitAnd(fe(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Kr=li([Cce,Rce]),Pce=z(([t,e,r])=>{const i=C(r).toVar(),s=C(e).toVar(),n=Pc(t).toVar();return B(Kr(n.x,s,i),Kr(n.y,s,i),Kr(n.z,s,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Ice=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=C(e).toVar(),o=Pc(t).toVar();return B(Kr(o.x,a,n,s),Kr(o.y,a,n,s),Kr(o.z,a,n,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),As=li([Pce,Ice]),Vce=z(([t])=>{const e=C(t).toVar();return ke(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Oce=z(([t])=>{const e=C(t).toVar();return ke(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Lce=z(([t])=>{const e=B(t).toVar();return ke(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),dO=li([Vce,Lce]),Fce=z(([t])=>{const e=B(t).toVar();return ke(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),mO=li([Oce,Fce]),ls=z(([t,e])=>{const r=P(e).toVar(),i=fe(t).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(P(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),pO=z(([t,e,r])=>{t.subAssign(r),t.bitXorAssign(ls(r,P(4))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(ls(t,P(6))),t.addAssign(r),r.subAssign(e),r.bitXorAssign(ls(e,P(8))),e.addAssign(t),t.subAssign(r),t.bitXorAssign(ls(r,P(16))),r.addAssign(e),e.subAssign(t),e.bitXorAssign(ls(t,P(19))),t.addAssign(r),r.subAssign(e),r.bitXorAssign(ls(e,P(4))),e.addAssign(t)}),Xm=z(([t,e,r])=>{const i=fe(r).toVar(),s=fe(e).toVar(),n=fe(t).toVar();return i.bitXorAssign(s),i.subAssign(ls(s,P(14))),n.bitXorAssign(i),n.subAssign(ls(i,P(11))),s.bitXorAssign(n),s.subAssign(ls(n,P(25))),i.bitXorAssign(s),i.subAssign(ls(s,P(16))),n.bitXorAssign(i),n.subAssign(ls(i,P(4))),s.bitXorAssign(n),s.subAssign(ls(n,P(14))),i.bitXorAssign(s),i.subAssign(ls(s,P(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Ti=z(([t])=>{const e=fe(t).toVar();return C(e).div(C(fe(P(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Bn=z(([t])=>{const e=C(t).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),zce=z(([t])=>{const e=P(t).toVar(),r=fe(fe(1)).toVar(),i=fe(fe(P(3735928559)).add(r.shiftLeft(fe(2))).add(fe(13))).toVar();return Xm(i.add(fe(e)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Bce=z(([t,e])=>{const r=P(e).toVar(),i=P(t).toVar(),s=fe(fe(2)).toVar(),n=fe().toVar(),a=fe().toVar(),o=fe().toVar();return n.assign(a.assign(o.assign(fe(P(3735928559)).add(s.shiftLeft(fe(2))).add(fe(13))))),n.addAssign(fe(i)),a.addAssign(fe(r)),Xm(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),kce=z(([t,e,r])=>{const i=P(r).toVar(),s=P(e).toVar(),n=P(t).toVar(),a=fe(fe(3)).toVar(),o=fe().toVar(),l=fe().toVar(),h=fe().toVar();return o.assign(l.assign(h.assign(fe(P(3735928559)).add(a.shiftLeft(fe(2))).add(fe(13))))),o.addAssign(fe(n)),l.addAssign(fe(s)),h.addAssign(fe(i)),Xm(o,l,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Uce=z(([t,e,r,i])=>{const s=P(i).toVar(),n=P(r).toVar(),a=P(e).toVar(),o=P(t).toVar(),l=fe(fe(4)).toVar(),h=fe().toVar(),u=fe().toVar(),c=fe().toVar();return h.assign(u.assign(c.assign(fe(P(3735928559)).add(l.shiftLeft(fe(2))).add(fe(13))))),h.addAssign(fe(o)),u.addAssign(fe(a)),c.addAssign(fe(n)),pO(h,u,c),h.addAssign(fe(s)),Xm(h,u,c)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Dce=z(([t,e,r,i,s])=>{const n=P(s).toVar(),a=P(i).toVar(),o=P(r).toVar(),l=P(e).toVar(),h=P(t).toVar(),u=fe(fe(5)).toVar(),c=fe().toVar(),d=fe().toVar(),m=fe().toVar();return c.assign(d.assign(m.assign(fe(P(3735928559)).add(u.shiftLeft(fe(2))).add(fe(13))))),c.addAssign(fe(h)),d.addAssign(fe(l)),m.addAssign(fe(o)),pO(c,d,m),c.addAssign(fe(a)),d.addAssign(fe(n)),Xm(c,d,m)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),vt=li([zce,Bce,kce,Uce,Dce]),$ce=z(([t,e])=>{const r=P(e).toVar(),i=P(t).toVar(),s=fe(vt(i,r)).toVar(),n=Pc().toVar();return n.x.assign(s.bitAnd(P(255))),n.y.assign(s.shiftRight(P(8)).bitAnd(P(255))),n.z.assign(s.shiftRight(P(16)).bitAnd(P(255))),n}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Gce=z(([t,e,r])=>{const i=P(r).toVar(),s=P(e).toVar(),n=P(t).toVar(),a=fe(vt(n,s,i)).toVar(),o=Pc().toVar();return o.x.assign(a.bitAnd(P(255))),o.y.assign(a.shiftRight(P(8)).bitAnd(P(255))),o.z.assign(a.shiftRight(P(16)).bitAnd(P(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Cs=li([$ce,Gce]),jce=z(([t])=>{const e=ne(t).toVar(),r=P().toVar(),i=P().toVar(),s=C($t(e.x,r)).toVar(),n=C($t(e.y,i)).toVar(),a=C(Bn(s)).toVar(),o=C(Bn(n)).toVar(),l=C(hO(Kr(vt(r,i),s,n),Kr(vt(r.add(P(1)),i),s.sub(1),n),Kr(vt(r,i.add(P(1))),s,n.sub(1)),Kr(vt(r.add(P(1)),i.add(P(1))),s.sub(1),n.sub(1)),a,o)).toVar();return dO(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Wce=z(([t])=>{const e=B(t).toVar(),r=P().toVar(),i=P().toVar(),s=P().toVar(),n=C($t(e.x,r)).toVar(),a=C($t(e.y,i)).toVar(),o=C($t(e.z,s)).toVar(),l=C(Bn(n)).toVar(),h=C(Bn(a)).toVar(),u=C(Bn(o)).toVar(),c=C(cO(Kr(vt(r,i,s),n,a,o),Kr(vt(r.add(P(1)),i,s),n.sub(1),a,o),Kr(vt(r,i.add(P(1)),s),n,a.sub(1),o),Kr(vt(r.add(P(1)),i.add(P(1)),s),n.sub(1),a.sub(1),o),Kr(vt(r,i,s.add(P(1))),n,a,o.sub(1)),Kr(vt(r.add(P(1)),i,s.add(P(1))),n.sub(1),a,o.sub(1)),Kr(vt(r,i.add(P(1)),s.add(P(1))),n,a.sub(1),o.sub(1)),Kr(vt(r.add(P(1)),i.add(P(1)),s.add(P(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return mO(c)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),lw=li([jce,Wce]),Hce=z(([t])=>{const e=ne(t).toVar(),r=P().toVar(),i=P().toVar(),s=C($t(e.x,r)).toVar(),n=C($t(e.y,i)).toVar(),a=C(Bn(s)).toVar(),o=C(Bn(n)).toVar(),l=B(hO(As(Cs(r,i),s,n),As(Cs(r.add(P(1)),i),s.sub(1),n),As(Cs(r,i.add(P(1))),s,n.sub(1)),As(Cs(r.add(P(1)),i.add(P(1))),s.sub(1),n.sub(1)),a,o)).toVar();return dO(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qce=z(([t])=>{const e=B(t).toVar(),r=P().toVar(),i=P().toVar(),s=P().toVar(),n=C($t(e.x,r)).toVar(),a=C($t(e.y,i)).toVar(),o=C($t(e.z,s)).toVar(),l=C(Bn(n)).toVar(),h=C(Bn(a)).toVar(),u=C(Bn(o)).toVar(),c=B(cO(As(Cs(r,i,s),n,a,o),As(Cs(r.add(P(1)),i,s),n.sub(1),a,o),As(Cs(r,i.add(P(1)),s),n,a.sub(1),o),As(Cs(r.add(P(1)),i.add(P(1)),s),n.sub(1),a.sub(1),o),As(Cs(r,i,s.add(P(1))),n,a,o.sub(1)),As(Cs(r.add(P(1)),i,s.add(P(1))),n.sub(1),a,o.sub(1)),As(Cs(r,i.add(P(1)),s.add(P(1))),n,a.sub(1),o.sub(1)),As(Cs(r.add(P(1)),i.add(P(1)),s.add(P(1))),n.sub(1),a.sub(1),o.sub(1)),l,h,u)).toVar();return mO(c)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),uw=li([Hce,qce]),Xce=z(([t])=>{const e=C(t).toVar(),r=P(mr(e)).toVar();return Ti(vt(r))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Yce=z(([t])=>{const e=ne(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar();return Ti(vt(r,i))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Zce=z(([t])=>{const e=B(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar();return Ti(vt(r,i,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Jce=z(([t])=>{const e=Oe(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar(),n=P(mr(e.w)).toVar();return Ti(vt(r,i,s,n))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),Kce=li([Xce,Yce,Zce,Jce]),Qce=z(([t])=>{const e=C(t).toVar(),r=P(mr(e)).toVar();return B(Ti(vt(r,P(0))),Ti(vt(r,P(1))),Ti(vt(r,P(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ede=z(([t])=>{const e=ne(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar();return B(Ti(vt(r,i,P(0))),Ti(vt(r,i,P(1))),Ti(vt(r,i,P(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),tde=z(([t])=>{const e=B(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar();return B(Ti(vt(r,i,s,P(0))),Ti(vt(r,i,s,P(1))),Ti(vt(r,i,s,P(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),rde=z(([t])=>{const e=Oe(t).toVar(),r=P(mr(e.x)).toVar(),i=P(mr(e.y)).toVar(),s=P(mr(e.z)).toVar(),n=P(mr(e.w)).toVar();return B(Ti(vt(r,i,s,n,P(0))),Ti(vt(r,i,s,n,P(1))),Ti(vt(r,i,s,n,P(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),fO=li([Qce,ede,tde,rde]),Eg=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar(),l=C(0).toVar(),h=C(1).toVar();return Et(a,()=>{l.addAssign(h.mul(lw(o))),h.mulAssign(s),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gO=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar(),l=B(0).toVar(),h=C(1).toVar();return Et(a,()=>{l.addAssign(h.mul(uw(o))),h.mulAssign(s),o.mulAssign(n)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),ide=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar();return ne(Eg(o,a,n,s),Eg(o.add(B(P(19),P(193),P(17))),a,n,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),sde=z(([t,e,r,i])=>{const s=C(i).toVar(),n=C(r).toVar(),a=P(e).toVar(),o=B(t).toVar(),l=B(gO(o,a,n,s)).toVar(),h=C(Eg(o.add(B(P(19),P(193),P(17))),a,n,s)).toVar();return Oe(l,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),nde=z(([t,e,r,i,s,n,a])=>{const o=P(a).toVar(),l=C(n).toVar(),h=P(s).toVar(),u=P(i).toVar(),c=P(r).toVar(),d=P(e).toVar(),m=ne(t).toVar(),p=B(fO(ne(d.add(u),c.add(h)))).toVar(),f=ne(p.x,p.y).toVar();f.subAssign(.5),f.mulAssign(l),f.addAssign(.5);const g=ne(ne(C(d),C(c)).add(f)).toVar(),y=ne(g.sub(m)).toVar();return je(o.equal(P(2)),()=>Vt(y.x).add(Vt(y.y))),je(o.equal(P(3)),()=>Gr(Vt(y.x),Vt(y.y))),Go(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),ade=z(([t,e,r,i,s,n,a,o,l])=>{const h=P(l).toVar(),u=C(o).toVar(),c=P(a).toVar(),d=P(n).toVar(),m=P(s).toVar(),p=P(i).toVar(),f=P(r).toVar(),g=P(e).toVar(),y=B(t).toVar(),T=B(fO(B(g.add(m),f.add(d),p.add(c)))).toVar();T.subAssign(.5),T.mulAssign(u),T.addAssign(.5);const M=B(B(C(g),C(f),C(p)).add(T)).toVar(),w=B(M.sub(y)).toVar();return je(h.equal(P(2)),()=>Vt(w.x).add(Vt(w.y)).add(Vt(w.z))),je(h.equal(P(3)),()=>Gr(Vt(w.x),Vt(w.y),Vt(w.z))),Go(w,w)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Vc=li([nde,ade]),ode=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=ne(t).toVar(),a=P().toVar(),o=P().toVar(),l=ne($t(n.x,a),$t(n.y,o)).toVar(),h=C(1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:c})=>{const d=C(Vc(l,u,c,a,o,s,i)).toVar();h.assign(js(h,d))})}),je(i.equal(P(0)),()=>{h.assign(Qn(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),lde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=ne(t).toVar(),a=P().toVar(),o=P().toVar(),l=ne($t(n.x,a),$t(n.y,o)).toVar(),h=ne(1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:c})=>{const d=C(Vc(l,u,c,a,o,s,i)).toVar();je(d.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.y.assign(d)})})}),je(i.equal(P(0)),()=>{h.assign(Qn(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),ude=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=ne(t).toVar(),a=P().toVar(),o=P().toVar(),l=ne($t(n.x,a),$t(n.y,o)).toVar(),h=B(1e6,1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:u})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:c})=>{const d=C(Vc(l,u,c,a,o,s,i)).toVar();je(d.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(d)}).ElseIf(d.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(d)}).ElseIf(d.lessThan(h.z),()=>{h.z.assign(d)})})}),je(i.equal(P(0)),()=>{h.assign(Qn(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),hde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=B(t).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),h=B($t(n.x,a),$t(n.y,o),$t(n.z,l)).toVar(),u=C(1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:c})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{Et({start:-1,end:P(1),name:"z",condition:"<="},({z:m})=>{const p=C(Vc(h,c,d,m,a,o,l,s,i)).toVar();u.assign(js(u,p))})})}),je(i.equal(P(0)),()=>{u.assign(Qn(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),cde=li([ode,hde]),dde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=B(t).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),h=B($t(n.x,a),$t(n.y,o),$t(n.z,l)).toVar(),u=ne(1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:c})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{Et({start:-1,end:P(1),name:"z",condition:"<="},({z:m})=>{const p=C(Vc(h,c,d,m,a,o,l,s,i)).toVar();je(p.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(p)}).ElseIf(p.lessThan(u.y),()=>{u.y.assign(p)})})})}),je(i.equal(P(0)),()=>{u.assign(Qn(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),mde=li([lde,dde]),pde=z(([t,e,r])=>{const i=P(r).toVar(),s=C(e).toVar(),n=B(t).toVar(),a=P().toVar(),o=P().toVar(),l=P().toVar(),h=B($t(n.x,a),$t(n.y,o),$t(n.z,l)).toVar(),u=B(1e6,1e6,1e6).toVar();return Et({start:-1,end:P(1),name:"x",condition:"<="},({x:c})=>{Et({start:-1,end:P(1),name:"y",condition:"<="},({y:d})=>{Et({start:-1,end:P(1),name:"z",condition:"<="},({z:m})=>{const p=C(Vc(h,c,d,m,a,o,l,s,i)).toVar();je(p.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(p)}).ElseIf(p.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(p)}).ElseIf(p.lessThan(u.z),()=>{u.z.assign(p)})})})}),je(i.equal(P(0)),()=>{u.assign(Qn(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),fde=li([ude,pde]),gde=z(([t])=>{const e=t.y,r=t.z,i=B().toVar();return je(e.lessThan(1e-4),()=>{i.assign(B(r,r,r))}).Else(()=>{let s=t.x;s=s.sub(zn(s)).mul(6).toVar();const n=P(PT(s)),a=s.sub(C(n)),o=r.mul(e.oneMinus()),l=r.mul(e.mul(a).oneMinus()),h=r.mul(e.mul(a.oneMinus()).oneMinus());je(n.equal(P(0)),()=>{i.assign(B(r,h,o))}).ElseIf(n.equal(P(1)),()=>{i.assign(B(l,r,o))}).ElseIf(n.equal(P(2)),()=>{i.assign(B(o,r,h))}).ElseIf(n.equal(P(3)),()=>{i.assign(B(o,l,r))}).ElseIf(n.equal(P(4)),()=>{i.assign(B(h,o,r))}).Else(()=>{i.assign(B(r,o,l))})}),i}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),yde=z(([t])=>{const e=B(t).toVar(),r=C(e.x).toVar(),i=C(e.y).toVar(),s=C(e.z).toVar(),n=C(js(r,js(i,s))).toVar(),a=C(Gr(r,Gr(i,s))).toVar(),o=C(a.sub(n)).toVar(),l=C().toVar(),h=C().toVar(),u=C().toVar();return u.assign(a),je(a.greaterThan(0),()=>{h.assign(o.div(a))}).Else(()=>{h.assign(0)}),je(h.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{je(r.greaterThanEqual(a),()=>{l.assign(i.sub(s).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(fr(2,s.sub(r).div(o)))}).Else(()=>{l.assign(fr(4,r.sub(i).div(o)))}),l.mulAssign(1/6),je(l.lessThan(0),()=>{l.addAssign(1)})}),B(l,h,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),xde=z(([t])=>{const e=B(t).toVar(),r=ST(_T(e,B(.04045))).toVar(),i=B(e.div(12.92)).toVar(),s=B(pn(Gr(e.add(B(.055)),B(0)).div(1.055),B(2.4))).toVar();return ur(i,s,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),yO=(t,e)=>{t=C(t),e=C(e);const r=ne(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Iu(t.sub(r),t.add(r),e)},xO=(t,e,r,i)=>ur(t,e,r[i].clamp()),bde=(t,e,r=jt())=>xO(t,e,r,"x"),vde=(t,e,r=jt())=>xO(t,e,r,"y"),bO=(t,e,r,i,s)=>ur(t,e,yO(r,i[s])),Tde=(t,e,r,i=jt())=>bO(t,e,r,i,"x"),wde=(t,e,r,i=jt())=>bO(t,e,r,i,"y"),Sde=(t=1,e=0,r=jt())=>r.mul(t).add(e),Mde=(t,e=1)=>(t=C(t),t.abs().pow(e).mul(t.sign())),_de=(t,e=1,r=.5)=>C(t).sub(r).mul(e).add(r),Nde=(t=jt(),e=1,r=0)=>lw(t.convert("vec2|vec3")).mul(e).add(r),Ede=(t=jt(),e=1,r=0)=>uw(t.convert("vec2|vec3")).mul(e).add(r),Ade=(t=jt(),e=1,r=0)=>(t=t.convert("vec2|vec3"),Oe(uw(t),lw(t.add(ne(19,73)))).mul(e).add(r)),Cde=(t=jt(),e=1)=>cde(t.convert("vec2|vec3"),e,P(1)),Rde=(t=jt(),e=1)=>mde(t.convert("vec2|vec3"),e,P(1)),Pde=(t=jt(),e=1)=>fde(t.convert("vec2|vec3"),e,P(1)),Ide=(t=jt())=>Kce(t.convert("vec2|vec3")),Vde=(t=jt(),e=3,r=2,i=.5,s=1)=>Eg(t,P(e),r,i).mul(s),Ode=(t=jt(),e=3,r=2,i=.5,s=1)=>ide(t,P(e),r,i).mul(s),Lde=(t=jt(),e=3,r=2,i=.5,s=1)=>gO(t,P(e),r,i).mul(s),Fde=(t=jt(),e=3,r=2,i=.5,s=1)=>sde(t,P(e),r,i).mul(s),zde=z(([t,e,r])=>{const i=Wu(t).toVar(),s=it(C(.5).mul(e.sub(r)),Nu).div(i).toVar(),n=it(C(-.5).mul(e.sub(r)),Nu).div(i).toVar(),a=B().toVar();a.x=i.x.greaterThan(C(0)).select(s.x,n.x),a.y=i.y.greaterThan(C(0)).select(s.y,n.y),a.z=i.z.greaterThan(C(0)).select(s.z,n.z);const o=js(a.x,a.y,a.z).toVar();return Nu.add(i.mul(o)).toVar().sub(r)}),Bde=z(([t,e])=>{const r=t.x,i=t.y,s=t.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(i)),n=n.add(e.element(2).mul(2*.511664).mul(s)),n=n.add(e.element(3).mul(2*.511664).mul(r)),n=n.add(e.element(4).mul(2*.429043).mul(r).mul(i)),n=n.add(e.element(5).mul(2*.429043).mul(i).mul(s)),n=n.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(r).mul(s)),n=n.add(e.element(8).mul(.429043).mul(ke(r,r).sub(ke(i,i)))),n});var b=Object.freeze({__proto__:null,BRDF_GGX:sle,BRDF_Lambert:Qoe,BasicPointShadowFilter:oO,BasicShadowFilter:eO,Break:dV,Const:lI,Continue:_oe,DFGApprox:nle,D_GGX:_V,Discard:_I,EPSILON:AP,F_Schlick:wV,Fn:z,INFINITY:Sne,If:je,Loop:Et,NodeAccess:Rn,NodeShaderStage:wd,NodeType:Nse,NodeUpdateType:Tt,PCFShadowFilter:tO,PCFSoftShadowFilter:rO,PI:bg,PI2:Mne,PointShadowFilter:lO,Return:$ne,Schlick_to_F0:ale,ScriptableNodeResources:$f,ShaderNode:qh,Stack:xy,Switch:Xse,TBNViewMatrix:XT,VSMShadowFilter:iO,V_GGX_SmithCorrelated:MV,Var:oI,abs:Vt,acesFilmicToneMapping:ohe,acos:FP,add:fr,addMethodChaining:W,addNodeElement:Wne,agxToneMapping:che,all:CP,alphaT:i1,and:dP,anisotropy:tP,anisotropyB:ac,anisotropyT:Uf,any:RP,append:Kse,array:nP,arrayBuffer:Zse,asin:LP,assign:aP,atan:AT,atan2:iI,atomicAdd:Ghe,atomicAnd:qhe,atomicFunc:ea,atomicLoad:Dhe,atomicMax:Whe,atomicMin:Hhe,atomicOr:Xhe,atomicStore:$he,atomicSub:jhe,atomicXor:Yhe,attenuationColor:yne,attenuationDistance:gne,attribute:Bo,attributeArray:wue,backgroundBlurriness:Nue,backgroundIntensity:Eue,backgroundRotation:Aue,batch:uV,billboarding:sue,bitAnd:gP,bitNot:yP,bitOr:xP,bitXor:bP,bitangentGeometry:Nae,bitangentLocal:Eae,bitangentView:qI,bitangentWorld:Aae,bitcast:_ne,blendBurn:$V,blendColor:Bue,blendDodge:GV,blendOverlay:WV,blendScreen:jV,blur:RV,bool:Hn,buffer:km,bufferAttribute:Bm,bumpMap:ZI,burn:Due,bvec2:H5,bvec3:ST,bvec4:Z5,bypass:TI,cache:bI,call:oP,cameraFar:bo,cameraIndex:_y,cameraNear:xo,cameraNormalMatrix:iae,cameraPosition:sae,cameraProjectionMatrix:Um,cameraProjectionMatrixInverse:tae,cameraViewMatrix:Zs,cameraWorldMatrix:rae,cbrt:JP,cdl:Yue,ceil:Ty,checker:Sce,cineonToneMapping:nhe,clamp:Ba,clearcoat:tne,clearcoatRoughness:rne,code:Ry,color:j5,colorSpaceToWorking:BT,colorToDirection:Joe,compute:xI,computeSkinning:Soe,cond:sI,context:OT,convert:K5,convertColorSpace:Ine,convertToTexture:yue,cos:ga,cross:Sy,cubeTexture:HT,cubeTextureBase:WT,cubeToUV:on,dFdx:CT,dFdy:RT,dashSize:hne,debug:EI,decrement:_P,decrementBefore:SP,defaultBuildStages:Ese,defaultShaderStages:z5,defined:am,degrees:IP,deltaTime:FV,densityFog:Mhe,densityFogFactor:JV,depth:QT,depthPass:ehe,difference:HP,diffuseColor:_s,directPointLight:wce,directionToColor:Zoe,dispersion:xne,distance:WP,div:qn,dodge:$ue,dot:Go,drawIndex:aV,dynamicBufferAttribute:yI,element:J5,emissive:r1,equal:MT,equals:GP,equirectUV:TV,exp:VP,exp2:wc,expression:ka,faceDirection:$m,faceForward:VT,faceforward:Nne,float:C,floor:zn,fog:sw,fract:Ha,frameGroup:bne,frameId:Xle,frontFacing:LI,fwidth:DP,gain:Dle,gapSize:cne,getConstNodeType:$5,getCurrentStack:G5,getDirection:AV,getDistanceAttenuation:uO,getGeometryRoughness:SV,getNormalFromDepth:bue,getParallaxCorrectNormal:zde,getRoughness:ele,getScreenPosition:xue,getShIrradianceAt:Bde,getShadowMaterial:sO,getShadowRenderObjectFunction:nO,getTextureIndex:OV,getViewPosition:Bh,globalId:Rhe,glsl:fhe,glslFn:yhe,grayscale:Wue,greaterThan:_T,greaterThanEqual:cP,hash:Ule,highpModelNormalViewMatrix:yae,highpModelViewMatrix:gae,hue:Xue,increment:MP,incrementBefore:wP,instance:goe,instanceIndex:Po,instancedArray:Sue,instancedBufferAttribute:Tg,instancedDynamicBufferAttribute:s1,instancedMesh:lV,int:P,inverseSqrt:ET,inversesqrt:Ene,invocationLocalIndex:foe,invocationSubgroupIndex:poe,ior:mne,iridescence:eP,iridescenceIOR:nne,iridescenceThickness:ane,ivec2:kr,ivec3:q5,ivec4:X5,js:mhe,label:aI,length:vg,lengthSq:IT,lessThan:uP,lessThanEqual:hP,lightPosition:KV,lightProjectionUV:Zhe,lightShadowMatrix:aw,lightTargetDirection:Khe,lightTargetPosition:QV,lightViewPosition:Jhe,lightingContext:fV,lights:rce,linearDepth:Mg,linearToneMapping:ihe,localId:Phe,log:NT,log2:Pa,logarithmicDepthToViewZ:Uoe,loop:Noe,luminance:iw,mat2:by,mat3:Gs,mat4:_u,matcapUV:Ele,materialAO:iV,materialAlphaTest:JI,materialAnisotropy:Jae,materialAnisotropyVector:zh,materialAttenuationColor:noe,materialAttenuationDistance:soe,materialClearcoat:Wae,materialClearcoatNormal:qae,materialClearcoatRoughness:Hae,materialColor:KI,materialDispersion:doe,materialEmissive:QI,materialEnvIntensity:vae,materialEnvRotation:jT,materialIOR:ioe,materialIridescence:Kae,materialIridescenceIOR:Qae,materialIridescenceThickness:eoe,materialLightMap:rV,materialLineDashOffset:hoe,materialLineDashSize:ooe,materialLineGapSize:loe,materialLineScale:aoe,materialLineWidth:uoe,materialMetalness:jae,materialNormal:tV,materialOpacity:eV,materialPointSize:coe,materialReference:gl,materialReflectivity:$ae,materialRefractionRatio:UI,materialRotation:Xae,materialRoughness:Gae,materialSheen:Yae,materialSheenRoughness:Zae,materialShininess:zae,materialSpecular:Bae,materialSpecularColor:Uae,materialSpecularIntensity:kae,materialSpecularStrength:Dae,materialThickness:roe,materialTransmission:toe,max:Gr,maxMipLevel:CI,mediumpModelViewMatrix:VI,metalness:ene,min:js,mix:ur,mixElement:tI,mod:zm,modInt:EP,modelDirection:hae,modelNormalMatrix:II,modelPosition:cae,modelRadius:pae,modelScale:dae,modelViewMatrix:Dm,modelViewPosition:mae,modelViewProjection:sV,modelWorldMatrix:Ta,modelWorldMatrixInverse:fae,morphReference:mV,mrt:LV,mul:ke,mx_aastep:yO,mx_cell_noise_float:Ide,mx_contrast:_de,mx_fractal_noise_float:Vde,mx_fractal_noise_vec2:Ode,mx_fractal_noise_vec3:Lde,mx_fractal_noise_vec4:Fde,mx_hsvtorgb:gde,mx_noise_float:Nde,mx_noise_vec3:Ede,mx_noise_vec4:Ade,mx_ramplr:bde,mx_ramptb:vde,mx_rgbtohsv:yde,mx_safepower:Mde,mx_splitlr:Tde,mx_splittb:wde,mx_srgb_texture_to_lin_rec709:xde,mx_transform_uv:Sde,mx_worley_noise_float:Cde,mx_worley_noise_vec2:Rde,mx_worley_noise_vec3:Pde,namespace:vI,negate:zP,neutralToneMapping:dhe,nodeArray:Mu,nodeImmutable:ue,nodeObject:X,nodeObjects:Lm,nodeProxy:Z,normalFlat:FI,normalGeometry:$T,normalLocal:qi,normalMap:a1,normalView:Xn,normalWorld:zI,normalize:Wu,not:pP,notEqual:lP,numWorkgroups:Ahe,objectDirection:nae,objectGroup:sP,objectPosition:PI,objectRadius:uae,objectScale:oae,objectViewPosition:lae,objectWorldMatrix:aae,oneMinus:BP,or:mP,orthographicDepthToViewZ:koe,oscSawtooth:tue,oscSine:Kle,oscSquare:Qle,oscTriangle:eue,output:oc,outputStruct:Ble,overlay:jue,overloadingFn:li,parabola:c1,parallaxDirection:YI,parallaxUV:Rae,parameter:Ple,pass:Kue,passTexture:Que,pcurve:$le,perspectiveDepthToViewZ:JT,pmremTexture:_le,pointShadow:Tce,pointUV:_ue,pointWidth:dne,positionGeometry:DT,positionLocal:cr,positionPrevious:wg,positionView:ti,positionViewDirection:ms,positionWorld:Nu,positionWorldDirection:OI,posterize:Jue,pow:pn,pow2:qP,pow3:XP,pow4:YP,premult:kue,property:Ic,radians:PP,rand:eI,range:Nhe,rangeFog:She,rangeFogFactor:ZV,reciprocal:UP,reference:Zt,referenceBuffer:n1,reflect:jP,reflectVector:GI,reflectView:DI,reflector:due,refract:QP,refractVector:jI,refractView:$I,reinhardToneMapping:she,remainder:NP,remap:SI,remapClamp:MI,renderGroup:Ye,renderOutput:NI,rendererReference:pI,rotate:IV,rotateUV:rue,roughness:Q5,round:kP,rtt:kV,sRGBTransferEOTF:cI,sRGBTransferOETF:dI,sampler:Zne,samplerComparison:Jne,saturate:KP,saturation:Hue,screen:Gue,screenCoordinate:Hm,screenSize:Sg,screenUV:jo,scriptable:whe,scriptableValue:Df,select:yi,setCurrentStack:t1,shaderStages:Ase,shadow:yce,shadowPositionWorld:ow,shapeCircle:Mce,sharedUniformGroup:vy,sheen:ine,sheenRoughness:sne,shiftLeft:vP,shiftRight:TP,shininess:une,sign:lm,sin:cs,sinc:Gle,skinning:cV,smoothstep:Iu,smoothstepElement:rI,specularColor:one,specularF90:lne,spherizeUV:iue,split:Jse,spritesheetUV:oue,sqrt:Qn,stack:Vle,step:wy,storage:Eu,storageBarrier:Lhe,storageObject:woe,storageTexture:UV,string:Yse,struct:zle,sub:it,subgroupIndex:moe,subgroupSize:Ihe,tan:OP,tangentGeometry:Ey,tangentLocal:Gm,tangentView:jm,tangentWorld:HI,temp:uI,texture:_t,texture3D:Vue,textureBarrier:Fhe,textureBicubic:ole,textureCubeUV:CV,textureLoad:tr,textureSize:Ro,textureStore:Rue,thickness:fne,time:Hu,timerDelta:Jle,timerGlobal:Zle,timerLocal:Yle,toneMapping:fI,toneMappingExposure:gI,toonOutlinePass:rhe,transformDirection:ZP,transformNormal:kI,transformNormalToView:GT,transformedBentNormalView:Pae,transformedBitangentView:XI,transformedBitangentWorld:Cae,transformedClearcoatNormalView:bae,transformedNormalView:Da,transformedNormalWorld:BI,transformedTangentView:qT,transformedTangentWorld:_ae,transmission:pne,transpose:$P,triNoise3D:Wle,triplanarTexture:uue,triplanarTextures:zV,trunc:PT,tslFn:Qse,uint:fe,uniform:Pe,uniformArray:dn,uniformCubeTexture:wae,uniformGroup:iP,uniformTexture:Yne,uniforms:Qne,unpremult:Uue,userData:Lue,uv:jt,uvec2:W5,uvec3:Pc,uvec4:Y5,varying:Ys,varyingProperty:om,vec2:ne,vec3:B,vec4:Oe,vectorComponents:Rc,velocity:zue,vertexColor:vV,vertexIndex:nV,vertexStage:hI,vibrance:que,viewZToLogarithmicDepth:KT,viewZToOrthographicDepth:lc,viewZToPerspectiveDepth:xV,viewport:YT,viewportBottomLeft:Loe,viewportCoordinate:yV,viewportDepthTexture:ZT,viewportLinearDepth:Doe,viewportMipTexture:zoe,viewportResolution:Voe,viewportSafeUV:nue,viewportSharedTexture:Yoe,viewportSize:gV,viewportTexture:Foe,viewportTopLeft:Ooe,viewportUV:Ioe,wgsl:phe,wgslFn:xhe,workgroupArray:khe,workgroupBarrier:Ohe,workgroupId:Che,workingToColorSpace:mI,xor:fP});const Vh=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4};Rn.READ_ONLY+"",Rn.WRITE_ONLY+"",Rn.READ_WRITE+"";Vh&&Vh.VERTEX,Vh&&Vh.FRAGMENT,Vh&&Vh.COMPUTE;const ll={tsl_xor:new Lr("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Lr("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Lr("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Lr("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Lr("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Lr("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Lr("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Lr("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Lr("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Lr("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Lr("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Lr("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Lr(`
486
486
  fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
487
487
 
488
488
  let res = vec2f( iRes );
@@ -508,5 +508,5 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
508
508
  * @license
509
509
  * Copyright 2010-2025 Three.js Authors
510
510
  * SPDX-License-Identifier: MIT
511
- */b.BRDF_GGX;b.BRDF_Lambert;b.BasicShadowFilter;b.Break;b.Continue;b.DFGApprox;b.D_GGX;b.Discard;b.EPSILON;b.F_Schlick;b.Fn;b.INFINITY;b.If;b.Switch;b.Loop;b.NodeShaderStage;b.NodeType;b.NodeUpdateType;b.NodeAccess;b.PCFShadowFilter;b.PCFSoftShadowFilter;b.PI;b.PI2;b.Return;b.Schlick_to_F0;b.ScriptableNodeResources;b.ShaderNode;b.TBNViewMatrix;b.VSMShadowFilter;b.V_GGX_SmithCorrelated;b.abs;b.acesFilmicToneMapping;b.acos;b.add;b.addNodeElement;b.agxToneMapping;b.all;b.alphaT;b.and;b.anisotropy;b.anisotropyB;b.anisotropyT;b.any;b.append;b.array;b.arrayBuffer;b.asin;b.assign;b.atan;b.atan2;b.atomicAdd;b.atomicAnd;b.atomicFunc;b.atomicMax;b.atomicMin;b.atomicOr;b.atomicStore;b.atomicSub;b.atomicXor;b.atomicLoad;b.attenuationColor;b.attenuationDistance;b.attribute;b.attributeArray;b.backgroundBlurriness;b.backgroundIntensity;b.backgroundRotation;b.batch;b.billboarding;b.bitAnd;b.bitNot;b.bitOr;b.bitXor;b.bitangentGeometry;b.bitangentLocal;b.bitangentView;b.bitangentWorld;b.bitcast;b.blendBurn;b.blendColor;b.blendDodge;b.blendOverlay;b.blendScreen;b.blur;b.bool;b.buffer;b.bufferAttribute;b.bumpMap;b.burn;b.bvec2;b.bvec3;b.bvec4;b.bypass;b.cache;b.call;b.cameraFar;b.cameraIndex;b.cameraNear;b.cameraNormalMatrix;b.cameraPosition;b.cameraProjectionMatrix;b.cameraProjectionMatrixInverse;b.cameraViewMatrix;b.cameraWorldMatrix;b.cbrt;b.cdl;b.ceil;b.checker;b.cineonToneMapping;b.clamp;b.clearcoat;b.clearcoatRoughness;b.code;b.color;b.colorSpaceToWorking;b.colorToDirection;b.compute;b.computeSkinning;b.cond;b.Const;b.context;b.convert;b.convertColorSpace;b.convertToTexture;b.cos;b.cross;b.cubeTexture;b.dFdx;b.dFdy;b.dashSize;b.debug;b.decrement;b.decrementBefore;b.defaultBuildStages;b.defaultShaderStages;b.defined;b.degrees;b.deltaTime;b.densityFog;b.densityFogFactor;b.depth;b.depthPass;b.difference;b.diffuseColor;b.directPointLight;b.directionToColor;b.dispersion;b.distance;b.div;b.dodge;b.dot;b.drawIndex;b.dynamicBufferAttribute;b.element;b.emissive;b.equal;b.equals;b.equirectUV;b.exp;b.exp2;b.expression;b.faceDirection;b.faceForward;b.faceforward;b.float;b.floor;b.fog;b.fract;b.frameGroup;b.frameId;b.frontFacing;b.fwidth;b.gain;b.gapSize;b.getConstNodeType;b.getCurrentStack;b.getDirection;b.getDistanceAttenuation;b.getGeometryRoughness;b.getNormalFromDepth;b.getParallaxCorrectNormal;b.getRoughness;b.getScreenPosition;b.getShIrradianceAt;b.getTextureIndex;b.getViewPosition;b.getShadowMaterial;b.getShadowRenderObjectFunction;b.glsl;b.glslFn;b.grayscale;b.greaterThan;b.greaterThanEqual;b.hash;b.highpModelNormalViewMatrix;b.highpModelViewMatrix;b.hue;b.increment;b.incrementBefore;b.instance;b.instanceIndex;b.instancedArray;b.instancedBufferAttribute;b.instancedDynamicBufferAttribute;b.instancedMesh;b.int;b.inverseSqrt;b.inversesqrt;b.invocationLocalIndex;b.invocationSubgroupIndex;b.ior;b.iridescence;b.iridescenceIOR;b.iridescenceThickness;b.ivec2;b.ivec3;b.ivec4;b.js;b.label;b.length;b.lengthSq;b.lessThan;b.lessThanEqual;b.lightPosition;b.lightShadowMatrix;b.lightTargetDirection;b.lightTargetPosition;b.lightViewPosition;b.lightingContext;b.lights;b.linearDepth;b.linearToneMapping;b.localId;b.globalId;b.log;b.log2;b.logarithmicDepthToViewZ;b.loop;b.luminance;b.mediumpModelViewMatrix;b.mat2;b.mat3;b.mat4;b.matcapUV;b.materialAO;b.materialAlphaTest;b.materialAnisotropy;b.materialAnisotropyVector;b.materialAttenuationColor;b.materialAttenuationDistance;b.materialClearcoat;b.materialClearcoatNormal;b.materialClearcoatRoughness;b.materialColor;b.materialDispersion;b.materialEmissive;b.materialIOR;b.materialIridescence;b.materialIridescenceIOR;b.materialIridescenceThickness;b.materialLightMap;b.materialLineDashOffset;b.materialLineDashSize;b.materialLineGapSize;b.materialLineScale;b.materialLineWidth;b.materialMetalness;b.materialNormal;b.materialOpacity;b.materialPointSize;b.materialReference;b.materialReflectivity;b.materialRefractionRatio;b.materialRotation;b.materialRoughness;b.materialSheen;b.materialSheenRoughness;b.materialShininess;b.materialSpecular;b.materialSpecularColor;b.materialSpecularIntensity;b.materialSpecularStrength;b.materialThickness;b.materialTransmission;b.max;b.maxMipLevel;b.metalness;b.min;b.mix;b.mixElement;b.mod;b.modInt;b.modelDirection;b.modelNormalMatrix;b.modelPosition;b.modelRadius;b.modelScale;b.modelViewMatrix;b.modelViewPosition;b.modelViewProjection;b.modelWorldMatrix;b.modelWorldMatrixInverse;b.morphReference;b.mrt;b.mul;b.mx_aastep;b.mx_cell_noise_float;b.mx_contrast;b.mx_fractal_noise_float;b.mx_fractal_noise_vec2;b.mx_fractal_noise_vec3;b.mx_fractal_noise_vec4;b.mx_hsvtorgb;b.mx_noise_float;b.mx_noise_vec3;b.mx_noise_vec4;b.mx_ramplr;b.mx_ramptb;b.mx_rgbtohsv;b.mx_safepower;b.mx_splitlr;b.mx_splittb;b.mx_srgb_texture_to_lin_rec709;b.mx_transform_uv;b.mx_worley_noise_float;b.mx_worley_noise_vec2;b.mx_worley_noise_vec3;b.namespace;b.negate;b.neutralToneMapping;b.nodeArray;b.nodeImmutable;b.nodeObject;b.nodeObjects;b.nodeProxy;b.normalFlat;b.normalGeometry;b.normalLocal;b.normalMap;b.normalView;b.normalWorld;b.normalize;b.not;b.notEqual;b.numWorkgroups;b.objectDirection;b.objectGroup;b.objectPosition;b.objectRadius;b.objectScale;b.objectViewPosition;b.objectWorldMatrix;b.oneMinus;b.or;b.orthographicDepthToViewZ;b.oscSawtooth;b.oscSine;b.oscSquare;b.oscTriangle;b.output;b.outputStruct;b.overlay;b.overloadingFn;b.parabola;b.parallaxDirection;b.parallaxUV;b.parameter;b.pass;b.passTexture;b.pcurve;b.perspectiveDepthToViewZ;b.pmremTexture;b.pointUV;b.pointWidth;b.positionGeometry;b.positionLocal;b.positionPrevious;b.positionView;b.positionViewDirection;b.positionWorld;b.positionWorldDirection;b.posterize;b.pow;b.pow2;b.pow3;b.pow4;b.premult;b.property;b.radians;b.rand;b.range;b.rangeFog;b.rangeFogFactor;b.reciprocal;b.lightProjectionUV;b.reference;b.referenceBuffer;b.reflect;b.reflectVector;b.reflectView;b.reflector;b.refract;b.refractVector;b.refractView;b.reinhardToneMapping;b.remainder;b.remap;b.remapClamp;b.renderGroup;b.renderOutput;b.rendererReference;b.rotate;b.rotateUV;b.roughness;b.round;b.rtt;b.sRGBTransferEOTF;b.sRGBTransferOETF;b.sampler;b.samplerComparison;b.saturate;b.saturation;b.screen;b.screenCoordinate;b.screenSize;b.screenUV;b.scriptable;b.scriptableValue;b.select;b.setCurrentStack;b.shaderStages;b.shadow;b.pointShadow;b.shadowPositionWorld;b.sharedUniformGroup;b.shapeCircle;b.sheen;b.sheenRoughness;b.shiftLeft;b.shiftRight;b.shininess;b.sign;b.sin;b.sinc;b.skinning;b.smoothstep;b.smoothstepElement;b.specularColor;b.specularF90;b.spherizeUV;b.split;b.spritesheetUV;b.sqrt;b.stack;b.step;b.storage;b.storageBarrier;b.storageObject;b.storageTexture;b.string;b.struct;b.sub;b.subgroupIndex;b.subgroupSize;b.tan;b.tangentGeometry;b.tangentLocal;b.tangentView;b.tangentWorld;b.temp;b.texture;b.texture3D;b.textureBarrier;b.textureBicubic;b.textureCubeUV;b.textureLoad;b.textureSize;b.textureStore;b.thickness;b.time;b.timerDelta;b.timerGlobal;b.timerLocal;b.toneMapping;b.toneMappingExposure;b.toonOutlinePass;b.transformDirection;b.transformNormal;b.transformNormalToView;b.transformedBentNormalView;b.transformedBitangentView;b.transformedBitangentWorld;b.transformedClearcoatNormalView;b.transformedNormalView;b.transformedNormalWorld;b.transformedTangentView;b.transformedTangentWorld;b.transmission;b.transpose;b.triNoise3D;b.triplanarTexture;b.triplanarTextures;b.trunc;b.tslFn;b.uint;b.uniform;b.uniformCubeTexture;b.uniformArray;b.uniformGroup;b.uniformTexture;b.uniforms;b.unpremult;b.userData;b.uv;b.uvec2;b.uvec3;b.uvec4;b.Var;b.varying;b.varyingProperty;b.vec2;b.vec3;const kde=b.vec4;b.vectorComponents;b.velocity;b.vertexColor;b.vertexIndex;b.vibrance;b.viewZToLogarithmicDepth;b.viewZToOrthographicDepth;b.viewZToPerspectiveDepth;b.viewport;b.viewportBottomLeft;b.viewportCoordinate;b.viewportDepthTexture;b.viewportLinearDepth;b.viewportMipTexture;b.viewportResolution;b.viewportSafeUV;b.viewportSharedTexture;b.viewportSize;b.viewportTexture;b.viewportTopLeft;b.viewportUV;b.wgsl;b.wgslFn;b.workgroupArray;b.workgroupBarrier;b.workgroupId;b.workingToColorSpace;b.xor;const ae=v.createContext(null),Ude=({children:t,hideNotice:e=!1,style:r={},className:i="",...s})=>{const n=v.useRef(null),a=v.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=v.useRef(null);o.current===null&&(o.current=gse());const l=v.useMemo(()=>(w,_,S,N,A=null)=>{if(_===null){try{o.current.removeNode(w)}catch(k){console.warn("Error removing node:",k)}return}try{o.current.registerNode(w,_,S,N,A)}catch(k){console.error("Error registering node:",k,{id:w,parentId:S,metadata:N})}},[]),h=v.useMemo(()=>(w,_,S)=>{try{o.current.updateUniformValue(w,_,S)}catch(N){console.warn("Error updating uniform:",N)}},[]),u=v.useMemo(()=>(w,_)=>{try{o.current.updateNodeMetadata(w,_)}catch(S){console.warn("Error updating metadata:",S)}},[]),c=v.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=v.useRef(!1),m=v.useRef(!1),p=v.useRef(!1),f=v.useRef(!1),g=v.useRef(null),y=async()=>{const w=n.current;if(!(!w||d.current||m.current)){console.log("[Shader] Initializing renderer..."),m.current=!0;try{const _=o.current;_.isInitialized()||await _.initialize({canvas:w}),_.registerNode(a,({childNode:S})=>S||kde(0,0,0,0),null,null,{}),d.current=!0,m.current=!1,e||_.showLicenseWarning(),console.log("[Shader] Renderer initialized successfully")}catch(_){throw console.error("[Shader] Initialization failed:",_),m.current=!1,_}}},T=()=>{const w=n.current;!w||g.current||(g.current=new IntersectionObserver(_=>{const S=_[0];if(!S)return;const N=w.getBoundingClientRect(),A=S.isIntersecting&&N&&N.width>0&&N.height>0;A&&!f.current?(console.log("[Shader] Canvas became visible, initializing..."),y().catch(console.error),f.current=!0):!A&&f.current&&(console.log("[Shader] Canvas became hidden, cleaning up renderer..."),o.current.cleanup(),d.current=!1,m.current=!1,f.current=!1)},{threshold:0}),g.current.observe(w))};v.useEffect(()=>{p.current=!1;const w=n.current;if(!w)return;const _=w.getBoundingClientRect();return _.width>0&&_.height>0?(console.log("[Shader] Canvas visible on mount, initializing..."),y().catch(console.error),f.current=!0):(console.log("[Shader] Canvas hidden on mount, setting up observer..."),f.current=!1),T(),()=>{if(!p.current){p.current=!0,g.current&&(g.current.disconnect(),g.current=null);try{o.current.cleanup(),d.current=!1,m.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(N){console.warn("[Shader] Error during cleanup:",N)}}}},[a,e]);const M={...i===""?{width:"1200px",height:"800px"}:{},...typeof r=="object"?r:{}};return Re.jsx(ae.Provider,{value:c,children:Re.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof r=="object"?r:{}},className:i,...s,children:[Re.jsx("canvas",{"data-renderer":"ombre",ref:n,style:M}),t]})})};function Dde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const vO={blendMode:"normal",renderOrder:0};try{El&&El.props&&Object.entries(El.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(vO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const $de=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${El.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Dde(t,vO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(El,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,El.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Gde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const TO={blendMode:"normal",renderOrder:0};try{Cl&&Cl.props&&Object.entries(Cl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(TO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const jde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Cl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Gde(t,TO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Cl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Cl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Wde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const wO={blendMode:"normal",renderOrder:0};try{Rl&&Rl.props&&Object.entries(Rl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(wO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Hde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Rl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Wde(t,wO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Rl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Rl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function qde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const SO={blendMode:"normal",renderOrder:0};try{Pl&&Pl.props&&Object.entries(Pl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(SO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Xde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Pl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>qde(t,SO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Pl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Pl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Yde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const MO={blendMode:"normal",renderOrder:0};try{zl&&zl.props&&Object.entries(zl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(MO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Zde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${zl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Yde(t,MO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(zl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,zl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Jde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const _O={blendMode:"normal",renderOrder:0};try{Il&&Il.props&&Object.entries(Il.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(_O[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Kde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Il.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Jde(t,_O),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Il,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Il.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Qde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const NO={blendMode:"normal",renderOrder:0};try{Vl&&Vl.props&&Object.entries(Vl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(NO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const eme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Qde(t,NO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Vl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Vl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function tme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const EO={blendMode:"normal",renderOrder:0};try{Ol&&Ol.props&&Object.entries(Ol.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(EO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const rme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ol.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>tme(t,EO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ol,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ol.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function ime(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const AO={blendMode:"normal",renderOrder:0};try{Ll&&Ll.props&&Object.entries(Ll.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(AO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const sme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ll.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ime(t,AO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ll,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ll.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function nme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const CO={blendMode:"normal",renderOrder:0};try{Fl&&Fl.props&&Object.entries(Fl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(CO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ame=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Fl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>nme(t,CO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Fl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Fl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function ome(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const RO={blendMode:"normal",renderOrder:0};try{Bl&&Bl.props&&Object.entries(Bl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(RO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const lme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Bl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ome(t,RO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Bl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Bl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function ume(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const PO={blendMode:"normal",renderOrder:0};try{kl&&kl.props&&Object.entries(kl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(PO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const hme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${kl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ume(t,PO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(kl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,kl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function cme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const IO={blendMode:"normal",renderOrder:0};try{Ul&&Ul.props&&Object.entries(Ul.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(IO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const dme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ul.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>cme(t,IO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ul,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ul.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function mme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const VO={blendMode:"normal",renderOrder:0};try{Dl&&Dl.props&&Object.entries(Dl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(VO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const pme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Dl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>mme(t,VO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Dl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Dl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function fme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const OO={blendMode:"normal",renderOrder:0};try{$l&&$l.props&&Object.entries($l.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(OO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const gme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${$l.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>fme(t,OO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe($l,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,$l.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function yme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const LO={blendMode:"normal",renderOrder:0};try{Gl&&Gl.props&&Object.entries(Gl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(LO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const xme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Gl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>yme(t,LO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Gl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Gl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function bme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const FO={blendMode:"normal",renderOrder:0};try{jl&&jl.props&&Object.entries(jl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(FO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const vme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${jl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>bme(t,FO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(jl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,jl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Tme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const zO={blendMode:"normal",renderOrder:0};try{Wl&&Wl.props&&Object.entries(Wl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(zO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const wme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Wl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Tme(t,zO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Wl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Wl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Sme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const BO={blendMode:"normal",renderOrder:0};try{Hl&&Hl.props&&Object.entries(Hl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(BO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Mme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Hl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Sme(t,BO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Hl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Hl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function _me(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const kO={blendMode:"normal",renderOrder:0};try{Xl&&Xl.props&&Object.entries(Xl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(kO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Nme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Xl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>_me(t,kO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Xl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Xl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Eme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const UO={blendMode:"normal",renderOrder:0};try{Yl&&Yl.props&&Object.entries(Yl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(UO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ame=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Yl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Eme(t,UO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Yl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Yl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Cme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const DO={blendMode:"normal",renderOrder:0};try{Zl&&Zl.props&&Object.entries(Zl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(DO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Rme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Zl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Cme(t,DO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Zl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Zl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Pme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const $O={blendMode:"normal",renderOrder:0};try{Jl&&Jl.props&&Object.entries(Jl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&($O[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ime=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Jl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Pme(t,$O),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Jl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Jl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Vme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const GO={blendMode:"normal",renderOrder:0};try{Kl&&Kl.props&&Object.entries(Kl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(GO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ome=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Kl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Vme(t,GO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Kl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Kl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Lme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const jO={blendMode:"normal",renderOrder:0};try{Ql&&Ql.props&&Object.entries(Ql.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(jO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Fme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ql.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Lme(t,jO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ql,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ql.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function zme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const WO={blendMode:"normal",renderOrder:0};try{eu&&eu.props&&Object.entries(eu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(WO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Bme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${eu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>zme(t,WO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(eu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,eu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function kme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const HO={blendMode:"normal",renderOrder:0};try{tu&&tu.props&&Object.entries(tu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(HO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ume=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${tu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>kme(t,HO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(tu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,tu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Dme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const qO={blendMode:"normal",renderOrder:0};try{ru&&ru.props&&Object.entries(ru.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(qO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const $me=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${ru.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Dme(t,qO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(ru,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,ru.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Gme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const XO={blendMode:"normal",renderOrder:0};try{iu&&iu.props&&Object.entries(iu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(XO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const jme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${iu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Gme(t,XO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(iu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,iu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Wme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const YO={blendMode:"normal",renderOrder:0};try{su&&su.props&&Object.entries(su.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(YO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Hme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${su.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Wme(t,YO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(su,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,su.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function qme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const ZO={blendMode:"normal",renderOrder:0};try{nu&&nu.props&&Object.entries(nu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(ZO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Xme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${nu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>qme(t,ZO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(nu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,nu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Yme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const JO={blendMode:"normal",renderOrder:0};try{au&&au.props&&Object.entries(au.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(JO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Zme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${au.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Yme(t,JO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(au,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,au.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Jme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const KO={blendMode:"normal",renderOrder:0};try{ou&&ou.props&&Object.entries(ou.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(KO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Kme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${ou.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Jme(t,KO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(ou,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,ou.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Qme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const QO={blendMode:"normal",renderOrder:0};try{lu&&lu.props&&Object.entries(lu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(QO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const epe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${lu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Qme(t,QO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(lu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,lu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function tpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const eL={blendMode:"normal",renderOrder:0};try{uu&&uu.props&&Object.entries(uu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(eL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const rpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${uu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>tpe(t,eL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(uu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,uu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function ipe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const tL={blendMode:"normal",renderOrder:0};try{hu&&hu.props&&Object.entries(hu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(tL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const spe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${hu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ipe(t,tL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(hu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,hu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function npe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const rL={blendMode:"normal",renderOrder:0};try{cu&&cu.props&&Object.entries(cu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(rL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ape=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${cu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>npe(t,rL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(cu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,cu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function ope(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const iL={blendMode:"normal",renderOrder:0};try{du&&du.props&&Object.entries(du.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(iL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const lpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${du.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ope(t,iL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(du,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,du.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function upe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const sL={blendMode:"normal",renderOrder:0};try{mu&&mu.props&&Object.entries(mu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(sL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const hpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${mu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>upe(t,sL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(mu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,mu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function cpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const nL={blendMode:"normal",renderOrder:0};try{pu&&pu.props&&Object.entries(pu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(nL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const dpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${pu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>cpe(t,nL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(pu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,pu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function mpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const aL={blendMode:"normal",renderOrder:0};try{fu&&fu.props&&Object.entries(fu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(aL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ppe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${fu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>mpe(t,aL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(fu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,fu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function fpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const oL={blendMode:"normal",renderOrder:0};try{gu&&gu.props&&Object.entries(gu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(oL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const gpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${gu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>fpe(t,oL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(gu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,gu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function ype(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const lL={blendMode:"normal",renderOrder:0};try{yu&&yu.props&&Object.entries(yu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(lL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const xpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${yu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ype(t,lL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(yu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,yu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function bpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const uL={blendMode:"normal",renderOrder:0};try{xu&&xu.props&&Object.entries(xu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(uL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const vpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${xu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>bpe(t,uL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(xu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,xu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Tpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const hL={blendMode:"normal",renderOrder:0};try{bu&&bu.props&&Object.entries(bu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(hL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const wpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${bu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Tpe(t,hL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(bu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,bu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Spe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const cL={blendMode:"normal",renderOrder:0};try{vu&&vu.props&&Object.entries(vu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(cL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Mpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${vu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Spe(t,cL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(vu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,vu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function _pe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const dL={blendMode:"normal",renderOrder:0};try{Tu&&Tu.props&&Object.entries(Tu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(dL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Npe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Tu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>_pe(t,dL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Tu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Tu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Epe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const mL={blendMode:"normal",renderOrder:0};try{wu&&wu.props&&Object.entries(wu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(mL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ape=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${wu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Epe(t,mL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(wu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,wu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};function Cpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const pL={blendMode:"normal",renderOrder:0};try{Su&&Su.props&&Object.entries(Su.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(pL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Rpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Su.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Cpe(t,pL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Su,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Su.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Re.jsx(ae.Provider,{value:h,children:t.children})};exports.Ascii=$de;exports.Blob=jde;exports.Blur=Hde;exports.Bulge=Xde;exports.CRTScreen=Zde;exports.Checkerboard=Kde;exports.ChromaFlow=eme;exports.ChromaticAberration=rme;exports.Circle=sme;exports.ColorMapping=ame;exports.Dither=lme;exports.DotGrid=hme;exports.Duotone=dme;exports.Exposure=pme;exports.FilmGrain=gme;exports.GlassTiles=xme;exports.Glitch=vme;exports.Glow=wme;exports.Godrays=Mme;exports.Grayscale=Nme;exports.Grid=Ame;exports.GridDistortion=Rme;exports.Group=Ime;exports.HalfTone=Ome;exports.HueShift=Fme;exports.ImageTexture=Bme;exports.Invert=Ume;exports.LinearGradient=$me;exports.Liquify=jme;exports.Mirror=Hme;exports.PerlinNoise=Xme;exports.Pixelate=Zme;exports.Posterize=Kme;exports.ProgressiveBlur=epe;exports.RadialGradient=rpe;exports.Saturation=spe;exports.Shader=Ude;exports.SimplexNoise=ape;exports.SineWave=lpe;exports.SolidColor=hpe;exports.Spiral=dpe;exports.Stretch=ppe;exports.Swirl=gpe;exports.TiltShift=xpe;exports.Tint=vpe;exports.Twirl=wpe;exports.VCR=Mpe;exports.Vibrance=Npe;exports.Vignette=Ape;exports.Voronoi=Rpe;
511
+ */b.BRDF_GGX;b.BRDF_Lambert;b.BasicShadowFilter;b.Break;b.Continue;b.DFGApprox;b.D_GGX;b.Discard;b.EPSILON;b.F_Schlick;b.Fn;b.INFINITY;b.If;b.Switch;b.Loop;b.NodeShaderStage;b.NodeType;b.NodeUpdateType;b.NodeAccess;b.PCFShadowFilter;b.PCFSoftShadowFilter;b.PI;b.PI2;b.Return;b.Schlick_to_F0;b.ScriptableNodeResources;b.ShaderNode;b.TBNViewMatrix;b.VSMShadowFilter;b.V_GGX_SmithCorrelated;b.abs;b.acesFilmicToneMapping;b.acos;b.add;b.addNodeElement;b.agxToneMapping;b.all;b.alphaT;b.and;b.anisotropy;b.anisotropyB;b.anisotropyT;b.any;b.append;b.array;b.arrayBuffer;b.asin;b.assign;b.atan;b.atan2;b.atomicAdd;b.atomicAnd;b.atomicFunc;b.atomicMax;b.atomicMin;b.atomicOr;b.atomicStore;b.atomicSub;b.atomicXor;b.atomicLoad;b.attenuationColor;b.attenuationDistance;b.attribute;b.attributeArray;b.backgroundBlurriness;b.backgroundIntensity;b.backgroundRotation;b.batch;b.billboarding;b.bitAnd;b.bitNot;b.bitOr;b.bitXor;b.bitangentGeometry;b.bitangentLocal;b.bitangentView;b.bitangentWorld;b.bitcast;b.blendBurn;b.blendColor;b.blendDodge;b.blendOverlay;b.blendScreen;b.blur;b.bool;b.buffer;b.bufferAttribute;b.bumpMap;b.burn;b.bvec2;b.bvec3;b.bvec4;b.bypass;b.cache;b.call;b.cameraFar;b.cameraIndex;b.cameraNear;b.cameraNormalMatrix;b.cameraPosition;b.cameraProjectionMatrix;b.cameraProjectionMatrixInverse;b.cameraViewMatrix;b.cameraWorldMatrix;b.cbrt;b.cdl;b.ceil;b.checker;b.cineonToneMapping;b.clamp;b.clearcoat;b.clearcoatRoughness;b.code;b.color;b.colorSpaceToWorking;b.colorToDirection;b.compute;b.computeSkinning;b.cond;b.Const;b.context;b.convert;b.convertColorSpace;b.convertToTexture;b.cos;b.cross;b.cubeTexture;b.dFdx;b.dFdy;b.dashSize;b.debug;b.decrement;b.decrementBefore;b.defaultBuildStages;b.defaultShaderStages;b.defined;b.degrees;b.deltaTime;b.densityFog;b.densityFogFactor;b.depth;b.depthPass;b.difference;b.diffuseColor;b.directPointLight;b.directionToColor;b.dispersion;b.distance;b.div;b.dodge;b.dot;b.drawIndex;b.dynamicBufferAttribute;b.element;b.emissive;b.equal;b.equals;b.equirectUV;b.exp;b.exp2;b.expression;b.faceDirection;b.faceForward;b.faceforward;b.float;b.floor;b.fog;b.fract;b.frameGroup;b.frameId;b.frontFacing;b.fwidth;b.gain;b.gapSize;b.getConstNodeType;b.getCurrentStack;b.getDirection;b.getDistanceAttenuation;b.getGeometryRoughness;b.getNormalFromDepth;b.getParallaxCorrectNormal;b.getRoughness;b.getScreenPosition;b.getShIrradianceAt;b.getTextureIndex;b.getViewPosition;b.getShadowMaterial;b.getShadowRenderObjectFunction;b.glsl;b.glslFn;b.grayscale;b.greaterThan;b.greaterThanEqual;b.hash;b.highpModelNormalViewMatrix;b.highpModelViewMatrix;b.hue;b.increment;b.incrementBefore;b.instance;b.instanceIndex;b.instancedArray;b.instancedBufferAttribute;b.instancedDynamicBufferAttribute;b.instancedMesh;b.int;b.inverseSqrt;b.inversesqrt;b.invocationLocalIndex;b.invocationSubgroupIndex;b.ior;b.iridescence;b.iridescenceIOR;b.iridescenceThickness;b.ivec2;b.ivec3;b.ivec4;b.js;b.label;b.length;b.lengthSq;b.lessThan;b.lessThanEqual;b.lightPosition;b.lightShadowMatrix;b.lightTargetDirection;b.lightTargetPosition;b.lightViewPosition;b.lightingContext;b.lights;b.linearDepth;b.linearToneMapping;b.localId;b.globalId;b.log;b.log2;b.logarithmicDepthToViewZ;b.loop;b.luminance;b.mediumpModelViewMatrix;b.mat2;b.mat3;b.mat4;b.matcapUV;b.materialAO;b.materialAlphaTest;b.materialAnisotropy;b.materialAnisotropyVector;b.materialAttenuationColor;b.materialAttenuationDistance;b.materialClearcoat;b.materialClearcoatNormal;b.materialClearcoatRoughness;b.materialColor;b.materialDispersion;b.materialEmissive;b.materialIOR;b.materialIridescence;b.materialIridescenceIOR;b.materialIridescenceThickness;b.materialLightMap;b.materialLineDashOffset;b.materialLineDashSize;b.materialLineGapSize;b.materialLineScale;b.materialLineWidth;b.materialMetalness;b.materialNormal;b.materialOpacity;b.materialPointSize;b.materialReference;b.materialReflectivity;b.materialRefractionRatio;b.materialRotation;b.materialRoughness;b.materialSheen;b.materialSheenRoughness;b.materialShininess;b.materialSpecular;b.materialSpecularColor;b.materialSpecularIntensity;b.materialSpecularStrength;b.materialThickness;b.materialTransmission;b.max;b.maxMipLevel;b.metalness;b.min;b.mix;b.mixElement;b.mod;b.modInt;b.modelDirection;b.modelNormalMatrix;b.modelPosition;b.modelRadius;b.modelScale;b.modelViewMatrix;b.modelViewPosition;b.modelViewProjection;b.modelWorldMatrix;b.modelWorldMatrixInverse;b.morphReference;b.mrt;b.mul;b.mx_aastep;b.mx_cell_noise_float;b.mx_contrast;b.mx_fractal_noise_float;b.mx_fractal_noise_vec2;b.mx_fractal_noise_vec3;b.mx_fractal_noise_vec4;b.mx_hsvtorgb;b.mx_noise_float;b.mx_noise_vec3;b.mx_noise_vec4;b.mx_ramplr;b.mx_ramptb;b.mx_rgbtohsv;b.mx_safepower;b.mx_splitlr;b.mx_splittb;b.mx_srgb_texture_to_lin_rec709;b.mx_transform_uv;b.mx_worley_noise_float;b.mx_worley_noise_vec2;b.mx_worley_noise_vec3;b.namespace;b.negate;b.neutralToneMapping;b.nodeArray;b.nodeImmutable;b.nodeObject;b.nodeObjects;b.nodeProxy;b.normalFlat;b.normalGeometry;b.normalLocal;b.normalMap;b.normalView;b.normalWorld;b.normalize;b.not;b.notEqual;b.numWorkgroups;b.objectDirection;b.objectGroup;b.objectPosition;b.objectRadius;b.objectScale;b.objectViewPosition;b.objectWorldMatrix;b.oneMinus;b.or;b.orthographicDepthToViewZ;b.oscSawtooth;b.oscSine;b.oscSquare;b.oscTriangle;b.output;b.outputStruct;b.overlay;b.overloadingFn;b.parabola;b.parallaxDirection;b.parallaxUV;b.parameter;b.pass;b.passTexture;b.pcurve;b.perspectiveDepthToViewZ;b.pmremTexture;b.pointUV;b.pointWidth;b.positionGeometry;b.positionLocal;b.positionPrevious;b.positionView;b.positionViewDirection;b.positionWorld;b.positionWorldDirection;b.posterize;b.pow;b.pow2;b.pow3;b.pow4;b.premult;b.property;b.radians;b.rand;b.range;b.rangeFog;b.rangeFogFactor;b.reciprocal;b.lightProjectionUV;b.reference;b.referenceBuffer;b.reflect;b.reflectVector;b.reflectView;b.reflector;b.refract;b.refractVector;b.refractView;b.reinhardToneMapping;b.remainder;b.remap;b.remapClamp;b.renderGroup;b.renderOutput;b.rendererReference;b.rotate;b.rotateUV;b.roughness;b.round;b.rtt;b.sRGBTransferEOTF;b.sRGBTransferOETF;b.sampler;b.samplerComparison;b.saturate;b.saturation;b.screen;b.screenCoordinate;b.screenSize;b.screenUV;b.scriptable;b.scriptableValue;b.select;b.setCurrentStack;b.shaderStages;b.shadow;b.pointShadow;b.shadowPositionWorld;b.sharedUniformGroup;b.shapeCircle;b.sheen;b.sheenRoughness;b.shiftLeft;b.shiftRight;b.shininess;b.sign;b.sin;b.sinc;b.skinning;b.smoothstep;b.smoothstepElement;b.specularColor;b.specularF90;b.spherizeUV;b.split;b.spritesheetUV;b.sqrt;b.stack;b.step;b.storage;b.storageBarrier;b.storageObject;b.storageTexture;b.string;b.struct;b.sub;b.subgroupIndex;b.subgroupSize;b.tan;b.tangentGeometry;b.tangentLocal;b.tangentView;b.tangentWorld;b.temp;b.texture;b.texture3D;b.textureBarrier;b.textureBicubic;b.textureCubeUV;b.textureLoad;b.textureSize;b.textureStore;b.thickness;b.time;b.timerDelta;b.timerGlobal;b.timerLocal;b.toneMapping;b.toneMappingExposure;b.toonOutlinePass;b.transformDirection;b.transformNormal;b.transformNormalToView;b.transformedBentNormalView;b.transformedBitangentView;b.transformedBitangentWorld;b.transformedClearcoatNormalView;b.transformedNormalView;b.transformedNormalWorld;b.transformedTangentView;b.transformedTangentWorld;b.transmission;b.transpose;b.triNoise3D;b.triplanarTexture;b.triplanarTextures;b.trunc;b.tslFn;b.uint;b.uniform;b.uniformCubeTexture;b.uniformArray;b.uniformGroup;b.uniformTexture;b.uniforms;b.unpremult;b.userData;b.uv;b.uvec2;b.uvec3;b.uvec4;b.Var;b.varying;b.varyingProperty;b.vec2;b.vec3;const kde=b.vec4;b.vectorComponents;b.velocity;b.vertexColor;b.vertexIndex;b.vibrance;b.viewZToLogarithmicDepth;b.viewZToOrthographicDepth;b.viewZToPerspectiveDepth;b.viewport;b.viewportBottomLeft;b.viewportCoordinate;b.viewportDepthTexture;b.viewportLinearDepth;b.viewportMipTexture;b.viewportResolution;b.viewportSafeUV;b.viewportSharedTexture;b.viewportSize;b.viewportTexture;b.viewportTopLeft;b.viewportUV;b.wgsl;b.wgslFn;b.workgroupArray;b.workgroupBarrier;b.workgroupId;b.workingToColorSpace;b.xor;const ae=v.createContext(null),Ude=({children:t,hideNotice:e=!1,style:r={},className:i="",...s})=>{const n=v.useRef(null),a=v.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=v.useRef(null);o.current===null&&(o.current=gse());const l=v.useMemo(()=>(w,_,S,N,A=null)=>{if(_===null){try{o.current.removeNode(w)}catch(k){console.warn("Error removing node:",k)}return}try{o.current.registerNode(w,_,S,N,A)}catch(k){console.error("Error registering node:",k,{id:w,parentId:S,metadata:N})}},[]),h=v.useMemo(()=>(w,_,S)=>{try{o.current.updateUniformValue(w,_,S)}catch(N){console.warn("Error updating uniform:",N)}},[]),u=v.useMemo(()=>(w,_)=>{try{o.current.updateNodeMetadata(w,_)}catch(S){console.warn("Error updating metadata:",S)}},[]),c=v.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=v.useRef(!1),m=v.useRef(!1),p=v.useRef(!1),f=v.useRef(!1),g=v.useRef(null),y=async()=>{const w=n.current;if(!(!w||d.current||m.current)){console.log("[Shader] Initializing renderer..."),m.current=!0;try{const _=o.current;_.isInitialized()||await _.initialize({canvas:w}),_.registerNode(a,({childNode:S})=>S||kde(0,0,0,0),null,null,{}),d.current=!0,m.current=!1,e||_.showLicenseWarning(),console.log("[Shader] Renderer initialized successfully")}catch(_){throw console.error("[Shader] Initialization failed:",_),m.current=!1,_}}},T=()=>{const w=n.current;!w||g.current||(g.current=new IntersectionObserver(_=>{const S=_[0];if(!S)return;const N=w.getBoundingClientRect(),A=S.isIntersecting&&N&&N.width>0&&N.height>0;A&&!f.current?(console.log("[Shader] Canvas became visible, initializing..."),y().catch(console.error),f.current=!0):!A&&f.current&&(console.log("[Shader] Canvas became hidden, cleaning up renderer..."),o.current.cleanup(),d.current=!1,m.current=!1,f.current=!1)},{threshold:0}),g.current.observe(w))};v.useEffect(()=>{p.current=!1;const w=n.current;if(!w)return;const _=w.getBoundingClientRect();return _.width>0&&_.height>0?(console.log("[Shader] Canvas visible on mount, initializing..."),y().catch(console.error),f.current=!0):(console.log("[Shader] Canvas hidden on mount, setting up observer..."),f.current=!1),T(),()=>{if(!p.current){p.current=!0,g.current&&(g.current.disconnect(),g.current=null);try{o.current.cleanup(),d.current=!1,m.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(N){console.warn("[Shader] Error during cleanup:",N)}}}},[a,e]);const M={width:"1200px",height:"800px",...typeof r=="object"?r:{}};return Ie.jsxs(ae.Provider,{value:c,children:[Ie.jsx("canvas",{"data-renderer":"ombre",ref:n,className:i,style:M,...s}),t]})};function Dde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const vO={blendMode:"normal",renderOrder:0};try{El&&El.props&&Object.entries(El.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(vO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const $de=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${El.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Dde(t,vO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(El,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,El.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Gde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const TO={blendMode:"normal",renderOrder:0};try{Cl&&Cl.props&&Object.entries(Cl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(TO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const jde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Cl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Gde(t,TO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Cl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Cl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Wde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const wO={blendMode:"normal",renderOrder:0};try{Rl&&Rl.props&&Object.entries(Rl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(wO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Hde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Rl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Wde(t,wO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Rl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Rl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function qde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const SO={blendMode:"normal",renderOrder:0};try{Pl&&Pl.props&&Object.entries(Pl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(SO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Xde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Pl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>qde(t,SO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Pl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Pl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Yde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const MO={blendMode:"normal",renderOrder:0};try{zl&&zl.props&&Object.entries(zl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(MO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Zde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${zl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Yde(t,MO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(zl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,zl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Jde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const _O={blendMode:"normal",renderOrder:0};try{Il&&Il.props&&Object.entries(Il.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(_O[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Kde=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Il.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Jde(t,_O),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Il,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Il.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Qde(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const NO={blendMode:"normal",renderOrder:0};try{Vl&&Vl.props&&Object.entries(Vl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(NO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const eme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Vl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Qde(t,NO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Vl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Vl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function tme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const EO={blendMode:"normal",renderOrder:0};try{Ol&&Ol.props&&Object.entries(Ol.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(EO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const rme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ol.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>tme(t,EO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ol,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ol.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function ime(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const AO={blendMode:"normal",renderOrder:0};try{Ll&&Ll.props&&Object.entries(Ll.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(AO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const sme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ll.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ime(t,AO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ll,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ll.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function nme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const CO={blendMode:"normal",renderOrder:0};try{Fl&&Fl.props&&Object.entries(Fl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(CO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ame=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Fl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>nme(t,CO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Fl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Fl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function ome(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const RO={blendMode:"normal",renderOrder:0};try{Bl&&Bl.props&&Object.entries(Bl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(RO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const lme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Bl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ome(t,RO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Bl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Bl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function ume(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const PO={blendMode:"normal",renderOrder:0};try{kl&&kl.props&&Object.entries(kl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(PO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const hme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${kl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ume(t,PO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(kl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,kl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function cme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const IO={blendMode:"normal",renderOrder:0};try{Ul&&Ul.props&&Object.entries(Ul.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(IO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const dme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ul.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>cme(t,IO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ul,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ul.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function mme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const VO={blendMode:"normal",renderOrder:0};try{Dl&&Dl.props&&Object.entries(Dl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(VO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const pme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Dl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>mme(t,VO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Dl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Dl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function fme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const OO={blendMode:"normal",renderOrder:0};try{$l&&$l.props&&Object.entries($l.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(OO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const gme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${$l.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>fme(t,OO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe($l,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,$l.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function yme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const LO={blendMode:"normal",renderOrder:0};try{Gl&&Gl.props&&Object.entries(Gl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(LO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const xme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Gl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>yme(t,LO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Gl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Gl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function bme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const FO={blendMode:"normal",renderOrder:0};try{jl&&jl.props&&Object.entries(jl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(FO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const vme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${jl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>bme(t,FO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(jl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,jl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Tme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const zO={blendMode:"normal",renderOrder:0};try{Wl&&Wl.props&&Object.entries(Wl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(zO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const wme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Wl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Tme(t,zO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Wl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Wl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Sme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const BO={blendMode:"normal",renderOrder:0};try{Hl&&Hl.props&&Object.entries(Hl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(BO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Mme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Hl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Sme(t,BO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Hl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Hl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function _me(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const kO={blendMode:"normal",renderOrder:0};try{Xl&&Xl.props&&Object.entries(Xl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(kO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Nme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Xl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>_me(t,kO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Xl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Xl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Eme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const UO={blendMode:"normal",renderOrder:0};try{Yl&&Yl.props&&Object.entries(Yl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(UO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ame=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Yl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Eme(t,UO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Yl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Yl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Cme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const DO={blendMode:"normal",renderOrder:0};try{Zl&&Zl.props&&Object.entries(Zl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(DO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Rme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Zl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Cme(t,DO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Zl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Zl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Pme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const $O={blendMode:"normal",renderOrder:0};try{Jl&&Jl.props&&Object.entries(Jl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&($O[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ime=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Jl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Pme(t,$O),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Jl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Jl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Vme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const GO={blendMode:"normal",renderOrder:0};try{Kl&&Kl.props&&Object.entries(Kl.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(GO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ome=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Kl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Vme(t,GO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Kl,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Kl.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Lme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const jO={blendMode:"normal",renderOrder:0};try{Ql&&Ql.props&&Object.entries(Ql.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(jO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Fme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Ql.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Lme(t,jO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Ql,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Ql.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function zme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const WO={blendMode:"normal",renderOrder:0};try{eu&&eu.props&&Object.entries(eu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(WO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Bme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${eu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>zme(t,WO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(eu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,eu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function kme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const HO={blendMode:"normal",renderOrder:0};try{tu&&tu.props&&Object.entries(tu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(HO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ume=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${tu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>kme(t,HO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(tu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,tu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Dme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const qO={blendMode:"normal",renderOrder:0};try{ru&&ru.props&&Object.entries(ru.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(qO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const $me=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${ru.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Dme(t,qO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(ru,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,ru.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Gme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const XO={blendMode:"normal",renderOrder:0};try{iu&&iu.props&&Object.entries(iu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(XO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const jme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${iu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Gme(t,XO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(iu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,iu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Wme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const YO={blendMode:"normal",renderOrder:0};try{su&&su.props&&Object.entries(su.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(YO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Hme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${su.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Wme(t,YO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(su,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,su.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function qme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const ZO={blendMode:"normal",renderOrder:0};try{nu&&nu.props&&Object.entries(nu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(ZO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Xme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${nu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>qme(t,ZO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(nu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,nu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Yme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const JO={blendMode:"normal",renderOrder:0};try{au&&au.props&&Object.entries(au.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(JO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Zme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${au.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Yme(t,JO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(au,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,au.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Jme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const KO={blendMode:"normal",renderOrder:0};try{ou&&ou.props&&Object.entries(ou.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(KO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Kme=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${ou.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Jme(t,KO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(ou,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,ou.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Qme(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const QO={blendMode:"normal",renderOrder:0};try{lu&&lu.props&&Object.entries(lu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(QO[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const epe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${lu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Qme(t,QO),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(lu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,lu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function tpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const eL={blendMode:"normal",renderOrder:0};try{uu&&uu.props&&Object.entries(uu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(eL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const rpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${uu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>tpe(t,eL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(uu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,uu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function ipe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const tL={blendMode:"normal",renderOrder:0};try{hu&&hu.props&&Object.entries(hu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(tL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const spe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${hu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ipe(t,tL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(hu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,hu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function npe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const rL={blendMode:"normal",renderOrder:0};try{cu&&cu.props&&Object.entries(cu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(rL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ape=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${cu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>npe(t,rL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(cu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,cu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function ope(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const iL={blendMode:"normal",renderOrder:0};try{du&&du.props&&Object.entries(du.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(iL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const lpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${du.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ope(t,iL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(du,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,du.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function upe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const sL={blendMode:"normal",renderOrder:0};try{mu&&mu.props&&Object.entries(mu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(sL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const hpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${mu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>upe(t,sL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(mu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,mu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function cpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const nL={blendMode:"normal",renderOrder:0};try{pu&&pu.props&&Object.entries(pu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(nL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const dpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${pu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>cpe(t,nL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(pu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,pu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function mpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const aL={blendMode:"normal",renderOrder:0};try{fu&&fu.props&&Object.entries(fu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(aL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const ppe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${fu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>mpe(t,aL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(fu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,fu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function fpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const oL={blendMode:"normal",renderOrder:0};try{gu&&gu.props&&Object.entries(gu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(oL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const gpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${gu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>fpe(t,oL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(gu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,gu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function ype(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const lL={blendMode:"normal",renderOrder:0};try{yu&&yu.props&&Object.entries(yu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(lL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const xpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${yu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>ype(t,lL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(yu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,yu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function bpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const uL={blendMode:"normal",renderOrder:0};try{xu&&xu.props&&Object.entries(xu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(uL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const vpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${xu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>bpe(t,uL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(xu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,xu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Tpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const hL={blendMode:"normal",renderOrder:0};try{bu&&bu.props&&Object.entries(bu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(hL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const wpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${bu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Tpe(t,hL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(bu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,bu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Spe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const cL={blendMode:"normal",renderOrder:0};try{vu&&vu.props&&Object.entries(vu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(cL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Mpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${vu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Spe(t,cL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(vu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,vu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function _pe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const dL={blendMode:"normal",renderOrder:0};try{Tu&&Tu.props&&Object.entries(Tu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(dL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Npe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Tu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>_pe(t,dL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Tu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Tu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Epe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const mL={blendMode:"normal",renderOrder:0};try{wu&&wu.props&&Object.entries(wu.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(mL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Ape=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${wu.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Epe(t,mL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(wu,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,wu.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};function Cpe(t,e){let r={...e};for(const[i,s]of Object.entries(t))i!=="children"&&i!=="ref"&&s!==void 0&&(r[i]=s);return r}const pL={blendMode:"normal",renderOrder:0};try{Su&&Su.props&&Object.entries(Su.props).forEach(([t,e])=>{const r=e;r&&typeof r=="object"&&"default"in r&&(pL[t]=r.default)})}catch(t){console.warn("Error extracting default props:",t)}const Rpe=t=>{const e=v.useContext(ae);if(!e)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:r,ombreNodeRegister:i,ombreUniformUpdate:s,ombreMetadataUpdate:n}=e,a=v.useMemo(()=>t.id||`${Su.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[t.id]),o=v.useMemo(()=>Cpe(t,pL),[t]),l=v.useRef(null);l.current===null&&(l.current=Fe(Su,o,a));const h=v.useMemo(()=>({...e,ombreParentId:a}),[e,a]);if(v.useEffect(()=>{if(l.current)try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};return i(a,Su.fragmentNode,r,u,l.current),()=>{i(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,r,i,t.blendMode,t.opacity,t.id,t.maskSource,t.maskType]),v.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u];d.value=m?m(p):p}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:m}=c;if(d?.value!==void 0&&u in o){const p=o[u],f=m?m(p):p;s(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,s]),v.useEffect(()=>{try{const u={blendMode:t.blendMode||"normal",opacity:t.opacity,id:t.id,mask:t.maskSource?{source:t.maskSource,type:t.maskType||"alpha"}:void 0,renderOrder:t.renderOrder||0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[t.blendMode,t.opacity,t.maskSource,t.maskType,t.renderOrder,t.id,a,n]),t.ref&&typeof t.ref=="function")try{t.ref(null)}catch{}return Ie.jsx(ae.Provider,{value:h,children:t.children})};exports.Ascii=$de;exports.Blob=jde;exports.Blur=Hde;exports.Bulge=Xde;exports.CRTScreen=Zde;exports.Checkerboard=Kde;exports.ChromaFlow=eme;exports.ChromaticAberration=rme;exports.Circle=sme;exports.ColorMapping=ame;exports.Dither=lme;exports.DotGrid=hme;exports.Duotone=dme;exports.Exposure=pme;exports.FilmGrain=gme;exports.GlassTiles=xme;exports.Glitch=vme;exports.Glow=wme;exports.Godrays=Mme;exports.Grayscale=Nme;exports.Grid=Ame;exports.GridDistortion=Rme;exports.Group=Ime;exports.HalfTone=Ome;exports.HueShift=Fme;exports.ImageTexture=Bme;exports.Invert=Ume;exports.LinearGradient=$me;exports.Liquify=jme;exports.Mirror=Hme;exports.PerlinNoise=Xme;exports.Pixelate=Zme;exports.Posterize=Kme;exports.ProgressiveBlur=epe;exports.RadialGradient=rpe;exports.Saturation=spe;exports.Shader=Ude;exports.SimplexNoise=ape;exports.SineWave=lpe;exports.SolidColor=hpe;exports.Spiral=dpe;exports.Stretch=ppe;exports.Swirl=gpe;exports.TiltShift=xpe;exports.Tint=vpe;exports.Twirl=wpe;exports.VCR=Mpe;exports.Vibrance=Npe;exports.Vignette=Ape;exports.Voronoi=Rpe;
512
512
  //# sourceMappingURL=index.cjs.map